[msan] Change linkage type of __msan_track_origins.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 5 Dec 2012 12:49:41 +0000 (12:49 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 5 Dec 2012 12:49:41 +0000 (12:49 +0000)
LinkOnceODRLinkage globals may be removed in GlobalOpt if not used in the
current module.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169377 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/MemorySanitizer.cpp
test/Instrumentation/MemorySanitizer/msan_basic.ll

index 81cbb07831c3477fc4714e41f5b1abc1d5713dea..4680994c32608d46a6004101deca8118cc72ecac 100644 (file)
@@ -244,7 +244,7 @@ bool MemorySanitizer::doInitialization(Module &M) {
   appendToGlobalCtors(M, cast<Function>(M.getOrInsertFunction(
                       "__msan_init", IRB.getVoidTy(), NULL)), 0);
 
-  new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::LinkOnceODRLinkage,
+  new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
                      IRB.getInt32(ClTrackOrigins), "__msan_track_origins");
 
   // Create the callback.
index acad4ba6bb0be5094dc83ccad1a3120946e7cd43..05cdaa7d6f3a4b95cc0460e4714586173d6e3c8f 100644 (file)
@@ -4,6 +4,9 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
 ; Check the presence of __msan_init
 ; CHECK: @llvm.global_ctors {{.*}} @__msan_init
 
+; Check the presence and the linkage type of __msan_track_origins
+; CHECK: @__msan_track_origins = weak_odr constant i32 0
+
 ; load followed by cmp: check that we load the shadow and call __msan_warning.
 define void @LoadAndCmp(i32* nocapture %a) nounwind uwtable {
 entry: