当前位置: 首页>>代码示例>>C++>>正文


C++ LandingPadInst::isCleanup方法代码示例

本文整理汇总了C++中LandingPadInst::isCleanup方法的典型用法代码示例。如果您正苦于以下问题:C++ LandingPadInst::isCleanup方法的具体用法?C++ LandingPadInst::isCleanup怎么用?C++ LandingPadInst::isCleanup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LandingPadInst的用法示例。


在下文中一共展示了LandingPadInst::isCleanup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addLandingPadInfo

void llvm::addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB) {
  MachineFunction &MF = *MBB.getParent();
  if (const auto *PF = dyn_cast<Function>(
          I.getParent()->getParent()->getPersonalityFn()->stripPointerCasts()))
    MF.getMMI().addPersonality(PF);

  if (I.isCleanup())
    MF.addCleanup(&MBB);

  // FIXME: New EH - Add the clauses in reverse order. This isn't 100% correct,
  //        but we need to do it this way because of how the DWARF EH emitter
  //        processes the clauses.
  for (unsigned i = I.getNumClauses(); i != 0; --i) {
    Value *Val = I.getClause(i - 1);
    if (I.isCatch(i - 1)) {
      MF.addCatchTypeInfo(&MBB,
                          dyn_cast<GlobalValue>(Val->stripPointerCasts()));
    } else {
      // Add filters in a list.
      Constant *CVal = cast<Constant>(Val);
      SmallVector<const GlobalValue *, 4> FilterList;
      for (User::op_iterator II = CVal->op_begin(), IE = CVal->op_end();
           II != IE; ++II)
        FilterList.push_back(cast<GlobalValue>((*II)->stripPointerCasts()));

      MF.addFilterTypeInfo(&MBB, FilterList);
    }
  }
}
开发者ID:davidlt,项目名称:root,代码行数:29,代码来源:MachineFunction.cpp

示例2: HandleInlinedInvoke

/// HandleInlinedInvoke - If we inlined an invoke site, we need to convert calls
/// in the body of the inlined function into invokes.
///
/// II is the invoke instruction being inlined.  FirstNewBlock is the first
/// block of the inlined code (the last block is the end of the function),
/// and InlineCodeInfo is information about the code that got inlined.
static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
                                ClonedCodeInfo &InlinedCodeInfo) {
    BasicBlock *InvokeDest = II->getUnwindDest();

    Function *Caller = FirstNewBlock->getParent();

    // The inlined code is currently at the end of the function, scan from the
    // start of the inlined code to its end, checking for stuff we need to
    // rewrite.
    InvokeInliningInfo Invoke(II);

    // Get all of the inlined landing pad instructions.
    SmallPtrSet<LandingPadInst*, 16> InlinedLPads;
    for (Function::iterator I = FirstNewBlock, E = Caller->end(); I != E; ++I)
        if (InvokeInst *II = dyn_cast<InvokeInst>(I->getTerminator()))
            InlinedLPads.insert(II->getLandingPadInst());

    // Append the clauses from the outer landing pad instruction into the inlined
    // landing pad instructions.
    LandingPadInst *OuterLPad = Invoke.getLandingPadInst();
    for (SmallPtrSet<LandingPadInst*, 16>::iterator I = InlinedLPads.begin(),
            E = InlinedLPads.end(); I != E; ++I) {
        LandingPadInst *InlinedLPad = *I;
        unsigned OuterNum = OuterLPad->getNumClauses();
        InlinedLPad->reserveClauses(OuterNum);
        for (unsigned OuterIdx = 0; OuterIdx != OuterNum; ++OuterIdx)
            InlinedLPad->addClause(OuterLPad->getClause(OuterIdx));
        if (OuterLPad->isCleanup())
            InlinedLPad->setCleanup(true);
    }

    for (Function::iterator BB = FirstNewBlock, E = Caller->end(); BB != E; ++BB) {
        if (InlinedCodeInfo.ContainsCalls)
            HandleCallsInBlockInlinedThroughInvoke(BB, Invoke);

        // Forward any resumes that are remaining here.
        if (ResumeInst *RI = dyn_cast<ResumeInst>(BB->getTerminator()))
            Invoke.forwardResume(RI, InlinedLPads);
    }

    // Now that everything is happy, we have one final detail.  The PHI nodes in
    // the exception destination block still have entries due to the original
    // invoke instruction. Eliminate these entries (which might even delete the
    // PHI node) now.
    InvokeDest->removePredecessor(II->getParent());
}
开发者ID:rui314,项目名称:llvm,代码行数:52,代码来源:InlineFunction.cpp

示例3: runOnModule


//.........这里部分代码省略.........
          II->replaceAllUsesWith(NewCall);
          ToErase.push_back(II);

          CallInst *Post = CallInst::Create(PostInvoke, "", II);
          Instruction *Post1 = new TruncInst(Post, i1, "", II);

          // Insert a branch based on the postInvoke
          BranchInst::Create(II->getUnwindDest(), II->getNormalDest(), Post1, II);
        } else {
          // This can't throw, and we don't need this invoke, just replace it with a call+branch
          SmallVector<Value*,16> CallArgs(II->op_begin(), II->op_end() - 3);
          CallInst *NewCall = CallInst::Create(II->getCalledValue(),
                                               CallArgs, "", II);
          NewCall->takeName(II);
          NewCall->setCallingConv(II->getCallingConv());
          NewCall->setAttributes(II->getAttributes());
          NewCall->setDebugLoc(II->getDebugLoc());
          II->replaceAllUsesWith(NewCall);
          ToErase.push_back(II);

          BranchInst::Create(II->getNormalDest(), II);

          // Remove any PHI node entries from the exception destination.
          II->getUnwindDest()->removePredecessor(BB);
        }

        Changed = true;
      }
      // scan the body of the basic block for resumes
      for (BasicBlock::iterator Iter = BB->begin(), E = BB->end();
           Iter != E; ) {
        Instruction *I = Iter++;
        if (ResumeInst *R = dyn_cast<ResumeInst>(I)) {
          // split the input into legal values
          Value *Input = R->getValue();
          ExtractValueInst *Low = ExtractValueInst::Create(Input, 0, "", R);
          ExtractValueInst *High = ExtractValueInst::Create(Input, 1, "", R);

          // create a resume call
          SmallVector<Value*,2> CallArgs;
          CallArgs.push_back(Low);
          CallArgs.push_back(High);
          CallInst::Create(Resume, CallArgs, "", R);

          new UnreachableInst(TheModule->getContext(), R); // add a terminator to the block

          ToErase.push_back(R);
        }
      }
    }

    // Look for orphan landingpads, can occur in blocks with no predecesors
    for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
      Instruction *I = BB->getFirstNonPHI();
      if (LandingPadInst *LP = dyn_cast<LandingPadInst>(I)) {
        LandingPads.insert(LP);
      }
    }

    // Handle all the landingpad for this function together, as multiple invokes may share a single lp
    for (std::set<LandingPadInst*>::iterator I = LandingPads.begin(); I != LandingPads.end(); I++) {
      // Replace the landingpad with a landingpad call to get the low part, and a getHigh for the high
      LandingPadInst *LP = *I;
      unsigned Num = LP->getNumClauses();
      SmallVector<Value*,16> NewLPArgs;
      NewLPArgs.push_back(LP->getPersonalityFn());
      for (unsigned i = 0; i < Num; i++) {
        Value *Arg = LP->getClause(i);
        // As a temporary workaround for the lack of aggregate varargs support
        // in the varargs lowering code, break out filter operands into their
        // component elements.
        if (LP->isFilter(i)) {
          ArrayType *ATy = cast<ArrayType>(Arg->getType());
          for (unsigned elem = 0, elemEnd = ATy->getNumElements(); elem != elemEnd; ++elem) {
            Instruction *EE = ExtractValueInst::Create(Arg, makeArrayRef(elem), "", LP);
            NewLPArgs.push_back(EE);
          }
        } else {
          NewLPArgs.push_back(Arg);
        }
      }
      NewLPArgs.push_back(LP->isCleanup() ? ConstantInt::getTrue(i1) : ConstantInt::getFalse(i1));
      CallInst *NewLP = CallInst::Create(LandingPad, NewLPArgs, "", LP);

      Instruction *High = CallInst::Create(GetHigh, "", LP);

      // New recreate an aggregate for them, which will be all simplified later (simplification cannot handle landingpad, hence all this)
      InsertValueInst *IVA = InsertValueInst::Create(UndefValue::get(LP->getType()), NewLP, 0, "", LP);
      InsertValueInst *IVB = InsertValueInst::Create(IVA, High, 1, "", LP);

      LP->replaceAllUsesWith(IVB);
      ToErase.push_back(LP);
    }

    // erase everything we no longer need in this function
    for (unsigned i = 0; i < ToErase.size(); i++) ToErase[i]->eraseFromParent();
  }

  return Changed;
}
开发者ID:UplinkCoder,项目名称:emscripten-fastcomp,代码行数:101,代码来源:LowerEmExceptionsPass.cpp


注:本文中的LandingPadInst::isCleanup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。