From 3760fc9f3de19c6d24f74d4a5ba4682647271a4a Mon Sep 17 00:00:00 2001 From: Kuba Mracek Date: Tue, 18 Dec 2018 21:20:17 +0000 Subject: [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 --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp') 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(MDN->getOperand(0)); + auto *V = mdconst::extract_or_null(MDN->getOperand(0)); // The optimizer may optimize away a global entirely. + if (!V) continue; + auto *StrippedV = V->stripPointerCasts(); + auto *GV = dyn_cast(StrippedV); if (!GV) continue; // We can already have an entry for GV if it was merged with another // global. -- cgit v1.2.3