> > Overall, it seems much simpler and safer to just correct overflows in the compiled code.
> Simpler: yes. Safer: yes. Unfortunately, it's also much slower.
In my experience with something similar - compiling LLVM to JavaScript in Emscripten, which also needs to properly implement integer math in JavaScript - it actually isn't a lot slower. On the Emscripten benchmark suite enabling overflow correction everywhere makes it only 5% slower. We might be running very different benchmarks I guess.
(However, overflow correction does increase code size a lot, which is why we have tools that let you get rid of it where it isn't needed.)
> Simpler: yes. Safer: yes. Unfortunately, it's also much slower.
In my experience with something similar - compiling LLVM to JavaScript in Emscripten, which also needs to properly implement integer math in JavaScript - it actually isn't a lot slower. On the Emscripten benchmark suite enabling overflow correction everywhere makes it only 5% slower. We might be running very different benchmarks I guess.
(However, overflow correction does increase code size a lot, which is why we have tools that let you get rid of it where it isn't needed.)