Skip to content

Commit 16aa35a

Browse files
committed
[DebugInfo] Restore test case for long double constants.
Summary: 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. Reviewers: cfe-commits, probinson Differential Revision: https://reviews.llvm.org/D27597 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289686 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 86337d6 commit 16aa35a

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed
+23-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1-
// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s
1+
// RUN: %clang_cc1 -emit-llvm -O0 -debug-info-kind=limited %s -o - | \
2+
// RUN: FileCheck --check-prefixes CHECK %s
3+
4+
// RUN: %clang_cc1 -triple hexagon-unknown--elf -emit-llvm -O0 -debug-info-kind=limited %s -o - | \
5+
// RUN: FileCheck --check-prefixes CHECK,CHECK-LDsm %s
6+
7+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -debug-info-kind=limited %s -o - | \
8+
// RUN: FileCheck --check-prefixes CHECK,CHECK-LDlg %s
29

310
// Per PR26619, check that for referenced static const of floating-point type,
4-
// we emit its constant value in debug info. NOTE that PR26619 is not yet fixed for long double.
11+
// we emit its constant value in debug info.
12+
//
13+
// NOTE that __fp16 is assumed to be 16 bits, float is assumed to be
14+
// 32 bits, and double is assumed to be 64 bits. Size of long double
15+
// is not known (for example, it is 64 bits for hexagon-unknown--elf,
16+
// but 128 bits for x86_64-unknown-linux-gnu). Therefore, we specify
17+
// target triples where it has a known size, and check accordingly:
18+
// for the absence of a constant (CHECK-LDlg) when the size exceeds 64
19+
// bits, and for the presence of a constant (CHECK-LDsm) but not its
20+
// value when the size does not exceed 64 bits.
21+
//
22+
// NOTE that PR26619 is not yet fixed for types greater than 64 bits.
523

624
static const __fp16 hVal = 29/13.0f; // 2.2307692307692307692 (2.23046875)
725

826
static const float fVal = -147/17.0f; // -8.6470588235294117647 (-8.64705849)
927

1028
static const double dVal = 19637/7.0; // 2805.2857142857142857 (2805.2857142857142)
1129

12-
static const long double ldVal = 3/1234567.0L; // 2.4300017739012949479e-06 (<optimized out>)
30+
static const long double ldVal = 3/1234567.0L; // 2.4300017739012949479e-06 (<depends on size of long double>)
1331

1432
int main() {
1533
return hVal + fVal + dVal + ldVal;
@@ -24,8 +42,5 @@ int main() {
2442
// CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]]
2543
// CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value)
2644

27-
// Temporarily removing this check -- for some targets (such as
28-
// "--target=hexagon-unknown-elf"), long double does not exceed 64
29-
// bits, and so we actually do get the constant value (expr) emitted.
30-
//
31-
// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true)
45+
// CHECK-LDlg: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true)
46+
// CHECK-LDsm: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true, expr:

0 commit comments

Comments
 (0)