summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2017-10-02 18:13:14 +0000
committerDehao Chen <dehao@google.com>2017-10-02 18:13:14 +0000
commitf464627f2828b3496456a41b5697f31c6756431f (patch)
tree5c74c754c0bf8c82e24f97a18b4d0c896308c04c /llvm/lib/IR
parentbf11424b7fcabf997c2d43c7d0d9949351588b45 (diff)
downloadbcm5719-llvm-f464627f2828b3496456a41b5697f31c6756431f.tar.gz
bcm5719-llvm-f464627f2828b3496456a41b5697f31c6756431f.zip
Update getMergedLocation to check the instruction type and merge properly.
Summary: If the merged instruction is call instruction, we need to set the scope to the closes common scope between 2 locations, otherwise it will cause trouble when the call is getting inlined. Reviewers: dblaikie, aprantl Reviewed By: dblaikie, aprantl Subscribers: llvm-commits, sanjoy Differential Revision: https://reviews.llvm.org/D37877 llvm-svn: 314694
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 1dc6c5bdd51..289798648b5 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -669,3 +669,26 @@ unsigned llvm::getDebugMetadataVersionFromModule(const Module &M) {
return Val->getZExtValue();
return 0;
}
+
+void Instruction::applyMergedLocation(const DILocation *LocA,
+ const DILocation *LocB) {
+ if (LocA && LocB && (LocA == LocB || !LocA->canDiscriminate(*LocB))) {
+ setDebugLoc(LocA);
+ return;
+ }
+ if (!LocA || !LocB || !isa<CallInst>(this)) {
+ setDebugLoc(nullptr);
+ return;
+ }
+ SmallPtrSet<DILocation *, 5> InlinedLocationsA;
+ for (DILocation *L = LocA->getInlinedAt(); L; L = L->getInlinedAt())
+ InlinedLocationsA.insert(L);
+ const DILocation *Result = LocB;
+ for (DILocation *L = LocB->getInlinedAt(); L; L = L->getInlinedAt()) {
+ Result = L;
+ if (InlinedLocationsA.count(L))
+ break;
+ }
+ setDebugLoc(DILocation::get(
+ Result->getContext(), 0, 0, Result->getScope(), Result->getInlinedAt()));
+}
OpenPOWER on IntegriCloud