summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2004-07-31 15:14:29 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2004-07-31 15:14:29 +0000
commit2303d3f660557d32dd8e1d61e244841f6e0d8951 (patch)
treef2f0a573509d4482d467e83d345b27f55cb82823 /llvm/lib/CodeGen
parent1e8d8fd81fe8096eaae017d7502792e7599ca647 (diff)
downloadbcm5719-llvm-2303d3f660557d32dd8e1d61e244841f6e0d8951.tar.gz
bcm5719-llvm-2303d3f660557d32dd8e1d61e244841f6e0d8951.zip
Use next() helper to make code more readable. Use
MachineFunction::iterator instead of MachineBasicBlock* to avoid dereferencing end iterators. llvm-svn: 15373
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index b5103750f77..ef28c958859 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -20,6 +20,7 @@
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
+#include "Support/STLExtras.h"
using namespace llvm;
namespace {
@@ -113,7 +114,7 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB,
// explicitly.
if (MBB->empty()) {
if (MBB->pred_empty()) return false;
- MachineFunction::iterator FallThrough = MBB; ++FallThrough;
+ MachineFunction::iterator FallThrough = next(MBB);
assert(FallThrough != MBB->getParent()->end() &&
"Fell off the end of the function!");
while (!MBB->pred_empty()) {
@@ -138,7 +139,7 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB,
// If MBB does not end with a barrier, add a goto instruction to the end.
if (Pred->empty() || !TII.isBarrier(Pred->back().getOpcode()))
- TII.insertGoto(*Pred, *++MachineFunction::iterator(MBB));
+ TII.insertGoto(*Pred, *next(MBB));
// Update the CFG now.
Pred->removeSuccessor(Pred->succ_begin());
@@ -170,7 +171,7 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB,
if (isUncondBranch(--MBB->end(), TII)) {
MachineBasicBlock::iterator MI = --MBB->end();
MachineInstr *UncondBr = MI;
- MachineFunction::iterator FallThrough = MBB; ++FallThrough;
+ MachineFunction::iterator FallThrough = next(MBB);
MachineFunction::iterator UncondDest =
MI->getOperand(0).getMachineBasicBlock();
@@ -187,7 +188,8 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB,
// We assume that conditional branches always have the branch dest as the
// last operand. This could be generalized in the future if needed.
unsigned LastOpnd = MI->getNumOperands()-1;
- if (MI->getOperand(LastOpnd).getMachineBasicBlock() == &*FallThrough) {
+ if (MachineFunction::iterator(
+ MI->getOperand(LastOpnd).getMachineBasicBlock()) == FallThrough) {
// Change the cond branch to go to the uncond dest, nuke the uncond,
// then reverse the condition.
MI->getOperand(LastOpnd).setMachineBasicBlock(UncondDest);
OpenPOWER on IntegriCloud