1; RUN: llc -O2 %s -o %t -filetype=obj
2; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
3
4; Check that Machine CSE correctly handles during the transformation, the
5; debug location information for variables.
6
7; Generated with clang -c -g -O2
8
9; typedef float __attribute__((__vector_size__(16))) f4;
10; f4 get();
11; int main() {
12;   float MyVar = get()[0];
13;   if (MyVar)
14;     return 1;
15; }
16
17; ModuleID = 'test.cpp'
18source_filename = "test.cpp"
19target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
20target triple = "x86_64-pc-linux-gnu"
21
22define dso_local i32 @main() !dbg !7 {
23entry:
24  %call = tail call <4 x float> @_Z3getv(), !dbg !14
25  %vecext = extractelement <4 x float> %call, i32 0, !dbg !14
26  call void @llvm.dbg.value(metadata float %vecext, metadata !12, metadata !DIExpression()), !dbg !15
27  %tobool = fcmp une float %vecext, 0.000000e+00, !dbg !16
28  %. = zext i1 %tobool to i32, !dbg !18
29  ret i32 %., !dbg !19
30}
31
32declare dso_local <4 x float> @_Z3getv()
33
34declare void @llvm.dbg.value(metadata, metadata, metadata) #2
35
36!llvm.dbg.cu = !{!0}
37!llvm.module.flags = !{!3, !4, !5}
38!llvm.ident = !{!6}
39
40!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 339665)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
41!1 = !DIFile(filename: "test.cpp", directory: ".")
42!2 = !{}
43!3 = !{i32 2, !"Dwarf Version", i32 4}
44!4 = !{i32 2, !"Debug Info Version", i32 3}
45!5 = !{i32 1, !"wchar_size", i32 4}
46!6 = !{!"clang version 8.0.0 (trunk 339665)"}
47!7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
48!8 = !DISubroutineType(types: !9)
49!9 = !{!10}
50!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
51!11 = !{!12}
52!12 = !DILocalVariable(name: "MyVar", scope: !7, file: !1, line: 4, type: !13)
53!13 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
54!14 = !DILocation(line: 4, column: 18, scope: !7)
55!15 = !DILocation(line: 4, column: 9, scope: !7)
56!16 = !DILocation(line: 5, column: 7, scope: !17)
57!17 = distinct !DILexicalBlock(scope: !7, file: !1, line: 5, column: 7)
58!18 = !DILocation(line: 6, column: 5, scope: !17)
59!19 = !DILocation(line: 7, column: 1, scope: !7)
60
61; Look at the debug location information for variable 'MyVar'.
62; Verify that we see a sequence of DI entries, that looks like:
63; DW_TAG_variable
64;   DW_AT_location        (0x00000000
65;     [0x0000000000000009,  0x0000000000000012): DW_OP_reg17 XMM0)
66;   DW_AT_name    ("MyVar")
67
68; CHECK-LABEL: DW_TAG_variable
69; CHECK-NEXT: DW_AT_location{{.*}}
70; CHECK-NEXT: {{.*}}DW_OP_reg17 XMM0
71; CHECK-NEXT: DW_AT_name{{.*}}("MyVar")
72