[zeek/spicy] befe46: Properly model switch case condition reads.

0 views
Skip to first unread message

Benjamin Bannier

unread,
Aug 29, 2025, 10:59:45 AM (11 days ago) Aug 29
to spicy-...@zeek.org
Branch: refs/heads/topic/bbannier/issue-2124
Home: https://github.com/zeek/spicy
Commit: befe46e31244af1bb2b442b03c9f419718f92814
https://github.com/zeek/spicy/commit/befe46e31244af1bb2b442b03c9f419718f92814
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-08-29 (Fri, 29 Aug 2025)

Changed paths:
M hilti/toolchain/src/compiler/cfg.cc
M tests/Baseline/hilti.cfg.switch/output

Log Message:
-----------
Properly model switch case condition reads.

For switch statements we synthesize a condition declaration and each
switch case we then perform equality checks. Previously we would only
store the case label in the CFG.

This patch fixes the implementation so we instead store the checks
against the condition variable. With that we properly model e.g., reads
of the condition variable which otherwise could appear unused.


Commit: 065522cc05cf5f111ffa5cbf7681420a4596d9a4
https://github.com/zeek/spicy/commit/065522cc05cf5f111ffa5cbf7681420a4596d9a4
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-08-29 (Fri, 29 Aug 2025)

Changed paths:
M hilti/toolchain/src/compiler/cfg.cc
M tests/Baseline/hilti.cfg.switch/output

Log Message:
-----------
Fix CFG modelling of switch cases with multiple labels.

Switch cases with multiple labels were previously stored as a chain of
expressions which roughly corresponds to an AND. This patch fixes the
implementation to instead model them as separate branches which
corresponds to an OR and is closer to their actual behavior.


Commit: 192da07df940e5b21c35ae459c39bbfec9463cba
https://github.com/zeek/spicy/commit/192da07df940e5b21c35ae459c39bbfec9463cba
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-08-29 (Fri, 29 Aug 2025)

Changed paths:
M hilti/toolchain/src/compiler/cfg.cc
M tests/Baseline/hilti.cfg.switch/output

Log Message:
-----------
Prevent removing switch statements which only have a default case.


Commit: a9d2b9321ac2c06182c3abb4ea60c5e39b04dc4d
https://github.com/zeek/spicy/commit/a9d2b9321ac2c06182c3abb4ea60c5e39b04dc4d
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-08-29 (Fri, 29 Aug 2025)

Changed paths:
M hilti/toolchain/include/compiler/detail/cfg.h
M hilti/toolchain/src/compiler/cfg.cc
M hilti/toolchain/src/compiler/optimizer.cc
M tests/Baseline/hilti.cfg.assign/output
M tests/Baseline/hilti.cfg.dead-write-shadowed/output
M tests/Baseline/hilti.cfg.return/output
M tests/Baseline/hilti.cfg.switch/output
M tests/Baseline/hilti.optimization.dataflow-unreachable/output
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/hilti/cfg/assign.hlt

Log Message:
-----------
Properly store declarations.


Commit: 92b4c74592bbf7a0fa0359d14cd448584be877ec
https://github.com/zeek/spicy/commit/92b4c74592bbf7a0fa0359d14cd448584be877ec
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-08-29 (Fri, 29 Aug 2025)

Changed paths:
M hilti/toolchain/src/compiler/cfg.cc
M tests/Baseline/hilti.cfg.assign/output
M tests/Baseline/hilti.cfg.dead-write-shadowed/output
M tests/Baseline/hilti.cfg.try/output
M tests/Baseline/hilti.cfg.unreachable-return/output
M tests/hilti/cfg/assign.hlt

Log Message:
-----------
Fix cfg handling of RHS assignments in variable declarations.


Commit: 35687ac33b314993fbb9e0a5c8cbf38cf7585123
https://github.com/zeek/spicy/commit/35687ac33b314993fbb9e0a5c8cbf38cf7585123
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-08-29 (Fri, 29 Aug 2025)

Changed paths:
M hilti/toolchain/include/compiler/detail/cfg.h
M hilti/toolchain/src/compiler/cfg.cc
M tests/Baseline/hilti.cfg.assign/output
A tests/Baseline/hilti.cfg.local-struct-value/output
M tests/Baseline/hilti.optimization.dataflow-unreachable/output
A tests/hilti/cfg/local-struct-value.hlt

Log Message:
-----------
Fix computation of aliasing and variable access in CFG.

We would previously not computing aliasing and variable reads correctly
which could lead to us incorrectly modifying code involving e.g., struct
values. This patch reworks how this is done.

To implement this correctly we also need to add function parameters to
the CFG.

Closes #2124.


Commit: 154e8908b47261d50db4030a0e9ab6bd1b2674da
https://github.com/zeek/spicy/commit/154e8908b47261d50db4030a0e9ab6bd1b2674da
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-08-29 (Fri, 29 Aug 2025)

Changed paths:
M hilti/toolchain/src/compiler/optimizer.cc

Log Message:
-----------
Remove workaround for C++17.


Commit: 5ee34e762163fceb58873402412c26e250bfc5e2
https://github.com/zeek/spicy/commit/5ee34e762163fceb58873402412c26e250bfc5e2
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-08-29 (Fri, 29 Aug 2025)

Changed paths:
M .pre-commit-config.yaml

Log Message:
-----------
Bump pre-commit hooks.


Commit: 89e1c9d82d2b72884ad7937f8f7851b1ecba3a3d
https://github.com/zeek/spicy/commit/89e1c9d82d2b72884ad7937f8f7851b1ecba3a3d
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-08-29 (Fri, 29 Aug 2025)

Changed paths:
M .pre-commit-config.yaml

Log Message:
-----------
Use non-legacy ruff-check version for pre-commit.


Compare: https://github.com/zeek/spicy/compare/8755213f670f...89e1c9d82d2b

To unsubscribe from these emails, change your notification settings at https://github.com/zeek/spicy/settings/notifications

Benjamin Bannier

unread,
Sep 2, 2025, 1:36:39 PM (7 days ago) Sep 2
to spicy-...@zeek.org
Branch: refs/heads/main
Commit: 7f021f99d7788418e98628d97bb597bd317bebe5
https://github.com/zeek/spicy/commit/7f021f99d7788418e98628d97bb597bd317bebe5
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-09-02 (Tue, 02 Sep 2025)

Changed paths:
M hilti/toolchain/src/compiler/cfg.cc
M tests/Baseline/hilti.cfg.switch/output

Log Message:
-----------
Prevent removing switch statements which only have a default case.


Commit: ded30b45d0eaf7d405994c08be537bc3e969fc8f
https://github.com/zeek/spicy/commit/ded30b45d0eaf7d405994c08be537bc3e969fc8f
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-09-02 (Tue, 02 Sep 2025)

Changed paths:
M hilti/toolchain/include/compiler/detail/cfg.h
M hilti/toolchain/src/compiler/cfg.cc
M hilti/toolchain/src/compiler/optimizer.cc
M tests/Baseline/hilti.cfg.assign/output
M tests/Baseline/hilti.cfg.dead-write-shadowed/output
M tests/Baseline/hilti.cfg.return/output
M tests/Baseline/hilti.cfg.switch/output
M tests/Baseline/hilti.optimization.dataflow-unreachable/output
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/hilti/cfg/assign.hlt

Log Message:
-----------
Properly store declarations.


Commit: fb7e8427afe9750ff99d34ad5473069a038d5b5b
https://github.com/zeek/spicy/commit/fb7e8427afe9750ff99d34ad5473069a038d5b5b
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-09-02 (Tue, 02 Sep 2025)

Changed paths:
M hilti/toolchain/src/compiler/cfg.cc
M tests/Baseline/hilti.cfg.assign/output
M tests/Baseline/hilti.cfg.dead-write-shadowed/output
M tests/Baseline/hilti.cfg.try/output
M tests/Baseline/hilti.cfg.unreachable-return/output
M tests/hilti/cfg/assign.hlt

Log Message:
-----------
Fix cfg handling of RHS assignments in variable declarations.


Commit: 041d6af57a389e8fe39fc56be6719f9e950039b7
https://github.com/zeek/spicy/commit/041d6af57a389e8fe39fc56be6719f9e950039b7
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-09-02 (Tue, 02 Sep 2025)

Changed paths:
M hilti/toolchain/include/compiler/detail/cfg.h
M hilti/toolchain/src/compiler/cfg.cc
M tests/Baseline/hilti.cfg.assign/output
A tests/Baseline/hilti.cfg.local-struct-value/output
M tests/Baseline/hilti.optimization.dataflow-unreachable/output
A tests/hilti/cfg/local-struct-value.hlt

Log Message:
-----------
Fix computation of aliasing and variable access in CFG.

We would previously not computing aliasing and variable reads correctly
which could lead to us incorrectly modifying code involving e.g., struct
values. This patch reworks how this is done.

To implement this correctly we also need to add function parameters to
the CFG.

Closes #2124.


Commit: e485bebe29ccce84bec584bdd0a8ad6ed69632bb
https://github.com/zeek/spicy/commit/e485bebe29ccce84bec584bdd0a8ad6ed69632bb
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-09-02 (Tue, 02 Sep 2025)

Changed paths:
M hilti/toolchain/src/compiler/optimizer.cc

Log Message:
-----------
Remove workaround for C++17.


Commit: 86b308c0b9250fdcaa5cfbf40636a8f1f0283f13
https://github.com/zeek/spicy/commit/86b308c0b9250fdcaa5cfbf40636a8f1f0283f13
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-09-02 (Tue, 02 Sep 2025)

Changed paths:
M .pre-commit-config.yaml

Log Message:
-----------
Bump pre-commit hooks.


Commit: 6e66a223e39121fe841cfb8da5a95e91fc669599
https://github.com/zeek/spicy/commit/6e66a223e39121fe841cfb8da5a95e91fc669599
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-09-02 (Tue, 02 Sep 2025)

Changed paths:
M .pre-commit-config.yaml

Log Message:
-----------
Use non-legacy ruff-check version for pre-commit.


Commit: c64ab406169ffda46bccbcb95c6ced7c49d8018e
https://github.com/zeek/spicy/commit/c64ab406169ffda46bccbcb95c6ced7c49d8018e
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-09-02 (Tue, 02 Sep 2025)

Changed paths:
M hilti/toolchain/src/compiler/cfg.cc

Log Message:
-----------
Rename variable for clarity.

This variable stopped referring to statements so its previous name
became potentially confusing. Rename it to a more generic identifier.


Commit: 39ec9ae5f26d1634beb843ef2abe7390e62d3846
https://github.com/zeek/spicy/commit/39ec9ae5f26d1634beb843ef2abe7390e62d3846
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-09-02 (Tue, 02 Sep 2025)

Changed paths:
M .pre-commit-config.yaml
M CHANGES
M VERSION
M hilti/toolchain/include/compiler/detail/cfg.h
M hilti/toolchain/src/compiler/cfg.cc
M hilti/toolchain/src/compiler/optimizer.cc
M tests/Baseline/hilti.cfg.assign/output
M tests/Baseline/hilti.cfg.dead-write-shadowed/output
A tests/Baseline/hilti.cfg.local-struct-value/output
M tests/Baseline/hilti.cfg.return/output
M tests/Baseline/hilti.cfg.switch/output
M tests/Baseline/hilti.cfg.try/output
M tests/Baseline/hilti.cfg.unreachable-return/output
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/hilti/cfg/assign.hlt
A tests/hilti/cfg/local-struct-value.hlt

Log Message:
-----------
Merge branch 'topic/bbannier/issue-2124'


Compare: https://github.com/zeek/spicy/compare/ff8932567729...39ec9ae5f26d
Reply all
Reply to author
Forward
0 new messages