本文整理汇总了C++中DILocation::getFile方法的典型用法代码示例。如果您正苦于以下问题:C++ DILocation::getFile方法的具体用法?C++ DILocation::getFile怎么用?C++ DILocation::getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DILocation
的用法示例。
在下文中一共展示了DILocation::getFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runOnFunction
bool runOnFunction(Function &F) override {
DecoupleLoopsPass &DLP = Pass::getAnalysis<DecoupleLoopsPass>();
const LoopInfo *LI = DLP.getLI(&F);
DIFile *File = nullptr; // The file in which this loop is defined.
vector<int> lines; // Line per instruction in the order of traversal.
vector<int> cols; // Column per instruction in the order of traversal.
vector<int> BBs; // Basic-block for each line.
vector<int> Loops; // Loop for each line.
vector<bool> branchLines; // true if instruction n is a branch instruction
vector<bool> workLines;
vector<bool> iterLines;
int bb_count = 0;
int loop_count = 0;
for (Loop *L : *LI) {
// Ignore loops we cannot decouple.
if (!DLP.hasWork(L))
continue;
for (Loop::block_iterator BI = L->block_begin(), BE = L->block_end();
BI != BE; ++BI, ++bb_count) {
BasicBlock *BB = *BI;
for (Instruction &Inst : *BB) {
DILocation *Loc = Inst.getDebugLoc();
if (!Loc) {
continue;
}
if (!File) {
File = Loc->getFile();
}
int line = Loc->getLine();
int col = Loc->getColumn();
lines.push_back(line);
cols.push_back(col);
BBs.push_back(bb_count);
Loops.push_back(loop_count);
branchLines.push_back(dyn_cast<BranchInst>(&Inst) ? true : false);
workLines.push_back(DLP.isWork(Inst, L) ? true : false);
iterLines.push_back(DLP.isIter(Inst, L) ? true : false);
}
}
++loop_count;
}
if (File != nullptr) {
int prevLoop = -1;
raw_os_ostream roos(cout);
for (int i = 0; i < lines.size(); ++i) {
int line = lines[i];
if (line == -1)
continue; // Already traversed.
if (Loops[i] != prevLoop) {
prevLoop = Loops[i];
roos << "Loop " << Loops[i] << "\n";
}
roos << File->getFilename() << ":" << line;
int prevBB = -1;
for (int j = 0; j < lines.size(); ++j) {
if (lines[j] != line)
continue;
// Destructive and messy (and slow).
lines[j] = -1;
if (BBs[j] != prevBB) {
prevBB = BBs[j];
roos << " ; BB" << BBs[j] << ":";
}
roos << " " << cols[j] << ":";
if (branchLines[j])
roos << "b-";
if (workLines[j])
roos << "w";
if (iterLines[j])
roos << "i";
}
roos << '\n';
}
} else {
llvm::errs() << "ERROR: No debugging information found!\n";
}
return false;
}