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