[LLVMdev] Call to address 0 gets removed

John McCall rjmccall at apple.com
Wed Jun 10 12:25:42 PDT 2009


There's another point that hasn't been raised yet here, which is that  
the
undefinedness of calling (void*) 0 is a property of C, not necessarily  
of
the LLVM abstract language.  I think you can make an excellent case that
the standard optimizations should not be enforcing C language semantics,
or at least should allow such optimizations to be disabled.

Case in point — calls/loads/stores to null may be undefined behavior  
in C,
but they're certainly not undefined behavior in (say) Java.  There's a  
well-
known implementation trick in JVMs where you optimistically emit code
assuming non-null objects, and then you install signal handlers to raise
exceptions in the cases where you're wrong.  Now, obviously that trick
is going to have implications for the optimizers beyond "don't mark null
stores as unreachable" , but even so, it really shouldn't be totally  
precluded
by widespread assumptions of C semantics.

John.



More information about the llvm-dev mailing list