<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="HOEnZb"><div class="h5"><br>
<br>
</div></div>A couple review comments:<br>
<br>
AddressSanitizer::appendToGlobalCtors is messy at best; </blockquote><div><br></div><div>Agree (the code is stolen from some other part of LLVM and fixed to actually work).  </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
is there<br>
really no better way to get the asan init function to run when it<br>
needs to?<br></blockquote><div><br></div><div>I see no other way other than to append to llvm.global_ctors.</div><div>Given that I didn't find whether LLVM guaranties the particular order of CTOR execution, I have to call them twice, at the beginning and at the end of llvm.global_ctors</div>
<div>Suggestions?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Please get rid of blockHasException and the dependent code; the<br>
eh_exception intrinsic is going away very soon, and you shouldn't run<br>
into similar issues with the new exception handling framework.<br></blockquote><div><br></div><div>Done. </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
+  GlobalValue *asan_mapping_offset =<br>
+      new GlobalVariable(M, IntPtrTy, true, GlobalValue::LinkOnceODRLinkage,<br>
+                     ConstantInt::get(IntPtrTy, 1ULL << MappingOffsetLog),<br>
+                     "__asan_mapping_offset");<br>
+  GlobalValue *asan_mapping_scale =<br>
+      new GlobalVariable(M, IntPtrTy, true, GlobalValue::LinkOnceODRLinkage,<br>
+                         ConstantInt::get(IntPtrTy, MappingScale),<br>
+                         "__asan_mapping_scale");<br>
<br>
If you use WeakLinkage for these, you won't need the fake loads.<br></blockquote><div><br></div><div>Surprisingly these globals *were* optimized away at -O3, at least at some point. </div><div>Dropped the fake loads for now. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<span class="HOEnZb"><font color="#888888"><br>
-Eli<br>
</font></span></blockquote></div><br>