[llvm] r370631 - [DWARFVerifier] Verify GNU extensions of call site DWARF symbols
Djordje Todorovic via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 2 02:20:46 PDT 2019
Author: djtodoro
Date: Mon Sep 2 02:20:46 2019
New Revision: 370631
URL: http://llvm.org/viewvc/llvm-project?rev=370631&view=rev
Log:
[DWARFVerifier] Verify GNU extensions of call site DWARF symbols
Verify that the call site DWARF symbols (added during the implementation
of the debug entry values feature) are generated properly.
Differential Revision: https://reviews.llvm.org/D66865
Added:
llvm/trunk/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll
Modified:
llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp?rev=370631&r1=370630&r2=370631&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp Mon Sep 2 02:20:46 2019
@@ -203,7 +203,7 @@ unsigned DWARFVerifier::verifyUnitConten
}
unsigned DWARFVerifier::verifyDebugInfoCallSite(const DWARFDie &Die) {
- if (Die.getTag() != DW_TAG_call_site)
+ if (Die.getTag() != DW_TAG_call_site && Die.getTag() != DW_TAG_GNU_call_site)
return 0;
DWARFDie Curr = Die.getParent();
@@ -223,7 +223,9 @@ unsigned DWARFVerifier::verifyDebugInfoC
Optional<DWARFFormValue> CallAttr =
Curr.find({DW_AT_call_all_calls, DW_AT_call_all_source_calls,
- DW_AT_call_all_tail_calls});
+ DW_AT_call_all_tail_calls, DW_AT_GNU_all_call_sites,
+ DW_AT_GNU_all_source_call_sites,
+ DW_AT_GNU_all_tail_call_sites});
if (!CallAttr) {
error() << "Subprogram with call site entry has no DW_AT_call attribute:";
Curr.dump(OS);
@@ -500,6 +502,9 @@ unsigned DWARFVerifier::verifyDebugInfoA
break;
if (DieTag == DW_TAG_variable && RefTag == DW_TAG_member)
break;
+ // This might be reference to a function declaration.
+ if (DieTag == DW_TAG_GNU_call_site && RefTag == DW_TAG_subprogram)
+ break;
ReportError("DIE with tag " + TagString(DieTag) + " has " +
AttributeString(Attr) +
" that points to DIE with "
Added: llvm/trunk/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll?rev=370631&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll (added)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll Mon Sep 2 02:20:46 2019
@@ -0,0 +1,103 @@
+; RUN: llc -debug-entry-values %s -o - -filetype=obj \
+; RUN: | llvm-dwarfdump -verify - | FileCheck %s
+;
+; CHECK: No errors.
+;
+; The source code of the test case:
+;
+;extern int fn1();
+;extern int fn3(int);
+;
+;__attribute__((noinline))
+;void
+;fn2 (int *arg) {
+; int a = ++(*arg);
+; fn3 (a);
+;}
+;
+;__attribute__((noinline))
+;int f() {
+; int x = fn1();
+; fn2 (&x);
+; return 0;
+;}
+;
+; ModuleID = 'test.c'
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: noinline nounwind uwtable
+define dso_local void @fn2(i32* nocapture %arg) local_unnamed_addr !dbg !15 {
+entry:
+ call void @llvm.dbg.value(metadata i32* %arg, metadata !20, metadata !DIExpression()), !dbg !22
+ %0 = load i32, i32* %arg, align 4, !dbg !23
+ %inc = add nsw i32 %0, 1, !dbg !23
+ store i32 %inc, i32* %arg, align 4, !dbg !23
+ call void @llvm.dbg.value(metadata i32 %inc, metadata !21, metadata !DIExpression()), !dbg !22
+ %call = tail call i32 @fn3(i32 %inc), !dbg !23
+ ret void, !dbg !23
+}
+
+; Function Attrs: argmemonly nounwind willreturn
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
+
+declare !dbg !4 dso_local i32 @fn3(i32) local_unnamed_addr
+
+; Function Attrs: argmemonly nounwind willreturn
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
+
+; Function Attrs: noinline nounwind uwtable
+define dso_local i32 @f() local_unnamed_addr !dbg !24 {
+entry:
+ %x = alloca i32, align 4
+ %0 = bitcast i32* %x to i8*, !dbg !29
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0), !dbg !29
+ %call = tail call i32 (...) @fn1() #4, !dbg !29
+ call void @llvm.dbg.value(metadata i32 %call, metadata !28, metadata !DIExpression()), !dbg !30
+ store i32 %call, i32* %x, align 4, !dbg !29
+ call void @llvm.dbg.value(metadata i32* %x, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !30
+ call void @fn2(i32* nonnull %x), !dbg !29
+ call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %0), !dbg !29
+ ret i32 0, !dbg !29
+}
+
+declare !dbg !8 dso_local i32 @fn1(...) local_unnamed_addr
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!11, !12, !13}
+!llvm.ident = !{!14}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
+!1 = !DIFile(filename: "test.c", directory: "dir")
+!2 = !{}
+!3 = !{!4, !8}
+!4 = !DISubprogram(name: "fn3", scope: !1, file: !1, line: 2, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7, !7}
+!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!8 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !9, spFlags: DISPFlagOptimized, retainedNodes: !2)
+!9 = !DISubroutineType(types: !10)
+!10 = !{!7, null}
+!11 = !{i32 2, !"Dwarf Version", i32 4}
+!12 = !{i32 2, !"Debug Info Version", i32 3}
+!13 = !{i32 1, !"wchar_size", i32 4}
+!14 = !{!"clang version 10.0.0"}
+!15 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 6, type: !16, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !19)
+!16 = !DISubroutineType(types: !17)
+!17 = !{null, !18}
+!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
+!19 = !{!20, !21}
+!20 = !DILocalVariable(name: "arg", arg: 1, scope: !15, file: !1, line: 6, type: !18, flags: DIFlagArgumentNotModified)
+!21 = !DILocalVariable(name: "a", scope: !15, file: !1, line: 7, type: !7)
+!22 = !DILocation(line: 0, scope: !15)
+!23 = !DILocation(line: 7, column: 11, scope: !15)
+!24 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 12, type: !25, scopeLine: 12, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !27)
+!25 = !DISubroutineType(types: !17)
+!26 = !{!7}
+!27 = !{!28}
+!28 = !DILocalVariable(name: "x", scope: !24, file: !1, line: 13, type: !7)
+!29 = !DILocation(line: 13, column: 3, scope: !24)
+!30 = !DILocation(line: 0, scope: !24)
More information about the llvm-commits
mailing list