Branch: refs/heads/main
Commit: 12e4ee6fca24fdeab5156b7b025c996a3502ae57
https://github.com/zeek/spicy/commit/12e4ee6fca24fdeab5156b7b025c996a3502ae57
M hilti/toolchain/include/ast/visitor.h
M hilti/toolchain/include/compiler/detail/optimizer/pass.h
M hilti/toolchain/src/ast/visitor.cc
M hilti/toolchain/src/compiler/optimizer/pass.cc
M hilti/toolchain/src/compiler/optimizer/passes/constant-propagation.cc
M hilti/toolchain/src/compiler/optimizer/passes/dead-code-static.cc
M hilti/toolchain/src/compiler/optimizer/passes/peephole.cc
M hilti/toolchain/src/compiler/optimizer/passes/propagate-function-returns.cc
M hilti/toolchain/src/compiler/optimizer/passes/remove-unused-fields.cc
M hilti/toolchain/src/compiler/resolver.cc
M spicy/toolchain/src/compiler/codegen/codegen.cc
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
Log Message:
-----------
Make the visitors' `replaceNode()` safe.
The existing `replaceNode()` method was impossible to use safely: if
it was passed a replacement node that was already part of the AST
somewhere, the method would disconnect that node from its original
position first. That, however, is generally not safe because AST nodes
do not give any guarantees about their internal child layout, so that
simply removing one can lead to trouble. Plus, one always had to keep
mind that the replacement node would now disappear from its original
place, which is error-prone even in safe cases.
This changes `replaceNode()` to instead use our standard semantics
when making AST modifications: If a node is being inserted that
already has a parent, we deep-copy it first. That way, the caller
doesn't need to worry about safe memory management. In addition, we
add a new method `replaceNodeWithChild()` that optimizes the operation
for a special case: If an existing child is taking the position of a
parent of itself, then we can always safely move it over into its new
place without copying. We now use that for cases across the code base
that match this special case.
Commit: 08a055295927521ceed1ac054c616b11b555518e
https://github.com/zeek/spicy/commit/08a055295927521ceed1ac054c616b11b555518e
Author: Robin Sommer <
ro...@corelight.com>
Date: 2026-03-03 (Tue, 03 Mar 2026)
Changed paths:
M hilti/toolchain/include/ast/expressions/grouping.h
M hilti/toolchain/src/compiler/optimizer/passes/peephole.cc
M tests/Baseline/hilti.expressions.grouping-with-local/output
M tests/Baseline/hilti.optimization.unimplemented_hook/log
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/expressions/grouping-with-local.hlt
Log Message:
-----------
Optimize grouping with side-effect free local variables.
Our resolver can sometimes leave new groupings behind that are more
complex than necessary because they introduce local temporary
variables even though their value is constant and side-effect free.
The problem is that the resolver can't tell if something is
side-effect free (that needs data flow analysis) and hence it needs to
remain conservative.
This commit adds a peephole optimization that removes local variables
from groupings if they aren't necessary. We generally prefer repeating
the side-effect expressions for readability and further optimizations
down the line.
Commit: c6ee43119b37104b35526e6284ff09aea8435a49
https://github.com/zeek/spicy/commit/c6ee43119b37104b35526e6284ff09aea8435a49
Author: Robin Sommer <
ro...@corelight.com>
Date: 2026-03-03 (Tue, 03 Mar 2026)
Changed paths:
M hilti/toolchain/include/ast/visitor.h
M hilti/toolchain/include/compiler/detail/optimizer/pass.h
M hilti/toolchain/src/ast/visitor.cc
M hilti/toolchain/src/compiler/optimizer/pass.cc
M hilti/toolchain/src/compiler/optimizer/passes/constant-propagation.cc
M hilti/toolchain/src/compiler/optimizer/passes/dead-code-static.cc
M hilti/toolchain/src/compiler/optimizer/passes/peephole.cc
M hilti/toolchain/src/compiler/optimizer/passes/propagate-function-returns.cc
M hilti/toolchain/src/compiler/optimizer/passes/remove-unused-fields.cc
M hilti/toolchain/src/compiler/resolver.cc
M spicy/toolchain/src/compiler/codegen/codegen.cc
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
Log Message:
-----------
Merge remote-tracking branch 'origin/topic/robin/replace-node'
* origin/topic/robin/replace-node:
Make the visitors' `replaceNode()` safe.
Commit: 4e0dee9c428fc05f7fefad54dd91d824a0f730a2
https://github.com/zeek/spicy/commit/4e0dee9c428fc05f7fefad54dd91d824a0f730a2
Author: Robin Sommer <
ro...@corelight.com>
Date: 2026-03-03 (Tue, 03 Mar 2026)
Changed paths:
M CHANGES
M VERSION
M hilti/toolchain/include/ast/expressions/grouping.h
M hilti/toolchain/src/compiler/cfg.cc
M hilti/toolchain/src/compiler/optimizer/passes/peephole.cc
M tests/Baseline/hilti.expressions.grouping-with-local/output
M tests/Baseline/hilti.optimization.unimplemented_hook/log
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/expressions/grouping-with-local.hlt
Log Message:
-----------
Merge remote-tracking branch 'origin/topic/robin/opt-groupings'
* origin/topic/robin/opt-groupings:
Optimize grouping with side-effect free local variables.
Extend analysis of side effects.
Compare:
https://github.com/zeek/spicy/compare/ad81722b3a51...4e0dee9c428f