aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorHaohai Wen <haohai.wen@intel.com>2024-04-08 09:44:34 +0800
committerGitHub <noreply@github.com>2024-04-08 09:44:34 +0800
commitcebf77fb936a7270c7e3fa5c4a7e76216321d385 (patch)
tree6feb58161912f149cd2815d25234993bffe42be0 /llvm/lib/CodeGen
parentda675b922cca3dc9a76642d792e882979a3d8c82 (diff)
downloadllvm-cebf77fb936a7270c7e3fa5c4a7e76216321d385.zip
llvm-cebf77fb936a7270c7e3fa5c4a7e76216321d385.tar.gz
llvm-cebf77fb936a7270c7e3fa5c4a7e76216321d385.tar.bz2
[CodeGen][DebugInfo] Add missing DebugLoc for SplitCriticalEdge (#72192)
In SplitCriticalEdge, DebugLoc of the branch instruction in new created MBB was set to empty. It should be set and we can find proper DebugLoc for it in most cases. This patch set it to non empty merged DebugLoc of current MBB branches.
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 4410fb7..b2114c2 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1137,7 +1137,6 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
MachineFunction *MF = getParent();
MachineBasicBlock *PrevFallthrough = getNextNode();
- DebugLoc DL; // FIXME: this is nowhere
MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock();
NMBB->setCallFrameSize(Succ->getCallFrameSize());
@@ -1218,6 +1217,15 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
SlotIndexUpdateDelegate SlotUpdater(*MF, Indexes);
SmallVector<MachineOperand, 4> Cond;
const TargetInstrInfo *TII = getParent()->getSubtarget().getInstrInfo();
+
+ // In original 'this' BB, there must be a branch instruction targeting at
+ // Succ. We can not find it out since currently getBranchDestBlock was not
+ // implemented for all targets. However, if the merged DL has column or line
+ // number, the scope and non-zero column and line number is same with that
+ // branch instruction so we can safely use it.
+ DebugLoc DL, MergedDL = findBranchDebugLoc();
+ if (MergedDL && (MergedDL.getLine() || MergedDL.getCol()))
+ DL = MergedDL;
TII->insertBranch(*NMBB, Succ, nullptr, Cond, DL);
}