Branch: refs/heads/topic/etyp/move-last-uses
Home:
https://github.com/zeek/spicy
Commit: 88183bc02867a031634111ffbe3add68ca926745
https://github.com/zeek/spicy/commit/88183bc02867a031634111ffbe3add68ca926745
Author: Evan Typanski <
evan.t...@corelight.com>
Date: 2026-07-24 (Fri, 24 Jul 2026)
Changed paths:
M hilti/runtime/CMakeLists.txt
M hilti/runtime/include/util.h
A hilti/runtime/src/tests/move.cc
M hilti/toolchain/src/compiler/codegen/expressions.cc
M tests/hilti/optimization/flatten-block.hlt
M tests/hilti/output/optimization/cfg-const-copy-prop.hlt
Log Message:
-----------
Make hilti moves a RT function
This avoids adding C++ semantics to the hilti codegen. Instead, it's just
a runtime helper that moves-or-not.
This also uncovered a "bug" in codegen: switch statements used auto&&,
which could bind to an lvalue, but everything in hilti sees it as an
rvalue. This was fixed in the commit before, but it arose because of
this and the move last uses optimizer pass.
Commit: ca85720b97839c950acaed8eee934c4c47909c53
https://github.com/zeek/spicy/commit/ca85720b97839c950acaed8eee934c4c47909c53
Author: Evan Typanski <
evan.t...@corelight.com>
Date: 2026-07-24 (Fri, 24 Jul 2026)
Changed paths:
M hilti/toolchain/src/compiler/cfg.cc
M tests/Baseline/hilti.cfg.switch/output
Log Message:
-----------
Fix CFG for switch cases
The CFG was making many parallel branches for a switch:
switch (s)
/ | \
/ | \
/ | \
/ | \
/ | \
s == "a" s == "b" s == "c"
| | |
| | |
case A case B case C
But, that's not what's happening. In reality, the first case will compare
first, then the second, then the third: it's not a choice, it's a
sequential series of comparisons:
switch (s)
|
|
s == "a"
| \
| \
| case A
|
s == "b"
| \
| \
| case B
|
s == "c"
\
\
case C
This bug would make 's' appear dead after each case expression
(comparison with "a", "b", and "c") when in reality it's only dead after
the comparison with "c".
This just updated the switch CFG baselines, since including the test for
move last uses that caused it (basically a switch over multiple strings)
would require baselining C++, which is a bit brittle.
Commit: d2c0ebbb0c59341bfcd4154d0c901c087b6162cb
https://github.com/zeek/spicy/commit/d2c0ebbb0c59341bfcd4154d0c901c087b6162cb
Author: Evan Typanski <
evan.t...@corelight.com>
Date: 2026-07-24 (Fri, 24 Jul 2026)
Changed paths:
M hilti/toolchain/CMakeLists.txt
M hilti/toolchain/include/compiler/detail/optimizer/pass-id.h
A hilti/toolchain/src/compiler/optimizer/passes/move-last-uses.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.default-parser-functions/opt.hlt
M tests/Baseline/spicy.optimization.feature_requirements/log
M tests/Baseline/spicy.optimization.feature_requirements/opt.hlt
M tests/Baseline/spicy.optimization.unused-functions/log
M tests/Baseline/spicy.optimization.unused-functions/opt.hlt
M tests/Baseline/spicy.optimization.unused-types/log
M tests/Baseline/spicy.optimization.unused-types/opt.hlt
M tests/Baseline/spicy.rt.debug-trace/.stderr
A tests/hilti/output/optimization/move-last-uses.hlt
Log Message:
-----------
Implement optimizer pass to `move` last uses
Closes #1960
Adds an optimization pass that adds moves when it's the last use. This is
relatively conservative; it doesn't try to understand expression ordering
and won't move in many cases. But, in user-code (not generated parser
code) this could give a bit of a speedup.
The analysis is just a liveness analysis. If the name isn't live after a
CFG node, we theoretically can move it.
Compare:
https://github.com/zeek/spicy/compare/a4b278fd5abd...d2c0ebbb0c59
To unsubscribe from these emails, change your notification settings at
https://github.com/zeek/spicy/settings/notifications