Index: test/DebugInfo/Generic/static-const-fp.ll =================================================================== --- /dev/null +++ test/DebugInfo/Generic/static-const-fp.ll @@ -0,0 +1,97 @@ +; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s + +; Per PR26619, check that for referenced static const of +; floating-point type, we emit its constant value in debug info. +; NOTE that PR26619 is not yet fixed for long double. + +; Generated with clang -O0 -S -g static-const-fp.c + +; static const __fp16 hVal = 29/13.0f; // 2.2307692307692307692 (2.23046875) +; +; static const float fVal = -147/17.0f; // -8.6470588235294117647 (-8.64705849) +; +; static const double dVal = 19637/7.0; // 2805.2857142857142857 (2805.2857142857142) +; +; static const long double ldVal = 3/1234567.0L; // 2.4300017739012949479e-06 () +; +; int main() { +; return hVal + fVal + dVal + ldVal; +; } + +; Function Attrs: nounwind uwtable +define i32 @main() !dbg !22 { +entry: + %retval = alloca i32, align 4 + store i32 0, i32* %retval, align 4 + %0 = call float @llvm.convert.from.fp16.f32(i16 16502), !dbg !26 + %add = fadd float %0, 0xC0214B4B40000000, !dbg !27 + %conv = fpext float %add to double, !dbg !26 + %add1 = fadd double %conv, 0x40A5EA9249249249, !dbg !28 + %conv2 = fpext double %add1 to x86_fp80, !dbg !26 + %add3 = fadd x86_fp80 %conv2, 0xK3FECA3131CD2DCE5A434, !dbg !29 + %conv4 = fptosi x86_fp80 %add3 to i32, !dbg !26 + ret i32 %conv4, !dbg !30 +} + +; Function Attrs: nounwind readnone +declare float @llvm.convert.from.fp16.f32(i16) + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!19, !20} +!llvm.ident = !{!21} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 288414) (llvm/trunk 288418)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3) +!1 = !DIFile(filename: "static-const-fp.c", directory: "/tmp") +!2 = !{} +!3 = !{!4, !8, !12, !16} +!4 = distinct !DIGlobalVariable(name: "hVal", scope: !0, file: !1, line: 6, type: !5, isLocal: true, isDefinition: true, expr: !7) +!5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6) +!6 = !DIBasicType(name: "__fp16", size: 16, encoding: DW_ATE_float) +!7 = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) +!8 = distinct !DIGlobalVariable(name: "fVal", scope: !0, file: !1, line: 8, type: !9, isLocal: true, isDefinition: true, expr: !11) +!9 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !10) +!10 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float) +!11 = !DIExpression(DW_OP_constu, 3238681178, DW_OP_stack_value) +!12 = distinct !DIGlobalVariable(name: "dVal", scope: !0, file: !1, line: 10, type: !13, isLocal: true, isDefinition: true, expr: !15) +!13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !14) +!14 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float) +!15 = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) +!16 = distinct !DIGlobalVariable(name: "ldVal", scope: !0, file: !1, line: 12, type: !17, isLocal: true, isDefinition: true) +!17 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !18) +!18 = !DIBasicType(name: "long double", size: 128, encoding: DW_ATE_float) +!19 = !{i32 2, !"Dwarf Version", i32 4} +!20 = !{i32 2, !"Debug Info Version", i32 3} +!21 = !{!"clang version 4.0.0 (trunk 288414) (llvm/trunk 288418)"} +!22 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 14, type: !23, isLocal: false, isDefinition: true, scopeLine: 14, isOptimized: false, unit: !0, variables: !2) +!23 = !DISubroutineType(types: !24) +!24 = !{!25} +!25 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!26 = !DILocation(line: 15, column: 10, scope: !22) +!27 = !DILocation(line: 15, column: 15, scope: !22) +!28 = !DILocation(line: 15, column: 22, scope: !22) +!29 = !DILocation(line: 15, column: 29, scope: !22) +!30 = !DILocation(line: 15, column: 3, scope: !22) + +; CHECK: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "hVal" +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_const_value {{.*}} (16502) + +; CHECK: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "fVal" +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_const_value {{.*}} (3238681178) + +; CHECK: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "dVal" +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_const_value {{.*}} (4658387303597904457) + +; CHECK: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "ldVal" +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_location {{.*}} ()