[LLVMdev] inttoptr weirdness

Chris Lattner clattner at apple.com
Mon Dec 14 15:50:33 PST 2009

On Dec 14, 2009, at 2:21 PM, Jeffrey Yasskin wrote:
>> @"compile-test::*testObj*" = external constant i8*              ;  
>> <i8**> [#uses=1]
>> define void @"compile-test::__toplevel-main"() {
>> entry:
>>        store i8* null, i8** @"compile-test::*testObj*"
> I'm surprised this store got optimized out, even though LLVM can
> optimize away the subsequent load. Writing to an external global
> variable is a visible side-effect, and unless there's other undefined
> behavior, LLVM shouldn't remove it.

Sure it can, llvm can delete any non-volatile redundant load, or any  
non-volatile redundant store.  It doesn't matter whether it is to a  
global or not, LLVM (as with many compilers) memory models are for  
single threaded programs.  We do try to conform to the C++'0x memory  
model by not introducing memory accesses where they did not exist  
before, but deleting non-volatile accesses is always fine.


More information about the llvm-dev mailing list