本文整理汇总了C++中basicblock::iterator::getContext方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::getContext方法的具体用法?C++ iterator::getContext怎么用?C++ iterator::getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类basicblock::iterator
的用法示例。
在下文中一共展示了iterator::getContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fixupLineNumbers
/// fixupLineNumbers - Update inlined instructions' line numbers to
/// to encode location where these instructions are inlined.
static void fixupLineNumbers(Function *Fn, Function::iterator FI,
Instruction *TheCall) {
DebugLoc TheCallDL = TheCall->getDebugLoc();
if (TheCallDL.isUnknown())
return;
for (; FI != Fn->end(); ++FI) {
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end();
BI != BE; ++BI) {
DebugLoc DL = BI->getDebugLoc();
if (!DL.isUnknown()) {
BI->setDebugLoc(updateInlinedAtInfo(DL, TheCallDL, BI->getContext()));
if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(BI)) {
LLVMContext &Ctx = BI->getContext();
MDNode *InlinedAt = BI->getDebugLoc().getInlinedAt(Ctx);
DVI->setOperand(2, createInlinedVariable(DVI->getVariable(),
InlinedAt, Ctx));
}
}
}
}
}
示例2: processModule
/// processModule - Process entire module and collect debug info.
void DebugInfoFinder::processModule(Module &M) {
if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu"))
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i)
addCompileUnit(DICompileUnit(CU_Nodes->getOperand(i)));
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
for (Function::iterator FI = (*I).begin(), FE = (*I).end(); FI != FE; ++FI)
for (BasicBlock::iterator BI = (*FI).begin(), BE = (*FI).end(); BI != BE;
++BI) {
if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(BI))
processDeclare(DDI);
DebugLoc Loc = BI->getDebugLoc();
if (Loc.isUnknown())
continue;
LLVMContext &Ctx = BI->getContext();
DIDescriptor Scope(Loc.getScope(Ctx));
if (Scope.isCompileUnit())
addCompileUnit(DICompileUnit(Scope));
else if (Scope.isSubprogram())
processSubprogram(DISubprogram(Scope));
else if (Scope.isLexicalBlock())
processLexicalBlock(DILexicalBlock(Scope));
if (MDNode *IA = Loc.getInlinedAt(Ctx))
processLocation(DILocation(IA));
}
if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.gv")) {
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
DIGlobalVariable DIG(cast<MDNode>(NMD->getOperand(i)));
if (addGlobalVariable(DIG)) {
if (DIG.getVersion() <= LLVMDebugVersion10)
addCompileUnit(DIG.getCompileUnit());
processType(DIG.getType());
}
}
}
if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.sp"))
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i)
processSubprogram(DISubprogram(NMD->getOperand(i)));
}
示例3: processInst
void Matcher::processInst(Function *F)
{
for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; FI++) {
/** Get each instruction's scope information **/
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; BI++) {
DebugLoc Loc = BI->getDebugLoc();
if (Loc.isUnknown())
continue;
LLVMContext & Ctx = BI->getContext();
DIDescriptor Scope(Loc.getScope(Ctx));
if (Scope.isLexicalBlock()) {
DILexicalBlock DILB(Scope);
errs() << "Block :" << DILB.getLineNumber() << ", " << DILB.getColumnNumber() << "\n";
}
}
}
}
示例4: bypassSlowDivision
// bypassSlowDivision - This optimization identifies DIV instructions that can
// be profitably bypassed and carried out with a shorter, faster divide.
bool llvm::bypassSlowDivision(Function &F,
Function::iterator &I,
const DenseMap<unsigned int, unsigned int> &BypassWidths) {
DivCacheTy DivCache;
bool MadeChange = false;
for (BasicBlock::iterator J = I->begin(); J != I->end(); J++) {
// Get instruction details
unsigned Opcode = J->getOpcode();
bool UseDivOp = Opcode == Instruction::SDiv || Opcode == Instruction::UDiv;
bool UseRemOp = Opcode == Instruction::SRem || Opcode == Instruction::URem;
bool UseSignedOp = Opcode == Instruction::SDiv ||
Opcode == Instruction::SRem;
// Only optimize div or rem ops
if (!UseDivOp && !UseRemOp)
continue;
// Skip division on vector types, only optimize integer instructions
if (!J->getType()->isIntegerTy())
continue;
// Get bitwidth of div/rem instruction
IntegerType *T = cast<IntegerType>(J->getType());
unsigned int bitwidth = T->getBitWidth();
// Continue if bitwidth is not bypassed
DenseMap<unsigned int, unsigned int>::const_iterator BI = BypassWidths.find(bitwidth);
if (BI == BypassWidths.end())
continue;
// Get type for div/rem instruction with bypass bitwidth
IntegerType *BT = IntegerType::get(J->getContext(), BI->second);
MadeChange |= reuseOrInsertFastDiv(F, I, J, BT, UseDivOp,
UseSignedOp, DivCache);
}
return MadeChange;
}
示例5: SimplifyDivRemOfSelect
/// SimplifyDivRemOfSelect - Try to fold a divide or remainder of a select
/// instruction.
bool InstCombiner::SimplifyDivRemOfSelect(BinaryOperator &I) {
SelectInst *SI = cast<SelectInst>(I.getOperand(1));
// div/rem X, (Cond ? 0 : Y) -> div/rem X, Y
int NonNullOperand = -1;
if (Constant *ST = dyn_cast<Constant>(SI->getOperand(1)))
if (ST->isNullValue())
NonNullOperand = 2;
// div/rem X, (Cond ? Y : 0) -> div/rem X, Y
if (Constant *ST = dyn_cast<Constant>(SI->getOperand(2)))
if (ST->isNullValue())
NonNullOperand = 1;
if (NonNullOperand == -1)
return false;
Value *SelectCond = SI->getOperand(0);
// Change the div/rem to use 'Y' instead of the select.
I.setOperand(1, SI->getOperand(NonNullOperand));
// Okay, we know we replace the operand of the div/rem with 'Y' with no
// problem. However, the select, or the condition of the select may have
// multiple uses. Based on our knowledge that the operand must be non-zero,
// propagate the known value for the select into other uses of it, and
// propagate a known value of the condition into its other users.
// If the select and condition only have a single use, don't bother with this,
// early exit.
if (SI->use_empty() && SelectCond->hasOneUse())
return true;
// Scan the current block backward, looking for other uses of SI.
BasicBlock::iterator BBI = &I, BBFront = I.getParent()->begin();
while (BBI != BBFront) {
--BBI;
// If we found a call to a function, we can't assume it will return, so
// information from below it cannot be propagated above it.
if (isa<CallInst>(BBI) && !isa<IntrinsicInst>(BBI))
break;
// Replace uses of the select or its condition with the known values.
for (Instruction::op_iterator I = BBI->op_begin(), E = BBI->op_end();
I != E; ++I) {
if (*I == SI) {
*I = SI->getOperand(NonNullOperand);
Worklist.Add(BBI);
} else if (*I == SelectCond) {
*I = NonNullOperand == 1 ? ConstantInt::getTrue(BBI->getContext()) :
ConstantInt::getFalse(BBI->getContext());
Worklist.Add(BBI);
}
}
// If we past the instruction, quit looking for it.
if (&*BBI == SI)
SI = 0;
if (&*BBI == SelectCond)
SelectCond = 0;
// If we ran out of things to eliminate, break out of the loop.
if (SelectCond == 0 && SI == 0)
break;
}
return true;
}
示例6: runOnModule
//.........这里部分代码省略.........
}
}
//Print all the lookup instructions with tainted values..:
if(GetElementPtrInst *GI = dyn_cast<GetElementPtrInst>(I))
{
moduleDepGraph* mdG = new moduleDepGraph();
mdG->CheckifRelevantField(GI,depGraph);
LoopupInsts.insert(I);
Value* sensitiveObject = GI->getPointerOperand();
SecSensitiveObjs.insert(sensitiveObject);
}
//check if any operand is global string..
if(writeStrings)
{
for (unsigned int i = 0; i < cast<User> (I)->getNumOperands(); i++)
{
Value *v1 = cast<User> (I)->getOperand(i);
if(isa<GlobalVariable> (v1))
{
if(isa<Constant> (v1))
{
//string sName = v1->getName()
v1->print(FileS);
(FileS) << "\n";
}
}
}
}
LLVMContext& C = I->getContext();
MDNode* N = MDNode::get(C, MDString::get(C, "ComputeSSO"));
// char numstr[21]; // enough to hold all numbers up to 64-bits
//sprintf(numstr, "%d", inputDepVal_count);
//appendVal = ()
std::string taintVal = "TAINT_"+appendVal;
// if(debug) errs()<<"\nFunction : "<< F->getName()<<" Tainted Val " << *I <<" val: " << appendVal;
//For the given tainted Val try priniting all the uses of it.
// errs()<<"\nUsed in :: "<<I->getNumUses();
// std::string taintVal = std::strcat("tainted",numstr);
I->setMetadata(taintVal, N);
}
/* if (GetElementPtrInst *gep = dyn_cast<GetElementPtrInst>(&*I)) {
// Dump the GEP instruction
// gep->dump();
Value* firstOperand = gep->getOperand(0);
Type* type = firstOperand->getType();
// Figure out whether the first operand points to an array
if (PointerType *pointerType = dyn_cast<PointerType>(type)) {
Type* elementType = pointerType->getElementType();
//errs() << "The element type is: " << *elementType << "\n";
if (elementType->isArrayTy()) {
errs() << "\n .. points to an array!\n";
errs()<< "First op ..: "<< firstOperand <<" full def :";
gep->dump();
}