[zeek/spicy] 937e30: Remove `init` from if/while if unused.

0 views
Skip to first unread message

Evan Typanski

unread,
Mar 22, 2026, 12:17:35 PM (12 days ago) Mar 22
to spicy-...@zeek.org
Branch: refs/heads/topic/etyp/copy-prop
Home: https://github.com/zeek/spicy
Commit: 937e308af2a0cd13095834ff5013bc4076296e3f
https://github.com/zeek/spicy/commit/937e308af2a0cd13095834ff5013bc4076296e3f
Author: Evan Typanski <evan.t...@corelight.com>
Date: 2026-03-22 (Sun, 22 Mar 2026)

Changed paths:
M hilti/toolchain/src/compiler/optimizer/passes/dead-code-cfg.cc
A tests/hilti/optimization/unused-while-if-init.hlt

Log Message:
-----------
Remove `init` from if/while if unused.


Commit: 2bd17075f46d6c42b285367d38a7f6114a84ac18
https://github.com/zeek/spicy/commit/2bd17075f46d6c42b285367d38a7f6114a84ac18
Author: Evan Typanski <evan.t...@corelight.com>
Date: 2026-03-22 (Sun, 22 Mar 2026)

Changed paths:
M hilti/toolchain/include/ast/types/any.h
M hilti/toolchain/src/compiler/optimizer/passes/constant-propagation.cc
M tests/Baseline/spicy.optimization.default-parser-functions/log
M tests/Baseline/spicy.optimization.feature_requirements/log
M tests/Baseline/spicy.rt.debug-trace/.stderr
M tests/hilti/output/optimization/cfg-constprop.hlt
M tests/spicy/optimization/offset_vs_random-access.spicy

Log Message:
-----------
Make constant propagation on calls more granular.

The constant propagation pass would get around certain cases with
functions having references by just marking everything as
not-a-constant. But, that really limits the utility, and it's something
that signalled a bug.

This changes constant propagation to only mark `inout` function
parameters as not-a-constant. This also necessitates marking a Spicy
runtime function as having an `inout any` parameter, since it would
otherwise cause a bitfield test to fail.

This should allow us to propagate constants more.


Commit: b0e0bc1a8ca5d1bcee5022e6cdc2b7f57ac915c9
https://github.com/zeek/spicy/commit/b0e0bc1a8ca5d1bcee5022e6cdc2b7f57ac915c9
Author: Evan Typanski <evan.t...@corelight.com>
Date: 2026-03-22 (Sun, 22 Mar 2026)

Changed paths:
M hilti/toolchain/CMakeLists.txt
M hilti/toolchain/include/compiler/detail/optimizer/pass-id.h
R hilti/toolchain/src/compiler/optimizer/passes/constant-propagation.cc
A hilti/toolchain/src/compiler/optimizer/passes/value-propagation.cc
M tests/Baseline/hilti.cfg.dead-write-shadowed/output
M tests/Baseline/hilti.cfg.local-struct-value/output
M tests/Baseline/hilti.cfg.unreachable-return/output
M tests/Baseline/hilti.optimization.dataflow-unreachable/output
M tests/Baseline/hilti.optimization.unimplemented_hook/log
M tests/Baseline/hilti.optimization.unreachable-code/log
M tests/Baseline/hilti.optimization.unused-init/output
M tests/Baseline/hilti.optimization.unused_function/log
M tests/Baseline/hilti.types.struct.on-heap/output
M tests/Baseline/spicy.optimization.default-parser-functions/log
M tests/Baseline/spicy.optimization.feature_requirements/log
M tests/Baseline/spicy.optimization.unused-functions/log
M tests/Baseline/spicy.optimization.unused-types/log
M tests/hilti/optimization/flatten-block.hlt
A tests/hilti/output/optimization/cfg-const-copy-prop.hlt
R tests/hilti/output/optimization/cfg-constprop.hlt

Log Message:
-----------
Add copy propagation.

Copy propagation is just an extension of constant propagation that will
also propagate a Name. That means that if you take in a parameter, like:

function f(x: uint8) {
local y = x;
print(y);
}

You can propagate `x` into the print. Before, because `y` was not a
constant, we would not propagate. This means the dead store can be
eliminated, which may help for larger parsers with register spill and
expensive copies.

We may also apply this to more than just Names. I tested with member
accesses, but it did not do much. The problem with doing more is that we
have to care about aliasing of the "parent," so we cannot just rely on
`inout` in order to see if something may change. Thus, the more we do,
it gets significantly more complex, with each step also adding potential
for too much propagation. Too much may hurt the performance gains.


Compare: https://github.com/zeek/spicy/compare/b3956a44be73...b0e0bc1a8ca5

To unsubscribe from these emails, change your notification settings at https://github.com/zeek/spicy/settings/notifications
Reply all
Reply to author
Forward
0 new messages