本文整理汇总了C++中DILocation类的典型用法代码示例。如果您正苦于以下问题:C++ DILocation类的具体用法?C++ DILocation怎么用?C++ DILocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DILocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processLocation
void DebugInfoFinder::processLocation(const Module &M, DILocation Loc) {
if (!Loc)
return;
InitializeTypeMap(M);
processScope(Loc.getScope());
processLocation(M, Loc.getOrigLocation());
}
示例2: emitInstructionAnnot
void LineNumberAnnotatedWriter::emitInstructionAnnot(
const Instruction *I, formatted_raw_ostream &Out)
{
DILocation *NewInstrLoc = I->getDebugLoc();
if (!NewInstrLoc) {
auto Loc = DebugLoc.find(I);
if (Loc != DebugLoc.end())
NewInstrLoc = Loc->second;
}
if (!NewInstrLoc || NewInstrLoc == InstrLoc)
return;
InstrLoc = NewInstrLoc;
std::vector<DILineInfo> DIvec;
do {
DIvec.emplace_back();
DILineInfo &DI = DIvec.back();
DIScope *scope = NewInstrLoc->getScope();
if (scope)
DI.FunctionName = scope->getName();
DI.FileName = NewInstrLoc->getFilename();
DI.Line = NewInstrLoc->getLine();
NewInstrLoc = NewInstrLoc->getInlinedAt();
} while (NewInstrLoc);
LinePrinter.emit_lineinfo(Out, DIvec);
}
示例3: getDebugLoc
void DiagnosticInfoOptimizationBase::getLocation(StringRef *Filename,
unsigned *Line,
unsigned *Column) const {
DILocation *L = getDebugLoc();
assert(L != nullptr && "debug location is invalid");
*Filename = L->getFilename();
*Line = L->getLine();
*Column = L->getColumn();
}
示例4: getDSPIPath
static std::string getDSPIPath(DILocation Loc) {
std::string dir = Loc.getDirectory();
std::string file = Loc.getFilename();
if (dir.empty()) {
return file;
} else if (*dir.rbegin() == '/') {
return dir + file;
} else {
return dir + "/" + file;
}
}
示例5: processLocation
/// processLocation - Process DILocation.
void DebugInfoFinder::processLocation(DILocation Loc) {
if (!Loc.Verify()) return;
DIDescriptor S(Loc.getScope());
if (S.isCompileUnit())
addCompileUnit(DICompileUnit(S));
else if (S.isSubprogram())
processSubprogram(DISubprogram(S));
else if (S.isLexicalBlock())
processLexicalBlock(DILexicalBlock(S));
processLocation(Loc.getOrigLocation());
}
示例6: processLocation
/// processLocation - Process DILocation.
void DebugInfoFinder::processLocation(DILocation Loc) {
if (Loc.isNull()) return;
DIScope S(Loc.getScope().getNode());
if (S.isNull()) return;
if (S.isCompileUnit())
addCompileUnit(DICompileUnit(S.getNode()));
else if (S.isSubprogram())
processSubprogram(DISubprogram(S.getNode()));
else if (S.isLexicalBlock())
processLexicalBlock(DILexicalBlock(S.getNode()));
processLocation(Loc.getOrigLocation());
}
示例7: getInstWeight
/// \brief Get the weight for an instruction.
///
/// The "weight" of an instruction \p Inst is the number of samples
/// collected on that instruction at runtime. To retrieve it, we
/// need to compute the line number of \p Inst relative to the start of its
/// function. We use HeaderLineno to compute the offset. We then
/// look up the samples collected for \p Inst using BodySamples.
///
/// \param Inst Instruction to query.
///
/// \returns The profiled weight of I.
unsigned SampleProfileLoader::getInstWeight(Instruction &Inst) {
DebugLoc DLoc = Inst.getDebugLoc();
if (!DLoc)
return 0;
unsigned Lineno = DLoc.getLine();
if (Lineno < HeaderLineno)
return 0;
DILocation DIL = DLoc.get();
int LOffset = Lineno - HeaderLineno;
unsigned Discriminator = DIL.getDiscriminator();
unsigned Weight = Samples->samplesAt(LOffset, Discriminator);
DEBUG(dbgs() << " " << Lineno << "." << Discriminator << ":" << Inst
<< " (line offset: " << LOffset << "." << Discriminator
<< " - weight: " << Weight << ")\n");
return Weight;
}
示例8: DILocation
/// CreateLocation - Creates a debug info location.
DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo,
DIScope S, DILocation OrigLoc) {
Value *Elts[] = {
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo),
S.getNode(),
OrigLoc.getNode(),
};
return DILocation(MDNode::get(VMContext, &Elts[0], 4));
}
示例9: ILoc
static MDNode *UpdateInlinedAtInfo(MDNode *InsnMD, MDNode *TheCallMD) {
DILocation ILoc(InsnMD);
if (!ILoc.Verify()) return InsnMD;
DILocation CallLoc(TheCallMD);
if (!CallLoc.Verify()) return InsnMD;
DILocation OrigLocation = ILoc.getOrigLocation();
MDNode *NewLoc = TheCallMD;
if (OrigLocation.Verify())
NewLoc = UpdateInlinedAtInfo(OrigLocation, TheCallMD);
Value *MDVs[] = {
InsnMD->getOperand(0), // Line
InsnMD->getOperand(1), // Col
InsnMD->getOperand(2), // Scope
NewLoc
};
return MDNode::get(InsnMD->getContext(), MDVs, 4);
}
示例10: ILoc
static MDNode *UpdateInlinedAtInfo(MDNode *InsnMD, MDNode *TheCallMD,
LLVMContext &Context) {
DILocation ILoc(InsnMD);
if (ILoc.isNull()) return InsnMD;
DILocation CallLoc(TheCallMD);
if (CallLoc.isNull()) return InsnMD;
DILocation OrigLocation = ILoc.getOrigLocation();
MDNode *NewLoc = TheCallMD;
if (!OrigLocation.isNull())
NewLoc = UpdateInlinedAtInfo(OrigLocation.getNode(), TheCallMD, Context);
SmallVector<Value *, 4> MDVs;
MDVs.push_back(InsnMD->getElement(0)); // Line
MDVs.push_back(InsnMD->getElement(1)); // Col
MDVs.push_back(InsnMD->getElement(2)); // Scope
MDVs.push_back(NewLoc);
return MDNode::get(Context, MDVs.data(), MDVs.size());
}
示例11: printSourceInfo
//
// Function: printSourceInfo()
//
// Description:
// Print source file and line number information about the instruction to
// standard output.
//
static void
printSourceInfo (std::string errorType, Instruction * I) {
//
// Print out where the fault will be inserted in the source code.
// If we can't find the source line information, use a dummy line number and
// the function name by default.
//
std::string fname = I->getParent()->getParent()->getNameStr();
std::string funcname = fname;
uint64_t lineno = 0;
unsigned dbgKind = I->getContext().getMDKindID("dbg");
if (MDNode *Dbg = I->getMetadata(dbgKind)) {
DILocation Loc (Dbg);
fname = Loc.getDirectory().str() + Loc.getFilename().str();
lineno = Loc.getLineNumber();
}
std::cout << "Inject: " << errorType << ": "
<< funcname << ": " << fname << ": " << lineno << "\n";
return;
}
示例12: ci
void
CallGraphPass::handleInstruction(llvm::CallSite cs, callgraphs::FunctionInfo *fun, llvm::Module &m){
// Check whether the instruction is actually a call
if (!cs.getInstruction()) {
return;
}
// Check whether the called function is directly invoked
auto called = dyn_cast<Function>(cs.getCalledValue()->stripPointerCasts());
if (!called) {
for(auto &f : m){
if(f.hasAddressTaken()){
bool match = true;
std::vector< Type* > argslist;
for (Use &U : cs.getInstruction()->operands()) {
Value *v = U.get();
argslist.push_back( v->getType() );
}
llvm::Function::ArgumentListType &alt = f.getArgumentList();
int j = 0;
for( auto &a : alt){
if( a.getType() != argslist[j++]){
match = false;
}
}
if( argslist.size() > (j+1) && !f.isVarArg() ){
match = false;
}
if(match){
DILocation *Loc = cs.getInstruction()->getDebugLoc();
callgraphs::CallInfo ci( &f, Loc->getLine() , Loc->getFilename(),
funcs.find( fun->getFunction() )->second.callCount);
funcs.find( &f )->second.weight++;
funcs.find( fun->getFunction() )->second.directCalls.push_back( ci );
}
}
}
funcs.find( fun->getFunction() )->second.callCount++;
return;
}
if(called->getName() == "llvm.dbg.declare")
return;
// Direct Calls heres
DILocation *Loc = cs.getInstruction()->getDebugLoc();
callgraphs::CallInfo ci(called, Loc->getLine() , Loc->getFilename(),
funcs.find( fun->getFunction() )->second.callCount );
funcs.find( called )->second.weight++;
funcs.find( fun->getFunction() )->second.directCalls.push_back( ci );
funcs.find( fun->getFunction() )->second.callCount++;
}
示例13: ExtractDebugLocation
/// ExtractDebugLocation - Extract debug location information
/// from DILocation.
DebugLoc ExtractDebugLocation(DILocation &Loc,
DebugLocTracker &DebugLocInfo) {
DebugLoc DL;
MDNode *Context = Loc.getScope().getNode();
MDNode *InlinedLoc = NULL;
if (!Loc.getOrigLocation().isNull())
InlinedLoc = Loc.getOrigLocation().getNode();
// If this location is already tracked then use it.
DebugLocTuple Tuple(Context, InlinedLoc, Loc.getLineNumber(),
Loc.getColumnNumber());
DenseMap<DebugLocTuple, unsigned>::iterator II
= DebugLocInfo.DebugIdMap.find(Tuple);
if (II != DebugLocInfo.DebugIdMap.end())
return DebugLoc::get(II->second);
// Add a new location entry.
unsigned Id = DebugLocInfo.DebugLocations.size();
DebugLocInfo.DebugLocations.push_back(Tuple);
DebugLocInfo.DebugIdMap[Tuple] = Id;
return DebugLoc::get(Id);
}
示例14: get
const DILocation *DILocation::getMergedLocation(const DILocation *LocA,
const DILocation *LocB,
bool GenerateLocation) {
if (!LocA || !LocB)
return nullptr;
if (LocA == LocB || !LocA->canDiscriminate(*LocB))
return LocA;
if (!GenerateLocation)
return nullptr;
SmallPtrSet<DILocation *, 5> InlinedLocationsA;
for (DILocation *L = LocA->getInlinedAt(); L; L = L->getInlinedAt())
InlinedLocationsA.insert(L);
const DILocation *Result = LocB;
for (DILocation *L = LocB->getInlinedAt(); L; L = L->getInlinedAt()) {
Result = L;
if (InlinedLocationsA.count(L))
break;
}
return DILocation::get(Result->getContext(), 0, 0, Result->getScope(),
Result->getInlinedAt());
}
示例15: while
const DILocation *DILocation::getMergedLocation(const DILocation *LocA,
const DILocation *LocB) {
if (!LocA || !LocB)
return nullptr;
if (LocA == LocB)
return LocA;
SmallPtrSet<DILocation *, 5> InlinedLocationsA;
for (DILocation *L = LocA->getInlinedAt(); L; L = L->getInlinedAt())
InlinedLocationsA.insert(L);
SmallSet<std::pair<DIScope *, DILocation *>, 5> Locations;
DIScope *S = LocA->getScope();
DILocation *L = LocA->getInlinedAt();
while (S) {
Locations.insert(std::make_pair(S, L));
S = S->getScope().resolve();
if (!S && L) {
S = L->getScope();
L = L->getInlinedAt();
}
}
const DILocation *Result = LocB;
S = LocB->getScope();
L = LocB->getInlinedAt();
while (S) {
if (Locations.count(std::make_pair(S, L)))
break;
S = S->getScope().resolve();
if (!S && L) {
S = L->getScope();
L = L->getInlinedAt();
}
}
// If the two locations are irreconsilable, just pick one. This is misleading,
// but on the other hand, it's a "line 0" location.
if (!S || !isa<DILocalScope>(S))
S = LocA->getScope();
return DILocation::get(Result->getContext(), 0, 0, S, L);
}