summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAmara Emerson <aemerson@apple.com>2019-06-13 22:15:35 +0000
committerAmara Emerson <aemerson@apple.com>2019-06-13 22:15:35 +0000
commitfb0a40f0648dca2986a5fa54eb6d7ad5a1fcf6d6 (patch)
treeb30cf70837aa8a0351ad8f2e64d9d01de11dfedb /llvm/lib
parentcf34a2bd5d6ec941e755d85e49525712453b0777 (diff)
downloadbcm5719-llvm-fb0a40f0648dca2986a5fa54eb6d7ad5a1fcf6d6.tar.gz
bcm5719-llvm-fb0a40f0648dca2986a5fa54eb6d7ad5a1fcf6d6.zip
[GlobalISel][IRTranslator] Add debug loc with line 0 to constants emitted into the entry block.
Constants, including G_GLOBAL_VALUE, are all emitted into the entry block which lets us use the vreg def assuming it dominates all other users. However, it can cause jumpy debug behaviour since the DebugLoc attached to these MIs are from a user instruction that could be in a different block. Fixes PR40887. Differential Revision: https://reviews.llvm.org/D63286 llvm-svn: 363331
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 78b452899ef..e900a797cc7 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -136,7 +136,11 @@ public:
LLVM_DEBUG(dbgs() << "Checking DILocation from " << *CurrInst
<< " was copied to " << MI);
#endif
- assert(CurrInst->getDebugLoc() == MI.getDebugLoc() &&
+ // We allow insts in the entry block to have a debug loc line of 0 because
+ // they could have originated from constants, and we don't want a jumpy
+ // debug experience.
+ assert((CurrInst->getDebugLoc() == MI.getDebugLoc() ||
+ MI.getDebugLoc().getLine() == 0) &&
"Line info was not transferred to all instructions");
}
};
@@ -1713,8 +1717,15 @@ bool IRTranslator::valueIsSplit(const Value &V,
bool IRTranslator::translate(const Instruction &Inst) {
CurBuilder->setDebugLoc(Inst.getDebugLoc());
- EntryBuilder->setDebugLoc(Inst.getDebugLoc());
- switch(Inst.getOpcode()) {
+ // We only emit constants into the entry block from here. To prevent jumpy
+ // debug behaviour set the line to 0.
+ if (const DebugLoc &DL = Inst.getDebugLoc())
+ EntryBuilder->setDebugLoc(
+ DebugLoc::get(0, 0, DL.getScope(), DL.getInlinedAt()));
+ else
+ EntryBuilder->setDebugLoc(DebugLoc());
+
+ switch (Inst.getOpcode()) {
#define HANDLE_INST(NUM, OPCODE, CLASS) \
case Instruction::OPCODE: \
return translate##OPCODE(Inst, *CurBuilder.get());
OpenPOWER on IntegriCloud