[asan] don't emit __asan_mapping_offset/__asan_mapping_scale by default -- they are...
authorKostya Serebryany <kcc@google.com>
Mon, 19 Mar 2012 16:40:35 +0000 (16:40 +0000)
committerKostya Serebryany <kcc@google.com>
Mon, 19 Mar 2012 16:40:35 +0000 (16:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153040 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/AddressSanitizer.cpp

index 544e22cc0179f452a81e4dbf304e99e4f1ef8ada..a51bd7e41c85ff629a7886c98a6bad1025b662ec 100644 (file)
@@ -579,18 +579,23 @@ bool AddressSanitizer::runOnModule(Module &M) {
   if (ClGlobals)
     Res |= insertGlobalRedzones(M);
 
-  // Tell the run-time the current values of mapping offset and scale.
-  GlobalValue *asan_mapping_offset =
-      new GlobalVariable(M, IntptrTy, true, GlobalValue::LinkOnceODRLinkage,
-                     ConstantInt::get(IntptrTy, MappingOffset),
-                     kAsanMappingOffsetName);
-  GlobalValue *asan_mapping_scale =
-      new GlobalVariable(M, IntptrTy, true, GlobalValue::LinkOnceODRLinkage,
-                         ConstantInt::get(IntptrTy, MappingScale),
-                         kAsanMappingScaleName);
-  // Read these globals, otherwise they may be optimized away.
-  IRB.CreateLoad(asan_mapping_scale, true);
-  IRB.CreateLoad(asan_mapping_offset, true);
+  if (ClMappingOffsetLog >= 0) {
+    // Tell the run-time the current values of mapping offset and scale.
+    GlobalValue *asan_mapping_offset =
+        new GlobalVariable(M, IntptrTy, true, GlobalValue::LinkOnceODRLinkage,
+                       ConstantInt::get(IntptrTy, MappingOffset),
+                       kAsanMappingOffsetName);
+    // Read the global, otherwise it may be optimized away.
+    IRB.CreateLoad(asan_mapping_offset, true);
+  }
+  if (ClMappingScale) {
+    GlobalValue *asan_mapping_scale =
+        new GlobalVariable(M, IntptrTy, true, GlobalValue::LinkOnceODRLinkage,
+                           ConstantInt::get(IntptrTy, MappingScale),
+                           kAsanMappingScaleName);
+    // Read the global, otherwise it may be optimized away.
+    IRB.CreateLoad(asan_mapping_scale, true);
+  }
 
 
   for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {