[llvm] [IfConversion] Preserve debug info when flipping a branch (PR #114614)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 1 15:11:03 PDT 2024
https://github.com/ellishg created https://github.com/llvm/llvm-project/pull/114614
Grab the debug info location of a branch condition before we remove it and insert a flipped condition.
>From 8109012fbeff173bfed0c30cd5895f000bd9099c Mon Sep 17 00:00:00 2001
From: Ellis Hoag <ellis.sparky.hoag at gmail.com>
Date: Fri, 1 Nov 2024 14:55:38 -0700
Subject: [PATCH] [IfConversion] Preseve debug info when flipping a branch
---
llvm/lib/CodeGen/IfConversion.cpp | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp
index ba5605ad5cb4a4..bb9ca7edf7844c 100644
--- a/llvm/lib/CodeGen/IfConversion.cpp
+++ b/llvm/lib/CodeGen/IfConversion.cpp
@@ -617,14 +617,13 @@ static MachineBasicBlock *findFalseBlock(MachineBasicBlock *BB,
/// Reverse the condition of the end of the block branch. Swap block's 'true'
/// and 'false' successors.
bool IfConverter::reverseBranchCondition(BBInfo &BBI) const {
- DebugLoc dl; // FIXME: this is nowhere
- if (!TII->reverseBranchCondition(BBI.BrCond)) {
- TII->removeBranch(*BBI.BB);
- TII->insertBranch(*BBI.BB, BBI.FalseBB, BBI.TrueBB, BBI.BrCond, dl);
- std::swap(BBI.TrueBB, BBI.FalseBB);
- return true;
- }
- return false;
+ if (TII->reverseBranchCondition(BBI.BrCond))
+ return false;
+ auto Dl = BBI.BB->findBranchDebugLoc();
+ TII->removeBranch(*BBI.BB);
+ TII->insertBranch(*BBI.BB, BBI.FalseBB, BBI.TrueBB, BBI.BrCond, Dl);
+ std::swap(BBI.TrueBB, BBI.FalseBB);
+ return true;
}
/// Returns the next block in the function blocks ordering. If it is the end,
More information about the llvm-commits
mailing list