diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2015-06-26 00:00:47 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2015-06-26 00:00:47 +0000 |
commit | 773e8c39665ef63e5d6e7797f862e90d84a9141d (patch) | |
tree | b17846df22c9d49a617b5c524842906591740acd | |
parent | 16dc86d9232cc0bf67d3e311c483a1b70a71ff99 (diff) | |
download | bcm5719-llvm-773e8c39665ef63e5d6e7797f862e90d84a9141d.tar.gz bcm5719-llvm-773e8c39665ef63e5d6e7797f862e90d84a9141d.zip |
[ASan] Use llvm::getDISubprogram() to get function entry debug location.
It can be more robust than copying debug info from first non-alloca
instruction in the entry basic block. We use the same strategy in
coverage instrumentation.
llvm-svn: 240738
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 92b13c49ede..e7ef9f96edc 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1674,12 +1674,6 @@ void FunctionStackPoisoner::SetShadowToStackAfterReturnInlined( } } -static DebugLoc getFunctionEntryDebugLocation(Function &F) { - for (const auto &Inst : F.getEntryBlock()) - if (!isa<AllocaInst>(Inst)) return Inst.getDebugLoc(); - return DebugLoc(); -} - PHINode *FunctionStackPoisoner::createPHI(IRBuilder<> &IRB, Value *Cond, Value *ValueIfTrue, Instruction *ThenTerm, @@ -1732,7 +1726,9 @@ void FunctionStackPoisoner::poisonStack() { if (AllocaVec.size() == 0) return; int StackMallocIdx = -1; - DebugLoc EntryDebugLocation = getFunctionEntryDebugLocation(F); + DebugLoc EntryDebugLocation; + if (auto SP = getDISubprogram(&F)) + EntryDebugLocation = DebugLoc::get(SP->getScopeLine(), 0, SP); Instruction *InsBefore = AllocaVec[0]; IRBuilder<> IRB(InsBefore); |