Skip to content

Commit

Permalink
[NFC][DebugInfo] assignment-tracking/sroa: do check !DIAssignID, and …
Browse files Browse the repository at this point in the history
…the metadata

Based on post-commit feedback for the original change.
  • Loading branch information
LebedevRI committed Dec 15, 2022
1 parent 6ffbb3f commit 4ff8d1e
Show file tree
Hide file tree
Showing 14 changed files with 887 additions and 62 deletions.
@@ -1,4 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt %s -S -passes=sroa -o - -experimental-assignment-tracking | FileCheck %s

;; Check that SROA preserves the InlinedAt status of new dbg.assign intriniscs
Expand Down Expand Up @@ -40,6 +40,10 @@ declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata,
declare void @llvm.lifetime.start.p0i8(i64 immarg, ptr nocapture) #2
declare void @llvm.lifetime.end.p0i8(i64 immarg, ptr nocapture) #2

;.
; CHECK: @[[F:[a-zA-Z0-9_$"\\.-]+]] = dso_local local_unnamed_addr global i32 0, align 4, !dbg [[DBG0:![0-9]+]]
; CHECK: @[[E:[a-zA-Z0-9_$"\\.-]+]] = dso_local local_unnamed_addr global i32 0, align 4, !dbg [[DBG9:![0-9]+]]
;.
define dso_local void @l() local_unnamed_addr #4 !dbg !73 {
; CHECK-LABEL: @l(
; CHECK-NEXT: entry:
Expand Down Expand Up @@ -145,3 +149,52 @@ entry:
!81 = !DILocation(line: 14, column: 5, scope: !40, inlinedAt: !79)
!82 = !DILocation(line: 20, column: 1, scope: !60, inlinedAt: !76)
!83 = !DILocation(line: 21, column: 17, scope: !73)
;.
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
; CHECK: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
;.
; CHECK: [[DBG0]] = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
; CHECK: [[META1:![0-9]+]] = distinct !DIGlobalVariable(name: "f", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
; CHECK: [[META2:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
; CHECK: [[META3:![0-9]+]] = !DIFile(filename: "test.c", directory: "/")
; CHECK: [[META4:![0-9]+]] = !{}
; CHECK: [[META5:![0-9]+]] = !{!6, !9, !0}
; CHECK: [[META6:![0-9]+]] = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
; CHECK: [[META7:![0-9]+]] = distinct !DIGlobalVariable(name: "d", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
; CHECK: [[META8:![0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
; CHECK: [[DBG9]] = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
; CHECK: [[META10:![0-9]+]] = distinct !DIGlobalVariable(name: "e", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
; CHECK: [[META11:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 4}
; CHECK: [[META12:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
; CHECK: [[META13:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
; CHECK: [[META14:![0-9]+]] = !{!"clang version 12.0.0)"}
; CHECK: [[META15:![0-9]+]] = distinct !DISubprogram(name: "l", scope: !3, file: !3, line: 21, type: !16, scopeLine: 21, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
; CHECK: [[META16:![0-9]+]] = !DISubroutineType(types: !17)
; CHECK: [[META17:![0-9]+]] = !{null}
; CHECK: [[META18]] = !DILocalVariable(name: "j", scope: !19, file: !3, line: 17, type: !21)
; CHECK: [[META19:![0-9]+]] = distinct !DISubprogram(name: "k", scope: !3, file: !3, line: 16, type: !16, scopeLine: 16, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !20)
; CHECK: [[META20:![0-9]+]] = !{!18}
; CHECK: [[META21:![0-9]+]] = !DIDerivedType(tag: DW_TAG_typedef, name: "c", file: !3, line: 4, baseType: !22)
; CHECK: [[META22:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !3, line: 1, size: 32, elements: !23)
; CHECK: [[META23:![0-9]+]] = !{!24, !25}
; CHECK: [[META24:![0-9]+]] = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !22, file: !3, line: 2, baseType: !8, size: 32)
; CHECK: [[META25:![0-9]+]] = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !22, file: !3, line: 3, baseType: !26, offset: 32)
; CHECK: [[META26:![0-9]+]] = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, elements: !27)
; CHECK: [[META27:![0-9]+]] = !{!28}
; CHECK: [[META28:![0-9]+]] = !DISubrange(count: -1)
; CHECK: [[META29]] = distinct !DIAssignID()
; CHECK: [[DBG30]] = !DILocation(line: 0, scope: !19, inlinedAt: !31)
; CHECK: [[META31:![0-9]+]] = distinct !DILocation(line: 21, column: 12, scope: !15)
; CHECK: [[DBG32]] = !DILocation(line: 0, scope: !33, inlinedAt: !41)
; CHECK: [[META33:![0-9]+]] = distinct !DISubprogram(name: "i", scope: !3, file: !3, line: 10, type: !34, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !37)
; CHECK: [[META34:![0-9]+]] = !DISubroutineType(types: !35)
; CHECK: [[META35:![0-9]+]] = !{null, !36}
; CHECK: [[META36:![0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !21, size: 64)
; CHECK: [[META37:![0-9]+]] = !{!38, !39}
; CHECK: [[META38:![0-9]+]] = !DILocalVariable(name: "h", arg: 1, scope: !33, file: !3, line: 10, type: !36)
; CHECK: [[META39:![0-9]+]] = !DILocalVariable(name: "j", scope: !33, file: !3, line: 11, type: !40)
; CHECK: [[META40:![0-9]+]] = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
; CHECK: [[META41:![0-9]+]] = distinct !DILocation(line: 19, column: 3, scope: !19, inlinedAt: !31)
; CHECK: [[DBG42]] = !DILocation(line: 14, column: 5, scope: !33, inlinedAt: !41)
; CHECK: [[DBG43]] = !DILocation(line: 21, column: 17, scope: !15)
;.
@@ -1,4 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -passes=sroa,verify -S %s -o - -experimental-assignment-tracking \
; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"

Expand All @@ -23,11 +23,14 @@ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16

@c = dso_local global i32 0, align 4, !dbg !0

;.
; CHECK: @[[C:[a-zA-Z0-9_$"\\.-]+]] = dso_local global i32 0, align 4, !dbg [[DBG0:![0-9]+]]
;.
define dso_local void @d() !dbg !11 {
; CHECK-LABEL: @d(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A_SROA_0:%.*]] = alloca i64, align 8, !DIAssignID !23
; CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata [[META15:![0-9]+]], metadata !DIExpression(), metadata [[META23:![0-9]+]], metadata ptr [[A_SROA_0]], metadata !DIExpression()), !dbg [[DBG24:![0-9]+]]
; CHECK-NEXT: [[A_SROA_0:%.*]] = alloca i64, align 8, !DIAssignID [[DIASSIGNID23:![0-9]+]]
; CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata [[META15:![0-9]+]], metadata !DIExpression(), metadata [[DIASSIGNID23]], metadata ptr [[A_SROA_0]], metadata !DIExpression()), !dbg [[DBG24:![0-9]+]]
; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 8, ptr [[A_SROA_0]]), !dbg [[DBG25:![0-9]+]]
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @c, align 4, !dbg [[DBG26:![0-9]+]]
; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64, !dbg [[DBG26]]
Expand Down Expand Up @@ -89,3 +92,38 @@ declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata,
!27 = !DILocation(line: 7, column: 3, scope: !11)
!28 = !DILocation(line: 7, column: 18, scope: !11)
!33 = !DILocation(line: 8, column: 1, scope: !11)
;.
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
; CHECK: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
; CHECK: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
;.
; CHECK: [[DBG0]] = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
; CHECK: [[META1:![0-9]+]] = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 4, type: !6, isLocal: false, isDefinition: true)
; CHECK: [[META2:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
; CHECK: [[META3:![0-9]+]] = !DIFile(filename: "test.c", directory: "/")
; CHECK: [[META4:![0-9]+]] = !{}
; CHECK: [[META5:![0-9]+]] = !{!0}
; CHECK: [[META6:![0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
; CHECK: [[META7:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 4}
; CHECK: [[META8:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
; CHECK: [[META9:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
; CHECK: [[META10:![0-9]+]] = !{!"clang version 12.0.0"}
; CHECK: [[META11:![0-9]+]] = distinct !DISubprogram(name: "d", scope: !3, file: !3, line: 5, type: !12, scopeLine: 5, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !14)
; CHECK: [[META12:![0-9]+]] = !DISubroutineType(types: !13)
; CHECK: [[META13:![0-9]+]] = !{null}
; CHECK: [[META14:![0-9]+]] = !{!15}
; CHECK: [[META15]] = !DILocalVariable(name: "a", scope: !11, file: !3, line: 6, type: !16)
; CHECK: [[META16:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "a", file: !3, line: 1, size: 64, elements: !17)
; CHECK: [[META17:![0-9]+]] = !{!18}
; CHECK: [[META18:![0-9]+]] = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !16, file: !3, line: 2, baseType: !19, size: 64)
; CHECK: [[META19:![0-9]+]] = !DICompositeType(tag: DW_TAG_array_type, baseType: !20, size: 64, elements: !21)
; CHECK: [[META20:![0-9]+]] = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
; CHECK: [[META21:![0-9]+]] = !{!22}
; CHECK: [[META22:![0-9]+]] = !DISubrange(count: 8)
; CHECK: [[DIASSIGNID23]] = distinct !DIAssignID()
; CHECK: [[DBG24]] = !DILocation(line: 0, scope: !11)
; CHECK: [[DBG25]] = !DILocation(line: 6, column: 3, scope: !11)
; CHECK: [[DBG26]] = !DILocation(line: 7, column: 18, scope: !11)
; CHECK: [[DBG27]] = !DILocation(line: 7, column: 3, scope: !11)
; CHECK: [[DBG28]] = !DILocation(line: 8, column: 1, scope: !11)
;.
25 changes: 24 additions & 1 deletion llvm/test/DebugInfo/Generic/assignment-tracking/sroa/complex.ll
@@ -1,4 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -passes=sroa -S -o - %s -experimental-assignment-tracking | FileCheck %s
;
;; Based on llvm/test/DebugInfo/ARM/sroa-complex.ll
Expand Down Expand Up @@ -73,3 +73,26 @@ declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata,
!18 = distinct !DIAssignID()
!19 = distinct !DIAssignID()
!20 = !DILocation(line: 2, column: 36, scope: !8)
;.
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
;.
; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
; CHECK: [[META1:![0-9]+]] = !DIFile(filename: "test.c", directory: "/")
; CHECK: [[META2:![0-9]+]] = !{}
; CHECK: [[META3:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 4}
; CHECK: [[META4:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
; CHECK: [[META5:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
; CHECK: [[META6:![0-9]+]] = !{i32 1, !"min_enum_size", i32 4}
; CHECK: [[META7:![0-9]+]] = !{!"clang version 12.0.0"}
; CHECK: [[META8:![0-9]+]] = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !9, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
; CHECK: [[META9:![0-9]+]] = !DISubroutineType(types: !10)
; CHECK: [[META10:![0-9]+]] = !{null, !11}
; CHECK: [[META11:![0-9]+]] = !DIBasicType(name: "complex", size: 128, encoding: DW_ATE_complex_float)
; CHECK: [[META12:![0-9]+]] = !{!13}
; CHECK: [[META13]] = !DILocalVariable(name: "c", arg: 1, scope: !8, file: !1, line: 2, type: !11)
; CHECK: [[META14]] = distinct !DIAssignID()
; CHECK: [[DBG15]] = !DILocation(line: 0, scope: !8)
; CHECK: [[META16]] = distinct !DIAssignID()
; CHECK: [[META17]] = distinct !DIAssignID()
; CHECK: [[DBG18]] = !DILocation(line: 2, column: 36, scope: !8)
;.

0 comments on commit 4ff8d1e

Please sign in to comment.