summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
diff options
context:
space:
mode:
authorKuba Mracek <mracek@apple.com>2018-03-08 20:05:45 +0000
committerKuba Mracek <mracek@apple.com>2018-03-08 20:05:45 +0000
commit584bd10803640444812afdf7ed76fabf56fc3d85 (patch)
tree9e612f55de349030eeae67216603809490032b51 /llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
parent45ae11cd80ab83d11c6310c954b0537c2d863a91 (diff)
downloadbcm5719-llvm-584bd10803640444812afdf7ed76fabf56fc3d85.tar.gz
bcm5719-llvm-584bd10803640444812afdf7ed76fabf56fc3d85.zip
[asan] Fix a false positive ODR violation due to LTO ConstantMerge pass [llvm part, take 2]
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: 327053
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 87576996d7b..6fa764ef089 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -2158,6 +2158,13 @@ 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 *>(
+ reinterpret_cast<GlobalValue **>(NewGlobals.data()),
+ NewGlobals.size()));
+
std::string ELFUniqueModuleId =
(UseGlobalsGC && TargetTriple.isOSBinFormatELF()) ? getUniqueModuleId(&M)
: "";
OpenPOWER on IntegriCloud