mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
IR: Restore the old behavior of getDISubprogram
getDISubprogram was mistakenly thought to contain a bug: we thought we might need to try harder if we found a DebugLoc we didn't find. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221044 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bdec4aee7b
commit
666a51320e
@ -914,17 +914,16 @@ DISubprogram llvm::getDISubprogram(const MDNode *Scope) {
|
||||
|
||||
DISubprogram llvm::getDISubprogram(const Function *F) {
|
||||
// We look for the first instr that has a debug annotation leading back to F.
|
||||
const LLVMContext &Ctx = F->getParent()->getContext();
|
||||
for (auto &BB : *F) {
|
||||
for (auto &Inst : BB.getInstList()) {
|
||||
DebugLoc DLoc = Inst.getDebugLoc();
|
||||
if (DLoc.isUnknown())
|
||||
continue;
|
||||
const MDNode *Scope = DLoc.getScopeNode(Ctx);
|
||||
DISubprogram Subprogram = getDISubprogram(Scope);
|
||||
if (Subprogram.describes(F))
|
||||
return Subprogram;
|
||||
}
|
||||
auto Inst = std::find_if(BB.begin(), BB.end(), [](const Instruction &Inst) {
|
||||
return !Inst.getDebugLoc().isUnknown();
|
||||
});
|
||||
if (Inst == BB.end())
|
||||
continue;
|
||||
DebugLoc DLoc = Inst->getDebugLoc();
|
||||
const MDNode *Scope = DLoc.getScopeNode(F->getParent()->getContext());
|
||||
DISubprogram Subprogram = getDISubprogram(Scope);
|
||||
return Subprogram.describes(F) ? Subprogram : DISubprogram();
|
||||
}
|
||||
|
||||
return DISubprogram();
|
||||
|
Loading…
Reference in New Issue
Block a user