[llvm-branch-commits] [clang] 14947cd - [clang] Fix signedness in vector bitcast evaluation

2021-01-25 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2021-01-25T12:01:42Z
New Revision: 14947cd04701d923a57a0161fd1967b81e00ff5e

URL: 
https://github.com/llvm/llvm-project/commit/14947cd04701d923a57a0161fd1967b81e00ff5e
DIFF: 
https://github.com/llvm/llvm-project/commit/14947cd04701d923a57a0161fd1967b81e00ff5e.diff

LOG: [clang] Fix signedness in vector bitcast evaluation

The included test case triggered a sign assertion on the result in
`Success()`.  This was caused by the APSInt created for a bitcast
having its signedness bit inverted.  The second APSInt constructor
argument is `isUnsigned`, so invert the result of
`isSignedIntegerType`.

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

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGenOpenCL/vector_literals.cl

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 56181bbe1166..c1973720e49a 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10193,7 +10193,7 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr 
*E) {
   Elt = SValInt.rotl(i*EltSize+EltSize).zextOrTrunc(EltSize);
 else
   Elt = SValInt.rotr(i*EltSize).zextOrTrunc(EltSize);
-Elts.push_back(APValue(APSInt(Elt, EltTy->isSignedIntegerType(;
+Elts.push_back(APValue(APSInt(Elt, !EltTy->isSignedIntegerType(;
   }
 } else {
   return Error(E);

diff  --git a/clang/test/CodeGenOpenCL/vector_literals.cl 
b/clang/test/CodeGenOpenCL/vector_literals.cl
index af571714368e..3115aef2b50a 100644
--- a/clang/test/CodeGenOpenCL/vector_literals.cl
+++ b/clang/test/CodeGenOpenCL/vector_literals.cl
@@ -63,3 +63,10 @@ void vector_literals_valid() {
   //CHECK: store <4 x float> , <4 x float>* %V2
   float4 V2 = (float4)(1);
 }
+
+void vector_literals_with_cast() {
+  // CHECK-LABEL: vector_literals_with_cast
+  // CHECK: store <2 x i32> , <2 x i32>*
+  // CHECK: extractelement <2 x i32> %{{[0-9]+}}, i64 0
+  unsigned int withCast = ((int2)((int2)(12, 34))).s0;
+}



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


[llvm-branch-commits] [clang] b16fb1f - Revert "[clang] Fix signedness in vector bitcast evaluation"

2021-01-25 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2021-01-25T12:43:30Z
New Revision: b16fb1ffc3ceebdff1f570668e73f257d7f7e499

URL: 
https://github.com/llvm/llvm-project/commit/b16fb1ffc3ceebdff1f570668e73f257d7f7e499
DIFF: 
https://github.com/llvm/llvm-project/commit/b16fb1ffc3ceebdff1f570668e73f257d7f7e499.diff

LOG: Revert "[clang] Fix signedness in vector bitcast evaluation"

This reverts commit 14947cd04701d923a57a0161fd1967b81e00ff5e because
it broke clang-cmake-armv7-quick.

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGenOpenCL/vector_literals.cl

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index c1973720e49ac..56181bbe11668 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10193,7 +10193,7 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr 
*E) {
   Elt = SValInt.rotl(i*EltSize+EltSize).zextOrTrunc(EltSize);
 else
   Elt = SValInt.rotr(i*EltSize).zextOrTrunc(EltSize);
-Elts.push_back(APValue(APSInt(Elt, !EltTy->isSignedIntegerType(;
+Elts.push_back(APValue(APSInt(Elt, EltTy->isSignedIntegerType(;
   }
 } else {
   return Error(E);

diff  --git a/clang/test/CodeGenOpenCL/vector_literals.cl 
b/clang/test/CodeGenOpenCL/vector_literals.cl
index 3115aef2b50ae..af571714368ef 100644
--- a/clang/test/CodeGenOpenCL/vector_literals.cl
+++ b/clang/test/CodeGenOpenCL/vector_literals.cl
@@ -63,10 +63,3 @@ void vector_literals_valid() {
   //CHECK: store <4 x float> , <4 x float>* %V2
   float4 V2 = (float4)(1);
 }
-
-void vector_literals_with_cast() {
-  // CHECK-LABEL: vector_literals_with_cast
-  // CHECK: store <2 x i32> , <2 x i32>*
-  // CHECK: extractelement <2 x i32> %{{[0-9]+}}, i64 0
-  unsigned int withCast = ((int2)((int2)(12, 34))).s0;
-}



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


[llvm-branch-commits] [clang] 7c77b53 - [OpenCL] Improve OpenCL operator tests

2021-01-13 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2021-01-13T14:50:49Z
New Revision: 7c77b536efdd953d6d97bffbd9ca320c517b26d7

URL: 
https://github.com/llvm/llvm-project/commit/7c77b536efdd953d6d97bffbd9ca320c517b26d7
DIFF: 
https://github.com/llvm/llvm-project/commit/7c77b536efdd953d6d97bffbd9ca320c517b26d7.diff

LOG: [OpenCL] Improve OpenCL operator tests

Extend testing of increment/decrement operators and make sure these
operators are tested in only one dedicated test file.

Rename logical-ops.cl to operators.cl, as it was already containing
more than just logical operators.

Add testing for the remainder operator on floating point types.

Added: 
clang/test/SemaOpenCL/operators.cl

Modified: 
clang/test/SemaOpenCL/invalid-vector-literals.cl
clang/test/SemaOpenCL/vector_inc_dec_ops.cl

Removed: 
clang/test/SemaOpenCL/logical-ops.cl



diff  --git a/clang/test/SemaOpenCL/invalid-vector-literals.cl 
b/clang/test/SemaOpenCL/invalid-vector-literals.cl
index 4e502aad3bad..1d82fedf29de 100644
--- a/clang/test/SemaOpenCL/invalid-vector-literals.cl
+++ b/clang/test/SemaOpenCL/invalid-vector-literals.cl
@@ -8,7 +8,6 @@ void vector_literals_invalid()
 {
   int4 a = (int4)(1,2,3); // expected-error{{too few elements}}
   int4 b = (int4)(1,2,3,4,5); // expected-error{{excess elements in vector}}
-  ((float4)(1.0f))++; // expected-error{{cannot increment value of type 
'float4'}}
   int8 d = (int8)(a,(float4)(1)); // expected-error{{initializing 'int' with 
an expression of incompatible type 'float4'}}
   ((int4)(0)).x = 8; // expected-error{{expression is not assignable}}
 }

diff  --git a/clang/test/SemaOpenCL/logical-ops.cl 
b/clang/test/SemaOpenCL/operators.cl
similarity index 90%
rename from clang/test/SemaOpenCL/logical-ops.cl
rename to clang/test/SemaOpenCL/operators.cl
index f6972c46e2ad..cf359acd5acb 100644
--- a/clang/test/SemaOpenCL/logical-ops.cl
+++ b/clang/test/SemaOpenCL/operators.cl
@@ -36,6 +36,8 @@ kernel void float_ops() {
 #if __OPENCL_C_VERSION__ < 120
 // expected-error@-2{{invalid argument type}}
 #endif
+  float fcst = 5.5f;
+  float fremainder = fcst % 2.0f; // expected-error {{invalid operands to 
binary expression}}
 }
 
 kernel void vec_float_ops() {
@@ -56,6 +58,8 @@ kernel void vec_float_ops() {
 #if __OPENCL_C_VERSION__ < 120
 // expected-error@-2{{invalid argument type}}
 #endif
+  float4 f4cst = (float4)(5.5f, 5.5f, 5.5f, 5.5f);
+  float4 f4remainder = f4cst % (float4)(2.0f, 2.0f, 2.0f, 2.0f); // 
expected-error {{invalid operands to binary expression}}
 }
 
 kernel void double_ops() {
@@ -85,6 +89,8 @@ kernel void double_ops() {
 #if __OPENCL_C_VERSION__ < 120
 // expected-error@-2{{invalid argument type}}
 #endif
+  double dcst = 5.5;
+  double dremainder = dcst % 2.0; // expected-error {{invalid operands to 
binary expression}}
 }
 
 kernel void vec_double_ops() {

diff  --git a/clang/test/SemaOpenCL/vector_inc_dec_ops.cl 
b/clang/test/SemaOpenCL/vector_inc_dec_ops.cl
index c65bbcb5b749..533253ee696f 100644
--- a/clang/test/SemaOpenCL/vector_inc_dec_ops.cl
+++ b/clang/test/SemaOpenCL/vector_inc_dec_ops.cl
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
-// expected-no-diagnostics
 
 typedef __attribute__((ext_vector_type(2)))  char char2;
 typedef __attribute__((ext_vector_type(4)))  unsigned int uint4;
 typedef __attribute__((ext_vector_type(8)))  long long8;
+typedef __attribute__((ext_vector_type(4)))  float float4;
 
 void vectorIncrementDecrementOps()
 {
@@ -17,3 +17,10 @@ void vectorIncrementDecrementOps()
   ++B;
   C++;
 }
+
+void invalidIncrementDecrementOps() {
+  ((float4)(1.0f))++; // expected-error{{cannot increment value of type 
'float4'}}
+  float4 i;
+  ++i; // expected-error{{cannot increment value of type '__private float4'}}
+  i--; // expected-error{{cannot decrement value of type '__private float4'}}
+}



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


[llvm-branch-commits] [llvm] 3e8d1e8 - [APSInt][NFC] Clean up doxygen comments

2021-01-22 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2021-01-22T09:23:41Z
New Revision: 3e8d1e8b12ba9017b861fff94afdd4a29b39de17

URL: 
https://github.com/llvm/llvm-project/commit/3e8d1e8b12ba9017b861fff94afdd4a29b39de17
DIFF: 
https://github.com/llvm/llvm-project/commit/3e8d1e8b12ba9017b861fff94afdd4a29b39de17.diff

LOG: [APSInt][NFC] Clean up doxygen comments

Add a Doxygen class comment and clean up other Doxygen comments in
this file while we're at it.

Added: 


Modified: 
llvm/include/llvm/ADT/APSInt.h

Removed: 




diff  --git a/llvm/include/llvm/ADT/APSInt.h b/llvm/include/llvm/ADT/APSInt.h
index 0f991826c457..82e9ba81141f 100644
--- a/llvm/include/llvm/ADT/APSInt.h
+++ b/llvm/include/llvm/ADT/APSInt.h
@@ -18,6 +18,7 @@
 
 namespace llvm {
 
+/// An arbitrary precision integer that knows its signedness.
 class LLVM_NODISCARD APSInt : public APInt {
   bool IsUnsigned;
 
@@ -25,8 +26,7 @@ class LLVM_NODISCARD APSInt : public APInt {
   /// Default constructor that creates an uninitialized APInt.
   explicit APSInt() : IsUnsigned(false) {}
 
-  /// APSInt ctor - Create an APSInt with the specified width, default to
-  /// unsigned.
+  /// Create an APSInt with the specified width, default to unsigned.
   explicit APSInt(uint32_t BitWidth, bool isUnsigned = true)
: APInt(BitWidth, 0), IsUnsigned(isUnsigned) {}
 
@@ -78,11 +78,11 @@ class LLVM_NODISCARD APSInt : public APInt {
   void setIsUnsigned(bool Val) { IsUnsigned = Val; }
   void setIsSigned(bool Val) { IsUnsigned = !Val; }
 
-  /// toString - Append this APSInt to the specified SmallString.
+  /// Append this APSInt to the specified SmallString.
   void toString(SmallVectorImpl &Str, unsigned Radix = 10) const {
 APInt::toString(Str, Radix, isSigned());
   }
-  /// toString - Converts an APInt to a std::string.  This is an inefficient
+  /// Converts an APInt to a std::string.  This is an inefficient
   /// method; you should prefer passing in a SmallString instead.
   std::string toString(unsigned Radix) const {
 return APInt::toString(Radix, isSigned());
@@ -282,15 +282,15 @@ class LLVM_NODISCARD APSInt : public APInt {
 return APSInt(~static_cast(*this), IsUnsigned);
   }
 
-  /// getMaxValue - Return the APSInt representing the maximum integer value
-  ///  with the given bit width and signedness.
+  /// Return the APSInt representing the maximum integer value with the given
+  /// bit width and signedness.
   static APSInt getMaxValue(uint32_t numBits, bool Unsigned) {
 return APSInt(Unsigned ? APInt::getMaxValue(numBits)
: APInt::getSignedMaxValue(numBits), Unsigned);
   }
 
-  /// getMinValue - Return the APSInt representing the minimum integer value
-  ///  with the given bit width and signedness.
+  /// Return the APSInt representing the minimum integer value with the given
+  /// bit width and signedness.
   static APSInt getMinValue(uint32_t numBits, bool Unsigned) {
 return APSInt(Unsigned ? APInt::getMinValue(numBits)
: APInt::getSignedMinValue(numBits), Unsigned);
@@ -331,8 +331,8 @@ class LLVM_NODISCARD APSInt : public APInt {
   static APSInt get(int64_t X) { return APSInt(APInt(64, X), false); }
   static APSInt getUnsigned(uint64_t X) { return APSInt(APInt(64, X), true); }
 
-  /// Profile - Used to insert APSInt objects, or objects that contain APSInt
-  ///  objects, into FoldingSets.
+  /// Used to insert APSInt objects, or objects that contain APSInt objects,
+  /// into FoldingSets.
   void Profile(FoldingSetNodeID& ID) const;
 };
 



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


[llvm-branch-commits] [clang] 0e4d236 - [OpenCL] Warn about side effects for unevaluated vec_step arg

2021-01-05 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2021-01-05T11:51:10Z
New Revision: 0e4d2361b817bd16f97cd45d5792017edc3891ee

URL: 
https://github.com/llvm/llvm-project/commit/0e4d2361b817bd16f97cd45d5792017edc3891ee
DIFF: 
https://github.com/llvm/llvm-project/commit/0e4d2361b817bd16f97cd45d5792017edc3891ee.diff

LOG: [OpenCL] Warn about side effects for unevaluated vec_step arg

The argument to the `vec_step` builtin is not evaluated.  Hoist the
diagnostic for this in `Sema::CheckUnaryExprOrTypeTraitOperand` such
that it comes before `Sema::CheckVecStepTraitOperandType`.

A minor side-effect of this change is that it also produces the
warning for `co_await` and `co_yield` as `sizeof` arguments now, which
seems to be reasonable given that the warning is emitted for `typeid`
already.

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

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/coroutines.cpp
clang/test/SemaOpenCL/vec_step.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 28f4c5bbf19b..d8bfd3f8b46a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4089,7 +4089,7 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
 
   bool IsUnevaluatedOperand =
   (ExprKind == UETT_SizeOf || ExprKind == UETT_AlignOf ||
-   ExprKind == UETT_PreferredAlignOf);
+   ExprKind == UETT_PreferredAlignOf || ExprKind == UETT_VecStep);
   if (IsUnevaluatedOperand) {
 ExprResult Result = CheckUnevaluatedOperand(E);
 if (Result.isInvalid())
@@ -4097,6 +4097,16 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
 E = Result.get();
   }
 
+  // The operand for sizeof and alignof is in an unevaluated expression 
context,
+  // so side effects could result in unintended consequences.
+  // Exclude instantiation-dependent expressions, because 'sizeof' is sometimes
+  // used to build SFINAE gadgets.
+  // FIXME: Should we consider instantiation-dependent operands to 'alignof'?
+  if (IsUnevaluatedOperand && !inTemplateInstantiation() &&
+  !E->isInstantiationDependent() &&
+  E->HasSideEffects(Context, false))
+Diag(E->getExprLoc(), diag::warn_side_effects_unevaluated_context);
+
   if (ExprKind == UETT_VecStep)
 return CheckVecStepTraitOperandType(*this, ExprTy, E->getExprLoc(),
 E->getSourceRange());
@@ -4133,16 +4143,6 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
 return true;
   }
 
-  // The operand for sizeof and alignof is in an unevaluated expression 
context,
-  // so side effects could result in unintended consequences.
-  // Exclude instantiation-dependent expressions, because 'sizeof' is sometimes
-  // used to build SFINAE gadgets.
-  // FIXME: Should we consider instantiation-dependent operands to 'alignof'?
-  if (IsUnevaluatedOperand && !inTemplateInstantiation() &&
-  !E->isInstantiationDependent() &&
-  E->HasSideEffects(Context, false))
-Diag(E->getExprLoc(), diag::warn_side_effects_unevaluated_context);
-
   if (CheckObjCTraitOperandConstraints(*this, ExprTy, E->getExprLoc(),
E->getSourceRange(), ExprKind))
 return true;

diff  --git a/clang/test/SemaCXX/coroutines.cpp 
b/clang/test/SemaCXX/coroutines.cpp
index f354b1f2a4bb..d7208f9a1010 100644
--- a/clang/test/SemaCXX/coroutines.cpp
+++ b/clang/test/SemaCXX/coroutines.cpp
@@ -328,6 +328,7 @@ void unevaluated() {
 // expected-warning@-1 {{declaration does not declare 
anything}}
   sizeof(co_await a); // expected-error {{'co_await' cannot be used in an 
unevaluated context}}
   // expected-error@-1 {{invalid application of 'sizeof' 
to an incomplete type 'void'}}
+  // expected-warning@-2 {{expression with side effects 
has no effect in an unevaluated context}}
   typeid(co_await a); // expected-error {{'co_await' cannot be used in an 
unevaluated context}}
   // expected-warning@-1 {{expression with side effects 
has no effect in an unevaluated context}}
   // expected-warning@-2 {{expression result unused}}
@@ -335,6 +336,7 @@ void unevaluated() {
 // expected-warning@-1 {{declaration does not declare 
anything}}
   sizeof(co_yield 2); // expected-error {{'co_yield' cannot be used in an 
unevaluated context}}
   // expected-error@-1 {{invalid application of 'sizeof' 
to an incomplete type 'void'}}
+  // expected-warning@-2 {{expression with side effects 
has no effect in an unevaluated context}}
   typeid(co_yield 3); // expected-error {{'co_yield' cannot be used in an 
unevaluated context}}
   // expected-warning@-1 {{expression with side effects 
has no effect in an unevaluated context}}
   // expected-warning@-2 {{expres

[llvm-branch-commits] [clang] 29d375f - [OpenCL][NFC] Improve OpenCL test file naming

2021-01-06 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2021-01-06T14:16:44Z
New Revision: 29d375f5ff27dc49c2c88c2ec1093cfcd826d449

URL: 
https://github.com/llvm/llvm-project/commit/29d375f5ff27dc49c2c88c2ec1093cfcd826d449
DIFF: 
https://github.com/llvm/llvm-project/commit/29d375f5ff27dc49c2c88c2ec1093cfcd826d449.diff

LOG: [OpenCL][NFC] Improve OpenCL test file naming

Change "negative" into "invalid" and put "invalid" at the beginning of
the file name, following the bulk of the invalid tests in the
SemaOpenCL directory.

Use the "invalid-" prefix only for tests that contain only invalid
constructs.

Drop the "valid" suffix for CodeGen tests, as inputs in this directory
are supposed to be valid anyway.

Added: 
clang/test/CodeGenOpenCL/vector_literals.cl
clang/test/CodeGenOpenCL/vector_shufflevector.cl
clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
clang/test/SemaOpenCL/invalid-vector-literals.cl
clang/test/SemaOpenCL/vector-conv.cl
clang/test/SemaOpenCLCXX/invalid-kernel.cl

Modified: 


Removed: 
clang/test/CodeGenOpenCL/vector_literals_valid.cl
clang/test/CodeGenOpenCL/vector_shufflevector_valid.cl
clang/test/SemaOpenCL/pipes-1.2-negative.cl
clang/test/SemaOpenCL/vector_conv_invalid.cl
clang/test/SemaOpenCL/vector_literals_invalid.cl
clang/test/SemaOpenCLCXX/kernel_invalid.cl



diff  --git a/clang/test/CodeGenOpenCL/vector_literals_valid.cl 
b/clang/test/CodeGenOpenCL/vector_literals.cl
similarity index 100%
rename from clang/test/CodeGenOpenCL/vector_literals_valid.cl
rename to clang/test/CodeGenOpenCL/vector_literals.cl

diff  --git a/clang/test/CodeGenOpenCL/vector_shufflevector_valid.cl 
b/clang/test/CodeGenOpenCL/vector_shufflevector.cl
similarity index 100%
rename from clang/test/CodeGenOpenCL/vector_shufflevector_valid.cl
rename to clang/test/CodeGenOpenCL/vector_shufflevector.cl

diff  --git a/clang/test/SemaOpenCL/pipes-1.2-negative.cl 
b/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
similarity index 100%
rename from clang/test/SemaOpenCL/pipes-1.2-negative.cl
rename to clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl

diff  --git a/clang/test/SemaOpenCL/vector_literals_invalid.cl 
b/clang/test/SemaOpenCL/invalid-vector-literals.cl
similarity index 100%
rename from clang/test/SemaOpenCL/vector_literals_invalid.cl
rename to clang/test/SemaOpenCL/invalid-vector-literals.cl

diff  --git a/clang/test/SemaOpenCL/vector_conv_invalid.cl 
b/clang/test/SemaOpenCL/vector-conv.cl
similarity index 100%
rename from clang/test/SemaOpenCL/vector_conv_invalid.cl
rename to clang/test/SemaOpenCL/vector-conv.cl

diff  --git a/clang/test/SemaOpenCLCXX/kernel_invalid.cl 
b/clang/test/SemaOpenCLCXX/invalid-kernel.cl
similarity index 100%
rename from clang/test/SemaOpenCLCXX/kernel_invalid.cl
rename to clang/test/SemaOpenCLCXX/invalid-kernel.cl



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


[llvm-branch-commits] [clang] 633cae3 - [OpenCL] Move kernel arg type tests into one file

2020-11-25 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2020-11-25T10:20:30Z
New Revision: 633cae30599cc5ec99f679079499a1f2ca4d3af3

URL: 
https://github.com/llvm/llvm-project/commit/633cae30599cc5ec99f679079499a1f2ca4d3af3
DIFF: 
https://github.com/llvm/llvm-project/commit/633cae30599cc5ec99f679079499a1f2ca4d3af3.diff

LOG: [OpenCL] Move kernel arg type tests into one file

Keep all kernel parameter type diagnostic tests in
invalid-kernel-parameters.cl .

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

Added: 


Modified: 
clang/test/SemaOpenCL/invalid-kernel-parameters.cl
clang/test/SemaOpenCL/invalid-kernel.cl

Removed: 




diff  --git a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl 
b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
index 48de39d0f87e..26859ee62cae 100644
--- a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,9 +1,21 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown 
-cl-std=CL2.0
 
 kernel void half_arg(half x) { } // expected-error{{declaring function 
parameter of type '__private half' is not allowed; did you forget * ?}}
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
+// expected-error@+1{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+kernel void no_ptrptr(global int * global *i) { }
+
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_privateptr(__private int *i) { }
+
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_privatearray(__private int i[]) { }
+
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_addrsp_ptr(int *ptr) { }
 
 // Disallowed: parameters with type
 // bool, half, size_t, ptr
diff _t, intptr_t, and uintptr_t
@@ -65,14 +77,14 @@ kernel void image_in_struct_arg(FooImage2D arg) { } // 
expected-error{{struct ke
 
 typedef struct Foo // expected-note{{within field of type 'Foo' declared here}}
 {
-  int* ptrField; // expected-note{{field of illegal pointer type '__private 
int *' declared here}}
+  int* ptrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
 } Foo;
 
 kernel void pointer_in_struct_arg(Foo arg) { } // expected-error{{struct 
kernel parameters may not contain pointers}}
 
 typedef union FooUnion // expected-note{{within field of type 'FooUnion' 
declared here}}
 {
-  int* ptrField; // expected-note{{field of illegal pointer type '__private 
int *' declared here}}
+  int* ptrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
 } FooUnion;
 
 kernel void pointer_in_union_arg(FooUnion arg) { }// expected-error{{union 
kernel parameters may not contain pointers}}
@@ -82,7 +94,7 @@ typedef struct NestedPointer // expected-note 2 {{within 
field of type 'NestedPo
   int x;
   struct InnerNestedPointer
   {
-int* ptrField; // expected-note 3 {{field of illegal pointer type 
'__private int *' declared here}}
+int* ptrField; // expected-note-re 3 {{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
   } inner; // expected-note 3 {{within field of type 'struct 
InnerNestedPointer' declared here}}
 } NestedPointer;
 
@@ -96,7 +108,7 @@ struct NestedPointerComplex // expected-note{{within field 
of type 'NestedPointe
   struct InnerNestedPointerComplex
   {
 int innerFoo;
-int* innerPtrField; // expected-note{{field of illegal pointer type 
'__private int *' declared here}}
+int* innerPtrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
   } inner; // expected-note{{within field of type 'struct 
InnerNestedPointerComplex' declared here}}
 
   float y;
@@ -167,8 +179,7 @@ kernel void pointer_in_nested_struct_arg_2(struct Valid 
valid, struct NestedPoin
 
 struct ArrayOfPtr // expected-note{{within field of type 'ArrayOfPtr' declared 
here}}
 {
-  float *arr[3]; // expected-note{{field of illegal type '__private float 
*[3]' declared here}}
- // expected-note@-1{{field of illegal type '__private float 
*[3]' declared here}}
+  float *arr[3]; // expected-note-re 2{{field of illegal type 
'__{{private|generic}} float *[3]' declared here}}
 };
 kernel void array_of_ptr(struct ArrayOfPtr arr) {} // expected-error{{struct 
kernel parameters may not contain pointers}}
 

diff  --git a/clang/test/SemaOpenCL/invalid-kernel.cl 
b/clang/test/SemaOpenCL/invalid-kernel.cl
index 031f6061a3b9..fd9cd6def00e 100644
--- a/clang/test/SemaOpenCL/invalid-kernel.cl
+++ b/clang/test/SemaOpenCL/invalid-k

[llvm-branch-commits] [clang] 523775f - [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

2020-12-01 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2020-12-01T11:33:10Z
New Revision: 523775f96742e6f099b3498b6606b7250c0af841

URL: 
https://github.com/llvm/llvm-project/commit/523775f96742e6f099b3498b6606b7250c0af841
DIFF: 
https://github.com/llvm/llvm-project/commit/523775f96742e6f099b3498b6606b7250c0af841.diff

LOG: [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

The restriction on pointer-to-pointer kernel arguments has been
relaxed in OpenCL 2.0.  Apply the same address space restrictions for
pointer argument types to the inner pointer types.

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaOpenCL/invalid-kernel-parameters.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9c282a73e0ed..2116b3f7b78e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8591,12 +8591,21 @@ static bool isOpenCLSizeDependentType(ASTContext &C, 
QualType Ty) {
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
   if (PT->isPointerType()) {
 QualType PointeeType = PT->getPointeeType();
-if (PointeeType->isPointerType())
-  return PtrPtrKernelParam;
 if (PointeeType.getAddressSpace() == LangAS::opencl_generic ||
 PointeeType.getAddressSpace() == LangAS::opencl_private ||
 PointeeType.getAddressSpace() == LangAS::Default)
   return InvalidAddrSpacePtrKernelParam;
+
+if (PointeeType->isPointerType()) {
+  // This is a pointer to pointer parameter.
+  // Recursively check inner type.
+  OpenCLParamType ParamKind = getOpenCLKernelParameterType(S, PointeeType);
+  if (ParamKind == InvalidAddrSpacePtrKernelParam ||
+  ParamKind == InvalidKernelParam)
+return ParamKind;
+
+  return PtrPtrKernelParam;
+}
 return PtrKernelParam;
   }
 
@@ -8649,11 +8658,17 @@ static void checkIsValidOpenCLKernelParameter(
 
   switch (getOpenCLKernelParameterType(S, PT)) {
   case PtrPtrKernelParam:
-// OpenCL v1.2 s6.9.a:
-// A kernel function argument cannot be declared as a
-// pointer to a pointer type.
-S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
-D.setInvalidType();
+// OpenCL v3.0 s6.11.a:
+// A kernel function argument cannot be declared as a pointer to a pointer
+// type. [...] This restriction only applies to OpenCL C 1.2 or below.
+if (S.getLangOpts().OpenCLVersion < 120 &&
+!S.getLangOpts().OpenCLCPlusPlus) {
+  S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
+  D.setInvalidType();
+  return;
+}
+
+ValidTypes.insert(PT.getTypePtr());
 return;
 
   case InvalidAddrSpacePtrKernelParam:

diff  --git a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl 
b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
index 26859ee62cae..9fce92dbd6c3 100644
--- a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -5,8 +5,14 @@ kernel void half_arg(half x) { } // expected-error{{declaring 
function parameter
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
-// expected-error@+1{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+#endif
 kernel void no_ptrptr(global int * global *i) { }
+kernel void no_lptrcptr(constant int * local *i) { }
+kernel void no_ptrptrptr(global int * global * global *i) { }
 
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_privateptr(__private int *i) { }
@@ -17,6 +23,15 @@ __kernel void no_privatearray(__private int i[]) { }
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_ptr_private_ptr(private int * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+kernel void no_ptr_private_ptr_ptr(global int * private * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+#endif
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptr

[llvm-branch-commits] [clang] 7ec6188 - [OpenCL] Add some more kernel argument tests

2020-12-03 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2020-12-03T10:21:29Z
New Revision: 7ec61889214d98f09eec7f18d0db66dcfdc68323

URL: 
https://github.com/llvm/llvm-project/commit/7ec61889214d98f09eec7f18d0db66dcfdc68323
DIFF: 
https://github.com/llvm/llvm-project/commit/7ec61889214d98f09eec7f18d0db66dcfdc68323.diff

LOG: [OpenCL] Add some more kernel argument tests

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

Added: 


Modified: 
clang/test/SemaOpenCL/invalid-kernel-parameters.cl

Removed: 




diff  --git a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl 
b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
index 9fce92dbd6c3..96e6f7886b73 100644
--- a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -23,7 +23,12 @@ __kernel void no_privatearray(__private int i[]) { }
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_defaultarray(int i[]) { }
+
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_genericptr(generic int *ptr) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 kernel void no_ptr_private_ptr(private int * global *i) { }
 // expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
@@ -32,6 +37,8 @@ kernel void no_ptr_private_ptr_ptr(global int * private * 
global *i) { }
 // expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 #endif
 
+void no_addrspace_param(global int x) { } // expected-error{{parameter may not 
be qualified with an address space}}
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptr
diff _t, intptr_t, and uintptr_t
 // or a struct / union with any of these types in them



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


[llvm-branch-commits] [clang] b65707e - [ReleaseNotes] Fix typos

2020-02-27 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2020-02-27T14:42:46Z
New Revision: b65707e4818e3b5694786b90e6ebdaa17910b016

URL: 
https://github.com/llvm/llvm-project/commit/b65707e4818e3b5694786b90e6ebdaa17910b016
DIFF: 
https://github.com/llvm/llvm-project/commit/b65707e4818e3b5694786b90e6ebdaa17910b016.diff

LOG: [ReleaseNotes] Fix typos

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d959791d75b6..c3097bcba8dc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -292,7 +292,7 @@ Objective-C Language Changes in Clang
 
   One particular issue you may run into is attempting to use a class
   as a key in a dictionary literal. This will now result in an error,
-  because ``Class`` is not convertable to ``id``. (Note that
+  because ``Class`` is not convertible to ``id``. (Note that
   this was already a warning in Objective-C mode.) While an arbitrary
   ``Class`` object is not guaranteed to implement ``NSCopying``, the
   default metaclass implementation does. Therefore, the recommended
@@ -500,7 +500,7 @@ Static Analyzer
 
 - ``deadcode.DeadStores`` now warns about nested dead stores.
 
-- Condition values that are relevant to the occurance of a bug are far better
+- Condition values that are relevant to the occurrence of a bug are far better
   explained in bug reports.
 
 - Despite still being at an alpha stage, checkers implementing taint analyses



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


[llvm-branch-commits] [clang] clang: Fix broken implicit cast to generic address space (PR #138863)

2025-05-07 Thread Sven van Haastregt via llvm-branch-commits

https://github.com/svenvh approved this pull request.


https://github.com/llvm/llvm-project/pull/138863
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] clang/OpenCL: Fix special casing OpenCL in call emission (PR #138864)

2025-05-07 Thread Sven van Haastregt via llvm-branch-commits

https://github.com/svenvh approved this pull request.


https://github.com/llvm/llvm-project/pull/138864
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits