Skip to content

Instantly share code, notes, and snippets.

@regehr
Last active March 24, 2016 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save regehr/d45247f36106a65e9479 to your computer and use it in GitHub Desktop.
Save regehr/d45247f36106a65e9479 to your computer and use it in GitHub Desktop.
implementation sketch for faster integer overflow checks in clang/llvm
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