Skip to content

Commit

Permalink
better fallback handling for getDebugLocation, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianbs96 committed Dec 15, 2024
1 parent 1482ac8 commit 2cd31a5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/PhasarLLVM/Utils/LLVMIRToSrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ const llvm::DIFile *psr::getDIFileFromIR(const llvm::Value *V) {
} else if (I->getMetadata(llvm::LLVMContext::MD_dbg)) {
return I->getDebugLoc()->getFile();
}
if (const auto *DIFun = I->getFunction()->getSubprogram()) {
return DIFun->getFile();
}
}
return nullptr;
}
Expand Down Expand Up @@ -233,6 +236,11 @@ std::pair<unsigned, unsigned> psr::getLineAndColFromIR(const llvm::Value *V) {
if (auto *DILoc = getDILocation(V)) {
return {DILoc->getLine(), DILoc->getColumn()};
}
if (const auto *I = llvm::dyn_cast<llvm::Instruction>(V)) {
if (const auto *DIFun = I->getFunction()->getSubprogram()) {
return {DIFun->getLine(), 0};
}
}
if (auto *DISubpr = getDISubprogram(V)) { // Function
return {DISubpr->getLine(), 0};
}
Expand Down Expand Up @@ -348,6 +356,11 @@ std::optional<DebugLocation> psr::getDebugLocation(const llvm::Value *V) {
return DebugLocation{DILoc->getLine(), DILoc->getColumn(),
DILoc->getFile()};
}
if (const auto *I = llvm::dyn_cast<llvm::Instruction>(V)) {
if (const auto *DIFun = I->getFunction()->getSubprogram()) {
return DebugLocation{DIFun->getLine(), 0, DIFun->getFile()};
}
}
if (auto *DISubpr = getDISubprogram(V)) { // Function
return DebugLocation{DISubpr->getLine(), 0, DISubpr->getFile()};
}
Expand Down

0 comments on commit 2cd31a5

Please sign in to comment.