本文整理汇总了C++中ExtractValueInst::idx_end方法的典型用法代码示例。如果您正苦于以下问题:C++ ExtractValueInst::idx_end方法的具体用法?C++ ExtractValueInst::idx_end怎么用?C++ ExtractValueInst::idx_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExtractValueInst
的用法示例。
在下文中一共展示了ExtractValueInst::idx_end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
}
示例2: 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;
}
示例3: 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));
//.........这里部分代码省略.........