[llvm] 5c83bed - More principled implementation of DISubprogram::describes()
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 10:03:39 PST 2020
Author: Adrian Prantl
Date: 2020-03-02T10:03:14-08:00
New Revision: 5c83bedecab94f4dbbb0449cced31aec1b8aaac5
URL: https://github.com/llvm/llvm-project/commit/5c83bedecab94f4dbbb0449cced31aec1b8aaac5
DIFF: https://github.com/llvm/llvm-project/commit/5c83bedecab94f4dbbb0449cced31aec1b8aaac5.diff
LOG: More principled implementation of DISubprogram::describes()
Previously we would also accept DISubprograms that matched in name
only, but this doesn't appear to be necessary any more.
I did a Full and Thin LTO build of Clang and it completed without a warning.
Differential Revision: https://reviews.llvm.org/D75213
Added:
llvm/test/Verifier/disubprogram-name-match-only.ll
Modified:
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/Verifier.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index b630a2893b4d..bd8829e92656 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -660,12 +660,7 @@ DISubprogram *DISubprogram::getImpl(
bool DISubprogram::describes(const Function *F) const {
assert(F && "Invalid function");
- if (F->getSubprogram() == this)
- return true;
- StringRef Name = getLinkageName();
- if (Name.empty())
- Name = getName();
- return F->getName() == Name;
+ return F->getSubprogram() == this;
}
DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index cf0eac908652..eaabd553e95b 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2364,8 +2364,7 @@ void Verifier::visitFunction(const Function &F) {
if (!HasDebugInfo)
return;
- // Check that all !dbg attachments lead to back to N (or, at least, another
- // subprogram that describes the same function).
+ // Check that all !dbg attachments lead to back to N.
//
// FIXME: Check this incrementally while visiting !dbg attachments.
// FIXME: Only check when N is the canonical subprogram for F.
@@ -2394,11 +2393,9 @@ void Verifier::visitFunction(const Function &F) {
if (SP && ((Scope != SP) && !Seen.insert(SP).second))
return;
- // FIXME: Once N is canonical, check "SP == &N".
AssertDI(SP->describes(&F),
"!dbg attachment points at wrong subprogram for function", N, &F,
&I, DL, Scope, SP);
- visitMDNode(*SP);
};
for (auto &BB : F)
for (auto &I : BB) {
diff --git a/llvm/test/Verifier/disubprogram-name-match-only.ll b/llvm/test/Verifier/disubprogram-name-match-only.ll
new file mode 100644
index 000000000000..ae23ae201d55
--- /dev/null
+++ b/llvm/test/Verifier/disubprogram-name-match-only.ll
@@ -0,0 +1,26 @@
+; RUN: llvm-as -disable-output <%s 2>&1| FileCheck %s
+
+define void @f() !dbg !14 {
+ ret void, !dbg !5
+}
+
+!llvm.module.flags = !{!15}
+!llvm.dbg.cu = !{!4}
+
+!0 = !{null}
+!1 = distinct !DICompositeType(tag: DW_TAG_structure_type)
+!2 = !DIFile(filename: "f.c", directory: "/")
+!3 = !DISubroutineType(types: !0)
+!4 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
+; CHECK: !dbg attachment points at wrong subprogram for function
+; CHECK: warning: ignoring invalid debug info
+!5 = !DILocation(line: 1, scope: !9)
+!9 = distinct !DISubprogram(name: "f", scope: !1,
+ file: !2, line: 1, type: !3, isLocal: true,
+ isDefinition: true, scopeLine: 2,
+ unit: !4)
+!14 = distinct !DISubprogram(name: "f", scope: !1,
+ file: !2, line: 1, type: !3, isLocal: true,
+ isDefinition: true, scopeLine: 2,
+ unit: !4)
+!15 = !{i32 1, !"Debug Info Version", i32 3}
More information about the llvm-commits
mailing list