r289686 - [DebugInfo] Restore test case for long double constants.

2016-12-14 Thread David Gross via cfe-commits
Author: dgross
Date: Wed Dec 14 12:52:33 2016
New Revision: 289686

URL: http://llvm.org/viewvc/llvm-project?rev=289686&view=rev
Log:
[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

Modified:
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c

Modified: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-static-const-fp.c?rev=289686&r1=289685&r2=289686&view=diff
==
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c Wed Dec 14 12:52:33 2016
@@ -1,7 +1,25 @@
-// 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)
 
@@ -9,7 +27,7 @@ static const float fVal = -147/17.0f;
 
 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 @@ int main() {
 // 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:


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289094 - [DebugInfo] Add support for __fp16, float, and double constants.

2016-12-08 Thread David Gross via cfe-commits
Author: dgross
Date: Thu Dec  8 14:02:46 2016
New Revision: 289094

URL: http://llvm.org/viewvc/llvm-project?rev=289094&view=rev
Log:
[DebugInfo] Add support for __fp16, float, and double constants.

Summary:
Partial fix for PR26619.

Prior to this change, a DIGlobalVariable corresponding to a static
const was marked with an expression corresponding to its constant
value only if it is of integral type.  With this change, we now do the
same if it is of __fp16, float, or double type (that is,
floating-point types that do not exceed 64 bits in size, and hence are
supported easily by the existing LLVM machinery for creating constant
expressions in debug info).

Reviewers: llvm-commits

Differential Revision: https://reviews.llvm.org/D27549

Added:
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=289094&r1=289093&r2=289094&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec  8 14:02:46 2016
@@ -3760,6 +3760,9 @@ void CGDebugInfo::EmitGlobalVariable(con
   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),

Added: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-static-const-fp.c?rev=289094&view=auto
==
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c Thu Dec  8 14:02:46 2016
@@ -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)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289103 - [DebugInfo] Relax test case for long double constants.

2016-12-08 Thread David Gross via cfe-commits
Author: dgross
Date: Thu Dec  8 15:15:17 2016
New Revision: 289103

URL: http://llvm.org/viewvc/llvm-project?rev=289103&view=rev
Log:
[DebugInfo] Relax 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.  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.

Reviewers: cfe-commits, probinson

Differential Revision: https://reviews.llvm.org/D27589

Modified:
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c

Modified: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-static-const-fp.c?rev=289103&r1=289102&r2=289103&view=diff
==
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c Thu Dec  8 15:15:17 2016
@@ -24,4 +24,8 @@ int main() {
 // 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


Re: [PATCH] D27597: [DebugInfo] Restore test case for long double constants.

2016-12-12 Thread David Gross via cfe-commits
I looked at what's supported by "requires", and couldn't find anything
appropriate.

The problem is that I want the test to be sensitive to the size of long
double -- either no greater than 64 bits, or greater than 64 bits.  It does
not seem practical to list all platforms (so I suspect your "xfail"
suggestion would not be suitable).  I'd like to find some way to make the
determination programmatically in the test suite.  It's certainly possible
that the answer is that there's no good way to do it.


On Mon, Dec 12, 2016 at 11:31 AM, David Blaikie  wrote:

> While it's possible to do arbitrary script things - we prefer nto to to
> ensure the tests are portable. (we have some custom implementations of
> common unix utilities for portability of those).
>
> In this case, can you xfail this on platforms that don't have the feature
> you want? rather than trying to detect it at test-execution time. (or say
> "requires" to opt the test in only on platforms you know have the thing you
> want)
>
> On Fri, Dec 9, 2016 at 4:00 AM David Gross via Phabricator via cfe-commits
>  wrote:
>
>> 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
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits