[llvm] r263579 - [msan] Don't put module constructors in comdats.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 15 13:25:47 PDT 2016
Author: eugenis
Date: Tue Mar 15 15:25:47 2016
New Revision: 263579
URL: http://llvm.org/viewvc/llvm-project?rev=263579&view=rev
Log:
[msan] Don't put module constructors in comdats.
There is something strange going on with debug info (.eh_frame_hdr)
disappearing when msan.module_ctor are placed in comdat sections.
Moving this functionality under flag, disabled by default.
Modified:
llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/trunk/test/Instrumentation/MemorySanitizer/global_ctors_2to3.ll
llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp?rev=263579&r1=263578&r2=263579&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Tue Mar 15 15:25:47 2016
@@ -190,6 +190,9 @@ static cl::opt<int> ClInstrumentationWit
static cl::opt<bool> ClCheckConstantShadow("msan-check-constant-shadow",
cl::desc("Insert checks for constant shadow values"),
cl::Hidden, cl::init(false));
+static cl::opt<bool> ClWithComdat("msan-with-comdat",
+ cl::desc("Place MSan constructors in comdat sections"),
+ cl::Hidden, cl::init(false));
static const char *const kMsanModuleCtorName = "msan.module_ctor";
static const char *const kMsanInitName = "__msan_init";
@@ -540,10 +543,14 @@ bool MemorySanitizer::doInitialization(M
createSanitizerCtorAndInitFunctions(M, kMsanModuleCtorName, kMsanInitName,
/*InitArgTypes=*/{},
/*InitArgs=*/{});
- Comdat *MsanCtorComdat = M.getOrInsertComdat(kMsanModuleCtorName);
- MsanCtorFunction->setComdat(MsanCtorComdat);
+ if (ClWithComdat) {
+ Comdat *MsanCtorComdat = M.getOrInsertComdat(kMsanModuleCtorName);
+ MsanCtorFunction->setComdat(MsanCtorComdat);
+ appendToGlobalCtors(M, MsanCtorFunction, 0, MsanCtorFunction);
+ } else {
+ appendToGlobalCtors(M, MsanCtorFunction, 0);
+ }
- appendToGlobalCtors(M, MsanCtorFunction, 0, MsanCtorFunction);
if (TrackOrigins)
new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
Modified: llvm/trunk/test/Instrumentation/MemorySanitizer/global_ctors_2to3.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/MemorySanitizer/global_ctors_2to3.ll?rev=263579&r1=263578&r2=263579&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/MemorySanitizer/global_ctors_2to3.ll (original)
+++ llvm/trunk/test/Instrumentation/MemorySanitizer/global_ctors_2to3.ll Tue Mar 15 15:25:47 2016
@@ -1,5 +1,5 @@
; MSan converts 2-element global_ctors to 3-element when adding the new entry.
-; RUN: opt < %s -msan -S | FileCheck %s
+; RUN: opt < %s -msan -msan-with-comdat -S | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Modified: llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll?rev=263579&r1=263578&r2=263579&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll (original)
+++ llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll Tue Mar 15 15:25:47 2016
@@ -4,8 +4,7 @@
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
-; CHECK: $msan.module_ctor = comdat any
-; CHECK: @llvm.global_ctors {{.*}} { i32 0, void ()* @msan.module_ctor, i8* bitcast (void ()* @msan.module_ctor to i8*) }
+; CHECK: @llvm.global_ctors {{.*}} { i32 0, void ()* @msan.module_ctor, i8* null }
; Check the presence and the linkage type of __msan_track_origins and
; other interface symbols.
@@ -982,5 +981,5 @@ define i8* @MismatchingCallMustTailCall(
; CHECK-NEXT: ret i8*
-; CHECK-LABEL: define internal void @msan.module_ctor() comdat {
+; CHECK-LABEL: define internal void @msan.module_ctor() {
; CHECK: call void @__msan_init()
More information about the llvm-commits
mailing list