1 ; RUN: opt -S -gvn-hoist < %s | FileCheck %s
3 ; Hoisted inlinable calls need to have accurate scope information, but we're
4 ; allowed to erase the line information.
6 source_filename = "t.c"
7 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-pc-windows-msvc19.0.24215"
10 ; Function Attrs: noinline nounwind readnone uwtable
11 define float @fabsf(float %f) #0 !dbg !7 {
13 %conv = fpext float %f to double, !dbg !9
14 %call = call double @fabs(double %conv) #1, !dbg !10
15 %conv1 = fptrunc double %call to float, !dbg !11
16 ret float %conv1, !dbg !12
19 ; Function Attrs: nounwind readnone
20 declare double @fabs(double) #1
22 ; Function Attrs: noinline nounwind uwtable
23 define void @hoistit(i32 %cond, float %f) #2 !dbg !13 {
25 %tobool = icmp ne i32 %cond, 0, !dbg !14
26 br i1 %tobool, label %if.then, label %if.else, !dbg !14
28 if.then: ; preds = %entry
29 %call = call float @fabsf(float %f) #1, !dbg !15
30 call void @useit1(float %call), !dbg !16
31 br label %if.end, !dbg !18
33 if.else: ; preds = %entry
34 %call1 = call float @fabsf(float %f) #1, !dbg !19
35 call void @useit2(float %call1), !dbg !20
38 if.end: ; preds = %if.else, %if.then
42 ; CHECK-LABEL: define void @hoistit
43 ; CHECK-SAME: !dbg ![[sp_hoistit:[0-9]+]]
44 ; CHECK: call float @fabsf(float %f) {{.*}} !dbg ![[dbgloc:[0-9]+]]
45 ; CHECK: br i1 %tobool, label %if.then, label %if.else
47 ; CHECK: ![[sp_hoistit]] = distinct !DISubprogram(name: "hoistit", {{.*}})
48 ; CHECK: ![[dbgloc]] = !DILocation({{.*}}, scope: ![[sp_hoistit]])
50 declare void @useit1(float)
52 declare void @useit2(float)
54 attributes #0 = { noinline nounwind readnone uwtable }
55 attributes #1 = { nounwind readnone willreturn }
56 attributes #2 = { noinline nounwind uwtable }
59 !llvm.module.flags = !{!3, !4, !5}
62 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
63 !1 = !DIFile(filename: "t.c", directory: "C:\5Csrc\5Cllvm\5Cbuild")
65 !3 = !{i32 2, !"Dwarf Version", i32 4}
66 !4 = !{i32 2, !"Debug Info Version", i32 3}
67 !5 = !{i32 1, !"PIC Level", i32 2}
68 !6 = !{!"clang version 5.0.0 "}
69 !7 = distinct !DISubprogram(name: "fabsf", scope: !1, file: !1, line: 4, type: !8, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
70 !8 = !DISubroutineType(types: !2)
71 !9 = !DILocation(line: 5, column: 22, scope: !7)
72 !10 = !DILocation(line: 5, column: 17, scope: !7)
73 !11 = !DILocation(line: 5, column: 10, scope: !7)
74 !12 = !DILocation(line: 5, column: 3, scope: !7)
75 !13 = distinct !DISubprogram(name: "hoistit", scope: !1, file: !1, line: 7, type: !8, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
76 !14 = !DILocation(line: 8, column: 7, scope: !13)
77 !15 = !DILocation(line: 9, column: 12, scope: !13)
78 !16 = !DILocation(line: 9, column: 5, scope: !17)
79 !17 = !DILexicalBlockFile(scope: !13, file: !1, discriminator: 1)
80 !18 = !DILocation(line: 10, column: 3, scope: !13)
81 !19 = !DILocation(line: 11, column: 12, scope: !13)
82 !20 = !DILocation(line: 11, column: 5, scope: !17)
83 !21 = !DILocation(line: 13, column: 1, scope: !13)