本文整理汇总了C++中InvokeInst类的典型用法代码示例。如果您正苦于以下问题:C++ InvokeInst类的具体用法?C++ InvokeInst怎么用?C++ InvokeInst使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InvokeInst类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pred_begin
/// SplitLandingPadPreds - The landing pad needs to be extracted with the invoke
/// instruction. The critical edge breaker will refuse to break critical edges
/// to a landing pad. So do them here. After this method runs, all landing pads
/// should have only one predecessor.
void BlockExtractorPass::SplitLandingPadPreds(Function *F) {
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
InvokeInst *II = dyn_cast<InvokeInst>(I);
if (!II) continue;
BasicBlock *Parent = II->getParent();
BasicBlock *LPad = II->getUnwindDest();
// Look through the landing pad's predecessors. If one of them ends in an
// 'invoke', then we want to split the landing pad.
bool Split = false;
for (pred_iterator
PI = pred_begin(LPad), PE = pred_end(LPad); PI != PE; ++PI) {
BasicBlock *BB = *PI;
if (BB->isLandingPad() && BB != Parent &&
isa<InvokeInst>(Parent->getTerminator())) {
Split = true;
break;
}
}
if (!Split) continue;
SmallVector<BasicBlock*, 2> NewBBs;
SplitLandingPadPredecessors(LPad, Parent, ".1", ".2", NewBBs);
}
}
示例2: assert
// visitCallInst - This converts all LLVM call instructions into invoke
// instructions. The except part of the invoke goes to the "LongJmpBlkPre"
// that grabs the exception and proceeds to determine if it's a longjmp
// exception or not.
void LowerSetJmp::visitCallInst(CallInst& CI)
{
if (CI.getCalledFunction())
if (!IsTransformableFunction(CI.getCalledFunction()->getName()) ||
CI.getCalledFunction()->isIntrinsic()) return;
BasicBlock* OldBB = CI.getParent();
// If not reachable from a setjmp call, don't transform.
if (!DFSBlocks.count(OldBB)) return;
BasicBlock* NewBB = OldBB->splitBasicBlock(CI);
assert(NewBB && "Couldn't split BB of \"call\" instruction!!");
DFSBlocks.insert(NewBB);
NewBB->setName("Call2Invoke");
Function* Func = OldBB->getParent();
// Construct the new "invoke" instruction.
TerminatorInst* Term = OldBB->getTerminator();
std::vector<Value*> Params(CI.op_begin() + 1, CI.op_end());
InvokeInst* II =
InvokeInst::Create(CI.getCalledValue(), NewBB, PrelimBBMap[Func],
Params.begin(), Params.end(), CI.getName(), Term);
II->setCallingConv(CI.getCallingConv());
II->setParamAttrs(CI.getParamAttrs());
// Replace the old call inst with the invoke inst and remove the call.
CI.replaceAllUsesWith(II);
CI.getParent()->getInstList().erase(&CI);
// The old terminator is useless now that we have the invoke inst.
Term->getParent()->getInstList().erase(Term);
++CallsTransformed;
}
示例3: if
void Preparer::expandCallSite(CallSite CS) {
if (!CS.getCalledFunction()) return;
Function *F = CS.getCalledFunction();
if (!F->isVarArg()) return;
vector<Value *> Args;
for (CallSite::arg_iterator ArgI = CS.arg_begin();
ArgI != CS.arg_end(); ArgI++) {
Args.push_back(*ArgI);
}
Args.push_back(ConstantInt::get(
IntegerType::get(CS.getInstruction()->getContext(), 8), 0));
string InstName = "";
if (CS.getInstruction()->getName() != "")
InstName = CS.getInstruction()->getName().str() + ".padded";
if (CallInst *CI = dyn_cast<CallInst>(CS.getInstruction())) {
CallInst *NewCI = CallInst::Create(F, Args, InstName, CI);
NewCI->setAttributes(CI->getAttributes());
CI->replaceAllUsesWith(NewCI);
CI->eraseFromParent();
} else if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) {
InvokeInst *NewII = InvokeInst::Create(F,
II->getNormalDest(), II->getUnwindDest(), Args, InstName, II);
NewII->setAttributes(II->getAttributes());
II->replaceAllUsesWith(NewII);
II->eraseFromParent();
}
}
示例4: splitLandingPadPreds
/// Extracts the landing pads to make sure all of them have only one
/// predecessor.
void BlockExtractor::splitLandingPadPreds(Function &F) {
for (BasicBlock &BB : F) {
for (Instruction &I : BB) {
if (!isa<InvokeInst>(&I))
continue;
InvokeInst *II = cast<InvokeInst>(&I);
BasicBlock *Parent = II->getParent();
BasicBlock *LPad = II->getUnwindDest();
// Look through the landing pad's predecessors. If one of them ends in an
// 'invoke', then we want to split the landing pad.
bool Split = false;
for (auto PredBB : predecessors(LPad)) {
if (PredBB->isLandingPad() && PredBB != Parent &&
isa<InvokeInst>(Parent->getTerminator())) {
Split = true;
break;
}
}
if (!Split)
continue;
SmallVector<BasicBlock *, 2> NewBBs;
SplitLandingPadPredecessors(LPad, Parent, ".1", ".2", NewBBs);
}
}
}
示例5: if
/*
* Replace called function of a given call site.
*/
void DeadStoreEliminationPass::replaceCallingInst(Instruction* caller,
Function* fn) {
if (isa<CallInst>(caller)) {
CallInst *callInst = dyn_cast<CallInst>(caller);
callInst->setCalledFunction(fn);
} else if (isa<InvokeInst>(caller)) {
InvokeInst *invokeInst = dyn_cast<InvokeInst>(caller);
invokeInst->setCalledFunction(fn);
}
}
示例6: HandleCallsInBlockInlinedThroughInvoke
/// HandleCallsInBlockInlinedThroughInvoke - When we inline a basic block into
/// an invoke, we have to turn all of the calls that can throw into
/// invokes. This function analyze BB to see if there are any calls, and if so,
/// it rewrites them to be invokes that jump to InvokeDest and fills in the PHI
/// nodes in that block with the values specified in InvokeDestPHIValues.
///
/// Returns true to indicate that the next block should be skipped.
static bool HandleCallsInBlockInlinedThroughInvoke(BasicBlock *BB,
InvokeInliningInfo &Invoke) {
LandingPadInst *LPI = Invoke.getLandingPadInst();
for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E; ) {
Instruction *I = BBI++;
if (LandingPadInst *L = dyn_cast<LandingPadInst>(I)) {
unsigned NumClauses = LPI->getNumClauses();
L->reserveClauses(NumClauses);
for (unsigned i = 0; i != NumClauses; ++i)
L->addClause(LPI->getClause(i));
}
// We only need to check for function calls: inlined invoke
// instructions require no special handling.
CallInst *CI = dyn_cast<CallInst>(I);
// If this call cannot unwind, don't convert it to an invoke.
// Inline asm calls cannot throw.
if (!CI || CI->doesNotThrow() || isa<InlineAsm>(CI->getCalledValue()))
continue;
// Convert this function call into an invoke instruction. First, split the
// basic block.
BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc");
// Delete the unconditional branch inserted by splitBasicBlock
BB->getInstList().pop_back();
// Create the new invoke instruction.
ImmutableCallSite CS(CI);
SmallVector<Value*, 8> InvokeArgs(CS.arg_begin(), CS.arg_end());
InvokeInst *II = InvokeInst::Create(CI->getCalledValue(), Split,
Invoke.getOuterResumeDest(),
InvokeArgs, CI->getName(), BB);
II->setCallingConv(CI->getCallingConv());
II->setAttributes(CI->getAttributes());
// Make sure that anything using the call now uses the invoke! This also
// updates the CallGraph if present, because it uses a WeakVH.
CI->replaceAllUsesWith(II);
// Delete the original call
Split->getInstList().pop_front();
// Update any PHI nodes in the exceptional block to indicate that there is
// now a new entry in them.
Invoke.addIncomingPHIValuesFor(BB);
return false;
}
return false;
}
示例7: runOverwrittenDeadStoreAnalysisOnFn
void DeadStoreEliminationPass::runOverwrittenDeadStoreAnalysisOnFn(Function &F) {
MDA = &getAnalysis<MemoryDependenceAnalysis>(F);
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
for (BasicBlock::iterator I = BB->begin(), IE = BB->end(); I != IE; ++I) {
Instruction *inst = I;
if (StoreInst* SI = dyn_cast<StoreInst>(inst)) {
Value *ptr = SI->getPointerOperand();
MemDepResult mdr = MDA->getDependency(inst);
Instruction *depInst = mdr.getInst();
if (depInst && (isa<CallInst>(depInst) || isa<InvokeInst>(depInst))) {
Function *calledFn;
if (CallInst* CI = dyn_cast<CallInst>(depInst)) {
calledFn = CI->getCalledFunction();
} else {
InvokeInst *II = dyn_cast<InvokeInst>(depInst);
calledFn = II->getCalledFunction();
}
if (!fnThatStoreOnArgs.count(calledFn)) continue;
CallSite CS(depInst);
CallSite::arg_iterator actualArgIter = CS.arg_begin();
Function::arg_iterator formalArgIter = calledFn->arg_begin();
int size = calledFn->arg_size();
std::set<Value*> storedArgs = fnThatStoreOnArgs[calledFn];
for (int i = 0; i < size; ++i, ++actualArgIter, ++formalArgIter) {
Value *formalArg = formalArgIter;
Value *actualArg = *actualArgIter;
if (ptr == actualArg && storedArgs.count(formalArg)) {
int64_t InstWriteOffset, DepWriteOffset;
DEBUG(errs() << " Verifying if store is completely overwritten.\n");
AliasAnalysis::Location Loc(ptr, getPointerSize(ptr, *AA), NULL);
AliasAnalysis::Location DepLoc(actualArg, getPointerSize(actualArg, *AA), NULL);
OverwriteResult OR = isOverwrite(Loc, DepLoc, *AA, DepWriteOffset, InstWriteOffset);
if (OR == OverwriteComplete) {
DEBUG(errs() << " Store on " << formalArg->getName() << " will be removed with cloning\n");
deadArguments[depInst].insert(formalArg);
}
}
}
if (deadArguments.count(depInst)) {
fn2Clone[calledFn].push_back(depInst);
}
}
}
}
}
}
示例8: if
CallSite GNUstep::IMPCacher::SplitSend(CallSite msgSend)
{
BasicBlock *lookupBB = msgSend->getParent();
Function *F = lookupBB->getParent();
Module *M = F->getParent();
Function *send = M->getFunction("objc_msgSend");
Function *send_stret = M->getFunction("objc_msgSend_stret");
Function *send_fpret = M->getFunction("objc_msgSend_fpret");
Value *self;
Value *cmd;
int selfIndex = 0;
if ((msgSend.getCalledFunction() == send) ||
(msgSend.getCalledFunction() == send_fpret)) {
self = msgSend.getArgument(0);
cmd = msgSend.getArgument(1);
} else if (msgSend.getCalledFunction() == send_stret) {
selfIndex = 1;
self = msgSend.getArgument(1);
cmd = msgSend.getArgument(2);
} else {
abort();
return CallSite();
}
CGBuilder B(&F->getEntryBlock(), F->getEntryBlock().begin());
Value *selfPtr = B.CreateAlloca(self->getType());
B.SetInsertPoint(msgSend.getInstruction());
B.CreateStore(self, selfPtr, true);
LLVMType *impTy = msgSend.getCalledValue()->getType();
LLVMType *slotTy = PointerType::getUnqual(StructType::get(PtrTy, PtrTy, PtrTy,
IntTy, impTy, PtrTy, NULL));
Value *slot;
Constant *lookupFn = M->getOrInsertFunction("objc_msg_lookup_sender",
slotTy, selfPtr->getType(), cmd->getType(), PtrTy, NULL);
if (msgSend.isCall()) {
slot = B.CreateCall3(lookupFn, selfPtr, cmd, Constant::getNullValue(PtrTy));
} else {
InvokeInst *inv = cast<InvokeInst>(msgSend.getInstruction());
BasicBlock *callBB = SplitBlock(lookupBB, msgSend.getInstruction(), Owner);
removeTerminator(lookupBB);
B.SetInsertPoint(lookupBB);
slot = B.CreateInvoke3(lookupFn, callBB, inv->getUnwindDest(), selfPtr, cmd,
Constant::getNullValue(PtrTy));
addPredecssor(inv->getUnwindDest(), msgSend->getParent(), lookupBB);
B.SetInsertPoint(msgSend.getInstruction());
}
Value *imp = B.CreateLoad(B.CreateStructGEP(slot, 4));
msgSend.setArgument(selfIndex, B.CreateLoad(selfPtr, true));
msgSend.setCalledFunction(imp);
return CallSite(slot);
}
示例9: HandleCallsInBlockInlinedThroughInvoke
/// HandleCallsInBlockInlinedThroughInvoke - When we inline a basic block into
/// an invoke, we have to turn all of the calls that can throw into
/// invokes. This function analyze BB to see if there are any calls, and if so,
/// it rewrites them to be invokes that jump to InvokeDest and fills in the PHI
/// nodes in that block with the values specified in InvokeDestPHIValues.
///
static void HandleCallsInBlockInlinedThroughInvoke(BasicBlock *BB,
BasicBlock *InvokeDest,
const SmallVectorImpl<Value*> &InvokeDestPHIValues) {
for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E; ) {
Instruction *I = BBI++;
// We only need to check for function calls: inlined invoke
// instructions require no special handling.
CallInst *CI = dyn_cast<CallInst>(I);
if (CI == 0) continue;
// If this call cannot unwind, don't convert it to an invoke.
if (CI->doesNotThrow())
continue;
// Convert this function call into an invoke instruction.
// First, split the basic block.
BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc");
// Next, create the new invoke instruction, inserting it at the end
// of the old basic block.
ImmutableCallSite CS(CI);
SmallVector<Value*, 8> InvokeArgs(CS.arg_begin(), CS.arg_end());
InvokeInst *II =
InvokeInst::Create(CI->getCalledValue(), Split, InvokeDest,
InvokeArgs.begin(), InvokeArgs.end(),
CI->getName(), BB->getTerminator());
II->setCallingConv(CI->getCallingConv());
II->setAttributes(CI->getAttributes());
// Make sure that anything using the call now uses the invoke! This also
// updates the CallGraph if present, because it uses a WeakVH.
CI->replaceAllUsesWith(II);
// Delete the unconditional branch inserted by splitBasicBlock
BB->getInstList().pop_back();
Split->getInstList().pop_front(); // Delete the original call
// Update any PHI nodes in the exceptional block to indicate that
// there is now a new entry in them.
unsigned i = 0;
for (BasicBlock::iterator I = InvokeDest->begin();
isa<PHINode>(I); ++I, ++i)
cast<PHINode>(I)->addIncoming(InvokeDestPHIValues[i], BB);
// This basic block is now complete, the caller will continue scanning the
// next one.
return;
}
}
示例10: visitInvokeInst
// visitInvokeInst - Converting the "invoke" instruction is fairly
// straight-forward. The old exception part is replaced by a query asking
// if this is a longjmp exception. If it is, then it goes to the longjmp
// exception blocks. Otherwise, control is passed the old exception.
void LowerSetJmp::visitInvokeInst(InvokeInst& II)
{
if (II.getCalledFunction())
if (!IsTransformableFunction(II.getCalledFunction()->getName()) ||
II.getCalledFunction()->isIntrinsic()) return;
BasicBlock* BB = II.getParent();
// If not reachable from a setjmp call, don't transform.
if (!DFSBlocks.count(BB)) return;
BasicBlock* ExceptBB = II.getUnwindDest();
Function* Func = BB->getParent();
BasicBlock* NewExceptBB = BasicBlock::Create(II.getContext(),
"InvokeExcept", Func);
// If this is a longjmp exception, then branch to the preliminary BB of
// the longjmp exception handling. Otherwise, go to the old exception.
CallInst* IsLJExcept = CallInst::Create(IsLJException, "IsLJExcept",
NewExceptBB);
BranchInst::Create(PrelimBBMap[Func], ExceptBB, IsLJExcept, NewExceptBB);
II.setUnwindDest(NewExceptBB);
++InvokesTransformed;
}
示例11: LLVMRustMarkAllFunctionsNounwind
extern "C" void LLVMRustMarkAllFunctionsNounwind(LLVMModuleRef M) {
for (Module::iterator GV = unwrap(M)->begin(), E = unwrap(M)->end(); GV != E;
++GV) {
GV->setDoesNotThrow();
Function *F = dyn_cast<Function>(GV);
if (F == nullptr)
continue;
for (Function::iterator B = F->begin(), BE = F->end(); B != BE; ++B) {
for (BasicBlock::iterator I = B->begin(), IE = B->end(); I != IE; ++I) {
if (isa<InvokeInst>(I)) {
InvokeInst *CI = cast<InvokeInst>(I);
CI->setDoesNotThrow();
}
}
}
}
}
示例12: if
void MemoryInstrumenter::instrumentPointerInstruction(Instruction *I) {
BasicBlock::iterator Loc;
if (isa<PHINode>(I)) {
// Cannot insert hooks right after a PHI, because PHINodes have to be
// grouped together.
Loc = I->getParent()->getFirstNonPHI();
} else if (!I->isTerminator()) {
Loc = I;
++Loc;
} else {
assert(isa<InvokeInst>(I));
InvokeInst *II = cast<InvokeInst>(I);
BasicBlock *NormalDest = II->getNormalDest();
// It's not always OK to insert HookTopLevel simply at the beginning of the
// normal destination, because the normal destionation may be shared by
// multiple InvokeInsts. In that case, we will create a critical edge block,
// and add the HookTopLevel over there.
if (NormalDest->getUniquePredecessor()) {
Loc = NormalDest->getFirstNonPHI();
} else {
BasicBlock *CritEdge = BasicBlock::Create(I->getContext(),
"crit_edge",
I->getParent()->getParent());
Loc = BranchInst::Create(NormalDest, CritEdge);
// Now that CritEdge becomes the new predecessor of NormalDest, replace
// all phi uses of I->getParent() with CritEdge.
for (auto J = NormalDest->begin();
NormalDest->getFirstNonPHI() != J;
++J) {
PHINode *Phi = cast<PHINode>(J);
int i;
while ((i = Phi->getBasicBlockIndex(I->getParent())) >= 0)
Phi->setIncomingBlock(i, CritEdge);
}
II->setNormalDest(CritEdge);
}
}
if (LoadInst *LI = dyn_cast<LoadInst>(I))
instrumentPointer(I, LI->getPointerOperand(), Loc);
else
instrumentPointer(I, NULL, Loc);
}
示例13: visitInvokeInst
void
visitInvokeInst(InvokeInst &I)
{
Function* target = I.getCalledFunction();
if (target == NULL) {
anyUnknown = true;
return;
}
if (isInternal(target)) {
if (used != NULL) used->push(target);
} else {
interface->call(target->getName(), arg_begin(I), arg_end(I));
}
this->visitInstruction(I);
}
示例14: if
void Preparer::expandCallSite(CallSite CS) {
// Skip the callsites that are not calling a va function.
Value *Callee = CS.getCalledValue();
FunctionType *CalleeType = cast<FunctionType>(
cast<PointerType>(Callee->getType())->getElementType());
if (!CalleeType->isVarArg()) {
return;
}
vector<Value *> Args;
for (CallSite::arg_iterator ArgI = CS.arg_begin();
ArgI != CS.arg_end(); ArgI++) {
Args.push_back(*ArgI);
}
Args.push_back(ConstantInt::get(
IntegerType::get(CS.getInstruction()->getContext(), 8), 0));
string InstName = "";
if (CS.getInstruction()->getName() != "")
InstName = CS.getInstruction()->getName().str() + ".padded";
if (CallInst *CI = dyn_cast<CallInst>(CS.getInstruction())) {
CallInst *NewCI = CallInst::Create(Callee, Args, InstName, CI);
NewCI->setAttributes(CI->getAttributes());
CI->replaceAllUsesWith(NewCI);
CI->eraseFromParent();
} else if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) {
InvokeInst *NewII = InvokeInst::Create(Callee,
II->getNormalDest(),
II->getUnwindDest(),
Args,
InstName,
II);
NewII->setAttributes(II->getAttributes());
II->replaceAllUsesWith(NewII);
II->eraseFromParent();
}
}
示例15: splitLiveRangesLiveAcrossInvokes
// First thing we need to do is scan the whole function for values that are
// live across unwind edges. Each value that is live across an unwind edge
// we spill into a stack location, guaranteeing that there is nothing live
// across the unwind edge. This process also splits all critical edges
// coming out of invoke's.
void LowerInvoke::
splitLiveRangesLiveAcrossInvokes(std::vector<InvokeInst*> &Invokes) {
// First step, split all critical edges from invoke instructions.
for (unsigned i = 0, e = Invokes.size(); i != e; ++i) {
InvokeInst *II = Invokes[i];
SplitCriticalEdge(II, 0, this);
SplitCriticalEdge(II, 1, this);
assert(!isa<PHINode>(II->getNormalDest()) &&
!isa<PHINode>(II->getUnwindDest()) &&
"critical edge splitting left single entry phi nodes?");
}
Function *F = Invokes.back()->getParent()->getParent();
// To avoid having to handle incoming arguments specially, we lower each arg
// to a copy instruction in the entry block. This ensures that the argument
// value itself cannot be live across the entry block.
BasicBlock::iterator AfterAllocaInsertPt = F->begin()->begin();
while (isa<AllocaInst>(AfterAllocaInsertPt) &&
isa<ConstantInt>(cast<AllocaInst>(AfterAllocaInsertPt)->getArraySize()))
++AfterAllocaInsertPt;
for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end();
AI != E; ++AI) {
// This is always a no-op cast because we're casting AI to AI->getType() so
// src and destination types are identical. BitCast is the only possibility.
CastInst *NC = new BitCastInst(
AI, AI->getType(), AI->getName()+".tmp", AfterAllocaInsertPt);
AI->replaceAllUsesWith(NC);
// Normally its is forbidden to replace a CastInst's operand because it
// could cause the opcode to reflect an illegal conversion. However, we're
// replacing it here with the same value it was constructed with to simply
// make NC its user.
NC->setOperand(0, AI);
}
// Finally, scan the code looking for instructions with bad live ranges.
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E; ++II) {
// Ignore obvious cases we don't have to handle. In particular, most
// instructions either have no uses or only have a single use inside the
// current block. Ignore them quickly.
Instruction *Inst = II;
if (Inst->use_empty()) continue;
if (Inst->hasOneUse() &&
cast<Instruction>(Inst->use_back())->getParent() == BB &&
!isa<PHINode>(Inst->use_back())) continue;
// If this is an alloca in the entry block, it's not a real register
// value.
if (AllocaInst *AI = dyn_cast<AllocaInst>(Inst))
if (isa<ConstantInt>(AI->getArraySize()) && BB == F->begin())
continue;
// Avoid iterator invalidation by copying users to a temporary vector.
std::vector<Instruction*> Users;
for (Value::use_iterator UI = Inst->use_begin(), E = Inst->use_end();
UI != E; ++UI) {
Instruction *User = cast<Instruction>(*UI);
if (User->getParent() != BB || isa<PHINode>(User))
Users.push_back(User);
}
// Scan all of the uses and see if the live range is live across an unwind
// edge. If we find a use live across an invoke edge, create an alloca
// and spill the value.
std::set<InvokeInst*> InvokesWithStoreInserted;
// Find all of the blocks that this value is live in.
std::set<BasicBlock*> LiveBBs;
LiveBBs.insert(Inst->getParent());
while (!Users.empty()) {
Instruction *U = Users.back();
Users.pop_back();
if (!isa<PHINode>(U)) {
MarkBlocksLiveIn(U->getParent(), LiveBBs);
} else {
// Uses for a PHI node occur in their predecessor block.
PHINode *PN = cast<PHINode>(U);
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
if (PN->getIncomingValue(i) == Inst)
MarkBlocksLiveIn(PN->getIncomingBlock(i), LiveBBs);
}
}
// Now that we know all of the blocks that this thing is live in, see if
// it includes any of the unwind locations.
bool NeedsSpill = false;
for (unsigned i = 0, e = Invokes.size(); i != e; ++i) {
BasicBlock *UnwindBlock = Invokes[i]->getUnwindDest();
if (UnwindBlock != BB && LiveBBs.count(UnwindBlock)) {
NeedsSpill = true;
}
}
//.........这里部分代码省略.........