[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / llvm / test / DebugInfo / assignment-tracking / X86 / single-memory-location.ll
bloba9cc55dbe84747c35da87c9b761665e6529049d2
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 (variable 'local').
11 ;; The variable 'local2' is tracked using a dbg.declare. Check the variable is
12 ;; dropped and doesn't cause a crash when the address is an empty metadata
13 ;; tuple and assignment tracking is enabled for the function.
15 ;; $ cat test.cpp
16 ;; void maybe_writes(int*);
17 ;; void ext(int, int, int, int, int, int, int, int, int, int);
18 ;; int example() {
19 ;;    int local;
20 ;;    maybe_writes(&local);
21 ;;    ext(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
22 ;;    return local;
23 ;; }
24 ;; $ clang++ -O2 -g -emit-llvm -S -c -Xclang -fexperimental-assignment-tracking
26 ; CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "local",
27 ; CHECK: stack:
28 ; CHECK-NEXT: - { id: 0, name: local, type: default, offset: 0, size: 4, alignment: 4,
29 ; CHECK-NEXT:     stack-id: default, callee-saved-register: '', callee-saved-restored: true,
30 ; CHECK-NEXT:     debug-info-variable: '![[VAR]]', debug-info-expression: '!DIExpression()',
31 ; CHECK-NEXT:     debug-info-location: '!{{.+}}' }
32 ; CHECK-NEXT: - { id: 1, name: local2, type: default, offset: 0, size: 4, alignment: 4,
33 ; CHECK-NEXT:     stack-id: default, callee-saved-register: '', callee-saved-restored: true,
34 ; CHECK-NEXT:     debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
36 source_filename = "test.cpp"
37 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
38 target triple = "x86_64-unknown-linux-gnu"
40 define dso_local i32 @_Z7examplev() local_unnamed_addr !dbg !7 {
41 entry:
42   %local = alloca i32, align 4, !DIAssignID !13
43   call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !13, metadata ptr %local, metadata !DIExpression()), !dbg !14
44   %local2 = alloca i32, align 4
45   call void @llvm.dbg.declare(metadata !2, metadata !32, metadata !DIExpression()), !dbg !14
46   %0 = bitcast ptr %local to ptr, !dbg !15
47   call void @llvm.lifetime.start.p0i8(i64 4, ptr nonnull %0), !dbg !15
48   call void @_Z12maybe_writesPi(ptr nonnull %local), !dbg !16
49   call void @_Z3extiiiiiiiiii(i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9), !dbg !17
50   %1 = load i32, ptr %local, align 4, !dbg !18
51   call void @llvm.lifetime.end.p0i8(i64 4, ptr nonnull %0), !dbg !23
52   ret i32 %1, !dbg !24
55 declare !dbg !25 dso_local void @_Z12maybe_writesPi(ptr) local_unnamed_addr
56 declare !dbg !29 dso_local void @_Z3extiiiiiiiiii(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) local_unnamed_addr
57 declare void @llvm.lifetime.start.p0i8(i64 immarg, ptr nocapture)
58 declare void @llvm.lifetime.end.p0i8(i64 immarg, ptr nocapture)
59 declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
60 declare void @llvm.dbg.declare(metadata, metadata, metadata)
62 !llvm.dbg.cu = !{!0}
63 !llvm.module.flags = !{!3, !4, !5, !1000}
64 !llvm.ident = !{!6}
66 !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)
67 !1 = !DIFile(filename: "test.cpp", directory: "/")
68 !2 = !{}
69 !3 = !{i32 7, !"Dwarf Version", i32 4}
70 !4 = !{i32 2, !"Debug Info Version", i32 3}
71 !5 = !{i32 1, !"wchar_size", i32 4}
72 !6 = !{!"clang version 12.0.0"}
73 !7 = distinct !DISubprogram(name: "example", linkageName: "_Z7examplev", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
74 !8 = !DISubroutineType(types: !9)
75 !9 = !{!10}
76 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
77 !11 = !{!12}
78 !12 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 4, type: !10)
79 !13 = distinct !DIAssignID()
80 !14 = !DILocation(line: 0, scope: !7)
81 !15 = !DILocation(line: 4, column: 4, scope: !7)
82 !16 = !DILocation(line: 5, column: 4, scope: !7)
83 !17 = !DILocation(line: 6, column: 4, scope: !7)
84 !18 = !DILocation(line: 7, column: 11, scope: !7)
85 !23 = !DILocation(line: 8, column: 1, scope: !7)
86 !24 = !DILocation(line: 7, column: 4, scope: !7)
87 !25 = !DISubprogram(name: "maybe_writes", linkageName: "_Z12maybe_writesPi", scope: !1, file: !1, line: 1, type: !26, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
88 !26 = !DISubroutineType(types: !27)
89 !27 = !{null, !28}
90 !28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
91 !29 = !DISubprogram(name: "ext", linkageName: "_Z3extiiiiiiiiii", scope: !1, file: !1, line: 2, type: !30, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
92 !30 = !DISubroutineType(types: !31)
93 !31 = !{null, !10, !10, !10, !10, !10, !10, !10, !10, !10, !10}
94 !32 = !DILocalVariable(name: "local2", scope: !7, file: !1, line: 4, type: !10)
95 !1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}