diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2015-06-12 01:48:47 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2015-06-12 01:48:47 +0000 |
commit | 201733b7f0b4fee6120dc1e0e43df90a860a34be (patch) | |
tree | a34da55f7a370e6f61419511d2c7880939f29d12 /llvm/lib | |
parent | 9947e48cd1d75d00271a0f83374981a6e56c7656 (diff) | |
download | bcm5719-llvm-201733b7f0b4fee6120dc1e0e43df90a860a34be.tar.gz bcm5719-llvm-201733b7f0b4fee6120dc1e0e43df90a860a34be.zip |
[SanitizerCoverage] Use llvm::getDISubprogram() to get location of the entry basic block.
DebugLoc::getFnDebugLoc() should soon be removed. Also,
getDISubprogram() might become more effective soon and wouldn't need to
scan debug locations at all, if function-level metadata would be emitted
by Clang.
llvm-svn: 239586
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index f6ae0c2dd5f..dff39efa5b9 100644 --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -33,6 +33,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/IR/CallSite.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/DebugInfo.h" #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/InlineAsm.h" @@ -385,9 +386,14 @@ void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F, BasicBlock &BB, } bool IsEntryBB = &BB == &F.getEntryBlock(); - DebugLoc EntryLoc = IsEntryBB && IP->getDebugLoc() - ? IP->getDebugLoc().getFnDebugLoc() - : IP->getDebugLoc(); + DebugLoc EntryLoc; + if (IsEntryBB) { + if (auto SP = getDISubprogram(&F)) + EntryLoc = DebugLoc::get(SP->getScopeLine(), 0, SP); + } else { + EntryLoc = IP->getDebugLoc(); + } + IRBuilder<> IRB(IP); IRB.SetCurrentDebugLocation(EntryLoc); SmallVector<Value *, 1> Indices; |