[llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp
Dale Johannesen
dalej at apple.com
Tue May 15 14:19:35 PDT 2007
Changes in directory llvm/lib/CodeGen:
BranchFolding.cpp updated: 1.52 -> 1.53
---
Log message:
Remove extra CFG edges before doing these passes; it makes them happier.
---
Diffs of the changes: (+16 -1)
BranchFolding.cpp | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletion(-)
Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.52 llvm/lib/CodeGen/BranchFolding.cpp:1.53
--- llvm/lib/CodeGen/BranchFolding.cpp:1.52 Thu May 10 18:59:23 2007
+++ llvm/lib/CodeGen/BranchFolding.cpp Tue May 15 16:19:17 2007
@@ -73,6 +73,12 @@
char BranchFolder::ID = 0;
}
+static bool CorrectExtraCFGEdges(MachineBasicBlock &MBB,
+ MachineBasicBlock *DestA,
+ MachineBasicBlock *DestB,
+ bool isCond,
+ MachineFunction::iterator FallThru);
+
FunctionPass *llvm::createBranchFoldingPass() { return new BranchFolder(); }
/// RemoveDeadBlock - Remove the specified dead machine basic block from the
@@ -106,12 +112,21 @@
TII = MF.getTarget().getInstrInfo();
if (!TII) return false;
+ // Fix CFG. The later algorithms expect it to be right.
+ bool EverMadeChange = false;
+ for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; I++) {
+ MachineBasicBlock *MBB = I, *TBB = 0, *FBB = 0;
+ std::vector<MachineOperand> Cond;
+ if (!TII->AnalyzeBranch(*MBB, TBB, FBB, Cond))
+ EverMadeChange |= CorrectExtraCFGEdges(*MBB, TBB, FBB,
+ !Cond.empty(), next(I));
+ }
+
RegInfo = MF.getTarget().getRegisterInfo();
RS = RegInfo->requiresRegisterScavenging(MF) ? new RegScavenger() : NULL;
MMI = getAnalysisToUpdate<MachineModuleInfo>();
- bool EverMadeChange = false;
bool MadeChangeThisIteration = true;
while (MadeChangeThisIteration) {
MadeChangeThisIteration = false;
More information about the llvm-commits
mailing list