xref: /llvm-project/llvm/test/Transforms/SCCP/pr50901.ll (revision 66cf995da76b9da3cfdee2f29eff6ea4d84305ef)
1; RUN: opt -passes=ipsccp -S -o - < %s | FileCheck %s
2
3; Global variables g_11, g_22, g_33, g_44, g_55, g_66 and g_77
4; are not visible in the debugger.
5
6;  1	int       g_1 = -4;
7;  2	float     g_2 = 4.44;
8;  3	char      g_3 = 'a';
9;  4	unsigned  g_4 = 4;
10;  5	bool      g_5 = true;
11;  6	int      *g_6 = nullptr;
12;  7	float    *g_7 = nullptr;
13;  8
14;  9	static int       g_11 = -5;
15; 10	static float     g_22 = 5.55;
16; 11	static char      g_33 = 'b';
17; 12	static unsigned  g_44 = 5;
18; 13	static bool      g_55 = true;
19; 14	static int      *g_66 = nullptr;
20; 15	static float    *g_77 = (float *)(55 + 15);
21; 16
22; 17	void bar() {
23; 18	  g_1 = g_11;
24; 19	  g_2 = g_22;
25; 20	  g_3 = g_33;
26; 21	  g_4 = g_44;
27; 22	  g_5 = g_55;
28; 23	  g_6 = g_66;
29; 24	  g_7 = g_77;
30; 25	}
31; 26
32; 27	int main() {
33; 28	  {
34; 29	    bar();
35; 30	  }
36; 31	}
37
38; CHECK: ![[G1:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG1:[0-9]+]], expr: !DIExpression(DW_OP_constu, 18446744073709551611, DW_OP_stack_value))
39; CHECK-DAG: ![[DBG1]] = distinct !DIGlobalVariable(name: "g_11", {{.*}}
40; CHECK: ![[G2:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG2:[0-9]+]], expr: !DIExpression(DW_OP_constu, 1085381018, DW_OP_stack_value))
41; CHECK-DAG: ![[DBG2]] = distinct !DIGlobalVariable(name: "g_22", {{.*}}
42; CHECK: ![[G3:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG3:[0-9]+]], expr: !DIExpression(DW_OP_constu, 98, DW_OP_stack_value))
43; CHECK-DAG: ![[DBG3]] = distinct !DIGlobalVariable(name: "g_33", {{.*}}
44; CHECK: ![[G4:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG4:[0-9]+]], expr: !DIExpression(DW_OP_constu, 5, DW_OP_stack_value))
45; CHECK-DAG: ![[DBG4]] = distinct !DIGlobalVariable(name: "g_44", {{.*}}
46; CHECK: ![[G5:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG5:[0-9]+]], expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value))
47; CHECK-DAG: ![[DBG5]] = distinct !DIGlobalVariable(name: "g_55", {{.*}}
48; CHECK: ![[G6:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG6:[0-9]+]], expr: !DIExpression(DW_OP_constu, 0, DW_OP_stack_value))
49; CHECK-DAG: ![[DBG6]] = distinct !DIGlobalVariable(name: "g_66", {{.*}}
50; CHECK: ![[G7:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG7:[0-9]+]], expr: !DIExpression(DW_OP_constu, 70, DW_OP_stack_value))
51; CHECK-DAG: ![[DBG7]] = distinct !DIGlobalVariable(name: "g_77", {{.*}}
52; CHECK:     = !DIGlobalVariableExpression(var: ![[DBG_FLOAT_UNDEF:.+]], expr: !DIExpression())
53; CHECK-DAG: ![[DBG_FLOAT_UNDEF]]  = distinct !DIGlobalVariable(name: "g_float_undef"
54
55; CHECK: ![[G8:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG8:[0-9]+]], expr: !DIExpression(DW_OP_constu, 22136, DW_OP_stack_value))
56; CHECK-DAG: ![[DBG8]] = distinct !DIGlobalVariable(name: "g_88", {{.*}}
57; CHECK: ![[G9:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG9:[0-9]+]], expr: !DIExpression(DW_OP_constu, 23726, DW_OP_stack_value))
58; CHECK-DAG: ![[DBG9]] = distinct !DIGlobalVariable(name: "g_99", {{.*}}
59
60; CHECK-DAG: ![[DBGA:[0-9]+]] = distinct !DIGlobalVariable(name: "g_i32_undef"
61; CHECK-DAG: ![[GA:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBGA]], expr: !DIExpression())
62; CHECK-DAG: ![[DBGB:[0-9]+]] = distinct !DIGlobalVariable(name: "g_ptr_undef"
63; CHECK-DAG: ![[GB:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBGB]], expr: !DIExpression())
64
65@g_1 = dso_local global i32 -4, align 4, !dbg !0
66@g_2 = dso_local global float 0x4011C28F60000000, align 4, !dbg !8
67@g_3 = dso_local global i8 97, align 1, !dbg !10
68@g_4 = dso_local global i32 4, align 4, !dbg !13
69@g_5 = dso_local global i8 1, align 1, !dbg !16
70@g_6 = dso_local global ptr null, align 8, !dbg !19
71@g_7 = dso_local global ptr null, align 8, !dbg !23
72@g_8 = dso_local global half 0xH4321, align 4, !dbg !86
73@g_9 = dso_local global bfloat 0xR3F80, align 4, !dbg !90
74@_ZL4g_11 = internal global i32 -5, align 4, !dbg !25
75@_ZL4g_22 = internal global float 0x4016333340000000, align 4, !dbg !27
76@_ZL4g_33 = internal global i8 98, align 1, !dbg !29
77@_ZL4g_44 = internal global i32 5, align 4, !dbg !31
78@_ZL4g_55 = internal global i8 1, align 1, !dbg !33
79@_ZL4g_66 = internal global ptr null, align 8, !dbg !35
80@_ZL4g_77 = internal global ptr inttoptr (i64 70 to ptr), align 8, !dbg !37
81@g_float_undef = internal global float undef, align 4, !dbg !83
82@_ZL4g_88 = internal global half 0xH5678, align 4, !dbg !88
83@_ZL4g_99 = internal global bfloat 0xR5CAE, align 4, !dbg !92
84@g_i32_undef = internal global i32 undef, align 4, !dbg !95
85@g_ptr_undef = internal global ptr undef, align 8, !dbg !97
86
87define dso_local void @_Z3barv() !dbg !46 {
88entry:
89  %0 = load i32, ptr @_ZL4g_11, align 4, !dbg !59
90  store i32 %0, ptr @g_1, align 4, !dbg !59
91  %1 = load float, ptr @_ZL4g_22, align 4, !dbg !59
92  store float %1, ptr @g_2, align 4, !dbg !59
93  %2 = load i8, ptr @_ZL4g_33, align 1, !dbg !59
94  store i8 %2, ptr @g_3, align 1, !dbg !59
95  %3 = load i32, ptr @_ZL4g_44, align 4, !dbg !59
96  store i32 %3, ptr @g_4, align 4, !dbg !59
97  %4 = load i8, ptr @_ZL4g_55, align 1, !dbg !59
98  %tobool = trunc i8 %4 to i1, !dbg !59
99  %frombool = zext i1 %tobool to i8, !dbg !59
100  store i8 %frombool, ptr @g_5, align 1, !dbg !59
101  %5 = load ptr, ptr @_ZL4g_66, align 8, !dbg !59
102  store ptr %5, ptr @g_6, align 8, !dbg !59
103  %6 = load ptr, ptr @_ZL4g_77, align 8, !dbg !59
104  store ptr %6, ptr @g_7, align 8, !dbg !59
105  %l = load float, ptr @g_float_undef, align 8, !dbg !59
106  store float %l, ptr @g_2, align 8, !dbg !59
107  %7 = load half, ptr @_ZL4g_88, align 4, !dbg !59
108  store half %7, ptr @g_8, align 4, !dbg !59
109  %8 = load bfloat, ptr @_ZL4g_99, align 4, !dbg !59
110  store bfloat %8, ptr @g_9, align 4, !dbg !59
111  %9 = load i32, ptr @g_i32_undef, align 4, !dbg !59
112  store i32 %9, ptr @g_1, align 4, !dbg !59
113  %10 = load ptr, ptr @g_ptr_undef, align 8, !dbg !59
114  store ptr %10, ptr @g_6, align 8, !dbg !59
115
116  ret void, !dbg !59
117}
118
119define dso_local noundef i32 @main() !dbg !77 {
120entry:
121  call void @_Z3barv(), !dbg !80
122  ret i32 0, !dbg !82
123}
124
125!llvm.dbg.cu = !{!2}
126!llvm.module.flags = !{!39, !40, !41, !42, !43, !44}
127!llvm.ident = !{!45}
128
129!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
130!1 = distinct !DIGlobalVariable(name: "g_1", scope: !2, file: !3, line: 1, type: !22, isLocal: false, isDefinition: true)
131!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 18.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, globals: !7, splitDebugInlining: false, nameTableKind: None)
132!3 = !DIFile(filename: "test.cpp", directory: "")
133!4 = !{!5}
134!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)
135!6 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
136!7 = !{!0, !8, !10, !13, !16, !19, !23, !25, !27, !29, !31, !33, !35, !37, !83, !86, !88, !90, !92, !95, !97}
137!8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression())
138!9 = distinct !DIGlobalVariable(name: "g_2", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)
139!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
140!11 = distinct !DIGlobalVariable(name: "g_3", scope: !2, file: !3, line: 3, type: !12, isLocal: false, isDefinition: true)
141!12 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
142!13 = !DIGlobalVariableExpression(var: !14, expr: !DIExpression())
143!14 = distinct !DIGlobalVariable(name: "g_4", scope: !2, file: !3, line: 4, type: !15, isLocal: false, isDefinition: true)
144!15 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
145!16 = !DIGlobalVariableExpression(var: !17, expr: !DIExpression())
146!17 = distinct !DIGlobalVariable(name: "g_5", scope: !2, file: !3, line: 5, type: !18, isLocal: false, isDefinition: true)
147!18 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)
148!19 = !DIGlobalVariableExpression(var: !20, expr: !DIExpression())
149!20 = distinct !DIGlobalVariable(name: "g_6", scope: !2, file: !3, line: 6, type: !21, isLocal: false, isDefinition: true)
150!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 64)
151!22 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
152!23 = !DIGlobalVariableExpression(var: !24, expr: !DIExpression())
153!24 = distinct !DIGlobalVariable(name: "g_7", scope: !2, file: !3, line: 7, type: !5, isLocal: false, isDefinition: true)
154!25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression())
155!26 = distinct !DIGlobalVariable(name: "g_11", linkageName: "_ZL4g_11", scope: !2, file: !3, line: 9, type: !22, isLocal: true, isDefinition: true)
156!27 = !DIGlobalVariableExpression(var: !28, expr: !DIExpression())
157!28 = distinct !DIGlobalVariable(name: "g_22", linkageName: "_ZL4g_22", scope: !2, file: !3, line: 10, type: !6, isLocal: true, isDefinition: true)
158!29 = !DIGlobalVariableExpression(var: !30, expr: !DIExpression())
159!30 = distinct !DIGlobalVariable(name: "g_33", linkageName: "_ZL4g_33", scope: !2, file: !3, line: 11, type: !12, isLocal: true, isDefinition: true)
160!31 = !DIGlobalVariableExpression(var: !32, expr: !DIExpression())
161!32 = distinct !DIGlobalVariable(name: "g_44", linkageName: "_ZL4g_44", scope: !2, file: !3, line: 12, type: !15, isLocal: true, isDefinition: true)
162!33 = !DIGlobalVariableExpression(var: !34, expr: !DIExpression())
163!34 = distinct !DIGlobalVariable(name: "g_55", linkageName: "_ZL4g_55", scope: !2, file: !3, line: 13, type: !18, isLocal: true, isDefinition: true)
164!35 = !DIGlobalVariableExpression(var: !36, expr: !DIExpression())
165!36 = distinct !DIGlobalVariable(name: "g_66", linkageName: "_ZL4g_66", scope: !2, file: !3, line: 14, type: !21, isLocal: true, isDefinition: true)
166!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression())
167!38 = distinct !DIGlobalVariable(name: "g_77", linkageName: "_ZL4g_77", scope: !2, file: !3, line: 15, type: !5, isLocal: true, isDefinition: true)
168!39 = !{i32 7, !"Dwarf Version", i32 5}
169!40 = !{i32 2, !"Debug Info Version", i32 3}
170!41 = !{i32 1, !"wchar_size", i32 4}
171!42 = !{i32 8, !"PIC Level", i32 2}
172!43 = !{i32 7, !"PIE Level", i32 2}
173!44 = !{i32 7, !"uwtable", i32 2}
174!45 = !{!"clang version 18.0.0"}
175!46 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !3, file: !3, line: 17, type: !47, scopeLine: 17, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)
176!47 = !DISubroutineType(types: !48)
177!48 = !{null}
178!59 = !DILocation(line: 20, column: 9, scope: !46)
179!77 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 27, type: !78, scopeLine: 27, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)
180!78 = !DISubroutineType(types: !79)
181!79 = !{!22}
182!80 = !DILocation(line: 29, column: 5, scope: !81)
183!81 = distinct !DILexicalBlock(scope: !77, file: !3, line: 28, column: 3)
184!82 = !DILocation(line: 31, column: 1, scope: !77)
185!83 = !DIGlobalVariableExpression(var: !84, expr: !DIExpression())
186!84 = distinct !DIGlobalVariable(name: "g_float_undef", linkageName: "g_float_undef", scope: !2, file: !3, line: 15, type: !6, isLocal: true, isDefinition: true)
187!85 = !DIBasicType(name: "float", size: 16, encoding: DW_ATE_float)
188!86 = !DIGlobalVariableExpression(var: !87, expr: !DIExpression())
189!87 = distinct !DIGlobalVariable(name: "g_8", scope: !2, file: !3, line: 2, type: !85, isLocal: false, isDefinition: true)
190!88 = !DIGlobalVariableExpression(var: !89, expr: !DIExpression())
191!89 = distinct !DIGlobalVariable(name: "g_88", linkageName: "_ZL4g_88", scope: !2, file: !3, line: 10, type: !85, isLocal: true, isDefinition: true)
192!90 = !DIGlobalVariableExpression(var: !91, expr: !DIExpression())
193!91 = distinct !DIGlobalVariable(name: "g_9", scope: !2, file: !3, line: 2, type: !85, isLocal: false, isDefinition: true)
194!92 = !DIGlobalVariableExpression(var: !93, expr: !DIExpression())
195!93 = distinct !DIGlobalVariable(name: "g_99", linkageName: "_ZL4g_99", scope: !2, file: !3, line: 10, type: !85, isLocal: true, isDefinition: true)
196
197!95 = !DIGlobalVariableExpression(var: !96, expr: !DIExpression())
198!96 = distinct !DIGlobalVariable(name: "g_i32_undef", linkageName: "g_i32_undef", scope: !2, file: !3, line: 9, type: !22, isLocal: true, isDefinition: true)
199!97 = !DIGlobalVariableExpression(var: !98, expr: !DIExpression())
200!98 = distinct !DIGlobalVariable(name: "g_ptr_undef", linkageName: "g_ptr_undef", scope: !2, file: !3, line: 14, type: !21, isLocal: true, isDefinition: true)
201