David Gross | ff06759 | 2016-12-14 18:52:33 +0000 | [diff] [blame] | 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 |
David Gross | 1118d59 | 2016-12-08 20:02:46 +0000 | [diff] [blame] | 9 | |
| 10 | // Per PR26619, check that for referenced static const of floating-point type, |
David Gross | ff06759 | 2016-12-14 18:52:33 +0000 | [diff] [blame] | 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. |
David Gross | 1118d59 | 2016-12-08 20:02:46 +0000 | [diff] [blame] | 23 | |
| 24 | static const __fp16 hVal = 29/13.0f; // 2.2307692307692307692 (2.23046875) |
| 25 | |
| 26 | static const float fVal = -147/17.0f; // -8.6470588235294117647 (-8.64705849) |
| 27 | |
| 28 | static const double dVal = 19637/7.0; // 2805.2857142857142857 (2805.2857142857142) |
| 29 | |
David Gross | ff06759 | 2016-12-14 18:52:33 +0000 | [diff] [blame] | 30 | static const long double ldVal = 3/1234567.0L; // 2.4300017739012949479e-06 (<depends on size of long double>) |
David Gross | 1118d59 | 2016-12-08 20:02:46 +0000 | [diff] [blame] | 31 | |
| 32 | int main() { |
| 33 | return hVal + fVal + dVal + ldVal; |
| 34 | } |
| 35 | |
Adrian Prantl | 5f4740d | 2016-12-20 02:10:02 +0000 | [diff] [blame] | 36 | // CHECK: !DIGlobalVariableExpression(var: [[HVAL:.*]], expr: [[HEXPR:.*]]) |
| 37 | // CHECK: [[HVAL]] = distinct !DIGlobalVariable(name: "hVal", |
| 38 | // CHECK-SAME: isLocal: true, isDefinition: true |
| 39 | // CHECK: [[HEXPR]] = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) |
David Gross | 1118d59 | 2016-12-08 20:02:46 +0000 | [diff] [blame] | 40 | |
Adrian Prantl | 5f4740d | 2016-12-20 02:10:02 +0000 | [diff] [blame] | 41 | // CHECK: !DIGlobalVariableExpression(var: [[FVAL:.*]], expr: [[FEXPR:.*]]) |
| 42 | // CHECK: [[FVAL]] = distinct !DIGlobalVariable(name: "fVal", |
| 43 | // CHECK-SAME: isLocal: true, isDefinition: true |
| 44 | // CHECK: [[FEXPR]] = !DIExpression(DW_OP_constu, 3238681178, DW_OP_stack_value) |
David Gross | 1118d59 | 2016-12-08 20:02:46 +0000 | [diff] [blame] | 45 | |
Adrian Prantl | 5f4740d | 2016-12-20 02:10:02 +0000 | [diff] [blame] | 46 | // CHECK: !DIGlobalVariableExpression(var: [[DVAL:.*]], expr: [[DEXPR:.*]]) |
| 47 | // CHECK: [[DVAL]] = distinct !DIGlobalVariable(name: "dVal", |
| 48 | // CHECK-SAME: isLocal: true, isDefinition: true |
| 49 | // CHECK: [[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) |
David Gross | 1118d59 | 2016-12-08 20:02:46 +0000 | [diff] [blame] | 50 | |
Adrian Prantl | 5f4740d | 2016-12-20 02:10:02 +0000 | [diff] [blame] | 51 | // CHECK-LDlg-DAG: [[LDVAL:.*]] = distinct !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) |
| 52 | // CHECK-LDlg-DAG: !DIGlobalVariableExpression(var: [[LDVAL]]) |
| 53 | // CHECK-LDsm-DAG: [[LDVAL:.*]] = distinct !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) |
| 54 | // CHECK-LDsm-DAG: !DIGlobalVariableExpression(var: [[LDVAL]], expr: |