[PATCH] D27597: [DebugInfo] Restore test case for long double constants.
This revision was automatically updated to reflect the committed changes. Closed by commit rL289686: [DebugInfo] Restore test case for long double constants. (authored by dgross). Changed prior to commit: https://reviews.llvm.org/D27597?vs=81321&id=81423#toc Repository: rL LLVM https://reviews.llvm.org/D27597 Files: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c === --- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c +++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c @@ -1,15 +1,33 @@ -// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK %s + +// RUN: %clang_cc1 -triple hexagon-unknown--elf -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK,CHECK-LDsm %s + +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK,CHECK-LDlg %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. +// we emit its constant value in debug info. +// +// NOTE that __fp16 is assumed to be 16 bits, float is assumed to be +// 32 bits, and double is assumed to be 64 bits. Size of long double +// is not known (for example, it is 64 bits for hexagon-unknown--elf, +// but 128 bits for x86_64-unknown-linux-gnu). Therefore, we specify +// target triples where it has a known size, and check accordingly: +// for the absence of a constant (CHECK-LDlg) when the size exceeds 64 +// bits, and for the presence of a constant (CHECK-LDsm) but not its +// value when the size does not exceed 64 bits. +// +// NOTE that PR26619 is not yet fixed for types greater than 64 bits. 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 () +static const long double ldVal = 3/1234567.0L; // 2.4300017739012949479e-06 () int main() { return hVal + fVal + dVal + ldVal; @@ -24,8 +42,5 @@ // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) -// Temporarily removing this check -- for some targets (such as -// "--target=hexagon-unknown-elf"), long double does not exceed 64 -// bits, and so we actually do get the constant value (expr) emitted. -// -// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) +// CHECK-LDlg: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) +// CHECK-LDsm: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true, expr: Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c === --- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c +++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c @@ -1,15 +1,33 @@ -// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK %s + +// RUN: %clang_cc1 -triple hexagon-unknown--elf -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK,CHECK-LDsm %s + +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK,CHECK-LDlg %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. +// we emit its constant value in debug info. +// +// NOTE that __fp16 is assumed to be 16 bits, float is assumed to be +// 32 bits, and double is assumed to be 64 bits. Size of long double +// is not known (for example, it is 64 bits for hexagon-unknown--elf, +// but 128 bits for x86_64-unknown-linux-gnu). Therefore, we specify +// target triples where it has a known size, and check accordingly: +// for the absence of a constant (CHECK-LDlg) when the size exceeds 64 +// bits, and for the presence of a constant (CHECK-LDsm) but not its +// value when the size does not exceed 64 bits. +// +// NOTE that PR26619 is not yet fixed for types greater than 64 bits. static const __fp16 hVal = 29/13.0f;//2.2307692307692307692 (2.23046875) static const float fVal = -147/17.0f;
[PATCH] D27597: [DebugInfo] Restore test case for long double constants.
dgross updated this revision to Diff 81321. dgross added a comment. Incorporate code review comments. - Use %clang_cc1 not %clang - Rather than trying to determine long double size for target, compile and check multiple times, and only check behavior of long double for known targets https://reviews.llvm.org/D27597 Files: test/CodeGen/debug-info-static-const-fp.c Index: test/CodeGen/debug-info-static-const-fp.c === --- test/CodeGen/debug-info-static-const-fp.c +++ test/CodeGen/debug-info-static-const-fp.c @@ -1,15 +1,33 @@ -// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK %s + +// RUN: %clang_cc1 -triple hexagon-unknown--elf -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK,CHECK-LDsm %s + +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK,CHECK-LDlg %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. +// we emit its constant value in debug info. +// +// NOTE that __fp16 is assumed to be 16 bits, float is assumed to be +// 32 bits, and double is assumed to be 64 bits. Size of long double +// is not known (for example, it is 64 bits for hexagon-unknown--elf, +// but 128 bits for x86_64-unknown-linux-gnu). Therefore, we specify +// target triples where it has a known size, and check accordingly: +// for the absence of a constant (CHECK-LDlg) when the size exceeds 64 +// bits, and for the presence of a constant (CHECK-LDsm) but not its +// value when the size does not exceed 64 bits. +// +// NOTE that PR26619 is not yet fixed for types greater than 64 bits. 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 () +static const long double ldVal = 3/1234567.0L; // 2.4300017739012949479e-06 () int main() { return hVal + fVal + dVal + ldVal; @@ -24,8 +42,5 @@ // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) -// Temporarily removing this check -- for some targets (such as -// "--target=hexagon-unknown-elf"), long double does not exceed 64 -// bits, and so we actually do get the constant value (expr) emitted. -// -// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) +// CHECK-LDlg: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) +// CHECK-LDsm: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true, expr: Index: test/CodeGen/debug-info-static-const-fp.c === --- test/CodeGen/debug-info-static-const-fp.c +++ test/CodeGen/debug-info-static-const-fp.c @@ -1,15 +1,33 @@ -// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK %s + +// RUN: %clang_cc1 -triple hexagon-unknown--elf -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK,CHECK-LDsm %s + +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -debug-info-kind=limited %s -o - | \ +// RUN: FileCheck --check-prefixes CHECK,CHECK-LDlg %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. +// we emit its constant value in debug info. +// +// NOTE that __fp16 is assumed to be 16 bits, float is assumed to be +// 32 bits, and double is assumed to be 64 bits. Size of long double +// is not known (for example, it is 64 bits for hexagon-unknown--elf, +// but 128 bits for x86_64-unknown-linux-gnu). Therefore, we specify +// target triples where it has a known size, and check accordingly: +// for the absence of a constant (CHECK-LDlg) when the size exceeds 64 +// bits, and for the presence of a constant (CHECK-LDsm) but not its +// value when the size does not exceed 64 bits. +// +// NOTE that PR26619 is not yet fixed for types greater than 64 bits. static const __fp16 hVal = 29/13.0f;//2.2307692307692307692 (2.23046875) static const float fVal = -147/17.0f; // -8.6470588235294117647 (-8.64705849) static const dou
[PATCH] D27597: [DebugInfo] Restore test case for long double constants.
dgross added a comment. In https://reviews.llvm.org/D27597#621596, @probinson wrote: > As dblaikie said in email, probably better to make this X86-specific; if > long-double varies by OS you can put in a specific triple. I think with this approach I'd want two test cases that are identical except for consideration of long double size: One that specifies a target where long double is "small" and one where it is "large". Actually, I guess I could make this a single test case, but have two compile and two filecheck lines, specifying different triples, as you suggest. Or even three: One for whatever the default target is (doesn't check long double), one for a triple where long double is small, and one for a triple where long double is large. > FTR we don't rely on Perl being available everywhere, anything that does this > kind of scripty stuff uses Python. So would a Python equivalent of the Perl be acceptable? I think this is an academic question -- better to explicitly test multiple triples. https://reviews.llvm.org/D27597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27597: [DebugInfo] Restore test case for long double constants.
dgross added a comment. I don't know exactly what the RUN syntax supported by lit is. What I've done here looks complex, but it does work for Linux. What about other platforms? Is there some better way of writing a test case where the checks to be done by FileCheck depend on some property of the file being analyzed (here, the size of long double, as embedded in the debug metadata)? I don't see any support for conditions in FileCheck. Maybe I'm going about this completely the wrong way? https://reviews.llvm.org/D27597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27597: [DebugInfo] Restore test case for long double constants.
dgross created this revision. dgross added reviewers: cfe-commits, probinson. https://reviews.llvm.org/D27549 (partial fix for PR26619) emits a constant value in the debug metadata for a floating-point static const that does not exceed 64 bits in size. Whether or not a long double exceeds 64 bits in size depends on the target. Modify the test case so that it expects a constant value for long double if and only if the long double is no larger than 64 bits. https://reviews.llvm.org/D27597 Files: test/CodeGen/debug-info-static-const-fp.c Index: test/CodeGen/debug-info-static-const-fp.c === --- test/CodeGen/debug-info-static-const-fp.c +++ test/CodeGen/debug-info-static-const-fp.c @@ -1,7 +1,23 @@ -// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s +// RUN: %clang -emit-llvm -O0 -S -g %s -o %t +// RUN: perl <%t >%t-check-prefix -n -e \ +// RUN: 'if (/"long double".*size:\s+(\d+)/) { \ +// RUN: printf "--check-prefix CHECK-LD%%s", ($1 <= 64 ? "sm" : "lg"); \ +// RUN: last; \ +// RUN:}' +// RUN: FileCheck --check-prefix CHECK $(cat %t-check-prefix) %s <%t // 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. +// we emit its constant value in debug info. +// +// NOTE that __fp16 is assumed to be 16 bits, float is assumed to be +// 32 bits, and double is assumed to be 64 bits. Size of long double +// is not known (for example, it is 64 bits for hexagon-unknown--elf, +// but 128 bits for x86_64-unknown-linux-gnu) Therefore, we test for +// the absence of a constant (CHECK-LDlg) when the size exceeds 64 +// bits, and for the presence of a constant (CHECK-LDsm) but not its +// value when the size does not exceed 64 bits. +// +// NOTE that PR26619 is not yet fixed for types greater than 64 bits. static const __fp16 hVal = 29/13.0f;//2.2307692307692307692 (2.23046875) @@ -24,8 +40,5 @@ // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) -// Temporarily removing this check -- for some targets (such as -// "--target=hexagon-unknown-elf"), long double does not exceed 64 -// bits, and so we actually do get the constant value (expr) emitted. -// -// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) +// CHECK-LDlg: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) +// CHECK-LDsm: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true, expr: Index: test/CodeGen/debug-info-static-const-fp.c === --- test/CodeGen/debug-info-static-const-fp.c +++ test/CodeGen/debug-info-static-const-fp.c @@ -1,7 +1,23 @@ -// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s +// RUN: %clang -emit-llvm -O0 -S -g %s -o %t +// RUN: perl <%t >%t-check-prefix -n -e \ +// RUN: 'if (/"long double".*size:\s+(\d+)/) { \ +// RUN: printf "--check-prefix CHECK-LD%%s", ($1 <= 64 ? "sm" : "lg"); \ +// RUN: last; \ +// RUN:}' +// RUN: FileCheck --check-prefix CHECK $(cat %t-check-prefix) %s <%t // 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. +// we emit its constant value in debug info. +// +// NOTE that __fp16 is assumed to be 16 bits, float is assumed to be +// 32 bits, and double is assumed to be 64 bits. Size of long double +// is not known (for example, it is 64 bits for hexagon-unknown--elf, +// but 128 bits for x86_64-unknown-linux-gnu) Therefore, we test for +// the absence of a constant (CHECK-LDlg) when the size exceeds 64 +// bits, and for the presence of a constant (CHECK-LDsm) but not its +// value when the size does not exceed 64 bits. +// +// NOTE that PR26619 is not yet fixed for types greater than 64 bits. static const __fp16 hVal = 29/13.0f;//2.2307692307692307692 (2.23046875) @@ -24,8 +40,5 @@ // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) -// Temporarily removing this check -- for some targets (such as -// "--target=hexagon-unknown-elf"), long double does not exceed 64 -// bits, and so we actually do get the constant value (expr) emitted. -// -// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true
[PATCH] D27589: [DebugInfo] Relax test case for long double constants.
This revision was automatically updated to reflect the committed changes. Closed by commit rL289103: [DebugInfo] Relax test case for long double constants. (authored by dgross). Changed prior to commit: https://reviews.llvm.org/D27589?vs=80815&id=80817#toc Repository: rL LLVM https://reviews.llvm.org/D27589 Files: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c === --- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c +++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c @@ -24,4 +24,8 @@ // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) -// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) +// Temporarily removing this check -- for some targets (such as +// "--target=hexagon-unknown-elf"), long double does not exceed 64 +// bits, and so we actually do get the constant value (expr) emitted. +// +// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c === --- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c +++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c @@ -24,4 +24,8 @@ // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) -// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) +// Temporarily removing this check -- for some targets (such as +// "--target=hexagon-unknown-elf"), long double does not exceed 64 +// bits, and so we actually do get the constant value (expr) emitted. +// +// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27589: [DebugInfo] Relax test case for long double constants.
dgross created this revision. dgross added reviewers: cfe-commits, probinson. https://reviews.llvm.org/D27549 (partial fix for PR26619) emits a constant value in the debug metadata for a floating-point static const that does not exceed 64 bits in size. The regression test accompanying that fix assumes that a long double exceeds 64 bits in size and hence does not get a constant value in the debug metadata. However, for some targets -- such as "--target=hexagon-unknown-elf" -- a long double does not exceed 64 bits in size, and hence the test fails. As a temporary fix, modify the regression test to no longer inspect the debug metadata for a long double. https://reviews.llvm.org/D27589 Files: test/CodeGen/debug-info-static-const-fp.c Index: test/CodeGen/debug-info-static-const-fp.c === --- test/CodeGen/debug-info-static-const-fp.c +++ test/CodeGen/debug-info-static-const-fp.c @@ -24,4 +24,8 @@ // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) -// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) +// Temporarily removing this check -- for some targets (such as +// "--target=hexagon-unknown-elf"), long double does not exceed 64 +// bits, and so we actually do get the constant value (expr) emitted. +// +// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) Index: test/CodeGen/debug-info-static-const-fp.c === --- test/CodeGen/debug-info-static-const-fp.c +++ test/CodeGen/debug-info-static-const-fp.c @@ -24,4 +24,8 @@ // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) -// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) +// Temporarily removing this check -- for some targets (such as +// "--target=hexagon-unknown-elf"), long double does not exceed 64 +// bits, and so we actually do get the constant value (expr) emitted. +// +// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27549: [DebugInfo] Add support for __fp16, float, and double constants.
This revision was automatically updated to reflect the committed changes. Closed by commit rL289094: [DebugInfo] Add support for __fp16, float, and double constants. (authored by dgross). Changed prior to commit: https://reviews.llvm.org/D27549?vs=80683&id=80806#toc Repository: rL LLVM https://reviews.llvm.org/D27549 Files: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/test/CodeGen/debug-info-static-const-fp.c Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c === --- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c +++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c @@ -0,0 +1,27 @@ +// RUN: %clang -emit-llvm -O0 -S -g %s -o - | 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. + +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; +} + +// CHECK: !DIGlobalVariable(name: "hVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[HEXPR:[0-9]+]] +// CHECK: ![[HEXPR]] = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "fVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[FEXPR:[0-9]+]] +// CHECK: ![[FEXPR]] = !DIExpression(DW_OP_constu, 3238681178, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] +// CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp === --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp @@ -3760,6 +3760,9 @@ if (Init.isInt()) InitExpr = DBuilder.createConstantValueExpression(Init.getInt().getExtValue()); + else if (Init.isFloat() && CGM.getContext().getTypeSize(VD->getType()) <= 64) +InitExpr = DBuilder.createConstantValueExpression( +Init.getFloat().bitcastToAPInt().getZExtValue()); GV.reset(DBuilder.createGlobalVariable( DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty, true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD), Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c === --- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c +++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c @@ -0,0 +1,27 @@ +// RUN: %clang -emit-llvm -O0 -S -g %s -o - | 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. + +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; +} + +// CHECK: !DIGlobalVariable(name: "hVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[HEXPR:[0-9]+]] +// CHECK: ![[HEXPR]] = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "fVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[FEXPR:[0-9]+]] +// CHECK: ![[FEXPR]] = !DIExpression(DW_OP_constu, 3238681178, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] +// CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp === --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp @@ -3760,6 +3760,9 @@ if (Init.isInt()) InitExpr = DBuilder.createConstantValueExpression(Init.getInt().getExtValue()); + else if (Init.isFloat() && CGM.getContext().getTypeSize(VD->getType()) <= 64) +InitExpr = DBuilder.createConstantValueExpression( +Init.getFloat().bitcastToAPInt().getZExtValue()); GV.reset(DBuilder.createGlobalVariable( DContext, Name, S
[PATCH] D27549: [DebugInfo] Add support for __fp16, float, and double constants.
dgross added inline comments. Comment at: lib/CodeGen/CGDebugInfo.cpp:3765 +InitExpr = + DBuilder.createConstantValueExpression(Init.getFloat().bitcastToAPInt().getZExtValue()); GV.reset(DBuilder.createGlobalVariable( probinson wrote: > This line exceeds 80 columns. clang-format is your friend. Done. Is clang-format mentioned in any of the documentation that describes the development process? I might have missed it (not that that's an excuse for a needless violation of the coding guidelines). Comment at: test/CodeGen/debug-info-static-const-fp.c:19 +// CHECK: !4 = distinct !DIGlobalVariable(name: "hVal", scope: !0, file: !1, line: 6, type: !5, isLocal: true, isDefinition: true, expr: !7) +// CHECK: !7 = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) +// CHECK: !8 = distinct !DIGlobalVariable(name: "fVal", scope: !0, file: !1, line: 8, type: !9, isLocal: true, isDefinition: true, expr: !11) probinson wrote: > Checking for the entire exact line for the variable is a bit fragile. Really > what you want to do is associate the variable with the correct expression, > and ignore all the irrelevant details. Something like this: > ``` > // CHECK: DIGlobalVariable(name: "hVal", {{.*}} expr: ![[HEXPR:{{[0-9]+}}]] > // CHECK: ![[HEXPR] = ! DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) > ``` > And similar pairs for the other variables. I'd use a different FileCheck > variable for each case. > Thanks for the suggestion. I didn't realize FileCheck had variable support. https://reviews.llvm.org/D27549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27549: [DebugInfo] Add support for __fp16, float, and double constants.
dgross updated this revision to Diff 80683. dgross added a comment. Incorporate code review feedback. - Reformat source. - Make test pattern more general. https://reviews.llvm.org/D27549 Files: lib/CodeGen/CGDebugInfo.cpp test/CodeGen/debug-info-static-const-fp.c Index: test/CodeGen/debug-info-static-const-fp.c === --- /dev/null +++ test/CodeGen/debug-info-static-const-fp.c @@ -0,0 +1,27 @@ +// RUN: %clang -emit-llvm -O0 -S -g %s -o - | 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. + +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; +} + +// CHECK: !DIGlobalVariable(name: "hVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[HEXPR:[0-9]+]] +// CHECK: ![[HEXPR]] = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "fVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[FEXPR:[0-9]+]] +// CHECK: ![[FEXPR]] = !DIExpression(DW_OP_constu, 3238681178, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] +// CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -3760,6 +3760,9 @@ if (Init.isInt()) InitExpr = DBuilder.createConstantValueExpression(Init.getInt().getExtValue()); + else if (Init.isFloat() && CGM.getContext().getTypeSize(VD->getType()) <= 64) +InitExpr = DBuilder.createConstantValueExpression( +Init.getFloat().bitcastToAPInt().getZExtValue()); GV.reset(DBuilder.createGlobalVariable( DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty, true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD), Index: test/CodeGen/debug-info-static-const-fp.c === --- /dev/null +++ test/CodeGen/debug-info-static-const-fp.c @@ -0,0 +1,27 @@ +// RUN: %clang -emit-llvm -O0 -S -g %s -o - | 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. + +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; +} + +// CHECK: !DIGlobalVariable(name: "hVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[HEXPR:[0-9]+]] +// CHECK: ![[HEXPR]] = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "fVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[FEXPR:[0-9]+]] +// CHECK: ![[FEXPR]] = !DIExpression(DW_OP_constu, 3238681178, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]] +// CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) + +// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -3760,6 +3760,9 @@ if (Init.isInt()) InitExpr = DBuilder.createConstantValueExpression(Init.getInt().getExtValue()); + else if (Init.isFloat() && CGM.getContext().getTypeSize(VD->getType()) <= 64) +InitExpr = DBuilder.createConstantValueExpression( +Init.getFloat().bitcastToAPInt().getZExtValue()); GV.reset(DBuilder.createGlobalVariable( DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty, true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits