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


C++ ExtractValueInst::getAggregateOperand方法代码示例

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


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

示例1: visitExtractValue

bool CallAnalyzer::visitExtractValue(ExtractValueInst &I) {
  // Constant folding for extract value is trivial.
  Constant *C = dyn_cast<Constant>(I.getAggregateOperand());
  if (!C)
    C = SimplifiedValues.lookup(I.getAggregateOperand());
  if (C) {
    SimplifiedValues[&I] = ConstantExpr::getExtractValue(C, I.getIndices());
    return true;
  }

  // SROA can look through these but give them a cost.
  return false;
}
开发者ID:headmyshoulder,项目名称:llvm,代码行数:13,代码来源:InlineCost.cpp

示例2: visitExtractValueInst

void GraphBuilder::visitExtractValueInst(ExtractValueInst& I) {
  DSNodeHandle Ptr = getValueDest(I.getOperand(0));

  // Make that the node is read from...
  Ptr.getNode()->setReadMarker();
  unsigned Offset = 0;
  Type* STy = I.getAggregateOperand()->getType();
  llvm::ExtractValueInst::idx_iterator i = I.idx_begin(), e = I.idx_end();
  for (; i != e; i++) {
    const StructLayout *SL = TD.getStructLayout(cast<StructType>(STy));
    Offset += SL->getElementOffset(*i);
    STy = (cast<StructType>(STy))->getTypeAtIndex(*i);
  }

  // Ensure a typerecord exists...
  Ptr.getNode()->mergeTypeInfo(I.getType(), Offset);

  if (isa<PointerType>(I.getType()))
    setDestTo(I, getLink(Ptr));
}
开发者ID:brills,项目名称:pfpa,代码行数:20,代码来源:Local.cpp

示例3: CheckAndInstrument

bool ExtractValueInstrumenter::CheckAndInstrument(Instruction* inst) { 
  ExtractValueInst* evInst = dyn_cast<ExtractValueInst>(inst); 

  if (evInst == NULL) {
    return false;
  }

  safe_assert(parent_ != NULL);

  count_++;

  InstrPtrVector instrs;

  Constant* iidC = IID_CONSTANT(evInst);

  Constant* inxC = computeIndex(evInst);

  Value* aggOp = evInst->getAggregateOperand();

  Constant* aggOpInxC = computeIndex(aggOp);

  KVALUE_STRUCTVALUE(aggOp, instrs);

  for (ExtractValueInst::idx_iterator idx = evInst->idx_begin(); idx != evInst->idx_end(); idx++) {
    Constant* idxOp = INT32_CONSTANT(*idx, UNSIGNED);
    Instruction* call = CALL_INT("llvm_push_getelementptr_inx2", idxOp);
    instrs.push_back(call);
  } 

  Instruction* call = CALL_IID_INT_INT("llvm_extractvalue", iidC, inxC, aggOpInxC);

  instrs.push_back(call);

  InsertAllBefore(instrs, evInst);

  return true;
}
开发者ID:corvette-berkeley,项目名称:shadow-execution,代码行数:37,代码来源:ExtractValueInstrumenter.cpp

示例4: runOnModule

//
// Method: runOnModule()
//
// Description:
//  Entry point for this LLVM pass. Search for insert/extractvalue instructions
//  that can be simplified.
//
// Inputs:
//  M - A reference to the LLVM module to transform.
//
// Outputs:
//  M - The transformed LLVM module.
//
// Return value:
// true  - The module was modified.
// false - The module was not modified.
//
bool SimplifyEV::runOnModule(Module& M) {
  // Repeat till no change
  bool changed;
  do {
    changed = false;
    for (Module::iterator F = M.begin(); F != M.end(); ++F) {
      for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) {      
        for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) {
          ExtractValueInst *EV = dyn_cast<ExtractValueInst>(I++);
          if(!EV)
            continue;
          Value *Agg = EV->getAggregateOperand();
          if (!EV->hasIndices()) {
            EV->replaceAllUsesWith(Agg);
            DEBUG(errs() << "EV:");
            DEBUG(errs() << "ERASE:");
            DEBUG(EV->dump());
            EV->eraseFromParent();
            numErased++;
            changed = true;
            continue;
          }
          if (Constant *C = dyn_cast<Constant>(Agg)) {
            if (isa<UndefValue>(C)) {
              EV->replaceAllUsesWith(UndefValue::get(EV->getType()));
              DEBUG(errs() << "EV:");
              DEBUG(errs() << "ERASE:");
              DEBUG(EV->dump());
              EV->eraseFromParent();
              numErased++;
              changed = true;
              continue;
            }
            if (isa<ConstantAggregateZero>(C)) {
              EV->replaceAllUsesWith(Constant::getNullValue(EV->getType()));
              DEBUG(errs() << "EV:");
              DEBUG(errs() << "ERASE:");
              DEBUG(EV->dump());
              EV->eraseFromParent();
              numErased++;
              changed = true;
              continue;
            }
            if (isa<ConstantArray>(C) || isa<ConstantStruct>(C)) {
              // Extract the element indexed by the first index out of the constant
              Value *V = C->getOperand(*EV->idx_begin());
              if (EV->getNumIndices() > 1) {
                // Extract the remaining indices out of the constant indexed by the
                // first index
                ExtractValueInst *EV_new = ExtractValueInst::Create(V, 
                                                                    EV->getIndices().slice(1), 
                                                                    "", EV);
                EV->replaceAllUsesWith(EV_new);
                DEBUG(errs() << "EV:");
                DEBUG(errs() << "ERASE:");
                DEBUG(EV->dump());
                EV->eraseFromParent();
                numErased++;
                changed = true;
                continue;
              }  else {
                EV->replaceAllUsesWith(V);
                DEBUG(errs() << "EV:");
                DEBUG(errs() << "ERASE:");
                DEBUG(EV->dump());
                EV->eraseFromParent();
                numErased++;
                changed = true;
                continue;
              }
            }
            continue;
          }
          if (LoadInst * LI = dyn_cast<LoadInst>(Agg)) {
            // if the Agg value came from a load instruction
            // replace the extract value intruction with
            // a gep and a load.
            SmallVector<Value*, 8> Indices;
            Type *Int32Ty = Type::getInt32Ty(M.getContext());
            Indices.push_back(Constant::getNullValue(Int32Ty));
            for (ExtractValueInst::idx_iterator I = EV->idx_begin(), E = EV->idx_end();
                 I != E; ++I) {
              Indices.push_back(ConstantInt::get(Int32Ty, *I));
//.........这里部分代码省略.........
开发者ID:C0deZLee,项目名称:llvm-dsa,代码行数:101,代码来源:SimplifyExtractValue.cpp


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