[cfe-dev] Status of __builtin_unreachable in clang

Stephan Tolksdorf st at quanttec.com
Thu Oct 3 12:04:01 PDT 2013


The GCC optimizer exploits statements like

   if (x < 0) __builtin_unreachable();

to infer that x must be non-negative. This way one can communicate value 
constraints to the optimizer that the optimizer otherwise couldn't infer 
itself. MSVC supports the  __assume intrinsic for the same purpose.

clang/LLVM currently does not seem to be able to exploit 
__builtin_unreachable() in this way. I'm curious, are there any plans to 
change this in the future?

I found this related note by Chris Lattner:
http://nondot.org/sabre/LLVMNotes/BuiltinUnreachable.txt

- Stephan



More information about the cfe-dev mailing list