diff options
author | Kuba Mracek <mracek@apple.com> | 2018-03-08 17:24:06 +0000 |
---|---|---|
committer | Kuba Mracek <mracek@apple.com> | 2018-03-08 17:24:06 +0000 |
commit | 0e06d37dba6e997bc75477523b313c5ba442e792 (patch) | |
tree | fa7da2c88ae83f8722d904642648b128ef03c353 /llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | |
parent | 788a4336cd8e84da0c8e572d6cbf012e1204b7f1 (diff) | |
download | bcm5719-llvm-0e06d37dba6e997bc75477523b313c5ba442e792.tar.gz bcm5719-llvm-0e06d37dba6e997bc75477523b313c5ba442e792.zip |
[asan] Fix a false positive ODR violation due to LTO ConstantMerge pass [llvm part]
This fixes a false positive ODR violation that is reported by ASan when using LTO. In cases, where two constant globals have the same value, LTO will merge them, which breaks ASan's ODR detection.
Differential Revision: https://reviews.llvm.org/D43959
llvm-svn: 327029
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 87576996d7b..6a8ba6f6c43 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -2158,6 +2158,12 @@ bool AddressSanitizerModule::InstrumentGlobals(IRBuilder<> &IRB, Module &M, bool Initializers[i] = Initializer; } + // Add instrumented globals to llvm.compiler.used list to avoid LTO from + // ConstantMerge'ing them. + appendToCompilerUsed( + M, ArrayRef<GlobalValue *>(cast<GlobalValue *>(NewGlobals.data()), + NewGlobals.size())); + std::string ELFUniqueModuleId = (UseGlobalsGC && TargetTriple.isOSBinFormatELF()) ? getUniqueModuleId(&M) : ""; |