[PATCH] D41284: [Concepts] Associated constraints infrastructure.

2018-08-19 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: 
test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/var-template-decl.cpp:10
+
+template  requires bool(U())
+int B::A = int(U());

saar.raz wrote:
> saar.raz wrote:
> > Rakete wrote:
> > > Quuxplusone wrote:
> > > > saar.raz wrote:
> > > > > Quuxplusone wrote:
> > > > > > For my own edification, could you explain whether, given
> > > > > > 
> > > > > > #define BOOL bool
> > > > > > using typedef_for_bool = bool;
> > > > > > 
> > > > > > you'd expect to diagnose a redeclaration of `B::A` with associated 
> > > > > > constraint
> > > > > > 
> > > > > > requires bool( U() )  // extra whitespace
> > > > > > 
> > > > > > or
> > > > > > 
> > > > > > requires BOOL(U())  // different spelling of `bool`
> > > > > > 
> > > > > > or
> > > > > > 
> > > > > > requires typedef_for_bool(U())  // different spelling of `bool`
> > > > > > 
> > > > > > ? My naive reading of N4762 temp.constr.atomic/2 says that none of 
> > > > > > these constraints (on line 10) would be "identical" to the 
> > > > > > constraint on line 6... but then I don't understand what's the 
> > > > > > salient difference between line 10 (which apparently gives no 
> > > > > > error) and line 22 (which apparently gives an error).
> > > > > Line 22 has a not (!) operator in front of the bool(), I guess you 
> > > > > missed that? 
> > > > I saw the `!`... but I don't understand how the compiler "knows" that 
> > > > `!bool(U())` is "different" from `bool(T())` in a way that doesn't 
> > > > equally apply to `bool(U())`.
> > > > 
> > > > Or suppose the constraint on line 10 was `requires bool(U())==true`... 
> > > > would that give a diagnostic?
> > > `bool(T())` and `bool(U())` are identical because they have the same 
> > > parameter mappings.
> > > 
> > > The "identical" requirement applies to the actual grammar composition of 
> > > the expression, so `bool(T())` would be different to `bool(T()) == true`.
> > > 
> > > At least that's how I understand it.
> > OK, I can see where the confusion is coming from.
> > 
> > The way it works (in clang, at least) - is that the compiler pays no 
> > attention to the name of a template parameter for any purpose other than 
> > actually finding it in the first place - once it is found, it is 'stored' 
> > simply as bool(()) where the first 0 is the depth 
> > of the template parameter list of the parameter in question (in case of a 
> > template within a template) and the second 0 is the index of the template 
> > parameter within that list.
> > 
> > I believe this treatment stems from [temp.over.link]p6 "When determining 
> > whether types or qualified-concept-names are equivalent, the rules above 
> > are used to compare expressions involving template parameters"
> Correction - p5 describes this better (see also the example in p4) 
Okay, I can see how this matches the apparent intent of 
http://eel.is/c++draft/temp.over.link#5 . I guess a strict reading of that 
passage would mean that my `BOOL` and `typedef_for_bool` versions should give 
diagnostics, and so should
```
#define V(x) U
template  requires bool(V(x) ())
```
but no diagnostic is expected for
```
#define V U
template  requires bool(V ())
```
Anyway, sounds like this rabbit hole is out-of-scope for this review, anyway, 
so I'll be quiet now. :)


Repository:
  rC Clang

https://reviews.llvm.org/D41284



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


r340135 - [CodeGen] add rotate builtins

2018-08-19 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Sun Aug 19 06:12:40 2018
New Revision: 340135

URL: http://llvm.org/viewvc/llvm-project?rev=340135&view=rev
Log:
[CodeGen] add rotate builtins

This exposes the LLVM funnel shift intrinsics as more familiar bit rotation 
functions in clang 
(when both halves of a funnel shift are the same value, it's a rotate).

We're free to name these as we want because we're not copying gcc, but if 
there's some other 
existing art (eg, the microsoft ops that are modified in this patch) that we 
want to replicate, 
we can change the names.

The funnel shift intrinsics were added here:
D49242

With improved codegen in:
rL337966
rL339359

And basic IR optimization added in:
rL338218
rL340022

...so these are expected to produce asm output that's equal or better to the 
multi-instruction 
alternatives using primitive C/IR ops.

In the motivating loop example from PR37387:
https://bugs.llvm.org/show_bug.cgi?id=37387#c7
...we get the expected 'rolq' x86 instructions if we substitute the rotate 
builtin into the source.

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

Added:
cfe/trunk/test/CodeGen/builtin-rotate.c
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=340135&r1=340134&r2=340135&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Sun Aug 19 06:12:40 2018
@@ -1739,6 +1739,70 @@ The '``__builtin_bitreverse``' family of
 the bitpattern of an integer value; for example ``0b10110110`` becomes
 ``0b01101101``.
 
+``__builtin_rotateleft``
+
+
+* ``__builtin_rotateleft8``
+* ``__builtin_rotateleft16``
+* ``__builtin_rotateleft32``
+* ``__builtin_rotateleft64``
+
+**Syntax**:
+
+.. code-block:: c++
+
+ __builtin_rotateleft32(x, y)
+
+**Examples**:
+
+.. code-block:: c++
+
+  uint8_t rot_x = __builtin_rotateleft8(x, y);
+  uint16_t rot_x = __builtin_rotateleft16(x, y);
+  uint32_t rot_x = __builtin_rotateleft32(x, y);
+  uint64_t rot_x = __builtin_rotateleft64(x, y);
+
+**Description**:
+
+The '``__builtin_rotateleft``' family of builtins is used to rotate
+the bits in the first argument by the amount in the second argument. 
+For example, ``0b1110`` rotated left by 11 becomes ``0b00110100``.
+The shift value is treated as an unsigned amount modulo the size of
+the arguments. Both arguments and the result have the bitwidth specified
+by the name of the builtin.
+
+``__builtin_rotateright``
+
+
+* ``__builtin_rotateright8``
+* ``__builtin_rotateright16``
+* ``__builtin_rotateright32``
+* ``__builtin_rotateright64``
+
+**Syntax**:
+
+.. code-block:: c++
+
+ __builtin_rotateright32(x, y)
+
+**Examples**:
+
+.. code-block:: c++
+
+  uint8_t rot_x = __builtin_rotateright8(x, y);
+  uint16_t rot_x = __builtin_rotateright16(x, y);
+  uint32_t rot_x = __builtin_rotateright32(x, y);
+  uint64_t rot_x = __builtin_rotateright64(x, y);
+
+**Description**:
+
+The '``__builtin_rotateright``' family of builtins is used to rotate
+the bits in the first argument by the amount in the second argument. 
+For example, ``0b1110`` rotated right by 3 becomes ``0b1101``.
+The shift value is treated as an unsigned amount modulo the size of
+the arguments. Both arguments and the result have the bitwidth specified
+by the name of the builtin.
+
 ``__builtin_unreachable``
 -
 

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=340135&r1=340134&r2=340135&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Sun Aug 19 06:12:40 2018
@@ -428,6 +428,15 @@ BUILTIN(__builtin_bitreverse16, "UsUs",
 BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
 BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
 
+BUILTIN(__builtin_rotateleft8, "UcUcUc", "nc")
+BUILTIN(__builtin_rotateleft16, "UsUsUs", "nc")
+BUILTIN(__builtin_rotateleft32, "UiUiUi", "nc")
+BUILTIN(__builtin_rotateleft64, "ULLiULLiULLi", "nc")
+BUILTIN(__builtin_rotateright8, "UcUcUc", "nc")
+BUILTIN(__builtin_rotateright16, "UsUsUs", "nc")
+BUILTIN(__builtin_rotateright32, "UiUiUi", "nc")
+BUILTIN(__builtin_rotateright64, "ULLiULLiULLi", "nc")
+
 // Random GCC builtins
 BUILTIN(__builtin_constant_p, "i.", "nctu")
 BUILTIN(__builtin_classify_type, "i.", "nctu")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=340135&r1=340134&r2=340135&view=diff
==

[PATCH] D50924: [CodeGen] add rotate builtins

2018-08-19 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340135: [CodeGen] add rotate builtins (authored by spatel, 
committed by ).
Herald added a subscriber: kristina.

Repository:
  rC Clang

https://reviews.llvm.org/D50924

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtin-rotate.c
  test/CodeGen/ms-intrinsics-rotations.c

Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1647,46 +1647,6 @@
  "cast");
 return RValue::get(Result);
   }
-  case Builtin::BI_rotr8:
-  case Builtin::BI_rotr16:
-  case Builtin::BI_rotr:
-  case Builtin::BI_lrotr:
-  case Builtin::BI_rotr64: {
-Value *Val = EmitScalarExpr(E->getArg(0));
-Value *Shift = EmitScalarExpr(E->getArg(1));
-
-llvm::Type *ArgType = Val->getType();
-Shift = Builder.CreateIntCast(Shift, ArgType, false);
-unsigned ArgWidth = ArgType->getIntegerBitWidth();
-Value *Mask = llvm::ConstantInt::get(ArgType, ArgWidth - 1);
-
-Value *RightShiftAmt = Builder.CreateAnd(Shift, Mask);
-Value *RightShifted = Builder.CreateLShr(Val, RightShiftAmt);
-Value *LeftShiftAmt = Builder.CreateAnd(Builder.CreateNeg(Shift), Mask);
-Value *LeftShifted = Builder.CreateShl(Val, LeftShiftAmt);
-Value *Result = Builder.CreateOr(LeftShifted, RightShifted);
-return RValue::get(Result);
-  }
-  case Builtin::BI_rotl8:
-  case Builtin::BI_rotl16:
-  case Builtin::BI_rotl:
-  case Builtin::BI_lrotl:
-  case Builtin::BI_rotl64: {
-Value *Val = EmitScalarExpr(E->getArg(0));
-Value *Shift = EmitScalarExpr(E->getArg(1));
-
-llvm::Type *ArgType = Val->getType();
-Shift = Builder.CreateIntCast(Shift, ArgType, false);
-unsigned ArgWidth = ArgType->getIntegerBitWidth();
-Value *Mask = llvm::ConstantInt::get(ArgType, ArgWidth - 1);
-
-Value *LeftShiftAmt = Builder.CreateAnd(Shift, Mask);
-Value *LeftShifted = Builder.CreateShl(Val, LeftShiftAmt);
-Value *RightShiftAmt = Builder.CreateAnd(Builder.CreateNeg(Shift), Mask);
-Value *RightShifted = Builder.CreateLShr(Val, RightShiftAmt);
-Value *Result = Builder.CreateOr(LeftShifted, RightShifted);
-return RValue::get(Result);
-  }
   case Builtin::BI__builtin_unpredictable: {
 // Always return the argument of __builtin_unpredictable. LLVM does not
 // handle this builtin. Metadata for this builtin should be added directly
@@ -1741,6 +1701,43 @@
   case Builtin::BI__builtin_bitreverse64: {
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bitreverse));
   }
+  case Builtin::BI__builtin_rotateleft8:
+  case Builtin::BI__builtin_rotateleft16:
+  case Builtin::BI__builtin_rotateleft32:
+  case Builtin::BI__builtin_rotateleft64:
+  case Builtin::BI_rotl8: // Microsoft variants of rotate left
+  case Builtin::BI_rotl16:
+  case Builtin::BI_rotl:
+  case Builtin::BI_lrotl:
+  case Builtin::BI_rotl64: {
+llvm::Value *Src = EmitScalarExpr(E->getArg(0));
+llvm::Value *ShiftAmt = EmitScalarExpr(E->getArg(1));
+// The builtin's shift arg may have a different type than the source arg and
+// result, but the LLVM intrinsic uses the same type for all values.
+llvm::Type *Ty = Src->getType();
+ShiftAmt = Builder.CreateIntCast(ShiftAmt, Ty, false);
+Value *F = CGM.getIntrinsic(Intrinsic::fshl, Ty);
+return RValue::get(Builder.CreateCall(F, { Src, Src, ShiftAmt }));
+  }
+  case Builtin::BI__builtin_rotateright8:
+  case Builtin::BI__builtin_rotateright16:
+  case Builtin::BI__builtin_rotateright32:
+  case Builtin::BI__builtin_rotateright64:
+  case Builtin::BI_rotr8: // Microsoft variants of rotate right
+  case Builtin::BI_rotr16:
+  case Builtin::BI_rotr:
+  case Builtin::BI_lrotr:
+  case Builtin::BI_rotr64: {
+llvm::Value *Src = EmitScalarExpr(E->getArg(0));
+llvm::Value *ShiftAmt = EmitScalarExpr(E->getArg(1));
+// The builtin's shift arg may have a different type than the source arg and
+// result, but the LLVM intrinsic uses the same type for all values.
+llvm::Type *Ty = Src->getType();
+ShiftAmt = Builder.CreateIntCast(ShiftAmt, Ty, false);
+Value *F = CGM.getIntrinsic(Intrinsic::fshr, Ty);
+return RValue::get(Builder.CreateCall(F, { Src, Src, ShiftAmt }));
+  }
+
   case Builtin::BI__builtin_object_size: {
 unsigned Type =
 E->getArg(1)->EvaluateKnownConstInt(getContext()).getZExtValue();
Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1739,6 +1739,70 @@
 the bitpattern of an integer value; for example ``0b10110110`` becomes
 ``0b01101101``.
 
+``__builtin_rotateleft``
+
+
+* ``__builtin_rotateleft8``
+* ``__builtin_rotateleft16``
+* ``__builtin_rotateleft32``
+* ``

[PATCH] D50737: [ASTImporter] Add test for CXXNoexceptExpr

2018-08-19 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D50737



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


[PATCH] D50932: [ASTImporter] Add test for C++ casts and fix broken const_cast importing.

2018-08-19 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

Thank you!




Comment at: tools/clang-import-test/clang-import-test.cpp:197
   Inv->getLangOpts()->DollarIdents = true;
+  Inv->getLangOpts()->RTTI = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);

Is this option set to check `dynamic_cast`?


Repository:
  rC Clang

https://reviews.llvm.org/D50932



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


r340136 - revert r340135: [CodeGen] add rotate builtins

2018-08-19 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Sun Aug 19 06:48:06 2018
New Revision: 340136

URL: http://llvm.org/viewvc/llvm-project?rev=340136&view=rev
Log:
revert r340135: [CodeGen] add rotate builtins

At least a couple of bots (PPC only?) are showing the compiler dying while 
trying to compile:
http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/11065/steps/build%20stage%201/logs/stdio
http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/18267/steps/build%20stage%201/logs/stdio

Removed:
cfe/trunk/test/CodeGen/builtin-rotate.c
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=340136&r1=340135&r2=340136&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Sun Aug 19 06:48:06 2018
@@ -1739,70 +1739,6 @@ The '``__builtin_bitreverse``' family of
 the bitpattern of an integer value; for example ``0b10110110`` becomes
 ``0b01101101``.
 
-``__builtin_rotateleft``
-
-
-* ``__builtin_rotateleft8``
-* ``__builtin_rotateleft16``
-* ``__builtin_rotateleft32``
-* ``__builtin_rotateleft64``
-
-**Syntax**:
-
-.. code-block:: c++
-
- __builtin_rotateleft32(x, y)
-
-**Examples**:
-
-.. code-block:: c++
-
-  uint8_t rot_x = __builtin_rotateleft8(x, y);
-  uint16_t rot_x = __builtin_rotateleft16(x, y);
-  uint32_t rot_x = __builtin_rotateleft32(x, y);
-  uint64_t rot_x = __builtin_rotateleft64(x, y);
-
-**Description**:
-
-The '``__builtin_rotateleft``' family of builtins is used to rotate
-the bits in the first argument by the amount in the second argument. 
-For example, ``0b1110`` rotated left by 11 becomes ``0b00110100``.
-The shift value is treated as an unsigned amount modulo the size of
-the arguments. Both arguments and the result have the bitwidth specified
-by the name of the builtin.
-
-``__builtin_rotateright``
-
-
-* ``__builtin_rotateright8``
-* ``__builtin_rotateright16``
-* ``__builtin_rotateright32``
-* ``__builtin_rotateright64``
-
-**Syntax**:
-
-.. code-block:: c++
-
- __builtin_rotateright32(x, y)
-
-**Examples**:
-
-.. code-block:: c++
-
-  uint8_t rot_x = __builtin_rotateright8(x, y);
-  uint16_t rot_x = __builtin_rotateright16(x, y);
-  uint32_t rot_x = __builtin_rotateright32(x, y);
-  uint64_t rot_x = __builtin_rotateright64(x, y);
-
-**Description**:
-
-The '``__builtin_rotateright``' family of builtins is used to rotate
-the bits in the first argument by the amount in the second argument. 
-For example, ``0b1110`` rotated right by 3 becomes ``0b1101``.
-The shift value is treated as an unsigned amount modulo the size of
-the arguments. Both arguments and the result have the bitwidth specified
-by the name of the builtin.
-
 ``__builtin_unreachable``
 -
 

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=340136&r1=340135&r2=340136&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Sun Aug 19 06:48:06 2018
@@ -428,15 +428,6 @@ BUILTIN(__builtin_bitreverse16, "UsUs",
 BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
 BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
 
-BUILTIN(__builtin_rotateleft8, "UcUcUc", "nc")
-BUILTIN(__builtin_rotateleft16, "UsUsUs", "nc")
-BUILTIN(__builtin_rotateleft32, "UiUiUi", "nc")
-BUILTIN(__builtin_rotateleft64, "ULLiULLiULLi", "nc")
-BUILTIN(__builtin_rotateright8, "UcUcUc", "nc")
-BUILTIN(__builtin_rotateright16, "UsUsUs", "nc")
-BUILTIN(__builtin_rotateright32, "UiUiUi", "nc")
-BUILTIN(__builtin_rotateright64, "ULLiULLiULLi", "nc")
-
 // Random GCC builtins
 BUILTIN(__builtin_constant_p, "i.", "nctu")
 BUILTIN(__builtin_classify_type, "i.", "nctu")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=340136&r1=340135&r2=340136&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Aug 19 06:48:06 2018
@@ -1647,6 +1647,46 @@ RValue CodeGenFunction::EmitBuiltinExpr(
  "cast");
 return RValue::get(Result);
   }
+  case Builtin::BI_rotr8:
+  case Builtin::BI_rotr16:
+  case Builtin::BI_rotr:
+  case Builtin::BI_lrotr:
+  case Builtin::BI_rotr64: {
+Value *Val = EmitScalarExpr(E->getArg(0));
+Value *Shift = EmitScalarExpr(E->getArg(1));
+
+llvm::Type *Arg

[PATCH] D50924: [CodeGen] add rotate builtins

2018-08-19 Thread Sanjay Patel via Phabricator via cfe-commits
spatel reopened this revision.
spatel added a comment.
This revision is now accepted and ready to land.

Reopening because I reverted at https://reviews.llvm.org/rL340136. Not sure yet 
what is causing the problem on those bots.


Repository:
  rC Clang

https://reviews.llvm.org/D50924



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


[PATCH] D50924: [CodeGen] add rotate builtins

2018-08-19 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In https://reviews.llvm.org/D50924#1205310, @spatel wrote:

> Reopening because I reverted at https://reviews.llvm.org/rL340136. Not sure 
> yet what is causing the problem on those bots.


The common trait for those failures appears to be that the host compiler is:
gcc version 7.3.1 20180130 (Red Hat 7.3.1-2) (GCC)

...but that compiler is crashing while compiling a file that this patch does 
not actually touch. Anyone know what our commit policy suggests for this 
situation?


Repository:
  rC Clang

https://reviews.llvm.org/D50924



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


[PATCH] D50942: SemaExceptionSpec: ensure old/new specs are both parsed and evaluated when comparing

2018-08-19 Thread Victor Zverovich via Phabricator via cfe-commits
vitaut added inline comments.



Comment at: lib/Sema/SemaExceptionSpec.cpp:915
+  // lexically-surrounding class.
+  switch (New->getType()->castAs()->getExceptionSpecType()) 
{
+  case EST_Unparsed:

Did you mean `Old` here?


Repository:
  rC Clang

https://reviews.llvm.org/D50942



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


r340137 - [CodeGen] add/fix rotate builtins that map to LLVM funnel shift (retry)

2018-08-19 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Sun Aug 19 07:44:47 2018
New Revision: 340137

URL: http://llvm.org/viewvc/llvm-project?rev=340137&view=rev
Log:
[CodeGen] add/fix rotate builtins that map to LLVM funnel shift (retry)

This is a retry of rL340135 (reverted at rL340136 because of gcc host compiler 
crashing)
with 2 changes:
1. Move the code into a helper to reduce code duplication (and hopefully 
work-around the crash).
2. The original commit had a formatting bug in the docs (missing an underscore).

Original commit message:

This exposes the LLVM funnel shift intrinsics as more familiar bit rotation 
functions in clang
(when both halves of a funnel shift are the same value, it's a rotate).

We're free to name these as we want because we're not copying gcc, but if 
there's some other
existing art (eg, the microsoft ops that are modified in this patch) that we 
want to replicate,
we can change the names.

The funnel shift intrinsics were added here:
https://reviews.llvm.org/D49242

With improved codegen in:
https://reviews.llvm.org/rL337966
https://reviews.llvm.org/rL339359

And basic IR optimization added in:
https://reviews.llvm.org/rL338218
https://reviews.llvm.org/rL340022

...so these are expected to produce asm output that's equal or better to the 
multi-instruction
alternatives using primitive C/IR ops.

In the motivating loop example from PR37387:
https://bugs.llvm.org/show_bug.cgi?id=37387#c7
...we get the expected 'rolq' x86 instructions if we substitute the rotate 
builtin into the source.

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

Added:
cfe/trunk/test/CodeGen/builtin-rotate.c
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=340137&r1=340136&r2=340137&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Sun Aug 19 07:44:47 2018
@@ -1739,6 +1739,70 @@ The '``__builtin_bitreverse``' family of
 the bitpattern of an integer value; for example ``0b10110110`` becomes
 ``0b01101101``.
 
+``__builtin_rotateleft``
+
+
+* ``__builtin_rotateleft8``
+* ``__builtin_rotateleft16``
+* ``__builtin_rotateleft32``
+* ``__builtin_rotateleft64``
+
+**Syntax**:
+
+.. code-block:: c++
+
+ __builtin_rotateleft32(x, y)
+
+**Examples**:
+
+.. code-block:: c++
+
+  uint8_t rot_x = __builtin_rotateleft8(x, y);
+  uint16_t rot_x = __builtin_rotateleft16(x, y);
+  uint32_t rot_x = __builtin_rotateleft32(x, y);
+  uint64_t rot_x = __builtin_rotateleft64(x, y);
+
+**Description**:
+
+The '``__builtin_rotateleft``' family of builtins is used to rotate
+the bits in the first argument by the amount in the second argument. 
+For example, ``0b1110`` rotated left by 11 becomes ``0b00110100``.
+The shift value is treated as an unsigned amount modulo the size of
+the arguments. Both arguments and the result have the bitwidth specified
+by the name of the builtin.
+
+``__builtin_rotateright``
+_
+
+* ``__builtin_rotateright8``
+* ``__builtin_rotateright16``
+* ``__builtin_rotateright32``
+* ``__builtin_rotateright64``
+
+**Syntax**:
+
+.. code-block:: c++
+
+ __builtin_rotateright32(x, y)
+
+**Examples**:
+
+.. code-block:: c++
+
+  uint8_t rot_x = __builtin_rotateright8(x, y);
+  uint16_t rot_x = __builtin_rotateright16(x, y);
+  uint32_t rot_x = __builtin_rotateright32(x, y);
+  uint64_t rot_x = __builtin_rotateright64(x, y);
+
+**Description**:
+
+The '``__builtin_rotateright``' family of builtins is used to rotate
+the bits in the first argument by the amount in the second argument. 
+For example, ``0b1110`` rotated right by 3 becomes ``0b1101``.
+The shift value is treated as an unsigned amount modulo the size of
+the arguments. Both arguments and the result have the bitwidth specified
+by the name of the builtin.
+
 ``__builtin_unreachable``
 -
 

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=340137&r1=340136&r2=340137&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Sun Aug 19 07:44:47 2018
@@ -428,6 +428,15 @@ BUILTIN(__builtin_bitreverse16, "UsUs",
 BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
 BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
 
+BUILTIN(__builtin_rotateleft8, "UcUcUc", "nc")
+BUILTIN(__builtin_rotateleft16, "UsUsUs", "nc")
+BUILTIN(__builtin_rotateleft32, "UiUiUi", "nc")
+BUILTIN(__builtin_rotateleft64

[PATCH] D50924: [CodeGen] add rotate builtins

2018-08-19 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340137: [CodeGen] add/fix rotate builtins that map to LLVM 
funnel shift (retry) (authored by spatel, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50924?vs=161397&id=161398#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50924

Files:
  cfe/trunk/docs/LanguageExtensions.rst
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/builtin-rotate.c
  cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c

Index: cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c
===
--- cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c
+++ cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c
@@ -30,128 +30,71 @@
   return _rotl8(value, shift);
 }
 // CHECK: i8 @test_rotl8
-// CHECK:   [[LSHIFT:%[0-9]+]] = and i8 [[SHIFT:%[0-9]+]], 7
-// CHECK:   [[HIGH:%[0-9]+]] = shl i8 [[VALUE:%[0-9]+]], [[LSHIFT]]
-// CHECK:   [[NEGATE:%[0-9]+]] = sub i8 0, [[SHIFT]]
-// CHECK:   [[RSHIFT:%[0-9]+]] = and i8 [[NEGATE]], 7
-// CHECK:   [[LOW:%[0-9]+]] = lshr i8 [[VALUE]], [[RSHIFT]]
-// CHECK:   [[RESULT:%[0-9]+]] = or i8 [[HIGH]], [[LOW]]
-// CHECK:   ret i8 [[RESULT]]
-// CHECK  }
+// CHECK:   [[R:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
+// CHECK:   ret i8 [[R]]
 
 unsigned short test_rotl16(unsigned short value, unsigned char shift) {
   return _rotl16(value, shift);
 }
 // CHECK: i16 @test_rotl16
-// CHECK:   [[LSHIFT:%[0-9]+]] = and i16 [[SHIFT:%[0-9]+]], 15
-// CHECK:   [[HIGH:%[0-9]+]] = shl i16 [[VALUE:%[0-9]+]], [[LSHIFT]]
-// CHECK:   [[NEGATE:%[0-9]+]] = sub i16 0, [[SHIFT]]
-// CHECK:   [[RSHIFT:%[0-9]+]] = and i16 [[NEGATE]], 15
-// CHECK:   [[LOW:%[0-9]+]] = lshr i16 [[VALUE]], [[RSHIFT]]
-// CHECK:   [[RESULT:%[0-9]+]] = or i16 [[HIGH]], [[LOW]]
-// CHECK:   ret i16 [[RESULT]]
-// CHECK  }
+// CHECK:   [[R:%.*]] = call i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
+// CHECK:   ret i16 [[R]]
 
 unsigned int test_rotl(unsigned int value, int shift) {
   return _rotl(value, shift);
 }
 // CHECK: i32 @test_rotl
-// CHECK:   [[LSHIFT:%[0-9]+]] = and i32 [[SHIFT:%[0-9]+]], 31
-// CHECK:   [[HIGH:%[0-9]+]] = shl i32 [[VALUE:%[0-9]+]], [[LSHIFT]]
-// CHECK:   [[NEGATE:%[0-9]+]] = sub i32 0, [[SHIFT]]
-// CHECK:   [[RSHIFT:%[0-9]+]] = and i32 [[NEGATE]], 31
-// CHECK:   [[LOW:%[0-9]+]] = lshr i32 [[VALUE]], [[RSHIFT]]
-// CHECK:   [[RESULT:%[0-9]+]] = or i32 [[HIGH]], [[LOW]]
-// CHECK:   ret i32 [[RESULT]]
-// CHECK  }
+// CHECK:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK:   ret i32 [[R]]
 
 unsigned LONG test_lrotl(unsigned LONG value, int shift) {
   return _lrotl(value, shift);
 }
 // CHECK-32BIT-LONG: i32 @test_lrotl
-// CHECK-32BIT-LONG:   [[LSHIFT:%[0-9]+]] = and i32 [[SHIFT:%[0-9]+]], 31
-// CHECK-32BIT-LONG:   [[HIGH:%[0-9]+]] = shl i32 [[VALUE:%[0-9]+]], [[LSHIFT]]
-// CHECK-32BIT-LONG:   [[NEGATE:%[0-9]+]] = sub i32 0, [[SHIFT]]
-// CHECK-32BIT-LONG:   [[RSHIFT:%[0-9]+]] = and i32 [[NEGATE]], 31
-// CHECK-32BIT-LONG:   [[LOW:%[0-9]+]] = lshr i32 [[VALUE]], [[RSHIFT]]
-// CHECK-32BIT-LONG:   [[RESULT:%[0-9]+]] = or i32 [[HIGH]], [[LOW]]
-// CHECK-32BIT-LONG:   ret i32 [[RESULT]]
-// CHECK-32BIT-LONG  }
+// CHECK-32BIT-LONG:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK-32BIT-LONG:   ret i32 [[R]]
 
 unsigned __int64 test_rotl64(unsigned __int64 value, int shift) {
   return _rotl64(value, shift);
 }
 // CHECK: i64 @test_rotl64
-// CHECK:   [[LSHIFT:%[0-9]+]] = and i64 [[SHIFT:%[0-9]+]], 63
-// CHECK:   [[HIGH:%[0-9]+]] = shl i64 [[VALUE:%[0-9]+]], [[LSHIFT]]
-// CHECK:   [[NEGATE:%[0-9]+]] = sub i64 0, [[SHIFT]]
-// CHECK:   [[RSHIFT:%[0-9]+]] = and i64 [[NEGATE]], 63
-// CHECK:   [[LOW:%[0-9]+]] = lshr i64 [[VALUE]], [[RSHIFT]]
-// CHECK:   [[RESULT:%[0-9]+]] = or i64 [[HIGH]], [[LOW]]
-// CHECK:   ret i64 [[RESULT]]
-// CHECK  }
+// CHECK:   [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
+// CHECK:   ret i64 [[R]]
 
 // rotate right
 
 unsigned char test_rotr8(unsigned char value, unsigned char shift) {
   return _rotr8(value, shift);
 }
 // CHECK: i8 @test_rotr8
-// CHECK:   [[RSHIFT:%[0-9]+]] = and i8 [[SHIFT:%[0-9]+]], 7
-// CHECK:   [[LOW:%[0-9]+]] = lshr i8 [[VALUE:%[0-9]+]], [[RSHIFT]]
-// CHECK:   [[NEGATE:%[0-9]+]] = sub i8 0, [[SHIFT]]
-// CHECK:   [[LSHIFT:%[0-9]+]] = and i8 [[NEGATE]], 7
-// CHECK:   [[HIGH:%[0-9]+]] = shl i8 [[VALUE]], [[LSHIFT]]
-// CHECK:   [[RESULT:%[0-9]+]] = or i8 [[HIGH]], [[LOW]]
-// CHECK  }
+// CHECK:   [[R:%.*]] = call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
+// CHECK:   ret i8 [[R]]
 
 unsigned short test_rotr16(unsigned short value, unsigned char shift) {
   return _rotr16(value, shift);
 }
 // CHECK: i16 @

[PATCH] D50451: [ASTImporter] Fix import of class templates partial specialization

2018-08-19 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added inline comments.



Comment at: lib/AST/ASTImporter.cpp:4550
+  // in the "From" context, but not in the "To" context.
+  for (auto *FromField : D->fields())
+Importer.Import(FromField);

martong wrote:
> martong wrote:
> > a_sidorin wrote:
> > > Importing additional fields can change the layout of the specialization. 
> > > For CSA, this usually results in strange assertions hard to debug. Could 
> > > you please share the results of testing of this change?
> > > This change also doesn't seem to have related tests in this patch.
> > TLDR; We will not create additional fields.
> > 
> > By the time when we import the field, we already know that the existing 
> > specialization is structurally equivalent with the new one. 
> > Since a ClassTemplateSpecializationDecl is the descendant of RecordDecl, 
> > the structural equivalence check ensures that they have the exact same 
> > fields.
> > When we import the field of the new spec and if there is an existing 
> > FieldDecl in the "To" context, then no new FieldDecl will be created (this 
> > is handled in `VisitFieldDecl` by first doing a lookup of existing field 
> > with the same name and type).
> > This patch extends `VisitFieldDecl` in a way that we add new initializer 
> > expressions to the existing FieldDecl, if it didn't have and in the "From" 
> > context it has.
> > 
> > For the record, I  added a new test to make sure that a new FieldDecl will 
> > not be created during the merge.
> This is the new test: 
> `ODRViolationOfClassTemplateSpecializationsShouldBeReported`. It checks that 
> it is not possible to add new fields to a specialization, rather an ODR 
> violation is diagnosed.
Thank you for the explanation. However, I find the comment very misleading. It 
tells: 
```
  // Check and merge those fields which have been instantiated
  // in the "From" context, but not in the "To" context.
```
Would it be correct to change it to "Import field initializers that are still 
not instantiated", or do I still misunderstand something?


Repository:
  rC Clang

https://reviews.llvm.org/D50451



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


r340138 - revert r340137: [CodeGen] add rotate builtins

2018-08-19 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Sun Aug 19 08:31:42 2018
New Revision: 340138

URL: http://llvm.org/viewvc/llvm-project?rev=340138&view=rev
Log:
revert r340137: [CodeGen] add rotate builtins

At least a couple of bots (gcc host compiler on PPC only?) are showing the 
compiler dying while trying to compile.

Removed:
cfe/trunk/test/CodeGen/builtin-rotate.c
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=340138&r1=340137&r2=340138&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Sun Aug 19 08:31:42 2018
@@ -1739,70 +1739,6 @@ The '``__builtin_bitreverse``' family of
 the bitpattern of an integer value; for example ``0b10110110`` becomes
 ``0b01101101``.
 
-``__builtin_rotateleft``
-
-
-* ``__builtin_rotateleft8``
-* ``__builtin_rotateleft16``
-* ``__builtin_rotateleft32``
-* ``__builtin_rotateleft64``
-
-**Syntax**:
-
-.. code-block:: c++
-
- __builtin_rotateleft32(x, y)
-
-**Examples**:
-
-.. code-block:: c++
-
-  uint8_t rot_x = __builtin_rotateleft8(x, y);
-  uint16_t rot_x = __builtin_rotateleft16(x, y);
-  uint32_t rot_x = __builtin_rotateleft32(x, y);
-  uint64_t rot_x = __builtin_rotateleft64(x, y);
-
-**Description**:
-
-The '``__builtin_rotateleft``' family of builtins is used to rotate
-the bits in the first argument by the amount in the second argument. 
-For example, ``0b1110`` rotated left by 11 becomes ``0b00110100``.
-The shift value is treated as an unsigned amount modulo the size of
-the arguments. Both arguments and the result have the bitwidth specified
-by the name of the builtin.
-
-``__builtin_rotateright``
-_
-
-* ``__builtin_rotateright8``
-* ``__builtin_rotateright16``
-* ``__builtin_rotateright32``
-* ``__builtin_rotateright64``
-
-**Syntax**:
-
-.. code-block:: c++
-
- __builtin_rotateright32(x, y)
-
-**Examples**:
-
-.. code-block:: c++
-
-  uint8_t rot_x = __builtin_rotateright8(x, y);
-  uint16_t rot_x = __builtin_rotateright16(x, y);
-  uint32_t rot_x = __builtin_rotateright32(x, y);
-  uint64_t rot_x = __builtin_rotateright64(x, y);
-
-**Description**:
-
-The '``__builtin_rotateright``' family of builtins is used to rotate
-the bits in the first argument by the amount in the second argument. 
-For example, ``0b1110`` rotated right by 3 becomes ``0b1101``.
-The shift value is treated as an unsigned amount modulo the size of
-the arguments. Both arguments and the result have the bitwidth specified
-by the name of the builtin.
-
 ``__builtin_unreachable``
 -
 

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=340138&r1=340137&r2=340138&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Sun Aug 19 08:31:42 2018
@@ -428,15 +428,6 @@ BUILTIN(__builtin_bitreverse16, "UsUs",
 BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
 BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
 
-BUILTIN(__builtin_rotateleft8, "UcUcUc", "nc")
-BUILTIN(__builtin_rotateleft16, "UsUsUs", "nc")
-BUILTIN(__builtin_rotateleft32, "UiUiUi", "nc")
-BUILTIN(__builtin_rotateleft64, "ULLiULLiULLi", "nc")
-BUILTIN(__builtin_rotateright8, "UcUcUc", "nc")
-BUILTIN(__builtin_rotateright16, "UsUsUs", "nc")
-BUILTIN(__builtin_rotateright32, "UiUiUi", "nc")
-BUILTIN(__builtin_rotateright64, "ULLiULLiULLi", "nc")
-
 // Random GCC builtins
 BUILTIN(__builtin_constant_p, "i.", "nctu")
 BUILTIN(__builtin_classify_type, "i.", "nctu")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=340138&r1=340137&r2=340138&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Aug 19 08:31:42 2018
@@ -1252,21 +1252,6 @@ static llvm::Value *dumpRecord(CodeGenFu
   return Res;
 }
 
-RValue CodeGenFunction::emitRotate(const CallExpr *E, bool IsRotateRight) {
-  llvm::Value *Src = EmitScalarExpr(E->getArg(0));
-  llvm::Value *ShiftAmt = EmitScalarExpr(E->getArg(1));
-
-  // The builtin's shift arg may have a different type than the source arg and
-  // result, but the LLVM intrinsic uses the same type for all values.
-  llvm::Type *Ty = Src->getType();
-  ShiftAmt = Builder.CreateIntCast(ShiftAmt, Ty, false);
-
-  // Rotate is a special case of LLVM f

[PATCH] D50945: [Lex] Make HeaderMaps a unique_ptr vector

2018-08-19 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

Given the context (class an file name itself) and documentation around the 
function, I don't think in this particular case it improves readability or 
maintainability, the lifetime of the `HeaderMap` is (IMHO) fairly obvious from 
the const qualifier and from the documentation of the function itself. I would 
say leave it as is.


Repository:
  rC Clang

https://reviews.llvm.org/D50945



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


[PATCH] D50942: SemaExceptionSpec: ensure old/new specs are both parsed and evaluated when comparing

2018-08-19 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande marked an inline comment as done.
elsteveogrande added inline comments.



Comment at: lib/Sema/SemaExceptionSpec.cpp:915
+  // lexically-surrounding class.
+  switch (New->getType()->castAs()->getExceptionSpecType()) 
{
+  case EST_Unparsed:

vitaut wrote:
> Did you mean `Old` here?
facepalm, haha.  Thanks @vitaut !  :)


Repository:
  rC Clang

https://reviews.llvm.org/D50942



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


[PATCH] D50942: SemaExceptionSpec: ensure old/new specs are both parsed and evaluated when comparing

2018-08-19 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande updated this revision to Diff 161399.
elsteveogrande marked an inline comment as done.
elsteveogrande added a comment.

fix dopey copy-paste error.  Tested again with `ninja check-clang-modules`


Repository:
  rC Clang

https://reviews.llvm.org/D50942

Files:
  lib/Sema/SemaExceptionSpec.cpp
  test/Modules/Inputs/lax-base-except/a.h
  test/Modules/Inputs/lax-base-except/module.modulemap
  test/Modules/lax-base-except.cpp

Index: test/Modules/lax-base-except.cpp
===
--- /dev/null
+++ test/Modules/lax-base-except.cpp
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang -c -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/lax-base-except %s -o %t2.o
+// expected-no-diagnostics
+
+#include "a.h"
+
+class D : public A, public B {
+ public:
+  virtual ~D() override = default;
+};
Index: test/Modules/Inputs/lax-base-except/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/lax-base-except/module.modulemap
@@ -0,0 +1,3 @@
+module a {
+  header "a.h"
+}
Index: test/Modules/Inputs/lax-base-except/a.h
===
--- /dev/null
+++ test/Modules/Inputs/lax-base-except/a.h
@@ -0,0 +1,19 @@
+class A {
+ public:
+  virtual ~A() = default;
+};
+
+class B {
+ public:
+  virtual ~B() {
+c.func();
+  }
+
+  struct C{
+void func() {}
+friend B::~B();
+  };
+
+  C c;
+};
+
Index: lib/Sema/SemaExceptionSpec.cpp
===
--- lib/Sema/SemaExceptionSpec.cpp
+++ lib/Sema/SemaExceptionSpec.cpp
@@ -899,11 +899,28 @@
 
 bool Sema::CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
 const CXXMethodDecl *Old) {
-  // If the new exception specification hasn't been parsed yet, skip the check.
+  // If the new exception spec hasn't been determined yet, skip the check.
   // We'll get called again once it's been parsed.
-  if (New->getType()->castAs()->getExceptionSpecType() ==
-  EST_Unparsed)
+  switch (New->getType()->castAs()->getExceptionSpecType()) {
+  case EST_Unparsed:
+  case EST_Unevaluated:
 return false;
+  default:
+;
+  }
+
+  // If the old exception spec hasn't been determined yet, remember that
+  // we need to perform this check when we get to the end of the outermost
+  // lexically-surrounding class.
+  switch (Old->getType()->castAs()->getExceptionSpecType()) {
+  case EST_Unparsed:
+  case EST_Unevaluated:
+DelayedExceptionSpecChecks.push_back(std::make_pair(New, Old));
+return false;
+  default:
+;
+  }
+
   if (getLangOpts().CPlusPlus11 && isa(New)) {
 // Don't check uninstantiated template destructors at all. We can only
 // synthesize correct specs after the template is instantiated.
@@ -916,17 +933,11 @@
   return false;
 }
   }
-  // If the old exception specification hasn't been parsed yet, remember that
-  // we need to perform this check when we get to the end of the outermost
-  // lexically-surrounding class.
-  if (Old->getType()->castAs()->getExceptionSpecType() ==
-  EST_Unparsed) {
-DelayedExceptionSpecChecks.push_back(std::make_pair(New, Old));
-return false;
-  }
+
   unsigned DiagID = diag::err_override_exception_spec;
   if (getLangOpts().MicrosoftExt)
 DiagID = diag::ext_override_exception_spec;
+
   return CheckExceptionSpecSubset(PDiag(DiagID),
   PDiag(diag::err_deep_exception_specs_differ),
   PDiag(diag::note_overridden_virtual_function),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50924: [CodeGen] add rotate builtins

2018-08-19 Thread Sanjay Patel via Phabricator via cfe-commits
spatel reopened this revision.
spatel added a comment.
This revision is now accepted and ready to land.

Reopening again because I reverted this again for the same reason at 
https://reviews.llvm.org/rL340138.


Repository:
  rL LLVM

https://reviews.llvm.org/D50924



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


[PATCH] D49075: [NEON] Define fp16 vld and vst intrinsics conditionally

2018-08-19 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340140: [NEON] Define fp16 vld and vst intrinsics 
conditionally (authored by kosarev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49075?vs=157960&id=161400#toc

Repository:
  rC Clang

https://reviews.llvm.org/D49075

Files:
  cfe/trunk/include/clang/Basic/arm_neon.td
  cfe/trunk/test/CodeGen/arm-neon-vld.c
  cfe/trunk/test/CodeGen/arm-neon-vst.c
  cfe/trunk/test/Sema/arm-no-fp16.c

Index: cfe/trunk/test/CodeGen/arm-neon-vst.c
===
--- cfe/trunk/test/CodeGen/arm-neon-vst.c
+++ cfe/trunk/test/CodeGen/arm-neon-vst.c
@@ -2,8 +2,8 @@
 // RUN: -S -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | \
 // RUN: FileCheck -check-prefixes=CHECK,CHECK-A64 %s
 // RUN: %clang_cc1 -triple armv8-none-linux-gnueabi -target-feature +neon \
-// RUN: -S -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | \
-// RUN: FileCheck -check-prefixes=CHECK,CHECK-A32 %s
+// RUN: -target-feature +fp16 -S -disable-O0-optnone -emit-llvm -o - %s | \
+// RUN: opt -S -mem2reg | FileCheck -check-prefixes=CHECK,CHECK-A32 %s
 
 #include 
 
Index: cfe/trunk/test/CodeGen/arm-neon-vld.c
===
--- cfe/trunk/test/CodeGen/arm-neon-vld.c
+++ cfe/trunk/test/CodeGen/arm-neon-vld.c
@@ -2,8 +2,8 @@
 // RUN: -S -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | \
 // RUN: FileCheck -check-prefixes=CHECK,CHECK-A64 %s
 // RUN: %clang_cc1 -triple armv8-none-linux-gnueabi -target-feature +neon \
-// RUN: -S -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | \
-// RUN: FileCheck -check-prefixes=CHECK,CHECK-A32 %s
+// RUN: -target-feature +fp16 -S -disable-O0-optnone -emit-llvm -o - %s | \
+// RUN: opt -S -mem2reg | FileCheck -check-prefixes=CHECK,CHECK-A32 %s
 
 #include 
 
Index: cfe/trunk/test/Sema/arm-no-fp16.c
===
--- cfe/trunk/test/Sema/arm-no-fp16.c
+++ cfe/trunk/test/Sema/arm-no-fp16.c
@@ -83,3 +83,213 @@
 float16x8_t test_vminnmq_f16(float16x8_t a, float16x8_t b) {
   return vminnmq_f16(a, b); // expected-warning{{implicit declaration of function 'vminnmq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
 }
+
+float16x4_t test_vld1_f16(const float16_t *a) {
+  return vld1_f16(a); // expected-warning{{implicit declaration of function 'vld1_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vld1q_f16(const float16_t *a) {
+  return vld1q_f16(a); // expected-warning{{implicit declaration of function 'vld1q_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4_t test_vld1_dup_f16(const float16_t *a) {
+  return vld1_dup_f16(a); // expected-warning{{implicit declaration of function 'vld1_dup_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vld1q_dup_f16(const float16_t *a) {
+  return vld1q_dup_f16(a); // expected-warning{{implicit declaration of function 'vld1q_dup_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4_t test_vld1_lane_f16(const float16_t *a, float16x4_t b) {
+  return vld1_lane_f16(a, b, 3); // expected-warning{{implicit declaration of function 'vld1_lane_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vld1q_lane_f16(const float16_t *a, float16x8_t b) {
+  return vld1q_lane_f16(a, b, 7); // expected-warning{{implicit declaration of function 'vld1q_lane_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4x2_t test_vld1_f16_x2(const float16_t *a) {
+  return vld1_f16_x2(a); // expected-warning{{implicit declaration of function 'vld1_f16_x2'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4x2_t'}}
+}
+
+float16x8x2_t test_vld1q_f16_x2(const float16_t *a) {
+  return vld1q_f16_x2(a); // expected-warning{{implicit declaration of function 'vld1q_f16_x2'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8x2_t'}}
+}
+
+float16x4x3_t test_vld1_f16_x3(const float16_t *a) {
+  return vld1_f16_x3(a); // expected-warning{{implicit declaration of function 'vld1_f16_x3'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4x3_t'}}
+}
+
+float16x8x3_t test_vld1q_f16_x3(const float16_t *a) {
+  return vld1q_f16_x3(a); // expected-warning{{implicit declaration of function 'vld1q_f16_x3'}} expected-error{{returning 'int' from a function with incompatible result type 'fl

r340140 - [NEON] Define fp16 vld and vst intrinsics conditionally

2018-08-19 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Sun Aug 19 09:30:57 2018
New Revision: 340140

URL: http://llvm.org/viewvc/llvm-project?rev=340140&view=rev
Log:
[NEON] Define fp16 vld and vst intrinsics conditionally

This patch fixes definitions of vld and vst NEON intrinsics so
that we only define them if half-precision arithmetic is
supported on the target platform, as prescribed in ACLE 2.0.

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

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/test/CodeGen/arm-neon-vld.c
cfe/trunk/test/CodeGen/arm-neon-vst.c
cfe/trunk/test/Sema/arm-no-fp16.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=340140&r1=340139&r2=340140&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Sun Aug 19 09:30:57 2018
@@ -337,48 +337,78 @@ def VSLI_N : WInst<"vsli_n", "dddi",
 

 // E.3.14 Loads and stores of a single vector
 def VLD1  : WInst<"vld1", "dc",
-  "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+  "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">;
 def VLD1_X2   : WInst<"vld1_x2", "2c",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VLD1_X3   : WInst<"vld1_x3", "3c",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VLD1_X4   : WInst<"vld1_x4", "4c",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VLD1_LANE : WInst<"vld1_lane", "dcdi",
-  "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+  "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">;
 def VLD1_DUP  : WInst<"vld1_dup", "dc",
-  "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+  "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">;
 def VST1  : WInst<"vst1", "vpd",
-  "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+  "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">;
 def VST1_X2   : WInst<"vst1_x2", "vp2",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VST1_X3   : WInst<"vst1_x3", "vp3",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VST1_X4   : WInst<"vst1_x4", "vp4",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VST1_LANE : WInst<"vst1_lane", "vpdi",
-  "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+  "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">;
+let ArchGuard = "(__ARM_FP & 2)" in {
+def VLD1_F16  : WInst<"vld1", "dc", "hQh">;
+def VLD1_X2_F16   : WInst<"vld1_x2", "2c", "hQh">;
+def VLD1_X3_F16   : WInst<"vld1_x3", "3c", "hQh">;
+def VLD1_X4_F16   : WInst<"vld1_x4", "4c", "hQh">;
+def VLD1_LANE_F16 : WInst<"vld1_lane", "dcdi", "hQh">;
+def VLD1_DUP_F16  : WInst<"vld1_dup", "dc", "hQh">;
+def VST1_F16  : WInst<"vst1", "vpd", "hQh">;
+def VST1_X2_F16   : WInst<"vst1_x2", "vp2", "hQh">;
+def VST1_X3_F16   : WInst<"vst1_x3", "vp3", "hQh">;
+def VST1_X4_F16   : WInst<"vst1_x4", "vp4", "hQh">;
+def VST1_LANE_F16 : WInst<"vst1_lane", "vpdi", "hQh">;
+}
 
 

 // E.3.15 Loads and stores of an N-element structure
-def VLD2 : WInst<"vld2", "2c", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
-def VLD3 : WInst<"vld3", "3c", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
-def VLD4 : WInst<"vld4", "4c", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+def VLD2 : WInst<"vld2", "2c", "QUcQUsQUiQcQsQiQfQPcQPsUcUsUiUlcsilfPcPs">;
+def VLD3 : WInst<"vld3", "3c", "QUcQUsQUiQcQsQiQfQPcQPsUcUsUiUlcsilfPcPs">;
+def VLD4 : WInst<"vld4", "4c", "QUcQUsQUiQcQsQiQfQPcQPsUcUsUiUlcsilfPcPs">;
 def VLD2_DUP  : WInst<"vld2_dup", "2c",
-  "UcUsUiUlcsilhfPcPsQcQfQhQiQlQsQPcQPsQUcQUiQUlQUs">;
+  "UcUsUiUlcsilfPcPsQcQfQiQlQsQPcQPsQUcQUiQUlQUs">;
 def VLD3_DUP  : WInst<"vld3_dup", "3c",
-  "UcUsUiUlcsilhfPcPsQcQfQhQiQlQsQPcQPsQUcQUiQUlQUs">;
+  "UcUsUiUlcsilfPcPsQcQfQiQlQsQPcQPsQUcQUiQUlQUs">;
 def VLD4_DUP  : WInst<"vld4_dup", "4c",
-  "UcUsUiUlcsilhfPcPsQcQfQhQiQlQsQPcQPsQUcQUiQUlQUs">;
-de

[PATCH] D49075: [NEON] Define fp16 vld and vst intrinsics conditionally

2018-08-19 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340140: [NEON] Define fp16 vld and vst intrinsics 
conditionally (authored by kosarev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D49075

Files:
  include/clang/Basic/arm_neon.td
  test/CodeGen/arm-neon-vld.c
  test/CodeGen/arm-neon-vst.c
  test/Sema/arm-no-fp16.c

Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -337,48 +337,78 @@
 
 // E.3.14 Loads and stores of a single vector
 def VLD1  : WInst<"vld1", "dc",
-  "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+  "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">;
 def VLD1_X2   : WInst<"vld1_x2", "2c",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VLD1_X3   : WInst<"vld1_x3", "3c",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VLD1_X4   : WInst<"vld1_x4", "4c",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VLD1_LANE : WInst<"vld1_lane", "dcdi",
-  "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+  "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">;
 def VLD1_DUP  : WInst<"vld1_dup", "dc",
-  "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+  "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">;
 def VST1  : WInst<"vst1", "vpd",
-  "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+  "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">;
 def VST1_X2   : WInst<"vst1_x2", "vp2",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VST1_X3   : WInst<"vst1_x3", "vp3",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VST1_X4   : WInst<"vst1_x4", "vp4",
-  "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
+  "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">;
 def VST1_LANE : WInst<"vst1_lane", "vpdi",
-  "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+  "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">;
+let ArchGuard = "(__ARM_FP & 2)" in {
+def VLD1_F16  : WInst<"vld1", "dc", "hQh">;
+def VLD1_X2_F16   : WInst<"vld1_x2", "2c", "hQh">;
+def VLD1_X3_F16   : WInst<"vld1_x3", "3c", "hQh">;
+def VLD1_X4_F16   : WInst<"vld1_x4", "4c", "hQh">;
+def VLD1_LANE_F16 : WInst<"vld1_lane", "dcdi", "hQh">;
+def VLD1_DUP_F16  : WInst<"vld1_dup", "dc", "hQh">;
+def VST1_F16  : WInst<"vst1", "vpd", "hQh">;
+def VST1_X2_F16   : WInst<"vst1_x2", "vp2", "hQh">;
+def VST1_X3_F16   : WInst<"vst1_x3", "vp3", "hQh">;
+def VST1_X4_F16   : WInst<"vst1_x4", "vp4", "hQh">;
+def VST1_LANE_F16 : WInst<"vst1_lane", "vpdi", "hQh">;
+}
 
 
 // E.3.15 Loads and stores of an N-element structure
-def VLD2 : WInst<"vld2", "2c", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
-def VLD3 : WInst<"vld3", "3c", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
-def VLD4 : WInst<"vld4", "4c", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
+def VLD2 : WInst<"vld2", "2c", "QUcQUsQUiQcQsQiQfQPcQPsUcUsUiUlcsilfPcPs">;
+def VLD3 : WInst<"vld3", "3c", "QUcQUsQUiQcQsQiQfQPcQPsUcUsUiUlcsilfPcPs">;
+def VLD4 : WInst<"vld4", "4c", "QUcQUsQUiQcQsQiQfQPcQPsUcUsUiUlcsilfPcPs">;
 def VLD2_DUP  : WInst<"vld2_dup", "2c",
-  "UcUsUiUlcsilhfPcPsQcQfQhQiQlQsQPcQPsQUcQUiQUlQUs">;
+  "UcUsUiUlcsilfPcPsQcQfQiQlQsQPcQPsQUcQUiQUlQUs">;
 def VLD3_DUP  : WInst<"vld3_dup", "3c",
-  "UcUsUiUlcsilhfPcPsQcQfQhQiQlQsQPcQPsQUcQUiQUlQUs">;
+  "UcUsUiUlcsilfPcPsQcQfQiQlQsQPcQPsQUcQUiQUlQUs">;
 def VLD4_DUP  : WInst<"vld4_dup", "4c",
-  "UcUsUiUlcsilhfPcPsQcQfQhQiQlQsQPcQPsQUcQUiQUlQUs">;
-def VLD2_LANE : WInst<"vld2_lane", "2c2i", "QUsQUiQsQiQhQfQPsUcUsUicsihfPcPs">;
-def VLD3_LANE : WInst<"vld3_lane", "3c3i", "QUsQUiQsQiQhQfQPsUcUsUicsihfPcPs">;
-def VLD4_LANE : WInst<"vld4_lane", "4c4i", "QUsQUiQsQiQhQfQPsUcUsUicsihfPcPs">;
-def VST2 : WInst<"vst2", "vp2", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
-def VST3 : WInst<"vst3", "vp3", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">;
-def VST4 : WInst<"vst4", "vp4", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcs

r340141 - [CodeGen] add rotate builtins that map to LLVM funnel shift

2018-08-19 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Sun Aug 19 09:50:30 2018
New Revision: 340141

URL: http://llvm.org/viewvc/llvm-project?rev=340141&view=rev
Log:
[CodeGen] add rotate builtins that map to LLVM funnel shift 
This is a partial retry of rL340137 (reverted at rL340138 because of gcc host 
compiler crashing)
with 1 change:
Remove the changes to make microsoft builtins also use the LLVM intrinsics.
 
This exposes the LLVM funnel shift intrinsics as more familiar bit rotation 
functions in clang
(when both halves of a funnel shift are the same value, it's a rotate).

We're free to name these as we want because we're not copying gcc, but if 
there's some other
existing art (eg, the microsoft ops) that we want to replicate, we can change 
the names.

The funnel shift intrinsics were added here:
https://reviews.llvm.org/D49242

With improved codegen in:
https://reviews.llvm.org/rL337966
https://reviews.llvm.org/rL339359

And basic IR optimization added in:
https://reviews.llvm.org/rL338218
https://reviews.llvm.org/rL340022

...so these are expected to produce asm output that's equal or better to the 
multi-instruction
alternatives using primitive C/IR ops.

In the motivating loop example from PR37387:
https://bugs.llvm.org/show_bug.cgi?id=37387#c7
...we get the expected 'rolq' x86 instructions if we substitute the rotate 
builtin into the source.

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

Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=340141&r1=340140&r2=340141&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Sun Aug 19 09:50:30 2018
@@ -1739,6 +1739,70 @@ The '``__builtin_bitreverse``' family of
 the bitpattern of an integer value; for example ``0b10110110`` becomes
 ``0b01101101``.
 
+``__builtin_rotateleft``
+
+
+* ``__builtin_rotateleft8``
+* ``__builtin_rotateleft16``
+* ``__builtin_rotateleft32``
+* ``__builtin_rotateleft64``
+
+**Syntax**:
+
+.. code-block:: c++
+
+ __builtin_rotateleft32(x, y)
+
+**Examples**:
+
+.. code-block:: c++
+
+  uint8_t rot_x = __builtin_rotateleft8(x, y);
+  uint16_t rot_x = __builtin_rotateleft16(x, y);
+  uint32_t rot_x = __builtin_rotateleft32(x, y);
+  uint64_t rot_x = __builtin_rotateleft64(x, y);
+
+**Description**:
+
+The '``__builtin_rotateleft``' family of builtins is used to rotate
+the bits in the first argument by the amount in the second argument. 
+For example, ``0b1110`` rotated left by 11 becomes ``0b00110100``.
+The shift value is treated as an unsigned amount modulo the size of
+the arguments. Both arguments and the result have the bitwidth specified
+by the name of the builtin.
+
+``__builtin_rotateright``
+_
+
+* ``__builtin_rotateright8``
+* ``__builtin_rotateright16``
+* ``__builtin_rotateright32``
+* ``__builtin_rotateright64``
+
+**Syntax**:
+
+.. code-block:: c++
+
+ __builtin_rotateright32(x, y)
+
+**Examples**:
+
+.. code-block:: c++
+
+  uint8_t rot_x = __builtin_rotateright8(x, y);
+  uint16_t rot_x = __builtin_rotateright16(x, y);
+  uint32_t rot_x = __builtin_rotateright32(x, y);
+  uint64_t rot_x = __builtin_rotateright64(x, y);
+
+**Description**:
+
+The '``__builtin_rotateright``' family of builtins is used to rotate
+the bits in the first argument by the amount in the second argument. 
+For example, ``0b1110`` rotated right by 3 becomes ``0b1101``.
+The shift value is treated as an unsigned amount modulo the size of
+the arguments. Both arguments and the result have the bitwidth specified
+by the name of the builtin.
+
 ``__builtin_unreachable``
 -
 

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=340141&r1=340140&r2=340141&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Sun Aug 19 09:50:30 2018
@@ -428,6 +428,15 @@ BUILTIN(__builtin_bitreverse16, "UsUs",
 BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
 BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
 
+BUILTIN(__builtin_rotateleft8, "UcUcUc", "nc")
+BUILTIN(__builtin_rotateleft16, "UsUsUs", "nc")
+BUILTIN(__builtin_rotateleft32, "UiUiUi", "nc")
+BUILTIN(__builtin_rotateleft64, "ULLiULLiULLi", "nc")
+BUILTIN(__builtin_rotateright8, "UcUcUc", "nc")
+BUILTIN(__builtin_rotateright16, "UsUsUs", "nc")
+BUILTIN(__builtin_rotateright32, "UiUiUi", "nc")
+BUILTIN(__builtin_rotateright64, "ULLiULLiULLi", "nc")
+
 // Random GCC builtins
 BUILTIN(__bui

[PATCH] D50924: [CodeGen] add rotate builtins

2018-08-19 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340141: [CodeGen] add rotate builtins that map to LLVM 
funnel shift  (authored by spatel, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50924?vs=161398&id=161402#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50924

Files:
  cfe/trunk/docs/LanguageExtensions.rst
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h

Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -1739,6 +1739,70 @@
 the bitpattern of an integer value; for example ``0b10110110`` becomes
 ``0b01101101``.
 
+``__builtin_rotateleft``
+
+
+* ``__builtin_rotateleft8``
+* ``__builtin_rotateleft16``
+* ``__builtin_rotateleft32``
+* ``__builtin_rotateleft64``
+
+**Syntax**:
+
+.. code-block:: c++
+
+ __builtin_rotateleft32(x, y)
+
+**Examples**:
+
+.. code-block:: c++
+
+  uint8_t rot_x = __builtin_rotateleft8(x, y);
+  uint16_t rot_x = __builtin_rotateleft16(x, y);
+  uint32_t rot_x = __builtin_rotateleft32(x, y);
+  uint64_t rot_x = __builtin_rotateleft64(x, y);
+
+**Description**:
+
+The '``__builtin_rotateleft``' family of builtins is used to rotate
+the bits in the first argument by the amount in the second argument. 
+For example, ``0b1110`` rotated left by 11 becomes ``0b00110100``.
+The shift value is treated as an unsigned amount modulo the size of
+the arguments. Both arguments and the result have the bitwidth specified
+by the name of the builtin.
+
+``__builtin_rotateright``
+_
+
+* ``__builtin_rotateright8``
+* ``__builtin_rotateright16``
+* ``__builtin_rotateright32``
+* ``__builtin_rotateright64``
+
+**Syntax**:
+
+.. code-block:: c++
+
+ __builtin_rotateright32(x, y)
+
+**Examples**:
+
+.. code-block:: c++
+
+  uint8_t rot_x = __builtin_rotateright8(x, y);
+  uint16_t rot_x = __builtin_rotateright16(x, y);
+  uint32_t rot_x = __builtin_rotateright32(x, y);
+  uint64_t rot_x = __builtin_rotateright64(x, y);
+
+**Description**:
+
+The '``__builtin_rotateright``' family of builtins is used to rotate
+the bits in the first argument by the amount in the second argument. 
+For example, ``0b1110`` rotated right by 3 becomes ``0b1101``.
+The shift value is treated as an unsigned amount modulo the size of
+the arguments. Both arguments and the result have the bitwidth specified
+by the name of the builtin.
+
 ``__builtin_unreachable``
 -
 
Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -428,6 +428,15 @@
 BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
 BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
 
+BUILTIN(__builtin_rotateleft8, "UcUcUc", "nc")
+BUILTIN(__builtin_rotateleft16, "UsUsUs", "nc")
+BUILTIN(__builtin_rotateleft32, "UiUiUi", "nc")
+BUILTIN(__builtin_rotateleft64, "ULLiULLiULLi", "nc")
+BUILTIN(__builtin_rotateright8, "UcUcUc", "nc")
+BUILTIN(__builtin_rotateright16, "UsUsUs", "nc")
+BUILTIN(__builtin_rotateright32, "UiUiUi", "nc")
+BUILTIN(__builtin_rotateright64, "ULLiULLiULLi", "nc")
+
 // Random GCC builtins
 BUILTIN(__builtin_constant_p, "i.", "nctu")
 BUILTIN(__builtin_classify_type, "i.", "nctu")
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -1252,6 +1252,21 @@
   return Res;
 }
 
+RValue CodeGenFunction::emitRotate(const CallExpr *E, bool IsRotateRight) {
+  llvm::Value *Src = EmitScalarExpr(E->getArg(0));
+  llvm::Value *ShiftAmt = EmitScalarExpr(E->getArg(1));
+
+  // The builtin's shift arg may have a different type than the source arg and
+  // result, but the LLVM intrinsic uses the same type for all values.
+  llvm::Type *Ty = Src->getType();
+  ShiftAmt = Builder.CreateIntCast(ShiftAmt, Ty, false);
+
+  // Rotate is a special case of LLVM funnel shift - 1st 2 args are the same.
+  unsigned IID = IsRotateRight ? Intrinsic::fshr : Intrinsic::fshl;
+  Value *F = CGM.getIntrinsic(IID, Ty);
+  return RValue::get(Builder.CreateCall(F, { Src, Src, ShiftAmt }));
+}
+
 RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
 unsigned BuiltinID, const CallExpr *E,
 ReturnValueSlot ReturnValue) {
@@ -1741,6 +1756,18 @@
   case Builtin::BI__builtin_bitreverse64: {
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bitreverse));
   }
+  case Builtin::BI__builtin_rotateleft8:
+  case Builtin::BI__builtin_rotateleft16:
+  case Builtin::BI__builtin_rotateleft

[PATCH] D50924: [CodeGen] add rotate builtins

2018-08-19 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a subscriber: lei.
spatel added a comment.

And the 3rd time is the charm...
I have no explanation for why this works, but I removed the microsoft diffs, 
and now gcc doesn't crash.
cc'ing @lei as owner of the bots that have this problem:
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/22826/steps/build%20stage%201/logs/stdio

I'm not sure if I can repro that crash locally (requires PPC?). Maybe there's 
something useful that can be recovered from the bots to repro and file a gcc 
bug?


Repository:
  rL LLVM

https://reviews.llvm.org/D50924



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


r340142 - [CodeGen] add test file that should have been included with r340141

2018-08-19 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Sun Aug 19 10:32:56 2018
New Revision: 340142

URL: http://llvm.org/viewvc/llvm-project?rev=340142&view=rev
Log:
[CodeGen] add test file that should have been included with r340141


Added:
cfe/trunk/test/CodeGen/builtin-rotate.c

Added: cfe/trunk/test/CodeGen/builtin-rotate.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-rotate.c?rev=340142&view=auto
==
--- cfe/trunk/test/CodeGen/builtin-rotate.c (added)
+++ cfe/trunk/test/CodeGen/builtin-rotate.c Sun Aug 19 10:32:56 2018
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+unsigned char rotl8(unsigned char x, unsigned char y) {
+// CHECK-LABEL: rotl8
+// CHECK: [[F:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 
[[Y:%.*]])
+// CHECK-NEXT: ret i8 [[F]]
+
+  return __builtin_rotateleft8(x, y);
+}
+
+short rotl16(short x, short y) {
+// CHECK-LABEL: rotl16
+// CHECK: [[F:%.*]] = call i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 
[[Y:%.*]])
+// CHECK-NEXT: ret i16 [[F]]
+
+  return __builtin_rotateleft16(x, y);
+}
+
+int rotl32(int x, unsigned int y) {
+// CHECK-LABEL: rotl32
+// CHECK: [[F:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 
[[Y:%.*]])
+// CHECK-NEXT: ret i32 [[F]]
+
+  return __builtin_rotateleft32(x, y);
+}
+
+unsigned long long rotl64(unsigned long long x, long long y) {
+// CHECK-LABEL: rotl64
+// CHECK: [[F:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 
[[Y:%.*]])
+// CHECK-NEXT: ret i64 [[F]]
+
+  return __builtin_rotateleft64(x, y);
+}
+
+char rotr8(char x, char y) {
+// CHECK-LABEL: rotr8
+// CHECK: [[F:%.*]] = call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 
[[Y:%.*]])
+// CHECK-NEXT: ret i8 [[F]]
+
+  return __builtin_rotateright8(x, y);
+}
+
+unsigned short rotr16(unsigned short x, unsigned short y) {
+// CHECK-LABEL: rotr16
+// CHECK: [[F:%.*]] = call i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 
[[Y:%.*]])
+// CHECK-NEXT: ret i16 [[F]]
+
+  return __builtin_rotateright16(x, y);
+}
+
+unsigned int rotr32(unsigned int x, int y) {
+// CHECK-LABEL: rotr32
+// CHECK: [[F:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 
[[Y:%.*]])
+// CHECK-NEXT: ret i32 [[F]]
+
+  return __builtin_rotateright32(x, y);
+}
+
+long long rotr64(long long x, unsigned long long y) {
+// CHECK-LABEL: rotr64
+// CHECK: [[F:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 
[[Y:%.*]])
+// CHECK-NEXT: ret i64 [[F]]
+
+  return __builtin_rotateright64(x, y);
+}
+


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


[PATCH] D50947: make PendingFakeDefinitionData a set, not map of decl data -> enum

2018-08-19 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande created this revision.
Herald added a subscriber: cfe-commits.

Of the three enums, only two are used (Fake and FakeLoaded), and even when 
switching the mapped value to FakeLoaded, it's leading to an unexpected state 
anyway (i.e. there's no check for only Fake's in the map).  Discard the enum, 
make this a simple set to test for membership / emptiness.

Test Plan: `ninja check-clang-modules`


Repository:
  rC Clang

https://reviews.llvm.org/D50947

Files:
  include/clang/Serialization/ASTReader.h
  lib/Serialization/ASTReaderDecl.cpp


Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1757,12 +1757,14 @@
   }
 
   auto PFDI = Reader.PendingFakeDefinitionData.find(&DD);
-  if (PFDI != Reader.PendingFakeDefinitionData.end() &&
-  PFDI->second == ASTReader::PendingFakeDefinitionKind::Fake) {
+  if (PFDI != Reader.PendingFakeDefinitionData.end()) {
 // We faked up this definition data because we found a class for which we'd
 // not yet loaded the definition. Replace it with the real thing now.
+
+Reader.PendingFakeDefinitionData.erase(PFDI);
+
+// FIXME: handle serialized lambdas
 assert(!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?");
-PFDI->second = ASTReader::PendingFakeDefinitionKind::FakeLoaded;
 
 // Don't change which declaration is the definition; that is required
 // to be invariant once we select it.
@@ -3077,8 +3079,7 @@
   RD->getCanonicalDecl()->DefinitionData = DD;
 
   // Track that we did this horrible thing so that we can fix it later.
-  Reader.PendingFakeDefinitionData.insert(
-  std::make_pair(DD, ASTReader::PendingFakeDefinitionKind::Fake));
+  Reader.PendingFakeDefinitionData.insert(DD);
 }
 
 return DD->Definition;
Index: include/clang/Serialization/ASTReader.h
===
--- include/clang/Serialization/ASTReader.h
+++ include/clang/Serialization/ASTReader.h
@@ -527,11 +527,9 @@
   /// to apply once we finish processing an import.
   llvm::SmallVector PendingUpdateRecords;
 
-  enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
-
   /// The DefinitionData pointers that we faked up for class definitions
   /// that we needed but hadn't loaded yet.
-  llvm::DenseMap PendingFakeDefinitionData;
+  llvm::DenseSet PendingFakeDefinitionData;
 
   /// Exception specification updates that have been loaded but not yet
   /// propagated across the relevant redeclaration chain. The map key is the


Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1757,12 +1757,14 @@
   }
 
   auto PFDI = Reader.PendingFakeDefinitionData.find(&DD);
-  if (PFDI != Reader.PendingFakeDefinitionData.end() &&
-  PFDI->second == ASTReader::PendingFakeDefinitionKind::Fake) {
+  if (PFDI != Reader.PendingFakeDefinitionData.end()) {
 // We faked up this definition data because we found a class for which we'd
 // not yet loaded the definition. Replace it with the real thing now.
+
+Reader.PendingFakeDefinitionData.erase(PFDI);
+
+// FIXME: handle serialized lambdas
 assert(!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?");
-PFDI->second = ASTReader::PendingFakeDefinitionKind::FakeLoaded;
 
 // Don't change which declaration is the definition; that is required
 // to be invariant once we select it.
@@ -3077,8 +3079,7 @@
   RD->getCanonicalDecl()->DefinitionData = DD;
 
   // Track that we did this horrible thing so that we can fix it later.
-  Reader.PendingFakeDefinitionData.insert(
-  std::make_pair(DD, ASTReader::PendingFakeDefinitionKind::Fake));
+  Reader.PendingFakeDefinitionData.insert(DD);
 }
 
 return DD->Definition;
Index: include/clang/Serialization/ASTReader.h
===
--- include/clang/Serialization/ASTReader.h
+++ include/clang/Serialization/ASTReader.h
@@ -527,11 +527,9 @@
   /// to apply once we finish processing an import.
   llvm::SmallVector PendingUpdateRecords;
 
-  enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
-
   /// The DefinitionData pointers that we faked up for class definitions
   /// that we needed but hadn't loaded yet.
-  llvm::DenseMap PendingFakeDefinitionData;
+  llvm::DenseSet PendingFakeDefinitionData;
 
   /// Exception specification updates that have been loaded but not yet
   /// propagated across the relevant redeclaration chain. The map key is the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50948: Change how LambdaDefinitionData is stored

2018-08-19 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande created this revision.
Herald added a subscriber: cfe-commits.

Previously `LambdaDefinitionData` extended `DefinitionData` and either might 
have been used interchangably in a `CXXRecordDecl`'s `DefinitionData` field.

However there are cases where `LambdaDefinitionData` ("LDD") aren't copied or 
moved completely, into this `DefinitionData` ("DD") field, as it has additional 
members of its own.

This patch:

- makes LDD a separate structure, no longer using DD as the base class, but 
otherwise kept the same so as to encapsulate lambda stuff properly
- stores lambda data within an `Optional` called `LambdaData`
- replaces `IsLambda` bit with `bool isLambda() const`, true IFF lambda data 
are present in that optional field
- as the formerly-subclass's LDD constructor set some members on DD, this is 
now done in a new method `SetLambdaData`; this sets those fields to values 
sensible for lambdas, and emplaces lambda data in the optional field

This solves one case where lambda data were not handled quite properly.

Note that this doesn't solve all lambda-handling in `pcm`'s (clang modules) but 
is more of a refactoring pre-step.

Test Plan: `ninja check-clang-modules`


Repository:
  rC Clang

https://reviews.llvm.org/D50948

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/DeclCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp

Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -6017,7 +6017,7 @@
 
 void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
   auto &Data = D->data();
-  Record->push_back(Data.IsLambda);
+  Record->push_back(Data.hasLambdaData());  // lambda-specific data added below
   Record->push_back(Data.UserDeclaredConstructor);
   Record->push_back(Data.UserDeclaredSpecialMembers);
   Record->push_back(Data.Aggregate);
@@ -6075,8 +6075,6 @@
   if (ModulesDebugInfo)
 Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));
 
-  // IsLambda bit is already saved.
-
   Record->push_back(Data.NumBases);
   if (Data.NumBases > 0)
 AddCXXBaseSpecifiers(Data.bases());
@@ -6092,8 +6090,8 @@
   AddDeclRef(D->getFirstFriend());
 
   // Add lambda-specific data.
-  if (Data.IsLambda) {
-auto &Lambda = D->getLambdaData();
+  if (Data.hasLambdaData()) {
+auto &Lambda = *Data.LambdaData;
 Record->push_back(Lambda.Dependent);
 Record->push_back(Lambda.IsGenericLambda);
 Record->push_back(Lambda.CaptureDefault);
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1636,7 +1636,7 @@
 
 void ASTDeclReader::ReadCXXDefinitionData(
 struct CXXRecordDecl::DefinitionData &Data, const CXXRecordDecl *D) {
-  // Note: the caller has deserialized the IsLambda bit already.
+  // Note: the caller has deserialized the bit for `isLambda()` already.
   Data.UserDeclaredConstructor = Record.readInt();
   Data.UserDeclaredSpecialMembers = Record.readInt();
   Data.Aggregate = Record.readInt();
@@ -1703,10 +1703,10 @@
   assert(Data.Definition && "Data.Definition should be already set!");
   Data.FirstFriend = ReadDeclID();
 
-  if (Data.IsLambda) {
+  if (Data.hasLambdaData()) {
 using Capture = LambdaCapture;
 
-auto &Lambda = static_cast(Data);
+auto &Lambda = *Data.LambdaData;
 Lambda.Dependent = Record.readInt();
 Lambda.IsGenericLambda = Record.readInt();
 Lambda.CaptureDefault = Record.readInt();
@@ -1764,7 +1764,10 @@
 Reader.PendingFakeDefinitionData.erase(PFDI);
 
 // FIXME: handle serialized lambdas
-assert(!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?");
+assert(!(DD.hasLambdaData() || MergeDD.hasLambdaData()) &&
+   "faked up lambda definition?");
+
+assert(DD.hasLambdaData() == MergeDD.hasLambdaData());
 
 // Don't change which declaration is the definition; that is required
 // to be invariant once we select it.
@@ -1828,7 +1831,6 @@
   MATCH_FIELD(ImplicitCopyAssignmentHasConstParam)
   OR_FIELD(HasDeclaredCopyConstructorWithConstParam)
   OR_FIELD(HasDeclaredCopyAssignmentWithConstParam)
-  MATCH_FIELD(IsLambda)
 #undef OR_FIELD
 #undef MATCH_FIELD
 
@@ -1847,7 +1849,7 @@
   // FIXME: Issue a diagnostic if FirstFriend doesn't match when we come to
   // lazily load it.
 
-  if (DD.IsLambda) {
+  if (DD.hasLambdaData()) {
 // FIXME: ODR-checking for merging lambdas (this happens, for instance,
 // when they occur within the body of a function template specialization).
   }
@@ -1862,17 +1864,17 @@
 }
 
 void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update) {
-  struct CXXRecordDecl::DefinitionData *DD;
   ASTContext &C = Reader.getContext();
 
+  struct CXXRecordDecl::DefinitionData *DD =
+  new (C) struct CXXRecordDecl::DefinitionData(D)

[PATCH] D50949: Handle lambdas in .pcm [de]serialization

2018-08-19 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande created this revision.
elsteveogrande added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.

- Drop a couple of asserts preventing this (in the merge function)
- Merge all fields as usual
- Ensure select fields match, for ODR checking
- add previously-failing test to merge-lambdas.cpp

Test case by Andrew Gallagher

Test Plan: Andrew's repro from https://bugs.llvm.org/show_bug.cgi?id=38531 
broke before this change, works after.


Repository:
  rC Clang

https://reviews.llvm.org/D50949

Files:
  include/clang/AST/LambdaCapture.h
  lib/Serialization/ASTReaderDecl.cpp
  test/Modules/merge-lambdas.cpp

Index: test/Modules/merge-lambdas.cpp
===
--- test/Modules/merge-lambdas.cpp
+++ test/Modules/merge-lambdas.cpp
@@ -49,3 +49,25 @@
 
 #pragma clang module import A
 void (*p)() = f();
+
+#pragma clang module build PR38531
+module PR38531 {}
+#pragma clang module contents
+#pragma clang module begin PR38531
+template 
+struct S {};
+struct Fun {
+  template ())>
+  Fun(F) {}
+};
+template 
+void foo(Fun=[]{}) {}
+struct T {
+  void func() {
+foo();
+  }
+};
+#pragma clang module end
+#pragma clang module endbuild
+#pragma clang module import PR38531
+S s;
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1763,12 +1763,6 @@
 
 Reader.PendingFakeDefinitionData.erase(PFDI);
 
-// FIXME: handle serialized lambdas
-assert(!(DD.hasLambdaData() || MergeDD.hasLambdaData()) &&
-   "faked up lambda definition?");
-
-assert(DD.hasLambdaData() == MergeDD.hasLambdaData());
-
 // Don't change which declaration is the definition; that is required
 // to be invariant once we select it.
 auto *Def = DD.Definition;
@@ -1849,9 +1843,44 @@
   // FIXME: Issue a diagnostic if FirstFriend doesn't match when we come to
   // lazily load it.
 
-  if (DD.hasLambdaData()) {
-// FIXME: ODR-checking for merging lambdas (this happens, for instance,
-// when they occur within the body of a function template specialization).
+  assert (DD.hasLambdaData() == MergeDD.hasLambdaData() &&
+  "Merging definitions, one of which is a lambda, the other not?");
+  if (DD.hasLambdaData() && MergeDD.hasLambdaData()) {
+auto &LDD = *DD.LambdaData;
+auto &MergeLDD = *MergeDD.LambdaData;
+
+#define MATCH_LAM_FIELD(Field) \
+DetectedOdrViolation |= LDD.Field != MergeLDD.Field;
+MATCH_LAM_FIELD(Dependent)
+MATCH_LAM_FIELD(IsGenericLambda)
+MATCH_LAM_FIELD(CaptureDefault)
+MATCH_LAM_FIELD(NumCaptures)
+MATCH_LAM_FIELD(NumExplicitCaptures)
+MATCH_LAM_FIELD(ManglingNumber)
+#undef MATCH_LAM_FIELD
+
+auto *C1 = LDD.Captures;
+auto *C2 = MergeLDD.Captures;
+for (int I = 0; !DetectedOdrViolation && I < LDD.NumCaptures; ++I) {
+  if (C1[I] != C2[I]) {
+DetectedOdrViolation = true;
+  }
+}
+
+if (LDD.MethodTyInfo || MergeLDD.MethodTyInfo) {
+  if (!LDD.MethodTyInfo ||
+  !MergeLDD.MethodTyInfo ||
+  (LDD.MethodTyInfo->getType().getTypePtrOrNull() !=
+  MergeLDD.MethodTyInfo->getType().getTypePtrOrNull())) {
+DetectedOdrViolation = true;
+llvm::errs() << "@@@ T1 " << LDD.MethodTyInfo->getType().getTypePtrOrNull()
+   << " T2 " << MergeLDD.MethodTyInfo->getType().getTypePtrOrNull()
+   << '\n';
+  }
+}
+
+// FIXME: Issue a diagnostic if ContextDecl doesn't match when we come to
+// lazily load it.
   }
 
   if (D->getODRHash() != MergeDD.ODRHash) {
Index: include/clang/AST/LambdaCapture.h
===
--- include/clang/AST/LambdaCapture.h
+++ include/clang/AST/LambdaCapture.h
@@ -135,6 +135,16 @@
 assert(isPackExpansion() && "No ellipsis location for a non-expansion");
 return EllipsisLoc;
   }
+
+  // [In]Equality operators -- primarily for ODR-compliance checking.
+
+  bool operator==(LambdaCapture const &RHS) const {
+return DeclAndBits == RHS.DeclAndBits;
+  }
+
+  bool operator!=(LambdaCapture const &RHS) const {
+return !operator==(RHS);
+  }
 };
 
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50942: SemaExceptionSpec: ensure old/new specs are both parsed and evaluated when comparing

2018-08-19 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande planned changes to this revision.
elsteveogrande marked an inline comment as done.
elsteveogrande added a comment.

This broke some tests.  It fixes the test case added here under `test/Modules` 
but causes errors in `test/CodeGenCXX` and other dirs.


Repository:
  rC Clang

https://reviews.llvm.org/D50942



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


r340145 - [Lex] Fix some inconsistent parameter names and duplicate comments. NFC

2018-08-19 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Sun Aug 19 15:23:42 2018
New Revision: 340145

URL: http://llvm.org/viewvc/llvm-project?rev=340145&view=rev
Log:
[Lex] Fix some inconsistent parameter names and duplicate comments. NFC

Modified:
cfe/trunk/include/clang/Lex/DirectoryLookup.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/include/clang/Lex/Pragma.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Lex/PreprocessorLexer.h
cfe/trunk/include/clang/Lex/TokenLexer.h

Modified: cfe/trunk/include/clang/Lex/DirectoryLookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/DirectoryLookup.h?rev=340145&r1=340144&r2=340145&view=diff
==
--- cfe/trunk/include/clang/Lex/DirectoryLookup.h (original)
+++ cfe/trunk/include/clang/Lex/DirectoryLookup.h Sun Aug 19 15:23:42 2018
@@ -191,7 +191,7 @@ private:
   SmallVectorImpl *RelativePath,
   Module *RequestingModule,
   ModuleMap::KnownHeader *SuggestedModule,
-  bool &InUserSpecifiedSystemHeader) const;
+  bool &InUserSpecifiedSystemFramework) const;
 
 };
 

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=340145&r1=340144&r2=340145&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Sun Aug 19 15:23:42 2018
@@ -55,7 +55,7 @@ struct HeaderFileInfo {
   /// True if this is a \#pragma once file.
   unsigned isPragmaOnce : 1;
 
-  /// DirInfo - Keep track of whether this is a system header, and if so,
+  /// Keep track of whether this is a system header, and if so,
   /// whether it is C++ clean or not.  This can be set by the include paths or
   /// by \#pragma gcc system_header.  This is an instance of
   /// SrcMgr::CharacteristicKind.
@@ -219,14 +219,14 @@ class HeaderSearch {
   /// name like "Carbon" to the Carbon.framework directory.
   llvm::StringMap FrameworkMap;
 
-  /// IncludeAliases - maps include file names (including the quotes or
+  /// Maps include file names (including the quotes or
   /// angle brackets) to other include file names.  This is used to support the
   /// include_alias pragma for Microsoft compatibility.
   using IncludeAliasMap =
   llvm::StringMap;
   std::unique_ptr IncludeAliases;
 
-  /// HeaderMaps - This is a mapping from FileEntry -> HeaderMap, uniquing
+  /// This is a mapping from FileEntry -> HeaderMap, uniquing
   /// headermaps.  This vector owns the headermap.
   std::vector> HeaderMaps;
 
@@ -314,7 +314,7 @@ public:
 (*IncludeAliases)[Source] = Dest;
   }
 
-  /// MapHeaderToIncludeAlias - Maps one header file name to a different header
+  /// Maps one header file name to a different header
   /// file name, for use with the include_alias pragma.  Note that the source
   /// file name should include the angle brackets or quotes.  Returns StringRef
   /// as null if the header cannot be mapped.
@@ -408,7 +408,7 @@ public:
   /// HIToolbox is a subframework within Carbon.framework.  If so, return
   /// the FileEntry for the designated file, otherwise return null.
   const FileEntry *LookupSubframeworkHeader(
-  StringRef Filename, const FileEntry *RelativeFileEnt,
+  StringRef Filename, const FileEntry *ContextFileEnt,
   SmallVectorImpl *SearchPath, SmallVectorImpl *RelativePath,
   Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule);
 
@@ -425,7 +425,7 @@ public:
   /// if we should include it.
   bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File,
   bool isImport, bool ModulesEnabled,
-  Module *CorrespondingModule);
+  Module *M);
 
   /// Return whether the specified file is a normal header,
   /// a system header, or a C++ friendly system header.
@@ -448,9 +448,9 @@ public:
   }
 
   /// Mark the specified file as part of a module.
-  void MarkFileModuleHeader(const FileEntry *File,
+  void MarkFileModuleHeader(const FileEntry *FE,
 ModuleMap::ModuleHeaderRole Role,
-bool IsCompiledModuleHeader);
+bool isCompilingModuleHeader);
 
   /// Increment the count for the number of times the specified
   /// FileEntry has been entered.
@@ -479,7 +479,7 @@ public:
   /// This routine does not consider the effect of \#import
   bool isFileMultipleIncludeGuarded(const FileEntry *File);
 
-  /// CreateHeaderMap - This method returns a HeaderMap for the specified
+  /// This method returns a HeaderMap for the specified
   /// FileEntry, uniquing them through the 'HeaderMaps' datastructure.
   const HeaderMap *CreateHeaderMap(const FileEntry *FE);
 
@@ -6

[PATCH] D50953: [clang-tidy] Handle sugared reference types in ExprMutationAnalyzer

2018-08-19 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision.
shuaiwang added reviewers: aaron.ballman, alexfh.
Herald added subscribers: cfe-commits, Szelethus, a.sidorin, xazax.hun.
Herald added a reviewer: george.karpenkov.

This handles cases like this:

  typedef int& IntRef;
  void mutate(IntRef);
  void f() {
int x;
mutate(x);
  }

where the param type is a sugared type (`TypedefType`) instead of a
reference type directly.

Note that another category of similar but different cases are already
handled properly before:

  typedef int Int;
  void mutate(Int&);
  void f() {
int x;
mutate(x);
  }


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50953

Files:
  clang-tidy/utils/ExprMutationAnalyzer.cpp
  unittests/clang-tidy/ExprMutationAnalyzerTest.cpp

Index: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
===
--- unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
+++ unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
@@ -168,6 +168,18 @@
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
 
+  AST = tooling::buildASTFromCode("typedef int& IntRef;"
+  "void g(IntRef); void f() { int x; g(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
+
+  AST = tooling::buildASTFromCode(
+  "template  struct identity { using type = T; };"
+  "template  void g(typename identity::type);"
+  "void f() { int x; g(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
+
   AST = tooling::buildASTFromCode(
   "void f() { struct A {}; A operator+(A&, int); A x; x + 1; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
@@ -348,13 +360,22 @@
 }
 
 TEST(ExprMutationAnalyzerTest, FollowRefModified) {
-  const auto AST = tooling::buildASTFromCode(
+  auto AST = tooling::buildASTFromCode(
   "void f() { int x; int& r0 = x; int& r1 = r0; int& r2 = r1; "
   "int& r3 = r2; r3 = 10; }");
-  const auto Results =
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
   ElementsAre("r0", "r1", "r2", "r3", "r3 = 10"));
+
+  AST = tooling::buildASTFromCode(
+  "typedef int& IntRefX;"
+  "using IntRefY = int&;"
+  "void f() { int x; IntRefX r0 = x; IntRefY r1 = r0;"
+  "decltype((x)) r2 = r1; r2 = 10; }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("r0", "r1", "r2", "r2 = 10"));
 }
 
 TEST(ExprMutationAnalyzerTest, FollowRefNotModified) {
@@ -424,12 +445,19 @@
 }
 
 TEST(ExprMutationAnalyzerTest, CastToRefModified) {
-  const auto AST = tooling::buildASTFromCode(
+  auto AST = tooling::buildASTFromCode(
   "void f() { int x; static_cast(x) = 10; }");
-  const auto Results =
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()),
   ElementsAre("static_cast(x) = 10"));
+
+  AST = tooling::buildASTFromCode(
+  "typedef int& IntRef;"
+  "void f() { int x; static_cast(x) = 10; }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()),
+  ElementsAre("static_cast(x) = 10"));
 }
 
 TEST(ExprMutationAnalyzerTest, CastToRefNotModified) {
@@ -483,11 +511,17 @@
 }
 
 TEST(ExprMutationAnalyzerTest, RangeForArrayByRefModified) {
-  const auto AST = tooling::buildASTFromCode(
+  auto AST = tooling::buildASTFromCode(
   "void f() { int x[2]; for (int& e : x) e = 10; }");
-  const auto Results =
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("e", "e = 10"));
+
+  AST = tooling::buildASTFromCode(
+  "typedef int& IntRef;"
+  "void f() { int x[2]; for (IntRef e : x) e = 10; }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("e", "e = 10"));
 }
 
 TEST(ExprMutationAnalyzerTest, RangeForArrayByRefNotModified) {
Index: clang-tidy/utils/ExprMutationAnalyzer.cpp
===
--- clang-tidy/utils/ExprMutationAnalyzer.cpp
+++ clang-tidy/utils/ExprMutationAnalyzer.cpp
@@ -48,7 +48,8 @@
 }
 
 const auto nonConstReferenceType = [] {
-  return referenceType(pointee(unless(isConstQualified(;
+  return hasUnqualifiedDesugaredType(
+  referenceType(pointee(unless(isConstQualified();
 };
 
 } // namespace
___