diff options
author | Dale Johannesen <dalej@apple.com> | 2007-05-15 21:19:17 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2007-05-15 21:19:17 +0000 |
commit | 14ba0cc42959a3fcc9b6781aea614b01877fb55f (patch) | |
tree | 791df52d45a9fc348117948c3d78d96859c19de1 /lib/CodeGen/BranchFolding.cpp | |
parent | e0adffa2d7964736bc7958bb2cf7b68da3e0e2b1 (diff) |
Remove extra CFG edges before doing these passes; it makes them happier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/BranchFolding.cpp')
-rw-r--r-- | lib/CodeGen/BranchFolding.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index 5fe0486eb1..7b4aaae482 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/lib/CodeGen/BranchFolding.cpp @@ -73,6 +73,12 @@ namespace { 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 @@ bool BranchFolder::runOnMachineFunction(MachineFunction &MF) { 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; |