summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
diff options
context:
space:
mode:
authorKuba Mracek <mracek@apple.com>2018-12-18 21:20:17 +0000
committerKuba Mracek <mracek@apple.com>2018-12-18 21:20:17 +0000
commit3760fc9f3de19c6d24f74d4a5ba4682647271a4a (patch)
tree6083c6342ab7cd3ca4275c6750cf898978393665 /llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
parent73c86852952d9a5862b2321f897f85a928433651 (diff)
downloadbcm5719-llvm-3760fc9f3de19c6d24f74d4a5ba4682647271a4a.tar.gz
bcm5719-llvm-3760fc9f3de19c6d24f74d4a5ba4682647271a4a.zip
[asan] In llvm.asan.globals, allow entries to be non-GlobalVariable and skip over them
Looks like there are valid reasons why we need to allow bitcasts in llvm.asan.globals, see discussion at https://github.com/apple/swift-llvm/pull/133. Let's look through bitcasts when iterating over entries in the llvm.asan.globals list. Differential Revision: https://reviews.llvm.org/D55794 llvm-svn: 349544
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index a5c64f354f4..769cd2343e0 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -441,8 +441,11 @@ public:
for (auto MDN : Globals->operands()) {
// Metadata node contains the global and the fields of "Entry".
assert(MDN->getNumOperands() == 5);
- auto *GV = mdconst::extract_or_null<GlobalVariable>(MDN->getOperand(0));
+ auto *V = mdconst::extract_or_null<Constant>(MDN->getOperand(0));
// The optimizer may optimize away a global entirely.
+ if (!V) continue;
+ auto *StrippedV = V->stripPointerCasts();
+ auto *GV = dyn_cast<GlobalVariable>(StrippedV);
if (!GV) continue;
// We can already have an entry for GV if it was merged with another
// global.
OpenPOWER on IntegriCloud