aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/Compile.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-06-24 15:03:15 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-25 01:41:08 -0700
commit9684947faae674e093dda4c81d94f51b9568369e (patch)
tree2ea16a1a8187e467877fac1dc7d87ede9e1e0898 /lib/std/Build/Step/Compile.zig
parent82ad66b2f2bd822e6d195768da9e5247ed4d78cc (diff)
downloadzig-9684947faae674e093dda4c81d94f51b9568369e.tar.gz
zig-9684947faae674e093dda4c81d94f51b9568369e.zip
compiler: start moving safety-checks into backends
This actually used to be how it worked in stage1, and there was this issue to change it: #2649 So this commit is a reversal to that idea. One motivation for that issue was avoiding emitting the panic handler in compilations that do not have any calls to panic. This commit only resolves the panic handler in the event of a safety check function being emitted, so it does not have that flaw. The other reason given in that issue was for optimizations that elide safety checks. It's yet to be determined whether that was a good idea or not; this can get re-explored when we start adding optimization passes to AIR. This commit adds these AIR instructions, which are only emitted if `backendSupportsFeature(.safety_checked_arithmetic)` is true: * add_safe * sub_safe * mul_safe It removes these nonsensical AIR instructions: * addwrap_optimized * subwrap_optimized * mulwrap_optimized The safety-checked arithmetic functions push the burden of invoking the panic handler into the backend. This makes for a messier compiler implementation, but it reduces the amount of AIR instructions emitted by Sema, which reduces time spent in the secondary bottleneck of the compiler. It also generates more compact LLVM IR, reducing time spent in the primary bottleneck of the compiler. Finally, it eliminates 1 stack allocation per safety-check which was being used to store the resulting tuple. These allocations were going to be annoying when combined with suspension points.
Diffstat (limited to 'lib/std/Build/Step/Compile.zig')
0 files changed, 0 insertions, 0 deletions