diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-06-14 06:08:32 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-06-14 06:08:32 +0000 |
commit | 844485af13aaca2bedb247b2ffee380046bd5a80 (patch) | |
tree | ecba08ffee7dd84ca08495bdd0fbb1958bed1f31 /llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | |
parent | 9925ec8bf44688f7e529f4c143d2d0933919b4a7 (diff) | |
download | bcm5719-llvm-844485af13aaca2bedb247b2ffee380046bd5a80.tar.gz bcm5719-llvm-844485af13aaca2bedb247b2ffee380046bd5a80.zip |
Implement Jakob's suggestion on how to detect fall thought without calling
AnalyzeBranch.
llvm-svn: 132981
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index f324148cea4..187963c26a1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1934,19 +1934,26 @@ isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const { if (Pred->empty()) return true; - // Otherwise, ask the backend. - const TargetInstrInfo *TII = MF->getTarget().getInstrInfo(); - MachineBasicBlock *PredTBB = NULL, *PredFBB = NULL; - SmallVector<MachineOperand, 4> PredCond; - if (TII->AnalyzeBranch(*Pred, PredTBB, PredFBB, PredCond)) - return false; - - if (PredTBB == MBB || PredFBB == MBB) - return false; + // Check the terminators in the previous blocks + for (MachineBasicBlock::iterator II = Pred->getFirstTerminator(), + IE = Pred->end(); II != IE; ++II) { + MachineInstr &MI = *II; + + // If it is not a simple branch, we are in a table somewhere. + if (!MI.getDesc().isBranch() || MI.getDesc().isIndirectBranch()) + return false; + + // If we are the operands of one of the branches, this is not + // a fall through. + for (MachineInstr::mop_iterator OI = MI.operands_begin(), + OE = MI.operands_end(); OI != OE; ++OI) { + const MachineOperand& OP = *OI; + if (OP.isMBB() && OP.getMBB() == MBB) + return false; + } + } - // This is a fall through if there is no conditions in the bb - // or if there is no explicit false branch. - return PredCond.empty() || !PredFBB; + return true; } |