blob: 46b169a713806076fa5308dbcf0a8ba0d31c648c [file] [log] [blame]
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +00001//===-- llvm/CodeGen/MachineBasicBlock.cpp ----------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +00007//
8//===----------------------------------------------------------------------===//
9//
10// Collect the sequence of machine instructions for a basic block.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/CodeGen/MachineBasicBlock.h"
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +000015#include "llvm/BasicBlock.h"
16#include "llvm/CodeGen/MachineFunction.h"
Dan Gohman6f0d0242008-02-10 18:45:23 +000017#include "llvm/Target/TargetRegisterInfo.h"
Owen Anderson07000c62006-05-12 06:33:49 +000018#include "llvm/Target/TargetData.h"
Chris Lattnerf14cf852008-01-07 07:42:25 +000019#include "llvm/Target/TargetInstrDesc.h"
Alkis Evlogimenos743d0a12004-02-23 18:14:48 +000020#include "llvm/Target/TargetMachine.h"
Dan Gohman2c3f7ae2008-07-17 23:49:46 +000021#include "llvm/Support/LeakDetector.h"
Daniel Dunbar1cd1d982009-07-24 10:36:58 +000022#include "llvm/Support/raw_ostream.h"
Chris Lattner52c09d72004-10-26 15:43:42 +000023#include <algorithm>
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +000024using namespace llvm;
25
Dan Gohman8e5f2c62008-07-07 23:14:23 +000026MachineBasicBlock::MachineBasicBlock(MachineFunction &mf, const BasicBlock *bb)
Dan Gohman8c2b5252009-10-30 01:27:03 +000027 : BB(bb), Number(-1), xParent(&mf), Alignment(0), IsLandingPad(false),
28 AddressTaken(false) {
Dan Gohmanfed90b62008-07-28 21:51:04 +000029 Insts.Parent = this;
Tanya Lattner17fb34b2004-05-24 07:14:35 +000030}
Tanya Lattner17fb34b2004-05-24 07:14:35 +000031
Dan Gohman2c3f7ae2008-07-17 23:49:46 +000032MachineBasicBlock::~MachineBasicBlock() {
33 LeakDetector::removeGarbageObject(this);
34}
35
Chris Lattner6371ed52009-08-23 00:35:30 +000036raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineBasicBlock &MBB) {
Daniel Dunbar1cd1d982009-07-24 10:36:58 +000037 MBB.print(OS);
38 return OS;
39}
Tanya Lattner17fb34b2004-05-24 07:14:35 +000040
Chris Lattner62ed6b92008-01-01 01:12:31 +000041/// addNodeToList (MBB) - When an MBB is added to an MF, we need to update the
42/// parent pointer of the MBB, the MBB numbering, and any instructions in the
43/// MBB to be on the right operand list for registers.
44///
45/// MBBs start out as #-1. When a MBB is added to a MachineFunction, it
46/// gets the next available unique MBB number. If it is removed from a
47/// MachineFunction, it goes back to being #-1.
Chris Lattner6371ed52009-08-23 00:35:30 +000048void ilist_traits<MachineBasicBlock>::addNodeToList(MachineBasicBlock *N) {
Dan Gohman8e5f2c62008-07-07 23:14:23 +000049 MachineFunction &MF = *N->getParent();
50 N->Number = MF.addToMBBNumbering(N);
Chris Lattner62ed6b92008-01-01 01:12:31 +000051
52 // Make sure the instructions have their operands in the reginfo lists.
Dan Gohman8e5f2c62008-07-07 23:14:23 +000053 MachineRegisterInfo &RegInfo = MF.getRegInfo();
Chris Lattner62ed6b92008-01-01 01:12:31 +000054 for (MachineBasicBlock::iterator I = N->begin(), E = N->end(); I != E; ++I)
55 I->AddRegOperandsToUseLists(RegInfo);
Dan Gohman2c3f7ae2008-07-17 23:49:46 +000056
57 LeakDetector::removeGarbageObject(N);
Brian Gaeke0bcb1ad2004-05-12 21:35:22 +000058}
59
Chris Lattner6371ed52009-08-23 00:35:30 +000060void ilist_traits<MachineBasicBlock>::removeNodeFromList(MachineBasicBlock *N) {
Chris Lattnerf20c1a42007-12-31 04:56:33 +000061 N->getParent()->removeFromMBBNumbering(N->Number);
Brian Gaeke0bcb1ad2004-05-12 21:35:22 +000062 N->Number = -1;
Dan Gohman2c3f7ae2008-07-17 23:49:46 +000063 LeakDetector::addGarbageObject(N);
Brian Gaeke0bcb1ad2004-05-12 21:35:22 +000064}
65
Chris Lattner5e61fa92004-02-19 16:13:54 +000066
Chris Lattner62ed6b92008-01-01 01:12:31 +000067/// addNodeToList (MI) - When we add an instruction to a basic block
68/// list, we update its parent pointer and add its operands from reg use/def
69/// lists if appropriate.
Chris Lattner6371ed52009-08-23 00:35:30 +000070void ilist_traits<MachineInstr>::addNodeToList(MachineInstr *N) {
Chris Lattnerf20c1a42007-12-31 04:56:33 +000071 assert(N->getParent() == 0 && "machine instruction already in a basic block");
Dan Gohman8e5f2c62008-07-07 23:14:23 +000072 N->setParent(Parent);
Chris Lattner62ed6b92008-01-01 01:12:31 +000073
Dan Gohman8e5f2c62008-07-07 23:14:23 +000074 // Add the instruction's register operands to their corresponding
75 // use/def lists.
76 MachineFunction *MF = Parent->getParent();
77 N->AddRegOperandsToUseLists(MF->getRegInfo());
Dan Gohman2c3f7ae2008-07-17 23:49:46 +000078
79 LeakDetector::removeGarbageObject(N);
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +000080}
81
Chris Lattner62ed6b92008-01-01 01:12:31 +000082/// removeNodeFromList (MI) - When we remove an instruction from a basic block
83/// list, we update its parent pointer and remove its operands from reg use/def
84/// lists if appropriate.
Chris Lattner6371ed52009-08-23 00:35:30 +000085void ilist_traits<MachineInstr>::removeNodeFromList(MachineInstr *N) {
Chris Lattnerf20c1a42007-12-31 04:56:33 +000086 assert(N->getParent() != 0 && "machine instruction not in a basic block");
Dan Gohman8e5f2c62008-07-07 23:14:23 +000087
88 // Remove from the use/def lists.
89 N->RemoveRegOperandsFromUseLists();
Chris Lattner62ed6b92008-01-01 01:12:31 +000090
Chris Lattnerf20c1a42007-12-31 04:56:33 +000091 N->setParent(0);
Dan Gohman2c3f7ae2008-07-17 23:49:46 +000092
93 LeakDetector::addGarbageObject(N);
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +000094}
95
Chris Lattner62ed6b92008-01-01 01:12:31 +000096/// transferNodesFromList (MI) - When moving a range of instructions from one
97/// MBB list to another, we need to update the parent pointers and the use/def
98/// lists.
Chris Lattner6371ed52009-08-23 00:35:30 +000099void ilist_traits<MachineInstr>::
100transferNodesFromList(ilist_traits<MachineInstr> &fromList,
101 MachineBasicBlock::iterator first,
102 MachineBasicBlock::iterator last) {
Dan Gohmanfed90b62008-07-28 21:51:04 +0000103 assert(Parent->getParent() == fromList.Parent->getParent() &&
104 "MachineInstr parent mismatch!");
105
Chris Lattnerf20c1a42007-12-31 04:56:33 +0000106 // Splice within the same MBB -> no change.
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000107 if (Parent == fromList.Parent) return;
Chris Lattner62ed6b92008-01-01 01:12:31 +0000108
109 // If splicing between two blocks within the same function, just update the
110 // parent pointers.
Dan Gohmanfed90b62008-07-28 21:51:04 +0000111 for (; first != last; ++first)
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000112 first->setParent(Parent);
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +0000113}
114
Dan Gohmanfed90b62008-07-28 21:51:04 +0000115void ilist_traits<MachineInstr>::deleteNode(MachineInstr* MI) {
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000116 assert(!MI->getParent() && "MI is still in a block!");
117 Parent->getParent()->DeleteMachineInstr(MI);
118}
119
Chris Lattner52c09d72004-10-26 15:43:42 +0000120MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() {
Alkis Evlogimenos743d0a12004-02-23 18:14:48 +0000121 iterator I = end();
Chris Lattner749c6f62008-01-07 07:27:27 +0000122 while (I != begin() && (--I)->getDesc().isTerminator())
Anton Korobeynikov406452d2007-09-02 22:11:14 +0000123 ; /*noop */
Chris Lattner749c6f62008-01-07 07:27:27 +0000124 if (I != end() && !I->getDesc().isTerminator()) ++I;
Alkis Evlogimenos743d0a12004-02-23 18:14:48 +0000125 return I;
126}
127
Chris Lattnerb49a30c2009-08-18 04:33:15 +0000128/// isOnlyReachableViaFallthough - Return true if this basic block has
129/// exactly one predecessor and the control transfer mechanism between
130/// the predecessor and this block is a fall-through.
Chris Lattnera006d4e2009-08-18 04:30:35 +0000131bool MachineBasicBlock::isOnlyReachableByFallthrough() const {
132 // If this is a landing pad, it isn't a fall through. If it has no preds,
133 // then nothing falls through to it.
134 if (isLandingPad() || pred_empty())
135 return false;
136
137 // If there isn't exactly one predecessor, it can't be a fall through.
138 const_pred_iterator PI = pred_begin(), PI2 = PI;
Chris Lattner1f50fc72009-08-18 04:34:36 +0000139 ++PI2;
140 if (PI2 != pred_end())
Chris Lattnera006d4e2009-08-18 04:30:35 +0000141 return false;
142
143 // The predecessor has to be immediately before this block.
144 const MachineBasicBlock *Pred = *PI;
145
146 if (!Pred->isLayoutSuccessor(this))
147 return false;
148
149 // If the block is completely empty, then it definitely does fall through.
150 if (Pred->empty())
151 return true;
152
153 // Otherwise, check the last instruction.
154 const MachineInstr &LastInst = Pred->back();
Chris Lattnerb49a30c2009-08-18 04:33:15 +0000155 return !LastInst.getDesc().isBarrier();
Dan Gohman968dc7a2009-03-31 18:39:13 +0000156}
157
Chris Lattner52c09d72004-10-26 15:43:42 +0000158void MachineBasicBlock::dump() const {
Chris Lattnercf143a42009-08-23 03:13:20 +0000159 print(errs());
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +0000160}
161
Daniel Dunbar1cd1d982009-07-24 10:36:58 +0000162static inline void OutputReg(raw_ostream &os, unsigned RegNo,
Dan Gohman6f0d0242008-02-10 18:45:23 +0000163 const TargetRegisterInfo *TRI = 0) {
164 if (!RegNo || TargetRegisterInfo::isPhysicalRegister(RegNo)) {
165 if (TRI)
Bill Wendlinge6d088a2008-02-26 21:47:57 +0000166 os << " %" << TRI->get(RegNo).Name;
Evan Cheng13d82852007-02-10 02:38:19 +0000167 else
168 os << " %mreg(" << RegNo << ")";
169 } else
170 os << " %reg" << RegNo;
171}
172
Chris Lattner2d8e3d22009-08-23 00:47:04 +0000173void MachineBasicBlock::print(raw_ostream &OS) const {
Evan Cheng13d82852007-02-10 02:38:19 +0000174 const MachineFunction *MF = getParent();
Chris Lattner6371ed52009-08-23 00:35:30 +0000175 if (!MF) {
Chris Lattner52c09d72004-10-26 15:43:42 +0000176 OS << "Can't print out MachineBasicBlock because parent MachineFunction"
177 << " is null\n";
Tanya Lattner792699c2004-05-24 06:11:51 +0000178 return;
179 }
Alkis Evlogimenosa6382862004-09-05 18:39:20 +0000180
181 const BasicBlock *LBB = getBasicBlock();
Chris Lattner6371ed52009-08-23 00:35:30 +0000182 OS << '\n';
Chris Lattnerc11ce862007-04-30 23:12:53 +0000183 if (LBB) OS << LBB->getName() << ": ";
184 OS << (const void*)this
185 << ", LLVM BB @" << (const void*) LBB << ", ID#" << getNumber();
Evan Chengfb8075d2008-02-28 00:43:03 +0000186 if (Alignment) OS << ", Alignment " << Alignment;
Chris Lattnerc11ce862007-04-30 23:12:53 +0000187 if (isLandingPad()) OS << ", EH LANDING PAD";
188 OS << ":\n";
Evan Cheng13d82852007-02-10 02:38:19 +0000189
Dan Gohman6f0d0242008-02-10 18:45:23 +0000190 const TargetRegisterInfo *TRI = MF->getTarget().getRegisterInfo();
Dan Gohmancb406c22007-10-03 19:26:29 +0000191 if (!livein_empty()) {
Evan Cheng13d82852007-02-10 02:38:19 +0000192 OS << "Live Ins:";
Evan Chengb371f452007-02-19 21:49:54 +0000193 for (const_livein_iterator I = livein_begin(),E = livein_end(); I != E; ++I)
Dan Gohman6f0d0242008-02-10 18:45:23 +0000194 OutputReg(OS, *I, TRI);
Chris Lattner6371ed52009-08-23 00:35:30 +0000195 OS << '\n';
Evan Cheng13d82852007-02-10 02:38:19 +0000196 }
Chris Lattner681764b2006-09-26 03:41:59 +0000197 // Print the preds of this block according to the CFG.
198 if (!pred_empty()) {
199 OS << " Predecessors according to CFG:";
200 for (const_pred_iterator PI = pred_begin(), E = pred_end(); PI != E; ++PI)
Chris Lattner6371ed52009-08-23 00:35:30 +0000201 OS << ' ' << *PI << " (#" << (*PI)->getNumber() << ')';
202 OS << '\n';
Chris Lattner681764b2006-09-26 03:41:59 +0000203 }
204
Alkis Evlogimenosa6382862004-09-05 18:39:20 +0000205 for (const_iterator I = begin(); I != end(); ++I) {
Chris Lattner2d8e3d22009-08-23 00:47:04 +0000206 OS << '\t';
Alkis Evlogimenosa6382862004-09-05 18:39:20 +0000207 I->print(OS, &getParent()->getTarget());
208 }
Chris Lattner380ae492005-04-01 06:48:38 +0000209
210 // Print the successors of this block according to the CFG.
211 if (!succ_empty()) {
212 OS << " Successors according to CFG:";
213 for (const_succ_iterator SI = succ_begin(), E = succ_end(); SI != E; ++SI)
Chris Lattner6371ed52009-08-23 00:35:30 +0000214 OS << ' ' << *SI << " (#" << (*SI)->getNumber() << ')';
215 OS << '\n';
Chris Lattner380ae492005-04-01 06:48:38 +0000216 }
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +0000217}
Chris Lattner52c09d72004-10-26 15:43:42 +0000218
Evan Chengb371f452007-02-19 21:49:54 +0000219void MachineBasicBlock::removeLiveIn(unsigned Reg) {
220 livein_iterator I = std::find(livein_begin(), livein_end(), Reg);
221 assert(I != livein_end() && "Not a live in!");
222 LiveIns.erase(I);
223}
224
Evan Chenga971dbd2008-04-24 09:06:33 +0000225bool MachineBasicBlock::isLiveIn(unsigned Reg) const {
226 const_livein_iterator I = std::find(livein_begin(), livein_end(), Reg);
227 return I != livein_end();
228}
229
Chris Lattnerc585a3f2006-10-24 00:02:26 +0000230void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) {
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000231 getParent()->splice(NewAfter, this);
Chris Lattnerc585a3f2006-10-24 00:02:26 +0000232}
233
234void MachineBasicBlock::moveAfter(MachineBasicBlock *NewBefore) {
Chris Lattnerc585a3f2006-10-24 00:02:26 +0000235 MachineFunction::iterator BBI = NewBefore;
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000236 getParent()->splice(++BBI, this);
Chris Lattnerc585a3f2006-10-24 00:02:26 +0000237}
238
239
Chris Lattner52c09d72004-10-26 15:43:42 +0000240void MachineBasicBlock::addSuccessor(MachineBasicBlock *succ) {
241 Successors.push_back(succ);
242 succ->addPredecessor(this);
243}
244
245void MachineBasicBlock::removeSuccessor(MachineBasicBlock *succ) {
246 succ->removePredecessor(this);
247 succ_iterator I = std::find(Successors.begin(), Successors.end(), succ);
248 assert(I != Successors.end() && "Not a current successor!");
249 Successors.erase(I);
250}
251
Chris Lattnerf20c1a42007-12-31 04:56:33 +0000252MachineBasicBlock::succ_iterator
253MachineBasicBlock::removeSuccessor(succ_iterator I) {
Chris Lattner52c09d72004-10-26 15:43:42 +0000254 assert(I != Successors.end() && "Not a current successor!");
255 (*I)->removePredecessor(this);
Dan Gohman5d5ee802009-01-08 22:19:34 +0000256 return Successors.erase(I);
Chris Lattner52c09d72004-10-26 15:43:42 +0000257}
258
259void MachineBasicBlock::addPredecessor(MachineBasicBlock *pred) {
260 Predecessors.push_back(pred);
261}
262
263void MachineBasicBlock::removePredecessor(MachineBasicBlock *pred) {
Misha Brukmanedf128a2005-04-21 22:36:52 +0000264 std::vector<MachineBasicBlock *>::iterator I =
Chris Lattner52c09d72004-10-26 15:43:42 +0000265 std::find(Predecessors.begin(), Predecessors.end(), pred);
266 assert(I != Predecessors.end() && "Pred is not a predecessor of this block!");
267 Predecessors.erase(I);
268}
Evan Cheng4f098782007-05-17 23:58:53 +0000269
Chris Lattner6371ed52009-08-23 00:35:30 +0000270void MachineBasicBlock::transferSuccessors(MachineBasicBlock *fromMBB) {
Mon P Wang63307c32008-05-05 19:05:59 +0000271 if (this == fromMBB)
272 return;
273
Chris Lattner6371ed52009-08-23 00:35:30 +0000274 for (MachineBasicBlock::succ_iterator I = fromMBB->succ_begin(),
275 E = fromMBB->succ_end(); I != E; ++I)
276 addSuccessor(*I);
277
278 while (!fromMBB->succ_empty())
Mon P Wang63307c32008-05-05 19:05:59 +0000279 fromMBB->removeSuccessor(fromMBB->succ_begin());
280}
281
Dan Gohman6d1b89e2009-03-30 20:06:29 +0000282bool MachineBasicBlock::isSuccessor(const MachineBasicBlock *MBB) const {
Evan Cheng4f098782007-05-17 23:58:53 +0000283 std::vector<MachineBasicBlock *>::const_iterator I =
284 std::find(Successors.begin(), Successors.end(), MBB);
285 return I != Successors.end();
286}
Evan Cheng0370fad2007-06-04 06:44:01 +0000287
Dan Gohman6d1b89e2009-03-30 20:06:29 +0000288bool MachineBasicBlock::isLayoutSuccessor(const MachineBasicBlock *MBB) const {
Dan Gohman6ade6f52008-10-02 22:09:09 +0000289 MachineFunction::const_iterator I(this);
290 return next(I) == MachineFunction::const_iterator(MBB);
291}
292
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000293/// removeFromParent - This method unlinks 'this' from the containing function,
294/// and returns it, but does not delete it.
295MachineBasicBlock *MachineBasicBlock::removeFromParent() {
296 assert(getParent() && "Not embedded in a function!");
297 getParent()->remove(this);
298 return this;
299}
300
301
302/// eraseFromParent - This method unlinks 'this' from the containing function,
303/// and deletes it.
304void MachineBasicBlock::eraseFromParent() {
305 assert(getParent() && "Not embedded in a function!");
306 getParent()->erase(this);
307}
308
309
Evan Cheng0370fad2007-06-04 06:44:01 +0000310/// ReplaceUsesOfBlockWith - Given a machine basic block that branched to
311/// 'Old', change the code and CFG so that it branches to 'New' instead.
312void MachineBasicBlock::ReplaceUsesOfBlockWith(MachineBasicBlock *Old,
313 MachineBasicBlock *New) {
314 assert(Old != New && "Cannot replace self with self!");
315
316 MachineBasicBlock::iterator I = end();
317 while (I != begin()) {
318 --I;
Chris Lattner749c6f62008-01-07 07:27:27 +0000319 if (!I->getDesc().isTerminator()) break;
Evan Cheng0370fad2007-06-04 06:44:01 +0000320
321 // Scan the operands of this machine instruction, replacing any uses of Old
322 // with New.
323 for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
Dan Gohmand735b802008-10-03 15:45:36 +0000324 if (I->getOperand(i).isMBB() &&
Dan Gohman014278e2008-09-13 17:58:21 +0000325 I->getOperand(i).getMBB() == Old)
Chris Lattner8aa797a2007-12-30 23:10:15 +0000326 I->getOperand(i).setMBB(New);
Evan Cheng0370fad2007-06-04 06:44:01 +0000327 }
328
Dan Gohman5412d062009-05-05 21:10:19 +0000329 // Update the successor information.
Evan Cheng0370fad2007-06-04 06:44:01 +0000330 removeSuccessor(Old);
Dan Gohman5412d062009-05-05 21:10:19 +0000331 addSuccessor(New);
Evan Cheng0370fad2007-06-04 06:44:01 +0000332}
333
Evan Cheng2bdb7d02007-06-18 22:43:58 +0000334/// CorrectExtraCFGEdges - Various pieces of code can cause excess edges in the
335/// CFG to be inserted. If we have proven that MBB can only branch to DestA and
336/// DestB, remove any other MBB successors from the CFG. DestA and DestB can
337/// be null.
Chris Lattnerf20c1a42007-12-31 04:56:33 +0000338/// Besides DestA and DestB, retain other edges leading to LandingPads
339/// (currently there can be only one; we don't check or require that here).
Evan Cheng2bdb7d02007-06-18 22:43:58 +0000340/// Note it is possible that DestA and/or DestB are LandingPads.
341bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA,
342 MachineBasicBlock *DestB,
343 bool isCond) {
344 bool MadeChange = false;
345 bool AddedFallThrough = false;
346
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000347 MachineFunction::iterator FallThru = next(MachineFunction::iterator(this));
Evan Cheng2bdb7d02007-06-18 22:43:58 +0000348
349 // If this block ends with a conditional branch that falls through to its
350 // successor, set DestB as the successor.
351 if (isCond) {
352 if (DestB == 0 && FallThru != getParent()->end()) {
353 DestB = FallThru;
354 AddedFallThrough = true;
355 }
356 } else {
357 // If this is an unconditional branch with no explicit dest, it must just be
358 // a fallthrough into DestB.
359 if (DestA == 0 && FallThru != getParent()->end()) {
360 DestA = FallThru;
361 AddedFallThrough = true;
362 }
363 }
364
365 MachineBasicBlock::succ_iterator SI = succ_begin();
366 MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB;
367 while (SI != succ_end()) {
368 if (*SI == DestA && DestA == DestB) {
369 DestA = DestB = 0;
370 ++SI;
371 } else if (*SI == DestA) {
372 DestA = 0;
373 ++SI;
374 } else if (*SI == DestB) {
375 DestB = 0;
376 ++SI;
377 } else if ((*SI)->isLandingPad() &&
378 *SI!=OrigDestA && *SI!=OrigDestB) {
379 ++SI;
380 } else {
381 // Otherwise, this is a superfluous edge, remove it.
David Greene8a46d342007-06-29 02:45:24 +0000382 SI = removeSuccessor(SI);
Evan Cheng2bdb7d02007-06-18 22:43:58 +0000383 MadeChange = true;
384 }
385 }
386 if (!AddedFallThrough) {
387 assert(DestA == 0 && DestB == 0 &&
388 "MachineCFG is missing edges!");
389 } else if (isCond) {
390 assert(DestA == 0 && "MachineCFG is missing edges!");
391 }
392 return MadeChange;
393}