<div>I have a problem where my LLVM-generated code works on Linux but not on OS X, and the problem involves non_lazy_ptr.</div><div><br></div><meta charset="utf-8"><div>I have an external symbol named "@gc_safepoint_map", which is generated by the linker's GCStrategy plugin. Since it is not generated until link time, I declared it as an external symbol so that the modules that use it can compile without error.</div>

<div><br></div><div>Here's what the generated IR looks like:</div><div><br></div><div>  @gc_safepoint_map = external global [0 x i32]</div><div><br></div><div>The runtime startup code gets the safepoint map and calls GC_init with the safepoint map. Here's what the code looks like in IR:</div>

<div><br></div><div><div>  %init = invoke {} @GC_init(i32* getelementptr inbounds ([0 x i32]* @gc_safepoint_map, i32 0, i32 0))</div><div>          to label %nounwind unwind label %catch</div><div><br></div></div><div>When lowered to assembly, the code looks like this on OS X:</div>

<div><br></div><div><div>   Ltmp426:</div><div>           movl    L_gc_safepoint_map$non_lazy_ptr, %eax</div><div>           movl    %eax, (%esp)</div><div>           calll   _GC_init</div></div><div><br></div><div>(and later on in the same file):</div>

<div><br></div><div><div>   L_gc_safepoint_map$non_lazy_ptr:</div><div>           .indirect_symbol        _gc_safepoint_map</div><div>           .long   0</div></div><div><br></div><div>This looks correct to me - it's dereferencing the non_lazy_ptr version of the global.</div>

<div><br></div><div>The GC_init function, which is written in C, simply looks like this:</div><div><br></div><div><div>  void GC_init(size_t * safepointMap) {</div></div><div>    // ... details omitted...</div><div>  }</div>

<div><br></div><div>On Linux, everything works as expected, however in OS X, the 'safepointMap' pointer is completely wrong - I'm not sure where it's getting the value from but it isn't sensible.</div>

<div><br></div><div>Unfortunately, gdb won't let me print out the value of of L_gc_safepoint_map$non_lazy_ptr (No symbol "L_gc_safepoint_map$non_lazy_ptr" in current context) so it's hard to tell what's actually going on.</div>

<br>-- <br>-- Talin<br>