Last active
March 24, 2016 19:47
-
-
Save regehr/d45247f36106a65e9479 to your computer and use it in GitHub Desktop.
implementation sketch for faster integer overflow checks in clang/llvm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I want to speed up integer overflow checking for hardening purposes by keeping a sticky overflow flag and only trapping when necessary. I want the implementation to be simple but hopefully amenable to optimizations. In the codegen part of clang: | |
- each function gets an i1 for storing overflow information, initialized to 0 | |
- each integer overflow check ORs its result into the overflow flag | |
- before each function call, return instruction, or other side-effecting operation, execude ud2 if overflow is set | |
Reasonable? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment