Revert "Warn when unique objects might be duplicated in shared libraries (#117622)"
[llvm-project.git] / llvm / test / DebugInfo / assignment-tracking / X86 / single-memory-location-2.ll
blobd68fb16a4f9637b3376ad5263e504cf2db9e73cb
1 ; RUN: llc -stop-after=finalize-isel %s -o - \
2 ; RUN: | FileCheck %s
5 ; RUN: llc --try-experimental-debuginfo-iterators -stop-after=finalize-isel %s -o - \
6 ; RUN: | FileCheck %s
8 ;; Check that a dbg.assign for a fully stack-homed variable causes the variable
9 ;; location to appear in the Machine Function side table. Similar to
10 ;; single-memory-location.ll except this has slightly more complicated input
11 ;; (there's a loop and an assignment).
13 ;; $ cat test.cpp
14 ;; int get();
15 ;; void esc(int*);
16 ;; void doSomething(int);
17 ;; void fun() {
18 ;;   int local;
19 ;;   esc(&local);
20 ;;   while (local) {
21 ;;     local = get();
22 ;;     doSomething(local);
23 ;;     esc(&local);    
24 ;;   }
25 ;; }
26 ;; $ clang++ -O2 -g -emit-llvm -S -c -Xclang -fexperimental-assignment-tracking
28 ; CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "local",
29 ; CHECK: stack:
30 ; CHECK-NEXT: - { id: 0, name: local, type: default, offset: 0, size: 4, alignment: 4, 
31 ; CHECK-NEXT:     stack-id: default, callee-saved-register: '', callee-saved-restored: true, 
32 ; CHECK-NEXT:     debug-info-variable: '![[VAR]]', debug-info-expression: '!DIExpression()', 
33 ; CHECK-NEXT:     debug-info-location: '!{{.+}}' }
35 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
36 target triple = "x86_64-unknown-linux-gnu"
38 ; Function Attrs: uwtable mustprogress
39 define dso_local void @_Z3funv() local_unnamed_addr #0 !dbg !7 {
40 entry:
41   %local = alloca i32, align 4, !DIAssignID !13
42   call void @llvm.dbg.assign(metadata i1 undef, metadata !11, metadata !DIExpression(), metadata !13, metadata ptr %local, metadata !DIExpression()), !dbg !14
43   %0 = bitcast ptr %local to ptr, !dbg !15
44   call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0) #4, !dbg !15
45   call void @_Z3escPi(ptr nonnull %local), !dbg !16
46   %1 = load i32, ptr %local, align 4, !dbg !17
47   %tobool.not1 = icmp eq i32 %1, 0, !dbg !17
48   br i1 %tobool.not1, label %while.end, label %while.body, !dbg !22
50 while.body:                                       ; preds = %entry, %while.body
51   %call = call i32 @_Z3getv(), !dbg !23
52   store i32 %call, ptr %local, align 4, !dbg !25, !DIAssignID !26
53   call void @llvm.dbg.assign(metadata i32 %call, metadata !11, metadata !DIExpression(), metadata !26, metadata ptr %local, metadata !DIExpression()), !dbg !14
54   call void @_Z11doSomethingi(i32 %call), !dbg !27
55   call void @_Z3escPi(ptr nonnull %local), !dbg !28
56   %2 = load i32, ptr %local, align 4, !dbg !17
57   %tobool.not = icmp eq i32 %2, 0, !dbg !17
58   br i1 %tobool.not, label %while.end, label %while.body, !dbg !22, !llvm.loop !29
60 while.end:                                        ; preds = %while.body, %entry
61   call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0) #4, !dbg !32
62   ret void, !dbg !32
65 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
66 declare !dbg !33 dso_local void @_Z3escPi(ptr) local_unnamed_addr
67 declare !dbg !37 dso_local i32 @_Z3getv() local_unnamed_addr
68 declare !dbg !40 dso_local void @_Z11doSomethingi(i32) local_unnamed_addr
69 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
70 declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
72 !llvm.dbg.cu = !{!0}
73 !llvm.module.flags = !{!3, !4, !5, !1000}
74 !llvm.ident = !{!6}
76 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
77 !1 = !DIFile(filename: "test.cpp", directory: "/")
78 !2 = !{}
79 !3 = !{i32 7, !"Dwarf Version", i32 4}
80 !4 = !{i32 2, !"Debug Info Version", i32 3}
81 !5 = !{i32 1, !"wchar_size", i32 4}
82 !6 = !{!"clang version 12.0.0"}
83 !7 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 4, type: !8, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
84 !8 = !DISubroutineType(types: !9)
85 !9 = !{null}
86 !10 = !{!11}
87 !11 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 5, type: !12)
88 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
89 !13 = distinct !DIAssignID()
90 !14 = !DILocation(line: 0, scope: !7)
91 !15 = !DILocation(line: 5, column: 3, scope: !7)
92 !16 = !DILocation(line: 6, column: 3, scope: !7)
93 !17 = !DILocation(line: 7, column: 10, scope: !7)
94 !22 = !DILocation(line: 7, column: 3, scope: !7)
95 !23 = !DILocation(line: 8, column: 13, scope: !24)
96 !24 = distinct !DILexicalBlock(scope: !7, file: !1, line: 7, column: 17)
97 !25 = !DILocation(line: 8, column: 11, scope: !24)
98 !26 = distinct !DIAssignID()
99 !27 = !DILocation(line: 9, column: 5, scope: !24)
100 !28 = !DILocation(line: 10, column: 5, scope: !24)
101 !29 = distinct !{!29, !22, !30, !31}
102 !30 = !DILocation(line: 11, column: 3, scope: !7)
103 !31 = !{!"llvm.loop.mustprogress"}
104 !32 = !DILocation(line: 12, column: 1, scope: !7)
105 !33 = !DISubprogram(name: "esc", linkageName: "_Z3escPi", scope: !1, file: !1, line: 2, type: !34, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
106 !34 = !DISubroutineType(types: !35)
107 !35 = !{null, !36}
108 !36 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
109 !37 = !DISubprogram(name: "get", linkageName: "_Z3getv", scope: !1, file: !1, line: 1, type: !38, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
110 !38 = !DISubroutineType(types: !39)
111 !39 = !{!12}
112 !40 = !DISubprogram(name: "doSomething", linkageName: "_Z11doSomethingi", scope: !1, file: !1, line: 3, type: !41, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
113 !41 = !DISubroutineType(types: !42)
114 !42 = !{null, !12}
115 !1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}