blob: 41e58ec5da2d93b09cdcf25008beb6493d0cdce8 [file] [log] [blame]
Chris Lattnerd1e693f2002-09-08 18:59:35 +00001//===-- BasicBlock.cpp - Implement BasicBlock related methods -------------===//
Misha Brukmanfd939082005-04-21 23:48:37 +00002//
John Criswellb576c942003-10-20 19:43:21 +00003// 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.
Misha Brukmanfd939082005-04-21 23:48:37 +00007//
John Criswellb576c942003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Chris Lattner00950542001-06-06 20:29:01 +00009//
Chandler Carruthc2c50cd2013-01-02 09:10:48 +000010// This file implements the BasicBlock class for the IR library.
Chris Lattner00950542001-06-06 20:29:01 +000011//
12//===----------------------------------------------------------------------===//
13
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000014#include "llvm/IR/BasicBlock.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000015#include "SymbolTableListTraitsImpl.h"
16#include "llvm/ADT/STLExtras.h"
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000017#include "llvm/IR/Constants.h"
18#include "llvm/IR/Instructions.h"
19#include "llvm/IR/IntrinsicInst.h"
20#include "llvm/IR/LLVMContext.h"
21#include "llvm/IR/Type.h"
Chris Lattner455889a2002-02-12 22:39:50 +000022#include "llvm/Support/CFG.h"
Reid Spencer551ccae2004-09-01 22:55:40 +000023#include "llvm/Support/LeakDetector.h"
Chris Lattner7e708292002-06-25 16:13:24 +000024#include <algorithm>
Chris Lattner108e4ab2003-11-21 16:52:05 +000025using namespace llvm;
Chris Lattner00950542001-06-06 20:29:01 +000026
Gabor Greif0dd2a6a2009-03-07 12:33:24 +000027ValueSymbolTable *BasicBlock::getValueSymbolTable() {
28 if (Function *F = getParent())
29 return &F->getValueSymbolTable();
Chris Lattner17fcdd52007-04-17 03:26:42 +000030 return 0;
31}
32
Owen Andersone922c022009-07-22 00:24:57 +000033LLVMContext &BasicBlock::getContext() const {
34 return getType()->getContext();
Owen Anderson0a205a42009-07-05 22:41:43 +000035}
36
Chris Lattner7e708292002-06-25 16:13:24 +000037// Explicit instantiation of SymbolTableListTraits since some of the methods
38// are not in the public header file...
John McCallc63ca0a2009-12-19 00:55:12 +000039template class llvm::SymbolTableListTraits<Instruction, BasicBlock>;
Chris Lattner7e708292002-06-25 16:13:24 +000040
Bill Wendling5d7a5a42011-04-10 23:18:04 +000041
Owen Anderson1d0be152009-08-13 21:58:54 +000042BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
Nick Lewycky280a6e62008-04-25 16:53:59 +000043 BasicBlock *InsertBefore)
Bill Wendling5d7a5a42011-04-10 23:18:04 +000044 : Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(0) {
Chris Lattner0a1a8742002-09-26 05:03:22 +000045
46 // Make sure that we get added to a function
47 LeakDetector::addGarbageObject(this);
48
49 if (InsertBefore) {
Chris Lattner17fcdd52007-04-17 03:26:42 +000050 assert(NewParent &&
Chris Lattner4f056112004-02-04 03:57:50 +000051 "Cannot insert block before another block with no function!");
Chris Lattner17fcdd52007-04-17 03:26:42 +000052 NewParent->getBasicBlockList().insert(InsertBefore, this);
53 } else if (NewParent) {
54 NewParent->getBasicBlockList().push_back(this);
Chris Lattner0a1a8742002-09-26 05:03:22 +000055 }
NAKAMURA Takumi8fc9b3d2011-08-09 23:12:56 +000056
Chris Lattnerdec628e2007-02-12 05:18:08 +000057 setName(Name);
Chris Lattner0a1a8742002-09-26 05:03:22 +000058}
59
Bill Wendling5d7a5a42011-04-10 23:18:04 +000060
Gordon Henriksenafba8fe2007-12-10 02:14:30 +000061BasicBlock::~BasicBlock() {
Chris Lattnerdac8bde2009-10-30 22:39:36 +000062 // If the address of the block is taken and it is being deleted (e.g. because
63 // it is dead), this means that there is either a dangling constant expr
64 // hanging off the block, or an undefined use of the block (source code
65 // expecting the address of a label to keep the block alive even though there
66 // is no indirect branch). Handle these cases by zapping the BlockAddress
Chris Lattnercdfc9402009-11-01 01:27:45 +000067 // nodes. There are no other possible uses at this point.
Chris Lattnerdac8bde2009-10-30 22:39:36 +000068 if (hasAddressTaken()) {
69 assert(!use_empty() && "There should be at least one blockaddress!");
Chris Lattnercdfc9402009-11-01 01:27:45 +000070 Constant *Replacement =
71 ConstantInt::get(llvm::Type::getInt32Ty(getContext()), 1);
Chris Lattnerdac8bde2009-10-30 22:39:36 +000072 while (!use_empty()) {
73 BlockAddress *BA = cast<BlockAddress>(use_back());
Chris Lattnercdfc9402009-11-01 01:27:45 +000074 BA->replaceAllUsesWith(ConstantExpr::getIntToPtr(Replacement,
75 BA->getType()));
Chris Lattnerdac8bde2009-10-30 22:39:36 +000076 BA->destroyConstant();
77 }
78 }
NAKAMURA Takumi8fc9b3d2011-08-09 23:12:56 +000079
Gordon Henriksenafba8fe2007-12-10 02:14:30 +000080 assert(getParent() == 0 && "BasicBlock still linked into the program!");
81 dropAllReferences();
82 InstList.clear();
Chris Lattner00950542001-06-06 20:29:01 +000083}
84
Chris Lattnerbded1322002-09-06 21:33:15 +000085void BasicBlock::setParent(Function *parent) {
Chris Lattnerd1e693f2002-09-08 18:59:35 +000086 if (getParent())
87 LeakDetector::addGarbageObject(this);
88
Chris Lattner17fcdd52007-04-17 03:26:42 +000089 // Set Parent=parent, updating instruction symtab entries as appropriate.
90 InstList.setSymTabObject(&Parent, parent);
Chris Lattnerd1e693f2002-09-08 18:59:35 +000091
92 if (getParent())
93 LeakDetector::removeGarbageObject(this);
Chris Lattnerbded1322002-09-06 21:33:15 +000094}
95
Chris Lattner4b833802004-10-11 22:21:39 +000096void BasicBlock::removeFromParent() {
97 getParent()->getBasicBlockList().remove(this);
98}
99
100void BasicBlock::eraseFromParent() {
101 getParent()->getBasicBlockList().erase(this);
102}
103
Chris Lattnera71965b2006-09-23 04:03:45 +0000104/// moveBefore - Unlink this basic block from its current function and
105/// insert it into the function that MovePos lives in, right before MovePos.
Chris Lattner6a13aed2005-08-12 22:14:06 +0000106void BasicBlock::moveBefore(BasicBlock *MovePos) {
107 MovePos->getParent()->getBasicBlockList().splice(MovePos,
108 getParent()->getBasicBlockList(), this);
109}
110
Chris Lattnera71965b2006-09-23 04:03:45 +0000111/// moveAfter - Unlink this basic block from its current function and
112/// insert it into the function that MovePos lives in, right after MovePos.
113void BasicBlock::moveAfter(BasicBlock *MovePos) {
114 Function::iterator I = MovePos;
115 MovePos->getParent()->getBasicBlockList().splice(++I,
116 getParent()->getBasicBlockList(), this);
117}
118
Chris Lattner4b833802004-10-11 22:21:39 +0000119
Chris Lattner00950542001-06-06 20:29:01 +0000120TerminatorInst *BasicBlock::getTerminator() {
121 if (InstList.empty()) return 0;
Chris Lattner7e708292002-06-25 16:13:24 +0000122 return dyn_cast<TerminatorInst>(&InstList.back());
Chris Lattner00950542001-06-06 20:29:01 +0000123}
124
Dan Gohman50cdabc2007-11-19 20:46:23 +0000125const TerminatorInst *BasicBlock::getTerminator() const {
Chris Lattner00950542001-06-06 20:29:01 +0000126 if (InstList.empty()) return 0;
Chris Lattner7e708292002-06-25 16:13:24 +0000127 return dyn_cast<TerminatorInst>(&InstList.back());
Chris Lattner00950542001-06-06 20:29:01 +0000128}
129
Dan Gohman02dea8b2008-05-23 21:05:58 +0000130Instruction* BasicBlock::getFirstNonPHI() {
131 BasicBlock::iterator i = begin();
132 // All valid basic blocks should have a terminator,
133 // which is not a PHINode. If we have an invalid basic
134 // block we'll get an assertion failure when dereferencing
135 // a past-the-end iterator.
136 while (isa<PHINode>(i)) ++i;
137 return &*i;
Vladimir Prusdd49dbf2006-06-08 15:46:18 +0000138}
139
Dale Johannesen7249ef02010-04-02 21:49:27 +0000140Instruction* BasicBlock::getFirstNonPHIOrDbg() {
141 BasicBlock::iterator i = begin();
142 // All valid basic blocks should have a terminator,
143 // which is not a PHINode. If we have an invalid basic
144 // block we'll get an assertion failure when dereferencing
145 // a past-the-end iterator.
146 while (isa<PHINode>(i) || isa<DbgInfoIntrinsic>(i)) ++i;
147 return &*i;
148}
149
Rafael Espindola77a2c372011-06-30 20:14:24 +0000150Instruction* BasicBlock::getFirstNonPHIOrDbgOrLifetime() {
151 // All valid basic blocks should have a terminator,
152 // which is not a PHINode. If we have an invalid basic
153 // block we'll get an assertion failure when dereferencing
154 // a past-the-end iterator.
155 BasicBlock::iterator i = begin();
156 for (;; ++i) {
157 if (isa<PHINode>(i) || isa<DbgInfoIntrinsic>(i))
158 continue;
159
160 const IntrinsicInst *II = dyn_cast<IntrinsicInst>(i);
161 if (!II)
162 break;
163 if (II->getIntrinsicID() != Intrinsic::lifetime_start &&
164 II->getIntrinsicID() != Intrinsic::lifetime_end)
165 break;
166 }
167 return &*i;
168}
169
Bill Wendlingd2e103d2011-08-16 20:42:52 +0000170BasicBlock::iterator BasicBlock::getFirstInsertionPt() {
171 iterator InsertPt = getFirstNonPHI();
172 if (isa<LandingPadInst>(InsertPt)) ++InsertPt;
173 return InsertPt;
174}
175
Chris Lattner00950542001-06-06 20:29:01 +0000176void BasicBlock::dropAllReferences() {
Chris Lattner7e708292002-06-25 16:13:24 +0000177 for(iterator I = begin(), E = end(); I != E; ++I)
178 I->dropAllReferences();
Chris Lattner00950542001-06-06 20:29:01 +0000179}
180
Chris Lattnerad993cb2005-02-24 02:37:26 +0000181/// getSinglePredecessor - If this basic block has a single predecessor block,
182/// return the block, otherwise return a null pointer.
183BasicBlock *BasicBlock::getSinglePredecessor() {
184 pred_iterator PI = pred_begin(this), E = pred_end(this);
185 if (PI == E) return 0; // No preds.
186 BasicBlock *ThePred = *PI;
187 ++PI;
188 return (PI == E) ? ThePred : 0 /*multiple preds*/;
189}
190
Torok Edwin87f1e772008-12-11 10:36:07 +0000191/// getUniquePredecessor - If this basic block has a unique predecessor block,
192/// return the block, otherwise return a null pointer.
NAKAMURA Takumi8fc9b3d2011-08-09 23:12:56 +0000193/// Note that unique predecessor doesn't mean single edge, there can be
194/// multiple edges from the unique predecessor to this block (for example
Torok Edwin9053a732008-12-11 11:44:49 +0000195/// a switch statement with multiple cases having the same destination).
Torok Edwin87f1e772008-12-11 10:36:07 +0000196BasicBlock *BasicBlock::getUniquePredecessor() {
197 pred_iterator PI = pred_begin(this), E = pred_end(this);
198 if (PI == E) return 0; // No preds.
199 BasicBlock *PredBB = *PI;
200 ++PI;
201 for (;PI != E; ++PI) {
202 if (*PI != PredBB)
203 return 0;
Torok Edwin9053a732008-12-11 11:44:49 +0000204 // The same predecessor appears multiple times in the predecessor list.
205 // This is OK.
Torok Edwin87f1e772008-12-11 10:36:07 +0000206 }
207 return PredBB;
208}
209
Chris Lattner566f6002005-04-21 16:06:03 +0000210/// removePredecessor - This method is used to notify a BasicBlock that the
211/// specified Predecessor of the block is no longer able to reach it. This is
Misha Brukmanfd939082005-04-21 23:48:37 +0000212/// actually not used to update the Predecessor list, but is actually used to
Chris Lattner566f6002005-04-21 16:06:03 +0000213/// update the PHI nodes that reside in the block. Note that this should be
214/// called while the predecessor still refers to this block.
215///
Chris Lattner34645472005-04-12 18:52:14 +0000216void BasicBlock::removePredecessor(BasicBlock *Pred,
Nick Lewycky280a6e62008-04-25 16:53:59 +0000217 bool DontDeleteUselessPHIs) {
Chris Lattner1f21ef12005-02-23 16:53:04 +0000218 assert((hasNUsesOrMore(16)||// Reduce cost of this assertion for complex CFGs.
Chris Lattner35f0aec2005-02-23 07:09:08 +0000219 find(pred_begin(this), pred_end(this), Pred) != pred_end(this)) &&
Jeff Cohen9d809302005-04-23 21:38:35 +0000220 "removePredecessor: BB is not a predecessor!");
Chris Lattner35f0aec2005-02-23 07:09:08 +0000221
Chris Lattnerf23586c2004-12-11 22:10:29 +0000222 if (InstList.empty()) return;
Chris Lattnera9e77812004-07-06 17:44:17 +0000223 PHINode *APN = dyn_cast<PHINode>(&front());
224 if (!APN) return; // Quick exit.
Chris Lattnerb47af252001-06-29 05:25:23 +0000225
226 // If there are exactly two predecessors, then we want to nuke the PHI nodes
Chris Lattnera9e77812004-07-06 17:44:17 +0000227 // altogether. However, we cannot do this, if this in this case:
Chris Lattner87a09b12002-05-21 19:52:49 +0000228 //
229 // Loop:
230 // %x = phi [X, Loop]
231 // %x2 = add %x, 1 ;; This would become %x2 = add %x2, 1
232 // br Loop ;; %x2 does not dominate all uses
233 //
234 // This is because the PHI node input is actually taken from the predecessor
Misha Brukmanfd939082005-04-21 23:48:37 +0000235 // basic block. The only case this can happen is with a self loop, so we
Chris Lattner87a09b12002-05-21 19:52:49 +0000236 // check for this case explicitly now.
Misha Brukmanfd939082005-04-21 23:48:37 +0000237 //
Chris Lattnera9e77812004-07-06 17:44:17 +0000238 unsigned max_idx = APN->getNumIncomingValues();
Chris Lattnerb47af252001-06-29 05:25:23 +0000239 assert(max_idx != 0 && "PHI Node in block with 0 predecessors!?!?!");
Chris Lattner87a09b12002-05-21 19:52:49 +0000240 if (max_idx == 2) {
Chris Lattnera9e77812004-07-06 17:44:17 +0000241 BasicBlock *Other = APN->getIncomingBlock(APN->getIncomingBlock(0) == Pred);
Chris Lattner87a09b12002-05-21 19:52:49 +0000242
243 // Disable PHI elimination!
244 if (this == Other) max_idx = 3;
245 }
246
Chris Lattner34645472005-04-12 18:52:14 +0000247 // <= Two predecessors BEFORE I remove one?
248 if (max_idx <= 2 && !DontDeleteUselessPHIs) {
Chris Lattnerb00c5822001-10-02 03:41:24 +0000249 // Yup, loop through and nuke the PHI nodes
Chris Lattner7e708292002-06-25 16:13:24 +0000250 while (PHINode *PN = dyn_cast<PHINode>(&front())) {
Chris Lattner34645472005-04-12 18:52:14 +0000251 // Remove the predecessor first.
Nick Lewycky280a6e62008-04-25 16:53:59 +0000252 PN->removeIncomingValue(Pred, !DontDeleteUselessPHIs);
Chris Lattnerb47af252001-06-29 05:25:23 +0000253
254 // If the PHI _HAD_ two uses, replace PHI node with its now *single* value
Chris Lattnerdee430d2002-10-08 21:36:34 +0000255 if (max_idx == 2) {
Jay Foadc1371202011-06-20 14:18:48 +0000256 if (PN->getIncomingValue(0) != PN)
257 PN->replaceAllUsesWith(PN->getIncomingValue(0));
Chris Lattner02a78cf2003-04-25 23:14:19 +0000258 else
259 // We are left with an infinite loop with no entries: kill the PHI.
Owen Anderson9e9a0d52009-07-30 23:03:37 +0000260 PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
Chris Lattnerdee430d2002-10-08 21:36:34 +0000261 getInstList().pop_front(); // Remove the PHI node
262 }
263
264 // If the PHI node already only had one entry, it got deleted by
265 // removeIncomingValue.
Chris Lattnerb47af252001-06-29 05:25:23 +0000266 }
267 } else {
268 // Okay, now we know that we need to remove predecessor #pred_idx from all
269 // PHI nodes. Iterate over each PHI node fixing them up
Chris Lattnerf8782182004-06-05 00:11:27 +0000270 PHINode *PN;
Chris Lattner80f4d882005-08-05 15:34:10 +0000271 for (iterator II = begin(); (PN = dyn_cast<PHINode>(II)); ) {
272 ++II;
Nick Lewycky280a6e62008-04-25 16:53:59 +0000273 PN->removeIncomingValue(Pred, false);
Nate Begemana83ba0f2005-08-04 23:24:19 +0000274 // If all incoming values to the Phi are the same, we can replace the Phi
275 // with that value.
Owen Anderson90245d42006-06-14 04:43:14 +0000276 Value* PNV = 0;
Duncan Sands23a19572010-11-17 10:23:23 +0000277 if (!DontDeleteUselessPHIs && (PNV = PN->hasConstantValue()))
278 if (PNV != PN) {
279 PN->replaceAllUsesWith(PNV);
280 PN->eraseFromParent();
281 }
Nate Begemana83ba0f2005-08-04 23:24:19 +0000282 }
Chris Lattnerb47af252001-06-29 05:25:23 +0000283 }
284}
285
Chris Lattner00950542001-06-06 20:29:01 +0000286
Chris Lattner0f67dd62005-04-21 16:04:49 +0000287/// splitBasicBlock - This splits a basic block into two at the specified
288/// instruction. Note that all instructions BEFORE the specified iterator stay
Misha Brukmanfd939082005-04-21 23:48:37 +0000289/// as part of the original basic block, an unconditional branch is added to
Chris Lattner0f67dd62005-04-21 16:04:49 +0000290/// the new BB, and the rest of the instructions in the BB are moved to the new
291/// BB, including the old terminator. This invalidates the iterator.
292///
Misha Brukmanfd939082005-04-21 23:48:37 +0000293/// Note that this only works on well formed basic blocks (must have a
Chris Lattner0f67dd62005-04-21 16:04:49 +0000294/// terminator), and 'I' must not be the end of instruction list (which would
295/// cause a degenerate basic block to be formed, having a terminator inside of
Misha Brukmanfd939082005-04-21 23:48:37 +0000296/// the basic block).
Chris Lattner0f67dd62005-04-21 16:04:49 +0000297///
Daniel Dunbar6e0d1cb2009-07-25 04:41:11 +0000298BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
Chris Lattner00950542001-06-06 20:29:01 +0000299 assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!");
Misha Brukmanfd939082005-04-21 23:48:37 +0000300 assert(I != InstList.end() &&
Jeff Cohen9d809302005-04-23 21:38:35 +0000301 "Trying to get me to create degenerate basic block!");
Chris Lattner00950542001-06-06 20:29:01 +0000302
Chris Lattner7896c9f2009-12-03 00:50:42 +0000303 BasicBlock *InsertBefore = llvm::next(Function::iterator(this))
Dan Gohmanfed90b62008-07-28 21:51:04 +0000304 .getNodePtrUnchecked();
Owen Anderson1d0be152009-08-13 21:58:54 +0000305 BasicBlock *New = BasicBlock::Create(getContext(), BBName,
306 getParent(), InsertBefore);
Chris Lattner00950542001-06-06 20:29:01 +0000307
Chris Lattnerf2c31062004-02-03 23:11:21 +0000308 // Move all of the specified instructions from the original basic block into
309 // the new basic block.
310 New->getInstList().splice(New->end(), this->getInstList(), I, end());
Chris Lattner00950542001-06-06 20:29:01 +0000311
312 // Add a branch instruction to the newly formed basic block.
Gabor Greif051a9502008-04-06 20:25:17 +0000313 BranchInst::Create(New, this);
Chris Lattnere8e320d2002-02-25 00:35:07 +0000314
315 // Now we must loop through all of the successors of the New block (which
316 // _were_ the successors of the 'this' block), and update any PHI nodes in
317 // successors. If there were PHI nodes in the successors, then they need to
318 // know that incoming branches will be from New, not from Old.
319 //
Chris Lattner1c9ab512003-09-24 22:03:22 +0000320 for (succ_iterator I = succ_begin(New), E = succ_end(New); I != E; ++I) {
Chris Lattnere8e320d2002-02-25 00:35:07 +0000321 // Loop over any phi nodes in the basic block, updating the BB field of
322 // incoming values...
323 BasicBlock *Successor = *I;
Chris Lattnerf8782182004-06-05 00:11:27 +0000324 PHINode *PN;
Chris Lattnere8e320d2002-02-25 00:35:07 +0000325 for (BasicBlock::iterator II = Successor->begin();
Chris Lattner9bf2a922004-06-05 17:43:52 +0000326 (PN = dyn_cast<PHINode>(II)); ++II) {
Chris Lattnere8e320d2002-02-25 00:35:07 +0000327 int IDX = PN->getBasicBlockIndex(this);
328 while (IDX != -1) {
329 PN->setIncomingBlock((unsigned)IDX, New);
330 IDX = PN->getBasicBlockIndex(this);
331 }
332 }
333 }
Chris Lattner00950542001-06-06 20:29:01 +0000334 return New;
335}
Dan Gohmaneeb8ef12009-10-29 00:09:08 +0000336
Jay Foad95c3e482011-06-23 09:09:15 +0000337void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) {
338 TerminatorInst *TI = getTerminator();
339 if (!TI)
340 // Cope with being called on a BasicBlock that doesn't have a terminator
341 // yet. Clang's CodeGenFunction::EmitReturnBlock() likes to do this.
342 return;
343 for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) {
344 BasicBlock *Succ = TI->getSuccessor(i);
NAKAMURA Takumi77c71402011-08-09 23:13:05 +0000345 // N.B. Succ might not be a complete BasicBlock, so don't assume
346 // that it ends with a non-phi instruction.
347 for (iterator II = Succ->begin(), IE = Succ->end(); II != IE; ++II) {
348 PHINode *PN = dyn_cast<PHINode>(II);
349 if (!PN)
350 break;
Jay Foad95c3e482011-06-23 09:09:15 +0000351 int i;
352 while ((i = PN->getBasicBlockIndex(this)) >= 0)
353 PN->setIncomingBlock(i, New);
354 }
355 }
356}
Bill Wendlinge6e88262011-08-12 20:24:12 +0000357
358/// isLandingPad - Return true if this basic block is a landing pad. I.e., it's
359/// the destination of the 'unwind' edge of an invoke instruction.
360bool BasicBlock::isLandingPad() const {
361 return isa<LandingPadInst>(getFirstNonPHI());
362}
363
364/// getLandingPadInst() - Return the landingpad instruction associated with
365/// the landing pad.
366LandingPadInst *BasicBlock::getLandingPadInst() {
367 return dyn_cast<LandingPadInst>(getFirstNonPHI());
368}
Bill Wendling7750c3f2012-01-31 00:26:24 +0000369const LandingPadInst *BasicBlock::getLandingPadInst() const {
370 return dyn_cast<LandingPadInst>(getFirstNonPHI());
371}