Commit Graph

7 Commits

Author SHA1 Message Date
John McCall 8cda95bca4 Don't delay stack deallocation of non-nested allocations
Credit to @eeckstein for noticing this possibility

I considered some much more complicated solutions to this problem, like
tracking all the deallocations we add and remove and then undoing them
for the allocations we end up marking non_nested, but ultimately I
figured out that this would work and was much less invasive, even if it
potentially yields slightly worse results in some cases.
2026-04-02 19:30:57 -04:00
John McCall a3c4f35c02 Add some abstractions for working with stack alloc/dealloc instructions.
NFC. Should make it easier to be exhaustive about these things.
2026-03-06 03:14:46 -05:00
Michael Gottesman 8a7b5f7c7f [sil-verifier] Make flow sensitive verification handle begin_apply token/allocation correctly.
Specifically:

1. We were tracking the stack allocation both in handleScopeInst and in the
Stack. We should only track it in one of them. I also used this as an
opportunity to make sure the code worked for non_nested code.

2. I made it so that we properly handle the end tracking part of the code so we
handle the token/stack part of begin_apply correctly. I generalized the code so
that we should handle non_nested stack allocations as well.

I included tests that validated that we now handle this correctly.
2025-12-02 14:17:27 -08:00
Michael Gottesman c9076506ec [sil-verifier] Convert a if (x && isa<Inst>(x)) -> (isa_and_present<Inst>(x)). 2025-12-02 13:11:26 -08:00
Michael Gottesman 94763c8429 [sil-verifier] Convert else-if chain to if + continue to clarify control flow.
else-if chains provide the possibility that there is additional code after the
else-if chain. In this case, no such code exists, so by using early continues we
communicate that the iteration ends at the end of an if block and the programmer
does not need to read to the end of the else-if block.

This also allows for me to eliminate one level of indentation in the successor
code as well.
2025-12-02 13:10:27 -08:00
Michael Gottesman 5ef8f3b248 [sil-verifier] Add a dump method to BBState for FlowSensitiveVerification.
Just to make it easier to diagnose problems in the debugger.
2025-12-02 13:07:40 -08:00
Michael Gottesman c739308f2b [sil-verifier] Extract the flow sensitive verifier into its own file.
This has grown large enough and complex enough that it makes sense to go into
its own file.

This is a NFCI change. The only substantial changes is I added a small require
impl based on the one in SILVerifier and I eliminated the namespace
VerifyFlowSensitiveRulesDetails.
2025-12-02 12:45:23 -08:00