Repository navigation
Prevent analysis of functions only referenced at comptime - #15891
Conversation
93a8cb5 to
1df228c
Compare
|
Note the second commit in this PR, which disables incremental test cases for now. After some discussion, Andrew and I agreed this is a better course of action than trying to patch a questionable fix into the incremental compilation logic; better to allow for immediate progress on the compiler and come back to these tests once incremental compilation is more mature. |
1df228c to
d0e0bac
Compare
The idea here is that there are two ways we can reference a function at runtime:
* Through a direct call, i.e. where the function is comptime-known
* Through a function pointer
This means we can easily perform a form of rudimentary escape analysis
on functions. If we ever see a `decl_ref` or `ref` of a function, we
have a function pointer, which could "leak" into runtime code, so we
emit the function; but for a plain `decl_val`, there's no need to.
This change means that `comptime { _ = f; }` no longer forces a function
to be emitted, which was used for some things (mainly tests). These use
sites have been replaced with `_ = &f;`, which still triggers analysis
of the function body, since you're taking a pointer to the function.
Resolves: ziglang#6256
Resolves: ziglang#15353
These were failing on the prior commit. Unfortunately, the fix would have been relatively complicated, and ties into underlying issues with the current incremental compilation logic. After discussing this with Andrew, we agreed that the best course of action is to completely disable incremental compilation tests for now until it's more mature, at which point we can re-enable them.
Head branch was pushed to by a user without write access
d0e0bac to
0f58d34
Compare
|
(aarch64-windows was a random failure and just needs a re-run) |
oh what the heck it happened again |
The idea here is that there are two ways we can reference a function at runtime:
This means we can easily perform a form of rudimentary escape analysis on functions. If we ever see a
decl_reforrefof a function, we have a function pointer, which could "leak" into runtime code, so we emit the function; but for a plaindecl_val, there's no need to.This change means that
comptime { _ = f; }no longer forces a function to be emitted, which was used for some things (mainly tests). These use sites have been replaced with_ = &f;, which still triggers analysis of the function body, since you're taking a pointer to the function.Resolves: #6256
Resolves: #15353