xref: /llvm-project/llvm/test/Transforms/Attributor/value-simplify-dbg.ll (revision cd3a4c31bc9694d160de54c6a4daa53e152cb463)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-annotate-decl-cs  -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
4
5@G = internal global i32 undef, align 4, !dbg !0
6
7;.
8; CHECK: @G = internal global i32 undef, align 4, !dbg [[META0:![0-9]+]]
9;.
10define void @dest() !dbg !15 {
11; CHECK-LABEL: define {{[^@]+}}@dest
12; CHECK-SAME: () !dbg [[DBG15:![0-9]+]] {
13; CHECK-NEXT:  entry:
14; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr @G, align 4, !dbg [[DBG19:![0-9]+]]
15; CHECK-NEXT:    call void @use(i32 noundef [[TMP0]]), !dbg [[DBG20:![0-9]+]]
16; CHECK-NEXT:    ret void, !dbg [[DBG21:![0-9]+]]
17;
18entry:
19  %0 = load i32, ptr @G, align 4, !dbg !19
20  call void @use(i32 noundef %0), !dbg !20
21  ret void, !dbg !21
22}
23
24declare void @use(i32 noundef)
25
26define void @src() norecurse !dbg !22 {
27; CHECK: Function Attrs: norecurse nosync memory(write)
28; CHECK-LABEL: define {{[^@]+}}@src
29; CHECK-SAME: () #[[ATTR0:[0-9]+]] !dbg [[DBG22:![0-9]+]] {
30; CHECK-NEXT:  entry:
31; CHECK-NEXT:    [[CALL:%.*]] = call i32 @speculatable() #[[ATTR2:[0-9]+]], !dbg [[DBG23:![0-9]+]]
32; CHECK-NEXT:    [[PLUS1:%.*]] = add i32 [[CALL]], 1
33; CHECK-NEXT:    store i32 [[PLUS1]], ptr @G, align 4, !dbg [[DBG24:![0-9]+]]
34; CHECK-NEXT:    ret void, !dbg [[DBG25:![0-9]+]]
35;
36entry:
37  %call = call i32 @speculatable(), !dbg !23
38  %plus1 = add i32 %call, 1
39  store i32 %plus1, ptr @G, align 4, !dbg !24
40  ret void, !dbg !25
41}
42
43declare i32 @speculatable() speculatable readnone
44
45!llvm.dbg.cu = !{!2}
46!llvm.module.flags = !{!7, !8, !9, !10, !11, !12, !13}
47!llvm.ident = !{!14}
48
49!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
50!1 = distinct !DIGlobalVariable(name: "G", scope: !2, file: !5, line: 1, type: !6, isLocal: true, isDefinition: true)
51!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git ef94609d6ebe981767788e6877b0b3b731d425af)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
52!3 = !DIFile(filename: "/app/example.c", directory: "/app", checksumkind: CSK_MD5, checksum: "b456b90cec5c3705a028b274d88ee970")
53!4 = !{!0}
54!5 = !DIFile(filename: "example.c", directory: "/app", checksumkind: CSK_MD5, checksum: "b456b90cec5c3705a028b274d88ee970")
55!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
56!7 = !{i32 7, !"Dwarf Version", i32 5}
57!8 = !{i32 2, !"Debug Info Version", i32 3}
58!9 = !{i32 1, !"wchar_size", i32 4}
59!10 = !{i32 8, !"PIC Level", i32 2}
60!11 = !{i32 7, !"PIE Level", i32 2}
61!12 = !{i32 7, !"uwtable", i32 2}
62!13 = !{i32 7, !"frame-pointer", i32 2}
63!14 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project.git ef94609d6ebe981767788e6877b0b3b731d425af)"}
64!15 = distinct !DISubprogram(name: "dest", scope: !5, file: !5, line: 4, type: !16, scopeLine: 4, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !18)
65!16 = !DISubroutineType(types: !17)
66!17 = !{null}
67!18 = !{}
68!19 = !DILocation(line: 5, column: 9, scope: !15)
69!20 = !DILocation(line: 5, column: 5, scope: !15)
70!21 = !DILocation(line: 6, column: 1, scope: !15)
71!22 = distinct !DISubprogram(name: "src", scope: !5, file: !5, line: 9, type: !16, scopeLine: 9, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !18)
72!23 = !DILocation(line: 10, column: 9, scope: !22)
73!24 = !DILocation(line: 10, column: 7, scope: !22)
74!25 = !DILocation(line: 11, column: 1, scope: !22)
75;.
76; CHECK: attributes #[[ATTR0]] = { norecurse nosync memory(write) }
77; CHECK: attributes #[[ATTR1:[0-9]+]] = { speculatable memory(none) }
78; CHECK: attributes #[[ATTR2]] = { nosync }
79;.
80; CHECK: [[META0]] = !DIGlobalVariableExpression(var: [[META1:![0-9]+]], expr: !DIExpression())
81; CHECK: [[META1]] = distinct !DIGlobalVariable(name: "G", scope: [[META2:![0-9]+]], file: [[META5:![0-9]+]], line: 1, type: [[META6:![0-9]+]], isLocal: true, isDefinition: true)
82; CHECK: [[META2]] = distinct !DICompileUnit(language: DW_LANG_C99, file: [[META3:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: [[META4:![0-9]+]], splitDebugInlining: false, nameTableKind: None)
83; CHECK: [[META3]] = !DIFile(filename: "/app/example.c", directory: {{.*}})
84; CHECK: [[META4]] = !{[[META0]]}
85; CHECK: [[META5]] = !DIFile(filename: "example.c", directory: {{.*}})
86; CHECK: [[META6]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
87; CHECK: [[META7:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 5}
88; CHECK: [[META8:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
89; CHECK: [[META9:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
90; CHECK: [[META10:![0-9]+]] = !{i32 8, !"PIC Level", i32 2}
91; CHECK: [[META11:![0-9]+]] = !{i32 7, !"PIE Level", i32 2}
92; CHECK: [[META12:![0-9]+]] = !{i32 7, !"uwtable", i32 2}
93; CHECK: [[META13:![0-9]+]] = !{i32 7, !"frame-pointer", i32 2}
94; CHECK: [[META14:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
95; CHECK: [[DBG15]] = distinct !DISubprogram(name: "dest", scope: [[META5]], file: [[META5]], line: 4, type: [[META16:![0-9]+]], scopeLine: 4, spFlags: DISPFlagDefinition, unit: [[META2]], retainedNodes: [[META18:![0-9]+]])
96; CHECK: [[META16]] = !DISubroutineType(types: [[META17:![0-9]+]])
97; CHECK: [[META17]] = !{null}
98; CHECK: [[META18]] = !{}
99; CHECK: [[DBG19]] = !DILocation(line: 5, column: 9, scope: [[DBG15]])
100; CHECK: [[DBG20]] = !DILocation(line: 5, column: 5, scope: [[DBG15]])
101; CHECK: [[DBG21]] = !DILocation(line: 6, column: 1, scope: [[DBG15]])
102; CHECK: [[DBG22]] = distinct !DISubprogram(name: "src", scope: [[META5]], file: [[META5]], line: 9, type: [[META16]], scopeLine: 9, spFlags: DISPFlagDefinition, unit: [[META2]], retainedNodes: [[META18]])
103; CHECK: [[DBG23]] = !DILocation(line: 10, column: 9, scope: [[DBG22]])
104; CHECK: [[DBG24]] = !DILocation(line: 10, column: 7, scope: [[DBG22]])
105; CHECK: [[DBG25]] = !DILocation(line: 11, column: 1, scope: [[DBG22]])
106;.
107;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
108; CGSCC: {{.*}}
109; TUNIT: {{.*}}
110