1; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s
2; RUN: llc < %s | llvm-mc -filetype=obj --triple=x86_64-windows | llvm-readobj - --codeview | FileCheck %s
3; RUN: llc < %s | FileCheck %s --check-prefix=ASM
4
5; C++ source to regenerate:
6; $ cat numeric-leaves.cpp
7; const long long Minus1 = -1;
8; const long long Minus128 = -128;
9; const long long Minus129 = -129;
10; const long long Minus32768 = -32768;
11; const long long Minus32769 = -32769;
12; const long long Minus2147483648 = -2147483648;
13; const long long Minus2147483649 = -2147483649;
14;
15; const long long Zero = 0;
16; const long long Plus32767 = 32767;
17; const long long Plus32768 = 32768;
18; const long long Plus2147483647 = 2147483647;
19; const long long Plus2147483648 = 2147483648;
20;
21; int main(){
22;   long long iDebug1 = Minus1 + Minus128 + Minus129 +
23;                       Minus32768 + Minus32769 +
24;                       Minus2147483648 + Minus2147483649;
25;   long long iDebug2 = Zero + Plus32767 + Plus32768 +
26;                       Plus2147483647 + Plus2147483648;
27;
28;   return 0;
29;}
30;
31; $ clang numeric-leaves.cpp -S -emit-llvm -g -gcodeview -o nl.ll
32
33; CHECK:         ConstantSym {
34; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
35; CHECK-NEXT:      Type: const __int64 (0x1003)
36; CHECK-NEXT:      Value: -1
37; CHECK-NEXT:      Name: Minus1
38; CHECK-NEXT:    }
39; CHECK:         ConstantSym {
40; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
41; CHECK-NEXT:      Type: const __int64 (0x1003)
42; CHECK-NEXT:      Value: -128
43; CHECK-NEXT:      Name: Minus128
44; CHECK-NEXT:    }
45; CHECK:         ConstantSym {
46; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
47; CHECK-NEXT:      Type: const __int64 (0x1003)
48; CHECK-NEXT:      Value: -129
49; CHECK-NEXT:      Name: Minus129
50; CHECK-NEXT:    }
51; CHECK:         ConstantSym {
52; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
53; CHECK-NEXT:      Type: const __int64 (0x1003)
54; CHECK-NEXT:      Value: -32768
55; CHECK-NEXT:      Name: Minus32768
56; CHECK-NEXT:    }
57; CHECK:         ConstantSym {
58; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
59; CHECK-NEXT:      Type: const __int64 (0x1003)
60; CHECK-NEXT:      Value: -32769
61; CHECK-NEXT:      Name: Minus32769
62; CHECK-NEXT:    }
63; CHECK:         ConstantSym {
64; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
65; CHECK-NEXT:      Type: const __int64 (0x1003)
66; CHECK-NEXT:      Value: -2147483648
67; CHECK-NEXT:      Name: Minus2147483648
68; CHECK-NEXT:    }
69; CHECK:         ConstantSym {
70; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
71; CHECK-NEXT:      Type: const __int64 (0x1003)
72; CHECK-NEXT:      Value: -2147483649
73; CHECK-NEXT:      Name: Minus2147483649
74; CHECK-NEXT:    }
75; CHECK:         ConstantSym {
76; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
77; CHECK-NEXT:      Type: const __int64 (0x1003)
78; CHECK-NEXT:      Value: 0
79; CHECK-NEXT:      Name: Zero
80; CHECK-NEXT:    }
81; CHECK:         ConstantSym {
82; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
83; CHECK-NEXT:      Type: const __int64 (0x1003)
84; CHECK-NEXT:      Value: 32767
85; CHECK-NEXT:      Name: Plus32767
86; CHECK-NEXT:    }
87; CHECK:         ConstantSym {
88; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
89; CHECK-NEXT:      Type: const __int64 (0x1003)
90; CHECK-NEXT:      Value: 32768
91; CHECK-NEXT:      Name: Plus32768
92; CHECK-NEXT:    }
93; CHECK:         ConstantSym {
94; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
95; CHECK-NEXT:      Type: const __int64 (0x1003)
96; CHECK-NEXT:      Value: 2147483647
97; CHECK-NEXT:      Name: Plus2147483647
98; CHECK-NEXT:    }
99; CHECK:         ConstantSym {
100; CHECK-NEXT:      Kind: S_CONSTANT (0x1107)
101; CHECK-NEXT:      Type: const __int64 (0x1003)
102; CHECK-NEXT:      Value: 2147483648
103; CHECK-NEXT:      Name: Plus2147483648
104
105; ASM-LABEL:    long     241                       # Symbol subsection for globals
106
107; ASM:          .short   4359                      # Record kind: S_CONSTANT
108; ASM-NEXT:     .long    4099                      # Type
109; ASM-NEXT:     .byte    0x00, 0x80, 0xff          # Value
110; ASM-NEXT:     .asciz   "Minus1"                  # Name
111
112; ASM:          .short   4359                      # Record kind: S_CONSTANT
113; ASM-NEXT:     .long    4099                      # Type
114; ASM-NEXT:     .byte    0x00, 0x80, 0x80          # Value
115; ASM-NEXT:     .asciz   "Minus128"                # Name
116
117; ASM:          .short   4359                      # Record kind: S_CONSTANT
118; ASM-NEXT:     .long    4099                      # Type
119; ASM-NEXT:     .byte    0x01, 0x80, 0x7f, 0xff    # Value
120; ASM-NEXT:     .asciz   "Minus129"                # Name
121
122; ASM:          .short   4359                      # Record kind: S_CONSTANT
123; ASM-NEXT:     .long    4099                      # Type
124; ASM-NEXT:     .byte    0x01, 0x80, 0x00, 0x80    # Value
125; ASM-NEXT:     .asciz   "Minus32768"              # Name
126
127; ASM:          .short   4359                      # Record kind: S_CONSTANT
128; ASM-NEXT:     .long    4099                      # Type
129; ASM-NEXT:     .byte    0x03, 0x80, 0xff, 0x7f    # Value
130; ASM-NEXT:     .byte    0xff, 0xff
131; ASM-NEXT:     .asciz   "Minus32769"              # Name
132
133; ASM:          .short   4359                      # Record kind: S_CONSTANT
134; ASM-NEXT:     .long    4099                      # Type
135; ASM-NEXT:     .byte    0x03, 0x80, 0x00, 0x00    # Value
136; ASM-NEXT:     .byte    0x00, 0x80
137; ASM-NEXT:     .asciz   "Minus2147483648"         # Name
138
139; ASM:          .short   4359                      # Record kind: S_CONSTANT
140; ASM-NEXT:     .long    4099                      # Type
141; ASM-NEXT:     .byte    0x09, 0x80, 0xff, 0xff    # Value
142; ASM-NEXT:     .byte    0xff, 0x7f, 0xff, 0xff
143; ASM-NEXT:     .byte    0xff, 0xff
144; ASM-NEXT:     .asciz   "Minus2147483649"         # Name
145
146; ASM:          .short   4359                      # Record kind: S_CONSTANT
147; ASM-NEXT:     .long    4099                      # Type
148; ASM-NEXT:     .byte    0x00, 0x00                # Value
149; ASM-NEXT:     .asciz   "Zero"                    # Name
150
151; ASM:          .short   4359                      # Record kind: S_CONSTANT
152; ASM-NEXT:     .long    4099                      # Type
153; ASM-NEXT:     .byte    0xff, 0x7f                # Value
154; ASM-NEXT:     .asciz   "Plus32767"               # Name
155
156; ASM:          .short   4359                      # Record kind: S_CONSTANT
157; ASM-NEXT:     .long    4099                      # Type
158; ASM-NEXT:     .byte    0x03, 0x80, 0x00, 0x80    # Value
159; ASM-NEXT:     .byte    0x00, 0x00
160; ASM-NEXT:     .asciz   "Plus32768"               # Name
161
162; ASM:          .short   4359                      # Record kind: S_CONSTANT
163; ASM-NEXT:     .long    4099                      # Type
164; ASM-NEXT:     .byte    0x03, 0x80, 0xff, 0xff    # Value
165; ASM-NEXT:     .byte    0xff, 0x7f
166; ASM-NEXT:     .asciz   "Plus2147483647"          # Name
167
168; ASM:          .short   4359                      # Record kind: S_CONSTANT
169; ASM-NEXT:     .long    4099                      # Type
170; ASM-NEXT:     .byte    0x09, 0x80, 0x00, 0x00    # Value
171; ASM-NEXT:     .byte    0x00, 0x80, 0x00, 0x00
172; ASM-NEXT:     .byte    0x00, 0x00
173; ASM-NEXT:     .asciz   "Plus2147483648"          # Name
174
175; ModuleID = 'numeric-leaves.cpp'
176source_filename = "numeric-leaves.cpp"
177target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
178target triple = "x86_64-pc-windows-msvc19.29.30133"
179
180; Function Attrs: mustprogress noinline norecurse nounwind optnone uwtable
181define dso_local noundef i32 @main() #0 !dbg !35 {
182entry:
183  %retval = alloca i32, align 4
184  %iDebug1 = alloca i64, align 8
185  %iDebug2 = alloca i64, align 8
186  store i32 0, i32* %retval, align 4
187  call void @llvm.dbg.declare(metadata i64* %iDebug1, metadata !40, metadata !DIExpression()), !dbg !41
188  store i64 -4295033092, i64* %iDebug1, align 8, !dbg !41
189  call void @llvm.dbg.declare(metadata i64* %iDebug2, metadata !42, metadata !DIExpression()), !dbg !43
190  store i64 4295032830, i64* %iDebug2, align 8, !dbg !43
191  ret i32 0, !dbg !44
192}
193
194; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
195declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
196
197attributes #0 = { mustprogress noinline norecurse nounwind optnone uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
198attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
199
200!llvm.dbg.cu = !{!0}
201!llvm.module.flags = !{!29, !30, !31, !32, !33}
202!llvm.ident = !{!34}
203
204!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !2, splitDebugInlining: false, nameTableKind: None)
205!1 = !DIFile(filename: "numeric-leaves.cpp", directory: "d:\\tmp", checksumkind: CSK_MD5, checksum: "9b1d86040d3b979a9b2b3e86c7bea0b4")
206!2 = !{!3, !7, !9, !11, !13, !15, !17, !19, !21, !23, !25, !27}
207!3 = !DIGlobalVariableExpression(var: !4, expr: !DIExpression(DW_OP_constu, 18446744073709551615, DW_OP_stack_value))
208!4 = distinct !DIGlobalVariable(name: "Minus1", scope: !0, file: !1, line: 1, type: !5, isLocal: true, isDefinition: true)
209!5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6)
210!6 = !DIBasicType(name: "long long", size: 64, encoding: DW_ATE_signed)
211!7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression(DW_OP_constu, 18446744073709551488, DW_OP_stack_value))
212!8 = distinct !DIGlobalVariable(name: "Minus128", scope: !0, file: !1, line: 2, type: !5, isLocal: true, isDefinition: true)
213!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression(DW_OP_constu, 18446744073709551487, DW_OP_stack_value))
214!10 = distinct !DIGlobalVariable(name: "Minus129", scope: !0, file: !1, line: 3, type: !5, isLocal: true, isDefinition: true)
215!11 = !DIGlobalVariableExpression(var: !12, expr: !DIExpression(DW_OP_constu, 18446744073709518848, DW_OP_stack_value))
216!12 = distinct !DIGlobalVariable(name: "Minus32768", scope: !0, file: !1, line: 4, type: !5, isLocal: true, isDefinition: true)
217!13 = !DIGlobalVariableExpression(var: !14, expr: !DIExpression(DW_OP_constu, 18446744073709518847, DW_OP_stack_value))
218!14 = distinct !DIGlobalVariable(name: "Minus32769", scope: !0, file: !1, line: 5, type: !5, isLocal: true, isDefinition: true)
219!15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression(DW_OP_constu, 18446744071562067968, DW_OP_stack_value))
220!16 = distinct !DIGlobalVariable(name: "Minus2147483648", scope: !0, file: !1, line: 6, type: !5, isLocal: true, isDefinition: true)
221!17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression(DW_OP_constu, 18446744071562067967, DW_OP_stack_value))
222!18 = distinct !DIGlobalVariable(name: "Minus2147483649", scope: !0, file: !1, line: 7, type: !5, isLocal: true, isDefinition: true)
223!19 = !DIGlobalVariableExpression(var: !20, expr: !DIExpression(DW_OP_constu, 0, DW_OP_stack_value))
224!20 = distinct !DIGlobalVariable(name: "Zero", scope: !0, file: !1, line: 9, type: !5, isLocal: true, isDefinition: true)
225!21 = !DIGlobalVariableExpression(var: !22, expr: !DIExpression(DW_OP_constu, 32767, DW_OP_stack_value))
226!22 = distinct !DIGlobalVariable(name: "Plus32767", scope: !0, file: !1, line: 10, type: !5, isLocal: true, isDefinition: true)
227!23 = !DIGlobalVariableExpression(var: !24, expr: !DIExpression(DW_OP_constu, 32768, DW_OP_stack_value))
228!24 = distinct !DIGlobalVariable(name: "Plus32768", scope: !0, file: !1, line: 11, type: !5, isLocal: true, isDefinition: true)
229!25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression(DW_OP_constu, 2147483647, DW_OP_stack_value))
230!26 = distinct !DIGlobalVariable(name: "Plus2147483647", scope: !0, file: !1, line: 12, type: !5, isLocal: true, isDefinition: true)
231!27 = !DIGlobalVariableExpression(var: !28, expr: !DIExpression(DW_OP_constu, 2147483648, DW_OP_stack_value))
232!28 = distinct !DIGlobalVariable(name: "Plus2147483648", scope: !0, file: !1, line: 13, type: !5, isLocal: true, isDefinition: true)
233!29 = !{i32 2, !"CodeView", i32 1}
234!30 = !{i32 2, !"Debug Info Version", i32 3}
235!31 = !{i32 1, !"wchar_size", i32 2}
236!32 = !{i32 7, !"PIC Level", i32 2}
237!33 = !{i32 7, !"uwtable", i32 2}
238!34 = !{!"clang version 15.0.0"}
239!35 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 15, type: !36, scopeLine: 15, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !39)
240!36 = !DISubroutineType(types: !37)
241!37 = !{!38}
242!38 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
243!39 = !{}
244!40 = !DILocalVariable(name: "iDebug1", scope: !35, file: !1, line: 16, type: !6)
245!41 = !DILocation(line: 16, scope: !35)
246!42 = !DILocalVariable(name: "iDebug2", scope: !35, file: !1, line: 19, type: !6)
247!43 = !DILocation(line: 19, scope: !35)
248!44 = !DILocation(line: 22, scope: !35)
249