diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2016-02-12 00:37:52 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2016-02-12 00:37:52 +0000 |
commit | ba6ca87ffb280bc274229bac588cfc87242ccd94 (patch) | |
tree | 62f56a4310ff949a0197e2acbf5252526f49dada /llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | |
parent | 0466c7ce23237cd9bac71884cc5d87d0ceb54359 (diff) | |
download | bcm5719-llvm-ba6ca87ffb280bc274229bac588cfc87242ccd94.tar.gz bcm5719-llvm-ba6ca87ffb280bc274229bac588cfc87242ccd94.zip |
[msan] Put msan constructor in a comdat.
MSan adds a constructor to each translation unit that calls
__msan_init, and does nothing else. The idea is to run __msan_init
before any instrumented code. This results in multiple constructors
and multiple .init_array entries in the final binary, one per
translation unit. This is absolutely unnecessary; one would be
enough.
This change moves the constructors to a comdat group in order to drop
the extra ones.
llvm-svn: 260632
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index b26a4b55505..6ebf6e20a4a 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -540,8 +540,10 @@ bool MemorySanitizer::doInitialization(Module &M) { createSanitizerCtorAndInitFunctions(M, kMsanModuleCtorName, kMsanInitName, /*InitArgTypes=*/{}, /*InitArgs=*/{}); + Comdat *MsanCtorComdat = M.getOrInsertComdat(kMsanModuleCtorName); + MsanCtorFunction->setComdat(MsanCtorComdat); - appendToGlobalCtors(M, MsanCtorFunction, 0); + appendToGlobalCtors(M, MsanCtorFunction, 0, MsanCtorFunction); if (TrackOrigins) new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage, |