[PATCH] D63640: [clang] Improve Serialization/Imporing of APValues

2020-10-15 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

In D63640#2331734 , @martong wrote:

> In D63640#2331410 , @rsmith wrote:
>
>> Reverse ping: I have a patch implementing class type non-type template 
>> parameters that's blocked on this landing. If you won't have time to address 
>> @martong's comments soon, do you mind if I take this over and land it?
>
> It is okay for me to commit this patch in its current state. The changes I 
> suggested could result in a cleaner code, but I can do those changes after we 
> land this.

i couldn't apply martong's suggestion because importChecked is part of 
ASTNodeImporter not ASTImporter, but cleaned up some code.
but the "real" blocker is that the testing depends on D85144 
 for testing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63640/new/

https://reviews.llvm.org/D63640

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


[PATCH] D63640: [clang] Improve Serialization/Imporing of APValues

2020-10-15 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 298318.
Tyker added a comment.

try to apply martongs's suggestions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63640/new/

https://reviews.llvm.org/D63640

Files:
  clang/include/clang/AST/APValue.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/ASTMerge/APValue/APValue.cpp

Index: clang/test/ASTMerge/APValue/APValue.cpp
===
--- /dev/null
+++ clang/test/ASTMerge/APValue/APValue.cpp
@@ -0,0 +1,460 @@
+// RUN: %clang_cc1 -std=gnu++2a -emit-pch %s -o %t.pch
+// RUN: %clang_cc1 -std=gnu++2a %s -DEMIT -ast-merge %t.pch -ast-dump-all | FileCheck %s
+
+#ifndef EMIT
+#define EMIT
+
+namespace Integer {
+
+consteval int fint() {
+  return 6789;
+}
+
+int Unique_Int = fint();
+//CHECK:  VarDecl {{.*}} Unique_Int
+//CHECK-NEXT: ConstantExpr {{.*}} 'int'
+//CHECK-NEXT: value: Int 6789
+
+consteval __uint128_t fint128() {
+  return ((__uint128_t)0x75f17d6b3588f843 << 64) | 0xb13dea7c9c324e51;
+}
+
+constexpr __uint128_t Unique_Int128 = fint128();
+//CHECK:  VarDecl {{.*}} Unique_Int128
+//CHECK-NEXT: value: Int 156773562844924187900898496343692168785
+//CHECK-NEXT: ConstantExpr
+//CHECK-NEXT: value: Int 156773562844924187900898496343692168785
+
+} // namespace Integer
+
+namespace FloatingPoint {
+
+consteval double fdouble() {
+  return double(567890.67890);
+}
+
+double Unique_Double = fdouble();
+//CHECK:  VarDecl {{.*}} Unique_Double
+//CHECK-NEXT: ConstantExpr {{.*}}
+//CHECK-NEXT: value: Float 5.678907e+05
+
+} // namespace FloatingPoint
+
+// FIXME: Add test for FixedPoint, ComplexInt, ComplexFloat, AddrLabelDiff.
+
+namespace Struct {
+
+struct B {
+  int i;
+  double d;
+};
+
+consteval B fB() {
+  return B{1, 0.7};
+}
+
+constexpr B Basic_Struct = fB();
+//CHECK:  VarDecl {{.*}} Basic_Struct
+//CHECK-NEXT: value: Struct
+//CHECK-NEXT: fields: Int 1, Float 7.00e-01
+//CHECK-NEXT: ImplicitCastExpr
+//CHECK-NEXT: ConstantExpr
+//CHECK-NEXT: value: Struct
+//CHECK-NEXT: fields: Int 1, Float 7.00e-01
+
+struct C {
+  int i = 9;
+};
+
+struct A : B {
+  constexpr A(B b, int I, double D, C _c) : B(b), i(I), d(D), c(_c) {}
+  int i;
+  double d;
+  C c;
+};
+
+consteval A fA() {
+  return A(Basic_Struct, 1, 79.789, {});
+}
+
+A Advanced_Struct = fA();
+//CHECK:  VarDecl {{.*}} Advanced_Struct
+//CHECK-NEXT: ConstantExpr {{.*}}
+//CHECK-NEXT: value: Struct
+//CHECK-NEXT: base: Struct
+//CHECK-NEXT: fields: Int 1, Float 7.00e-01
+//CHECK-NEXT: fields: Int 1, Float 7.978900e+01
+//CHECK-NEXT: field: Struct
+//CHECK-NEXT: field: Int 9
+
+} // namespace Struct
+
+namespace Vector {
+
+using v4si = int __attribute__((__vector_size__(16)));
+
+consteval v4si fv4si() {
+  return (v4si){8, 2, 3};
+}
+
+v4si Vector_Int = fv4si();
+//CHECK:  VarDecl {{.*}} Vector_Int
+//CHECK-NEXT: ConstantExpr
+//CHECK-NEXT: value: Vector length=4
+//CHECK-NEXT: elements: Int 8, Int 2, Int 3, Int 0
+
+} // namespace Vector
+
+namespace Array {
+
+struct B {
+  int arr[6];
+};
+
+consteval B fint() {
+  return B{1, 2, 3, 4, 5, 6};
+}
+
+B Array_Int = fint();
+//CHECK:  VarDecl {{.*}} Array_Int
+//CHECK-NEXT: ConstantExpr
+//CHECK-NEXT: value: Struct
+//CHECK-NEXT: field: Array size=6
+//CHECK-NEXT: elements: Int 1, Int 2, Int 3, Int 4
+//CHECK-NEXT: elements: Int 5, Int 6
+
+struct A {
+  int i = 789;
+  double d = 67890.09876;
+};
+
+struct C {
+  A arr[3];
+};
+
+consteval C fA() {
+  return {{A{}, A{-45678, 9.8}, A{9}}};
+}
+
+C Array2_Struct = fA();
+//CHECK:  VarDecl {{.*}} Array2_Struct
+//CHECK-NEXT: ConstantExpr {{.*}}
+
+using v4si = int __attribute__((__vector_size__(16)));
+
+struct D {
+  v4si arr[2];
+};
+
+consteval D fv4si() {
+  return {{{1, 2, 3, 4}, {4, 5, 6, 7}}};
+}
+
+D Array_Vector = fv4si();
+//CHECK:  VarDecl {{.*}} Array_Vector
+//CHECK-NEXT: ConstantExpr {{.*}}
+//CHECK-NEXT: value: Struct
+//CHECK-NEXT: field: Array size=2
+//CHECK-NEXT: element: Vector length=4
+//CHECK-NEXT: elements: Int 1, Int 2, Int 3, Int 4
+//CHECK-NEXT: element: Vector length=4
+//CHECK-NEXT: elements: Int 4, Int 5, Int 6, Int 7
+
+} // namespace Array
+
+namespace Union {
+
+struct A {
+  int i = 6789;
+  float f = 987.9876;
+};
+
+union U {
+  int i;
+  A a{567890, 9876.5678f};
+};
+
+consteval U fU1() {
+  return U{0};
+}
+
+U Unique_Union1 = fU1();
+//CHECK:  VarDecl {{.*}} Unique_Union
+//CHECK-NEXT: ConstantExpr
+//CHECK-NEXT: value: Union .i Int 0
+
+consteval U fU() {
+  return U{};
+}
+
+U Unique_Union2 = fU();
+//CHECK:  VarDecl {{.*}} Unique_Union
+//CHECK-NEXT: ConstantExpr
+//CHECK-NEXT: value: Union .a
+//CHECK-NEXT: Struct
+//CHECK-NEXT: fields: Int 567890, Float 9.876567e+03
+
+} // nam

[PATCH] D88295: [Sema] Fix volatile check when test if a return object can be implicitly move

2020-10-15 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment.

Ping!
I don't have commit access, can anyone help me commit this with "Yang Fan 
" ?
Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88295/new/

https://reviews.llvm.org/D88295

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


Re: [Lldb-commits] Upcoming upgrade of LLVM buildbot

2020-10-15 Thread Vitaly Buka via cfe-commits
Ok, I can switch them back to staging. However today's staging was
frequently offline.


On Wed, 14 Oct 2020 at 21:44, Galina Kistanova  wrote:

> Thanks everyone!
>
> I would like to keep the bots in the staging till Friday. And if
> everything is good, then apply the changes to the production and let you
> move all the green bots back there.
>
> Thanks
>
> Galina
>
>
> On Tue, Oct 13, 2020 at 10:43 PM Vitaly Buka 
> wrote:
>
>> They do on staging.
>> http://lab.llvm.org:8014/#/builders/sanitizer-windows
>> http://lab.llvm.org:8014/#/builders/clang-x64-windows-msvc
>>
>> Galina, when do you plan to push this to the primary server?
>> If it's a few days, I'd rather keep bots on staging to have colors.
>>
>>
>>
>> On Tue, 13 Oct 2020 at 11:11, Reid Kleckner  wrote:
>>
>>> FWIW, I don't see any issues with my two bots that use buildbot
>>> annotated commands:
>>> http://lab.llvm.org:8011/#/builders/sanitizer-windows
>>> http://lab.llvm.org:8011/#/builders/clang-x64-windows-msvc
>>> The individual steps don't highlight as green or red, but that's OK for
>>> now.
>>>
>>> On Mon, Oct 12, 2020 at 7:19 PM Galina Kistanova 
>>> wrote:
>>>
 We have a better version of AnnotatedCommand on the staging. It should
 be a functional equivalent of the old one.
 We need to stress test it well before moving to the production build
 bot.

 For that we need all sanitizer + other bots which use the
 AnnotatedCommand directly or indirectly moved temporarily to the staging.

 Please let me know when that could be arranged.

 Thanks

 Galina

 On Mon, Oct 12, 2020 at 11:39 AM Reid Kleckner  wrote:

> On Wed, Oct 7, 2020 at 4:32 PM Galina Kistanova via lldb-commits <
> lldb-comm...@lists.llvm.org> wrote:
>
>> They are online now -
>> http://lab.llvm.org:8011/#/waterfall?tags=sanitizer
>>
>> AnnotatedCommand has severe design conflict with the new buildbot.
>> We have changed it to be safe and still do something useful, but it
>> will need more love and care.
>>
>> Please let me know if you have some spare time to work on porting
>> AnnotatedCommand.
>>
>
> That's unfortunate, it would've been good to know that earlier. I and
> another team member have spent a fair amount of time porting things to use
> more AnnotatedCommand steps, because it gives us the flexibility to test
> steps locally and make changes to the steps without restarting the 
> buildbot
> master. IMO that is the Right Way to define steps: a script that you can
> run locally on a machine that satisfies the OS and dep requirements of the
> script.
>
> I am restarting the two bots that I am responsible for, and may need
> some help debugging further issues soon. I'll let you know.
>

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


[clang] 53122ce - [NFC] Correct name of profile function to Profile in APValue

2020-10-15 Thread via cfe-commits

Author: Tyker
Date: 2020-10-15T10:53:40+02:00
New Revision: 53122ce2b39f5fb52c7a5933cc4cf32aad43568f

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

LOG: [NFC] Correct name of profile function to Profile in APValue

Capitalize the profile function of APValue such that it can be used by 
FoldingSetNodeID

Reviewed By: rsmith

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

Added: 


Modified: 
clang/include/clang/AST/APValue.h
clang/lib/AST/APValue.cpp

Removed: 




diff  --git a/clang/include/clang/AST/APValue.h 
b/clang/include/clang/AST/APValue.h
index 5eb1f68f7690..0ee48f35a20a 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -151,7 +151,7 @@ class APValue {
 static LValueBase getDynamicAlloc(DynamicAllocLValue LV, QualType Type);
 static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo);
 
-void profile(llvm::FoldingSetNodeID &ID) const;
+void Profile(llvm::FoldingSetNodeID &ID) const;
 
 template 
 bool is() const { return Ptr.is(); }
@@ -219,7 +219,7 @@ class APValue {
 }
 uint64_t getAsArrayIndex() const { return Value; }
 
-void profile(llvm::FoldingSetNodeID &ID) const;
+void Profile(llvm::FoldingSetNodeID &ID) const;
 
 friend bool operator==(LValuePathEntry A, LValuePathEntry B) {
   return A.Value == B.Value;
@@ -363,10 +363,10 @@ class APValue {
   /// Swaps the contents of this and the given APValue.
   void swap(APValue &RHS);
 
-  /// Profile this value. There is no guarantee that values of 
diff erent
+  /// profile this value. There is no guarantee that values of 
diff erent
   /// types will not produce the same profiled value, so the type should
   /// typically also be profiled if it's not implied by the context.
-  void profile(llvm::FoldingSetNodeID &ID) const;
+  void Profile(llvm::FoldingSetNodeID &ID) const;
 
   ValueKind getKind() const { return Kind; }
 

diff  --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 7efd0caf3f1d..8d402ee8e3dc 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -77,7 +77,7 @@ QualType APValue::LValueBase::getDynamicAllocType() const {
   return QualType::getFromOpaquePtr(DynamicAllocType);
 }
 
-void APValue::LValueBase::profile(llvm::FoldingSetNodeID &ID) const {
+void APValue::LValueBase::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.AddPointer(Ptr.getOpaqueValue());
   if (is() || is())
 return;
@@ -103,7 +103,7 @@ APValue::LValuePathEntry::LValuePathEntry(BaseOrMemberType 
BaseOrMember) {
   Value = reinterpret_cast(BaseOrMember.getOpaqueValue());
 }
 
-void APValue::LValuePathEntry::profile(llvm::FoldingSetNodeID &ID) const {
+void APValue::LValuePathEntry::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.AddInteger(Value);
 }
 
@@ -414,7 +414,7 @@ void APValue::swap(APValue &RHS) {
   std::swap(Data, RHS.Data);
 }
 
-void APValue::profile(llvm::FoldingSetNodeID &ID) const {
+void APValue::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.AddInteger(Kind);
 
   switch (Kind) {
@@ -430,10 +430,10 @@ void APValue::profile(llvm::FoldingSetNodeID &ID) const {
   case Struct:
 ID.AddInteger(getStructNumBases());
 for (unsigned I = 0, N = getStructNumBases(); I != N; ++I)
-  getStructBase(I).profile(ID);
+  getStructBase(I).Profile(ID);
 ID.AddInteger(getStructNumFields());
 for (unsigned I = 0, N = getStructNumFields(); I != N; ++I)
-  getStructField(I).profile(ID);
+  getStructField(I).Profile(ID);
 return;
 
   case Union:
@@ -442,7 +442,7 @@ void APValue::profile(llvm::FoldingSetNodeID &ID) const {
   return;
 }
 ID.AddPointer(getUnionField()->getCanonicalDecl());
-getUnionValue().profile(ID);
+getUnionValue().Profile(ID);
 return;
 
   case Array: {
@@ -459,9 +459,9 @@ void APValue::profile(llvm::FoldingSetNodeID &ID) const {
 //   ['a', 'c', 'x', 'x', 'x'] is profiled as
 //   [5, 'x', 3, 'c', 'a']
 llvm::FoldingSetNodeID FillerID;
-(hasArrayFiller() ? getArrayFiller() :
- getArrayInitializedElt(getArrayInitializedElts() -
-   1)).profile(FillerID);
+(hasArrayFiller() ? getArrayFiller()
+  : getArrayInitializedElt(getArrayInitializedElts() - 1))
+.Profile(FillerID);
 ID.AddNodeID(FillerID);
 unsigned NumFillers = getArraySize() - getArrayInitializedElts();
 unsigned N = getArrayInitializedElts();
@@ -481,7 +481,7 @@ void APValue::profile(llvm::FoldingSetNodeID &ID) const {
   // element.
   if (N != getArraySize()) {
 llvm::FoldingSetNodeID ElemID;
-getArrayInitializedElt(N - 1).profile(ElemID);
+getArrayInitializedElt(N - 1).Profile(ElemID);
 if (ElemID != FillerID) {
   ID.AddIntege

[PATCH] D88643: [NFC] Correct name of profile function to Profile in APValue

2020-10-15 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG53122ce2b39f: [NFC] Correct name of profile function to 
Profile in APValue (authored by Tyker).

Changed prior to commit:
  https://reviews.llvm.org/D88643?vs=295502&id=298330#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88643/new/

https://reviews.llvm.org/D88643

Files:
  clang/include/clang/AST/APValue.h
  clang/lib/AST/APValue.cpp

Index: clang/lib/AST/APValue.cpp
===
--- clang/lib/AST/APValue.cpp
+++ clang/lib/AST/APValue.cpp
@@ -77,7 +77,7 @@
   return QualType::getFromOpaquePtr(DynamicAllocType);
 }
 
-void APValue::LValueBase::profile(llvm::FoldingSetNodeID &ID) const {
+void APValue::LValueBase::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.AddPointer(Ptr.getOpaqueValue());
   if (is() || is())
 return;
@@ -103,7 +103,7 @@
   Value = reinterpret_cast(BaseOrMember.getOpaqueValue());
 }
 
-void APValue::LValuePathEntry::profile(llvm::FoldingSetNodeID &ID) const {
+void APValue::LValuePathEntry::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.AddInteger(Value);
 }
 
@@ -414,7 +414,7 @@
   std::swap(Data, RHS.Data);
 }
 
-void APValue::profile(llvm::FoldingSetNodeID &ID) const {
+void APValue::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.AddInteger(Kind);
 
   switch (Kind) {
@@ -430,10 +430,10 @@
   case Struct:
 ID.AddInteger(getStructNumBases());
 for (unsigned I = 0, N = getStructNumBases(); I != N; ++I)
-  getStructBase(I).profile(ID);
+  getStructBase(I).Profile(ID);
 ID.AddInteger(getStructNumFields());
 for (unsigned I = 0, N = getStructNumFields(); I != N; ++I)
-  getStructField(I).profile(ID);
+  getStructField(I).Profile(ID);
 return;
 
   case Union:
@@ -442,7 +442,7 @@
   return;
 }
 ID.AddPointer(getUnionField()->getCanonicalDecl());
-getUnionValue().profile(ID);
+getUnionValue().Profile(ID);
 return;
 
   case Array: {
@@ -459,9 +459,9 @@
 //   ['a', 'c', 'x', 'x', 'x'] is profiled as
 //   [5, 'x', 3, 'c', 'a']
 llvm::FoldingSetNodeID FillerID;
-(hasArrayFiller() ? getArrayFiller() :
- getArrayInitializedElt(getArrayInitializedElts() -
-   1)).profile(FillerID);
+(hasArrayFiller() ? getArrayFiller()
+  : getArrayInitializedElt(getArrayInitializedElts() - 1))
+.Profile(FillerID);
 ID.AddNodeID(FillerID);
 unsigned NumFillers = getArraySize() - getArrayInitializedElts();
 unsigned N = getArrayInitializedElts();
@@ -481,7 +481,7 @@
   // element.
   if (N != getArraySize()) {
 llvm::FoldingSetNodeID ElemID;
-getArrayInitializedElt(N - 1).profile(ElemID);
+getArrayInitializedElt(N - 1).Profile(ElemID);
 if (ElemID != FillerID) {
   ID.AddInteger(NumFillers);
   ID.AddNodeID(ElemID);
@@ -497,14 +497,14 @@
 
 // Emit the remaining elements.
 for (; N != 0; --N)
-  getArrayInitializedElt(N - 1).profile(ID);
+  getArrayInitializedElt(N - 1).Profile(ID);
 return;
   }
 
   case Vector:
 ID.AddInteger(getVectorLength());
 for (unsigned I = 0, N = getVectorLength(); I != N; ++I)
-  getVectorElt(I).profile(ID);
+  getVectorElt(I).Profile(ID);
 return;
 
   case Int:
@@ -533,7 +533,7 @@
 return;
 
   case LValue:
-getLValueBase().profile(ID);
+getLValueBase().Profile(ID);
 ID.AddInteger(getLValueOffset().getQuantity());
 ID.AddInteger(isNullPointer());
 ID.AddInteger(isLValueOnePastTheEnd());
@@ -541,7 +541,7 @@
 // to union members, but we don't have the type here so we don't know
 // how to interpret the entries.
 for (LValuePathEntry E : getLValuePath())
-  E.profile(ID);
+  E.Profile(ID);
 return;
 
   case MemberPointer:
Index: clang/include/clang/AST/APValue.h
===
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -151,7 +151,7 @@
 static LValueBase getDynamicAlloc(DynamicAllocLValue LV, QualType Type);
 static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo);
 
-void profile(llvm::FoldingSetNodeID &ID) const;
+void Profile(llvm::FoldingSetNodeID &ID) const;
 
 template 
 bool is() const { return Ptr.is(); }
@@ -219,7 +219,7 @@
 }
 uint64_t getAsArrayIndex() const { return Value; }
 
-void profile(llvm::FoldingSetNodeID &ID) const;
+void Profile(llvm::FoldingSetNodeID &ID) const;
 
 friend bool operator==(LValuePathEntry A, LValuePathEntry B) {
   return A.Value == B.Value;
@@ -363,10 +363,10 @@
   /// Swaps the contents of this and the given APValue.
   void swap(APValue &RHS);
 
-  /// Profile this value. There is no guarantee that values of different
+  /// profile this value. There is no guarantee that values of different
   /// types will not produce

[PATCH] D63640: [clang] Improve Serialization/Imporing of APValues

2020-10-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D63640#2331779 , @Tyker wrote:

> In D63640#2331734 , @martong wrote:
>
>> In D63640#2331410 , @rsmith wrote:
>>
>>> Reverse ping: I have a patch implementing class type non-type template 
>>> parameters
>
> that's blocked on this landing. If you won't have time to address @martong's 
> comments soon, do you mind if I take this over and land it?
>
> nice to see this coming.
>
>> It is okay for me to commit this patch in its current state. The changes I 
>> suggested could result in a cleaner code, but I can do those changes after 
>> we land this.
>
> i couldn't apply martong's suggestion completely because importChecked is 
> part of ASTNodeImporter not ASTImporter, but cleaned up some code.

This indicates that the newly added `Import(APValue *)` function should be part 
of the `ASTNodeImporter`. I came up with a draft patch on top of your patch:
https://github.com/llvm/llvm-project/commit/ac738cf854bdafa83a23c400bd5b2a90520566f9
You can see, this way we can eliminate some redundant `if`s and `casts`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63640/new/

https://reviews.llvm.org/D63640

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


[PATCH] D89372: [OpenCL] Remove unused extensions

2020-10-15 Thread Marco Antognini via Phabricator via cfe-commits
mantognini updated this revision to Diff 298333.
mantognini added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89372/new/

https://reviews.llvm.org/D89372

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/test/Misc/amdgcn.languageOptsOpenCL.cl
  clang/test/Misc/nvptx.languageOptsOpenCL.cl
  clang/test/Misc/r600.languageOptsOpenCL.cl
  clang/test/Preprocessor/init.c
  clang/test/SemaOpenCL/extension-version.cl

Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -34,26 +34,8 @@
 #endif
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable
 
-#ifndef cl_khr_gl_sharing
-#error "Missing cl_khr_gl_sharing define"
-#endif
-#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
-
-#ifndef cl_khr_icd
-#error "Missing cl_khr_icd define"
-#endif
-#pragma OPENCL EXTENSION cl_khr_icd: enable
-
 // Core features in CL 1.1
 
-#ifndef cl_khr_byte_addressable_store
-#error "Missing cl_khr_byte_addressable_store define"
-#endif
-#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
-// expected-warning@-2{{OpenCL extension 'cl_khr_byte_addressable_store' is core feature or supported optional core feature - ignoring}}
-#endif
-
 #ifndef cl_khr_global_int32_base_atomics
 #error "Missing cl_khr_global_int32_base_atomics define"
 #endif
@@ -86,15 +68,6 @@
 // expected-warning@-2{{OpenCL extension 'cl_khr_local_int32_extended_atomics' is core feature or supported optional core feature - ignoring}}
 #endif
 
-#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 110)
-// Deprecated abvoe 1.0
-#ifndef cl_khr_select_fprounding_mode
-#error "Missing cl_khr_select_fp_rounding_mode define"
-#endif
-#pragma OPENCL EXTENSION cl_khr_select_fprounding_mode: enable
-#endif
-
-
 // Core feature in CL 1.2
 #ifndef cl_khr_fp64
 #error "Missing cl_khr_fp64 define"
@@ -113,87 +86,6 @@
 // expected-warning@-2{{OpenCL extension 'cl_khr_3d_image_writes' is core feature or supported optional core feature - ignoring}}
 #endif
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110)
-#ifndef cl_khr_gl_event
-#error "Missing cl_khr_gl_event define"
-#endif
-#else
-// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_gl_event' - ignoring}}
-#endif
-#pragma OPENCL EXTENSION cl_khr_gl_event : enable
-
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110)
-#ifndef cl_khr_d3d10_sharing
-#error "Missing cl_khr_d3d10_sharing define"
-#endif
-#else
-// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_d3d10_sharing' - ignoring}}
-#endif
-#pragma OPENCL EXTENSION cl_khr_d3d10_sharing : enable
-
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110)
-#ifndef cles_khr_int64
-#error "Missing cles_khr_int64 define"
-#endif
-#else
-// expected-warning@+2{{unsupported OpenCL extension 'cles_khr_int64' - ignoring}}
-#endif
-#pragma OPENCL EXTENSION cles_khr_int64 : enable
-
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
-#ifndef cl_khr_context_abort
-#error "Missing cl_context_abort define"
-#endif
-#else
-// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_context_abort' - ignoring}}
-#endif
-#pragma OPENCL EXTENSION cl_khr_context_abort : enable
-
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
-#ifndef cl_khr_d3d11_sharing
-#error "Missing cl_khr_d3d11_sharing define"
-#endif
-#else
-// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_d3d11_sharing' - ignoring}}
-#endif
-#pragma OPENCL EXTENSION cl_khr_d3d11_sharing : enable
-
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
-#ifndef cl_khr_dx9_media_sharing
-#error "Missing cl_khr_dx9_media_sharing define"
-#endif
-#else
-// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_dx9_media_sharing' - ignoring}}
-#endif
-#pragma OPENCL EXTENSION cl_khr_dx9_media_sharing : enable
-
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
-#ifndef cl_khr_image2d_from_buffer
-#error "Missing cl_khr_image2d_from_buffer define"
-#endif
-#else
-// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_image2d_from_buffer' - ignoring}}
-#endif
-#pragma OPENCL EXTENSION cl_khr_image2d_from_buffer : enable
-
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
-#ifndef cl_khr_initialize_memory
-#error "Missing cl_khr_initialize_memory define"
-#endif
-#else
-// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_initialize_memory' - ignoring}}
-#endif
-#pragma OPENCL EXTENSION cl_khr_initialize_memory : enable
-
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
-#ifndef cl_kh

[PATCH] D89372: [OpenCL] Remove unused extensions

2020-10-15 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added inline comments.



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:16
 //
 // If the extensions are to be enumerated without the supported OpenCL version,
 // define OPENCLEXT(ext) where ext is the name of the extension.

Anastasia wrote:
> yaxunl wrote:
> > Can you add a comment here referring the spec about "Every extension which 
> > affects the OpenCL language semantics, syntax or adds built-in functions to 
> > the language must create a preprocessor #define that matches the extension 
> > name string." and therefore only extensions "which affects the OpenCL 
> > language semantics, syntax or adds built-in functions to the language" are 
> > defined in this file. Thanks.
> Good idea! I also suggest we add clarifications regarding pragmas, that those 
> are to be added only when the compiler needs to change the compilation flow 
> i.e. if there is a difference in the language semantic from what is defined 
> in a standard.
I've added a comment. Let me know if it suits you.



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:74
 OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)

Anastasia wrote:
> azabaznov wrote:
> > mantognini wrote:
> > > azabaznov wrote:
> > > > cl_khr_srgb_image_writes - Extension allowing writes to sRGB images 
> > > > from a kernel. This extension enables write_imagef built-in function as 
> > > > it described [[ 
> > > > https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_Ext.html#cl_khr_srgb_image_writes
> > > >  | here]]. So I think we shouldn't remove it. Do I miss something?
> > > On second reading, this one is slightly ambiguous. On the language side, 
> > > the extension doesn't add an overload; it only specifies that existing 
> > > overload can be used with a different kind of image. On the API side, it 
> > > does extend the set of features. But at the same time if the extended API 
> > > is not supported, it's not possible to create an image in the first place 
> > > and therefore impossible to call write_imagef. So I question the 
> > > usefulness of such macro on the device side. Does this argument convince 
> > > you it should be removed?
> > > it's not possible to create an image in the first place and therefore 
> > > impossible
> > Not quite that right. Referring to [[ 
> > https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_C.html#conversion-rules-for-srgba-and-sbgra-images
> >  | this ]]:
> > 
> > read_imagef built-in functions for OpenCL C 2.0 devices do implicit 
> > conversions to RGB for sRGB images. However, implicit conversion from sRGB 
> > to RGB is done on write_imagef only if corresponding extension is 
> > supported. Otherwise, explicit conversions inside a kernel may be required.
> > 
> > I'm agree that this one is kind of confusing and requires some extra 
> > investigation. But I think now we should remove only those extensions which 
> > are only API related for sure.
> Ok, thanks for providing extra information. I agree this deserves extra 
> clarifications.
> 
> I am not sure whether the frontend will be able to perform such conversions 
> since it doesn't have information regarding the channels. The image types are 
> completely opaque. That means that potentially the BIFs can handle the 
> conversion internally. However, I am unclear whether the macro can be useful 
> i.e. whether there is anything that can be done differently at the source 
> level based on its availability in OpenCL kernel code.
> 
> It should be ok to leave this out for now from the clean up unless someone 
> else can help quickly with some more insights.
Thanks for the clarification; this indeed requires further investigations so 
I've removed this part from my patch for now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89372/new/

https://reviews.llvm.org/D89372

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


[clang] d7fa903 - [CodeGen][X86] Emit fshl/fshr ir intrinsics for shiftleft128/shiftright128 ms intrinsics

2020-10-15 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-15T10:22:41+01:00
New Revision: d7fa9030d47fa62ad443717f4d1c8da4096a1d6c

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

LOG: [CodeGen][X86] Emit fshl/fshr ir intrinsics for shiftleft128/shiftright128 
ms intrinsics

Now that funnel shift handling is pretty good, we can use the intrinsics 
directly and avoid a lot of zext/trunc issues.

https://godbolt.org/z/YqhnnM

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/X86/ms-x86-intrinsics.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 45deb4164553..157dae2831f2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -13926,25 +13926,15 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   }
   case X86::BI__shiftleft128:
   case X86::BI__shiftright128: {
-// FIXME: Once fshl/fshr no longer add an unneeded and and cmov, do this:
-// llvm::Function *F = CGM.getIntrinsic(
-//   BuiltinID == X86::BI__shiftleft128 ? Intrinsic::fshl : 
Intrinsic::fshr,
-//   Int64Ty);
-// Ops[2] = Builder.CreateZExt(Ops[2], Int64Ty);
-// return Builder.CreateCall(F, Ops);
-llvm::Type *Int128Ty = Builder.getInt128Ty();
-Value *HighPart128 =
-Builder.CreateShl(Builder.CreateZExt(Ops[1], Int128Ty), 64);
-Value *LowPart128 = Builder.CreateZExt(Ops[0], Int128Ty);
-Value *Val = Builder.CreateOr(HighPart128, LowPart128);
-Value *Amt = Builder.CreateAnd(Builder.CreateZExt(Ops[2], Int128Ty),
-   llvm::ConstantInt::get(Int128Ty, 0x3f));
-Value *Res;
-if (BuiltinID == X86::BI__shiftleft128)
-  Res = Builder.CreateLShr(Builder.CreateShl(Val, Amt), 64);
-else
-  Res = Builder.CreateLShr(Val, Amt);
-return Builder.CreateTrunc(Res, Int64Ty);
+llvm::Function *F = CGM.getIntrinsic(
+BuiltinID == X86::BI__shiftleft128 ? Intrinsic::fshl : Intrinsic::fshr,
+Int64Ty);
+// Flip low/high ops and zero-extend amount to matching type.
+// shiftleft128(Low, High, Amt) -> fshl(High, Low, Amt)
+// shiftright128(Low, High, Amt) -> fshr(High, Low, Amt)
+std::swap(Ops[0], Ops[1]);
+Ops[2] = Builder.CreateZExt(Ops[2], Int64Ty);
+return Builder.CreateCall(F, Ops);
   }
   case X86::BI_ReadWriteBarrier:
   case X86::BI_ReadBarrier:

diff  --git a/clang/test/CodeGen/X86/ms-x86-intrinsics.c 
b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
index ffcf09052bab..6f745ff00f54 100644
--- a/clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -144,14 +144,8 @@ unsigned __int64 test__shiftleft128(unsigned __int64 l, 
unsigned __int64 h,
   return __shiftleft128(l, h, d);
 }
 // CHECK-X64-LABEL: define dso_local i64 @test__shiftleft128(i64 %l, i64 %h, 
i8 %d)
-// CHECK-X64:  = zext i64 %{{.*}} to i128
-// CHECK-X64: = shl nuw i128 %{{.*}}, 64
-// CHECK-X64: = zext i64 %{{.*}} to i128
-// CHECK-X64: = or i128 %
-// CHECK-X64: = and i8 %{{.*}}, 63
-// CHECK-X64: = shl i128 %
-// CHECK-X64: = lshr i128 %
-// CHECK-X64: = trunc i128 %
+// CHECK-X64: = zext i8 %{{.*}} to i64
+// CHECK-X64: = tail call i64 @llvm.fshl.i64(i64 %h, i64 %l, i64 %{{.*}})
 // CHECK-X64:  ret i64 %
 
 unsigned __int64 test__shiftright128(unsigned __int64 l, unsigned __int64 h,
@@ -159,13 +153,8 @@ unsigned __int64 test__shiftright128(unsigned __int64 l, 
unsigned __int64 h,
   return __shiftright128(l, h, d);
 }
 // CHECK-X64-LABEL: define dso_local i64 @test__shiftright128(i64 %l, i64 %h, 
i8 %d)
-// CHECK-X64:  = zext i64 %{{.*}} to i128
-// CHECK-X64: = shl nuw i128 %{{.*}}, 64
-// CHECK-X64: = zext i64 %{{.*}} to i128
-// CHECK-X64: = or i128 %
-// CHECK-X64: = and i8 %{{.*}}, 63
-// CHECK-X64: = lshr i128 %
-// CHECK-X64: = trunc i128 %
+// CHECK-X64: = zext i8 %{{.*}} to i64
+// CHECK-X64: = tail call i64 @llvm.fshr.i64(i64 %h, i64 %l, i64 %{{.*}})
 // CHECK-X64:  ret i64 %
 
 #endif // defined(__x86_64__)



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


[PATCH] D89405: [CodeGen][X86] Emit fshl/fshr ir intrinsics for shiftleft128/shiftright128 ms intrinsics

2020-10-15 Thread Simon Pilgrim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7fa9030d47f: [CodeGen][X86] Emit fshl/fshr ir intrinsics 
for shiftleft128/shiftright128 ms… (authored by RKSimon).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89405/new/

https://reviews.llvm.org/D89405

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/ms-x86-intrinsics.c


Index: clang/test/CodeGen/X86/ms-x86-intrinsics.c
===
--- clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -144,14 +144,8 @@
   return __shiftleft128(l, h, d);
 }
 // CHECK-X64-LABEL: define dso_local i64 @test__shiftleft128(i64 %l, i64 %h, 
i8 %d)
-// CHECK-X64:  = zext i64 %{{.*}} to i128
-// CHECK-X64: = shl nuw i128 %{{.*}}, 64
-// CHECK-X64: = zext i64 %{{.*}} to i128
-// CHECK-X64: = or i128 %
-// CHECK-X64: = and i8 %{{.*}}, 63
-// CHECK-X64: = shl i128 %
-// CHECK-X64: = lshr i128 %
-// CHECK-X64: = trunc i128 %
+// CHECK-X64: = zext i8 %{{.*}} to i64
+// CHECK-X64: = tail call i64 @llvm.fshl.i64(i64 %h, i64 %l, i64 %{{.*}})
 // CHECK-X64:  ret i64 %
 
 unsigned __int64 test__shiftright128(unsigned __int64 l, unsigned __int64 h,
@@ -159,13 +153,8 @@
   return __shiftright128(l, h, d);
 }
 // CHECK-X64-LABEL: define dso_local i64 @test__shiftright128(i64 %l, i64 %h, 
i8 %d)
-// CHECK-X64:  = zext i64 %{{.*}} to i128
-// CHECK-X64: = shl nuw i128 %{{.*}}, 64
-// CHECK-X64: = zext i64 %{{.*}} to i128
-// CHECK-X64: = or i128 %
-// CHECK-X64: = and i8 %{{.*}}, 63
-// CHECK-X64: = lshr i128 %
-// CHECK-X64: = trunc i128 %
+// CHECK-X64: = zext i8 %{{.*}} to i64
+// CHECK-X64: = tail call i64 @llvm.fshr.i64(i64 %h, i64 %l, i64 %{{.*}})
 // CHECK-X64:  ret i64 %
 
 #endif // defined(__x86_64__)
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -13926,25 +13926,15 @@
   }
   case X86::BI__shiftleft128:
   case X86::BI__shiftright128: {
-// FIXME: Once fshl/fshr no longer add an unneeded and and cmov, do this:
-// llvm::Function *F = CGM.getIntrinsic(
-//   BuiltinID == X86::BI__shiftleft128 ? Intrinsic::fshl : 
Intrinsic::fshr,
-//   Int64Ty);
-// Ops[2] = Builder.CreateZExt(Ops[2], Int64Ty);
-// return Builder.CreateCall(F, Ops);
-llvm::Type *Int128Ty = Builder.getInt128Ty();
-Value *HighPart128 =
-Builder.CreateShl(Builder.CreateZExt(Ops[1], Int128Ty), 64);
-Value *LowPart128 = Builder.CreateZExt(Ops[0], Int128Ty);
-Value *Val = Builder.CreateOr(HighPart128, LowPart128);
-Value *Amt = Builder.CreateAnd(Builder.CreateZExt(Ops[2], Int128Ty),
-   llvm::ConstantInt::get(Int128Ty, 0x3f));
-Value *Res;
-if (BuiltinID == X86::BI__shiftleft128)
-  Res = Builder.CreateLShr(Builder.CreateShl(Val, Amt), 64);
-else
-  Res = Builder.CreateLShr(Val, Amt);
-return Builder.CreateTrunc(Res, Int64Ty);
+llvm::Function *F = CGM.getIntrinsic(
+BuiltinID == X86::BI__shiftleft128 ? Intrinsic::fshl : Intrinsic::fshr,
+Int64Ty);
+// Flip low/high ops and zero-extend amount to matching type.
+// shiftleft128(Low, High, Amt) -> fshl(High, Low, Amt)
+// shiftright128(Low, High, Amt) -> fshr(High, Low, Amt)
+std::swap(Ops[0], Ops[1]);
+Ops[2] = Builder.CreateZExt(Ops[2], Int64Ty);
+return Builder.CreateCall(F, Ops);
   }
   case X86::BI_ReadWriteBarrier:
   case X86::BI_ReadBarrier:


Index: clang/test/CodeGen/X86/ms-x86-intrinsics.c
===
--- clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -144,14 +144,8 @@
   return __shiftleft128(l, h, d);
 }
 // CHECK-X64-LABEL: define dso_local i64 @test__shiftleft128(i64 %l, i64 %h, i8 %d)
-// CHECK-X64:  = zext i64 %{{.*}} to i128
-// CHECK-X64: = shl nuw i128 %{{.*}}, 64
-// CHECK-X64: = zext i64 %{{.*}} to i128
-// CHECK-X64: = or i128 %
-// CHECK-X64: = and i8 %{{.*}}, 63
-// CHECK-X64: = shl i128 %
-// CHECK-X64: = lshr i128 %
-// CHECK-X64: = trunc i128 %
+// CHECK-X64: = zext i8 %{{.*}} to i64
+// CHECK-X64: = tail call i64 @llvm.fshl.i64(i64 %h, i64 %l, i64 %{{.*}})
 // CHECK-X64:  ret i64 %
 
 unsigned __int64 test__shiftright128(unsigned __int64 l, unsigned __int64 h,
@@ -159,13 +153,8 @@
   return __shiftright128(l, h, d);
 }
 // CHECK-X64-LABEL: define dso_local i64 @test__shiftright128(i64 %l, i64 %h, i8 %d)
-// CHECK-X64:  = zext i64 %{{.*}} to i128
-// CHECK-X64: = shl nuw i128 %{{.*}}, 64
-// CHECK-X64: = zext i64 %{{.*}} to i128
-// CHECK-X64: = or i128 %
-// CHECK-X64: = and i8 %{{.*}}, 63
-// CHECK-X64: = lshr i128 %
-// CHECK-X64: = trunc i128 %
+// CHECK-X64: = zext i8 %{{.*}} to i64
+// CHECK-X64: = tail call i64 @llvm.fshr.i64(i64 %h, i64 %l, i64 %{{.*}

[PATCH] D89453: Fix hidden-redecls.m test for some environments

2020-10-15 Thread Konstantin Schwarz via Phabricator via cfe-commits
kschwarz created this revision.
kschwarz added reviewers: bnbarham, akyrtzi.
Herald added subscribers: arphaman, dexonsmith.
Herald added a project: clang.
kschwarz requested review of this revision.

This test was failing in our CI environment, because Jenkins mounts the 
workspaces into Docker containers using their full path, i.e. 
/home/jenkins/workspaces/llvm-build.
We've seen permission denied errors because /home/jenkins is mounted with root 
permissions and the default cache directory under Linux is $HOME/.cache.

The fix is to explicitly provide the -fmodules-cache-path, which the other 
tests already seem to provide.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89453

Files:
  clang/test/Index/hidden-redecls.m


Index: clang/test/Index/hidden-redecls.m
===
--- clang/test/Index/hidden-redecls.m
+++ clang/test/Index/hidden-redecls.m
@@ -7,6 +7,7 @@
 // p1_method in protocol P1 is hidden since module_redecls.sub hasn't been
 // imported yet. Check it is still indexed.
 
-// RUN: c-index-test -index-file-full %s -isystem %S/Inputs -fmodules -target 
x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: rm -rf %t
+// RUN: c-index-test -index-file-full %s -isystem %S/Inputs -fmodules 
-fmodules-cache-path=%t -target x86_64-apple-macosx10.7 | FileCheck %s
 // CHECK: [indexDeclaration]: kind: objc-instance-method | name: p1_method | 
{{.*}} | loc: {{.*}}hidden-redecls-sub.h:2:9 | {{.*}} | isRedecl: 0
 // CHECK: [indexDeclaration]: kind: objc-instance-method | name: p1_method | 
{{.*}} | loc: {{.*}}hidden-redecls-sub.h:3:9 | {{.*}} | isRedecl: 1


Index: clang/test/Index/hidden-redecls.m
===
--- clang/test/Index/hidden-redecls.m
+++ clang/test/Index/hidden-redecls.m
@@ -7,6 +7,7 @@
 // p1_method in protocol P1 is hidden since module_redecls.sub hasn't been
 // imported yet. Check it is still indexed.
 
-// RUN: c-index-test -index-file-full %s -isystem %S/Inputs -fmodules -target x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: rm -rf %t
+// RUN: c-index-test -index-file-full %s -isystem %S/Inputs -fmodules -fmodules-cache-path=%t -target x86_64-apple-macosx10.7 | FileCheck %s
 // CHECK: [indexDeclaration]: kind: objc-instance-method | name: p1_method | {{.*}} | loc: {{.*}}hidden-redecls-sub.h:2:9 | {{.*}} | isRedecl: 0
 // CHECK: [indexDeclaration]: kind: objc-instance-method | name: p1_method | {{.*}} | loc: {{.*}}hidden-redecls-sub.h:3:9 | {{.*}} | isRedecl: 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74130: [clang] fix consteval call in default arguements

2020-10-15 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 298344.
Tyker retitled this revision from "[clang] fix consteval call in default 
arguements " to "[clang] fix consteval call in default arguements".
Tyker added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

rebased and add more fixes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74130/new/

https://reviews.llvm.org/D74130

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -258,6 +258,26 @@
   return f(0);  
 };
 
+consteval int f1() {
+// expected-note@-1+ {{declared here}}
+  return 0;
+}
+consteval auto g() { return f1; }
+consteval int h(int (*p)() = g()) { return p(); }
+int h1(int (*p)() = g()) { return p(); }
+// expected-error@-1 {{is not a constant expression}}
+// expected-note@-2 {{pointer to a consteval}}
+
+constexpr auto e = g();
+// expected-error@-1 {{must be initialized by a constant expression}}
+// expected-note@-2 {{is not a constant expression}}
+
+auto l = [](int (*p)() = g()) { return p(); };
+// expected-error@-1 {{is not a constant expression}}
+// expected-note@-2 {{pointer to a consteval}}
+
+auto l2 = [](int (*p)() = g()) consteval { return p(); };
+
 }
 
 namespace std {
@@ -594,3 +614,22 @@
 }
 
 } // namespace special_ctor
+
+namespace top_level {
+struct S {
+  consteval S() {}
+  int a;
+// expected-note@-1 {{subobject declared here}}
+};
+
+S s; // expected-error {{is not a constant expression}}
+// expected-note@-1 {{is not initialized}}
+
+struct S1 {
+  consteval S1() {}
+  int a = 0;
+};
+
+S1 s1;
+
+}
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -891,6 +891,10 @@
   LambdaScopeInfo *const LSI = getCurLambda();
   assert(LSI && "LambdaScopeInfo should be on stack!");
 
+  if (ParamInfo.getDeclSpec().getConstexprSpecifier() == CSK_consteval)
+ExprEvalContexts.back().IIEndScopeAction =
+ExpressionEvaluationContextRecord::IIESA_Drop;
+
   // Determine if we're within a context where we know that the lambda will
   // be dependent, because there are template parameters in scope.
   bool KnownDependent;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16097,13 +16097,16 @@
   return TransformToPE(*this).TransformExpr(E);
 }
 
-void
-Sema::PushExpressionEvaluationContext(
+void Sema::PushExpressionEvaluationContext(
 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl,
-ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
+ExpressionEvaluationContextRecord::ExpressionKind ExprContext,
+bool IsLambdaParamScope) {
   ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
 LambdaContextDecl, ExprContext);
   Cleanup.reset();
+  if (IsLambdaParamScope)
+ExprEvalContexts.back().IIEndScopeAction =
+Sema::ExpressionEvaluationContextRecord::IIESA_Propagate;
   if (!MaybeODRUseExprs.empty())
 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
 }
@@ -16183,7 +16186,9 @@
 
 ExprResult Sema::CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl) {
   if (!E.isUsable() || !Decl || !Decl->isConsteval() || isConstantEvaluated() ||
-  RebuildingImmediateInvocation)
+  RebuildingImmediateInvocation ||
+  ExprEvalContexts.back().IIEndScopeAction ==
+  ExpressionEvaluationContextRecord::IIESA_Drop)
 return E;
 
   /// Opportunistically remove the callee from ReferencesToConsteval if we can.
@@ -16312,14 +16317,31 @@
   It->getPointer()->setSubExpr(Res.get());
 }
 
-static void
-HandleImmediateInvocations(Sema &SemaRef,
-   Sema::ExpressionEvaluationContextRecord &Rec) {
+void Sema::HandleImmediateInvocations(
+Sema::ExpressionEvaluationContextRecord &Rec) {
   if ((Rec.ImmediateInvocationCandidates.size() == 0 &&
Rec.ReferenceToConsteval.size() == 0) ||
-  SemaRef.RebuildingImmediateInvocation)
+  RebuildingImmediateInvocation ||
+  Rec.IIEndScopeAction ==
+  Sema::ExpressionEvaluationContextRecord::IIESA_Drop)
 return;
 
+  /// If we can't handle immediate invocations yet. add them to the outer scope.
+  /// This occurs for default argument of lambdas as we can't know if the lambda
+  /// is consteval until after the parameter context has been poped.
+  if (Rec.IIEndScopeA

[PATCH] D89407: [clang-tidy] Add scoped enum constants to identifier naming check

2020-10-15 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 298349.
njames93 added a comment.

Removed runtime check in release mode that EnumConstant DeclContext is a 
EnumDecl


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89407/new/

https://reviews.llvm.org/D89407

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -18,6 +18,7 @@
 // RUN: {key: readability-identifier-naming.ConstexprVariableCase, value: lower_case}, \
 // RUN: {key: readability-identifier-naming.EnumCase, value: CamelCase}, \
 // RUN: {key: readability-identifier-naming.EnumPrefix, value: 'E'}, \
+// RUN: {key: readability-identifier-naming.ScopedEnumConstantCase, value: CamelCase}, \
 // RUN: {key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE}, \
 // RUN: {key: readability-identifier-naming.FunctionCase, value: camelBack}, \
 // RUN: {key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE}, \
@@ -160,6 +161,18 @@
 // CHECK-FIXES: {{^}}THIS_CONST_VALUE = 1,{{$}}
 };
 
+enum class EMyEnumeration {
+myConstant = 1,
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for scoped enum constant 'myConstant'
+// CHECK-FIXES: {{^}}MyConstant = 1,{{$}}
+your_CONST = 1,
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for scoped enum constant 'your_CONST'
+// CHECK-FIXES: {{^}}YourConst = 1,{{$}}
+THIS_ConstValue = 1,
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for scoped enum constant 'THIS_ConstValue'
+// CHECK-FIXES: {{^}}ThisConstValue = 1,{{$}}
+};
+
 constexpr int ConstExpr_variable = MyConstant;
 // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for constexpr variable 'ConstExpr_variable'
 // CHECK-FIXES: {{^}}constexpr int const_expr_variable = MY_CONSTANT;{{$}}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
@@ -76,6 +76,7 @@
  - :option:`ProtectedMethodCase`, :option:`ProtectedMethodPrefix`, :option:`ProtectedMethodSuffix`
  - :option:`PublicMemberCase`, :option:`PublicMemberPrefix`, :option:`PublicMemberSuffix`
  - :option:`PublicMethodCase`, :option:`PublicMethodPrefix`, :option:`PublicMethodSuffix`
+ - :option:`ScopedEnumConstantCase`, :option:`ScopedEnumConstantPrefix`, :option:`ScopedEnumConstantSuffix`
  - :option:`StaticConstantCase`, :option:`StaticConstantPrefix`, :option:`StaticConstantSuffix`
  - :option:`StaticVariableCase`, :option:`StaticVariablePrefix`, :option:`StaticVariableSuffix`
  - :option:`StructCase`, :option:`StructPrefix`, :option:`StructSuffix`
@@ -1595,6 +1596,41 @@
   int pre_member_method_post();
 }
 
+.. option:: ScopedEnumConstantCase
+
+When defined, the check will ensure scoped enum constant names conform to 
+the selected casing.
+
+.. option:: ScopedEnumConstantPrefix
+
+When defined, the check will ensure scoped enum constant names will add the
+prefixed with the given value (regardless of casing).
+
+.. option:: ScopedEnumConstantSuffix
+
+When defined, the check will ensure scoped enum constant names will add the
+suffix with the given value (regardless of casing).
+
+For example using values of:
+
+   - ScopedEnumConstantCase of ``lower_case``
+   - ScopedEnumConstantPrefix of ``pre_``
+   - ScopedEnumConstantSuffix of ``_post``
+
+Identifies and/or transforms enumeration constant names as follows:
+
+Before:
+
+.. code-block:: c++
+
+enum class FOO { One, Two, Three };
+
+After:
+
+.. code-block:: c++
+
+enum class FOO { pre_One_post, pre_Two_post, pre_Three_post };
+
 .. option:: StaticConstantCase
 
 When defined, the check will ensure static constant names conform to the
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -120,6 +120,9 @@
   Added an option `GetConfigPerFile` to support including files which use
   different naming styles.
 
+  Added support for specifying the style of scoped ``enum`` constants. If 
+  unspecified, will fall back to the style for regular ``enum`` constants.
+
 - Removed `google-runtime-references` che

[PATCH] D89446: [WebAssembly] Prototype i8x16.popcnt

2020-10-15 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:117
 
+TARGET_BUILTIN(__builtin_wasm_popcnt, "V16ScV16Sc", "nc", "simd128")
+

- Even if there's only one vector type for a builtin, it seems others still 
have type postfix attached.
- Is the result also a vector? Does that mean this instruction count each 16 
slot separately?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89446/new/

https://reviews.llvm.org/D89446

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


[PATCH] D89313: [SVE]Fix implicit TypeSize casts in EmitCheckValue

2020-10-15 Thread Caroline via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG145e44bb1885: [SVE]Fix implicit TypeSize casts in 
EmitCheckValue (authored by CarolineConcatto).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89313/new/

https://reviews.llvm.org/D89313

Files:
  clang/lib/CodeGen/CGExpr.cpp


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -2996,7 +2996,7 @@
   // Floating-point types which fit into intptr_t are bitcast to integers
   // and then passed directly (after zero-extension, if necessary).
   if (V->getType()->isFloatingPointTy()) {
-unsigned Bits = V->getType()->getPrimitiveSizeInBits();
+unsigned Bits = V->getType()->getPrimitiveSizeInBits().getFixedSize();
 if (Bits <= TargetTy->getIntegerBitWidth())
   V = Builder.CreateBitCast(V, llvm::Type::getIntNTy(getLLVMContext(),
  Bits));


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -2996,7 +2996,7 @@
   // Floating-point types which fit into intptr_t are bitcast to integers
   // and then passed directly (after zero-extension, if necessary).
   if (V->getType()->isFloatingPointTy()) {
-unsigned Bits = V->getType()->getPrimitiveSizeInBits();
+unsigned Bits = V->getType()->getPrimitiveSizeInBits().getFixedSize();
 if (Bits <= TargetTy->getIntegerBitWidth())
   V = Builder.CreateBitCast(V, llvm::Type::getIntNTy(getLLVMContext(),
  Bits));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 145e44b - [SVE]Fix implicit TypeSize casts in EmitCheckValue

2020-10-15 Thread Caroline Concatto via cfe-commits

Author: Caroline Concatto
Date: 2020-10-15T13:25:46+01:00
New Revision: 145e44bb18853bc9beeac0e64fffd9e6895e71f9

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

LOG: [SVE]Fix implicit TypeSize casts in EmitCheckValue

Using TypeSize::getFixedSize() instead of relying upon the implicit
TypeSize->uint64_cast as the type is always fixed width.

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

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 2f54097d9209..ed2c8e6a71f1 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2996,7 +2996,7 @@ llvm::Value *CodeGenFunction::EmitCheckValue(llvm::Value 
*V) {
   // Floating-point types which fit into intptr_t are bitcast to integers
   // and then passed directly (after zero-extension, if necessary).
   if (V->getType()->isFloatingPointTy()) {
-unsigned Bits = V->getType()->getPrimitiveSizeInBits();
+unsigned Bits = V->getType()->getPrimitiveSizeInBits().getFixedSize();
 if (Bits <= TargetTy->getIntegerBitWidth())
   V = Builder.CreateBitCast(V, llvm::Type::getIntNTy(getLLVMContext(),
  Bits));



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


[PATCH] D83088: Introduce CfgTraits abstraction

2020-10-15 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a comment.
Herald added a subscriber: rdzhabarov.

ping^2


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83088/new/

https://reviews.llvm.org/D83088

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


[PATCH] D89210: [Sema, CodeGen] Implement [[likely]] and [[unlikely]] in SwitchStmt

2020-10-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a documentation request, but you may want to wait a few days 
before committing in case Richard or John have opinions.

In D89210#2330466 , @Mordante wrote:

> In D89210#2328378 , @aaron.ballman 
> wrote:
>
>> Thank you for the continued work on this feature! I'd like to better 
>> understand the behavior of fallthrough labels because I think there are two 
>> conceptual models we could follow. When a label falls through to another 
>> label, should both labels be treated as having the same likelihood or should 
>> they be treated as distinct cases? e.g.,
>>
>>   switch (something) {
>>   case 1:
>> ...
>>   [[likely]] case 2:
>> ...
>> break;
>>   case 3:
>> ...
>
> The likelihood is not affected by falling though, so all cases are distinct. 
> This due to the standard's wording "A path of execution includes a label if 
> and only if it contains a jump to that label." 
> (http://eel.is/c++draft/dcl.attr.likelihood#2). The falling through would 
> affect cases where the likelihood isn't on the labels, like:
>
>   switch (something) {
>case 1: 
>case 2: [[likely]];
>   }
>
> I understood from our earlier conversations we didn't want to support that 
> option, due to:
>
>   switch (something) {
>case 1:
>   if(foo()) break;
>   // Falling through depends on the return value of foo()
>   // is this still the path of execution of 'case 1'?
>case 2: [[likely]];
>   }
>
> Here we get to the cases where it might confuse the user what the affect of 
> their attribute is. If we were to implement that not all cases are distinct. 
> Implementing that would require flow analyzes.

That's right, thank you for the reminder!

> I still have some more WIP patches regarding the likelihood. After they are 
> landed I still intend to start a conversation with other compiler vendors to 
> see whether we can agree on best practices regarding the likelihood 
> attributes. Depending on the outcome of that conversation I might change the 
> implementation in Clang.

Sounds good to me.

>> Should case 1 be considered likely because it falls through to case 2? From 
>> the patch, it looks like your answer is "yes", they should both be likely, 
>> but should that hold true even if case 1 does a lot of work and is not 
>> actually all that likely? Or is the user expected to write `[[unlikely]] 
>> case 1:` in that situation? We don't seem to have a test case for a 
>> situation where fallthrough says something like that:
>>
>>   switch (something) {
>>   [[likely]] case 0:
>> ...
>> // Note the fallthrough
>>   [[unlikely]] case 1:
>> ...
>>   }
>
> In this case the user can use `[[unlikely]]`. If the user omits an attribute 
> on `case 1` the label is considered neutral. Since `case 0` is positive, so 
> it'll be the more likely path of execution.

Okay, thank you for the explanation.




Comment at: clang/include/clang/Basic/AttrDocs.td:1815
 
+  switch(i) {
+[[likely]] case 1:// This value is likely

Can you add a second example that shows what to expect from fallthrough 
behavior? Perhaps something like:
```
switch (i) {
[[likely]] case 0: // This value and code path is likely
  ...
  [[fallthrough]];
case 1: // No likelihood attribute, code path is likely due to fallthrough
  break;
case 2: // No likelihood attribute, code path is neutral
  [[fallthrough]];
[[unlikely]] default: // This value and code path are both unlikely
  break;
}
```



Comment at: clang/lib/CodeGen/CGStmt.cpp:375
+ ArrayRef Attrs) {
+  // clang-format off
   switch (S->getStmtClass()) {

Mordante wrote:
> aaron.ballman wrote:
> > How ugly is the default clang-format formatting for this? If it's not too 
> > bad, perhaps we just re-format the switch statement as a whole?
> It looks fine default formatted, I just thought we wanted to keep it compact. 
> But I've no problem with keeping the code default formatted.
I tend to prefer whatever the default formatting is just so we don't have 
formatting comments all over the place (but I'm fine if the unique formatting 
is important for code readability).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89210/new/

https://reviews.llvm.org/D89210

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


[PATCH] D89464: Revert "[clang-format] Fix AlignConsecutive on PP blocks"

2020-10-15 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
sylvestre.ledru requested review of this revision.

This reverts commit b2eb439317576ce718193763c12bff9fccdfc166 
.

Caused the regression:
https://bugs.llvm.org/show_bug.cgi?id=47589


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89464

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestComments.cpp

Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -2780,27 +2780,6 @@
"   // line 2 about b\n"
"   long b;",
getLLVMStyleWithColumns(80)));
-
-  // Checks an edge case in preprocessor handling.
-  // These comments should *not* be aligned
-  EXPECT_EQ(
-  "#if FOO\n"
-  "#else\n"
-  "long a; // Line about a\n"
-  "#endif\n"
-  "#if BAR\n"
-  "#else\n"
-  "long b_long_name; // Line about b\n"
-  "#endif\n",
-  format("#if FOO\n"
- "#else\n"
- "long a;   // Line about a\n" // Previous (bad) behavior
- "#endif\n"
- "#if BAR\n"
- "#else\n"
- "long b_long_name; // Line about b\n"
- "#endif\n",
- getLLVMStyleWithColumns(80)));
 }
 
 TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12252,29 +12252,6 @@
   verifyFormat("int oneTwoThree = 123; // comment\n"
"int oneTwo  = 12;  // comment",
Alignment);
-
-  // Bug 25167
-  verifyFormat("#if A\n"
-   "#else\n"
-   "int  = 12;\n"
-   "#endif\n"
-   "#if B\n"
-   "#else\n"
-   "int a = 12;\n"
-   "#endif\n",
-   Alignment);
-  verifyFormat("enum foo {\n"
-   "#if A\n"
-   "#else\n"
-   "   = 12;\n"
-   "#endif\n"
-   "#if B\n"
-   "#else\n"
-   "  a = 12;\n"
-   "#endif\n"
-   "};\n",
-   Alignment);
-
   EXPECT_EQ("int a = 5;\n"
 "\n"
 "int oneTwoThree = 123;",
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -411,11 +411,9 @@
 if (Changes[i].NewlinesBefore != 0) {
   CommasBeforeMatch = 0;
   EndOfSequence = i;
-  // If there is a blank line, there is a forced-align-break (eg,
-  // preprocessor), or if the last line didn't contain any matching token,
-  // the sequence ends here.
-  if (Changes[i].NewlinesBefore > 1 ||
-  Changes[i].Tok->MustBreakAlignBefore || !FoundMatchOnLine)
+  // If there is a blank line, or if the last line didn't contain any
+  // matching token, the sequence ends here.
+  if (Changes[i].NewlinesBefore > 1 || !FoundMatchOnLine)
 AlignCurrentSequence();
 
   FoundMatchOnLine = false;
@@ -726,8 +724,6 @@
 if (Changes[i].StartOfBlockComment)
   continue;
 Newlines += Changes[i].NewlinesBefore;
-if (Changes[i].Tok->MustBreakAlignBefore)
-  BreakBeforeNext = true;
 if (!Changes[i].IsTrailingComment)
   continue;
 
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -3037,7 +3037,6 @@
   }
   FormatTok = Tokens->getNextToken();
   FormatTok->MustBreakBefore = true;
-  FormatTok->MustBreakAlignBefore = true;
 }
 
 if (!PPStack.empty() && (PPStack.back().Kind == PP_Unreachable) &&
@@ -3062,7 +3061,6 @@
   Line->Tokens.push_back(UnwrappedLineNode(Tok));
   if (MustBreakBeforeNextToken) {
 Line->Tokens.back().Tok->MustBreakBefore = true;
-Line->Tokens.back().Tok->MustBreakAlignBefore = true;
 MustBreakBeforeNextToken = false;
   }
 }
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -206,12 +206,11 @@
 struct FormatToken {
   FormatToken()
   : HasUnescapedNewline(false), IsMultiline(false), IsFirst(false),
-MustBreakBefore(false), MustBreakAlignBefore(false),
-IsUntermina

[PATCH] D84362: [NFC] Refactor DiagnosticBuilder and PartialDiagnostic

2020-10-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 298368.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Rename StreamableDiagnosticBase to StreamingDiagnostic.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84362/new/

https://reviews.llvm.org/D84362

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Attr.h
  clang/include/clang/AST/CanonicalType.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/DeclarationName.h
  clang/include/clang/AST/DependentDiagnostic.h
  clang/include/clang/AST/NestedNameSpecifier.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/AST/TemplateName.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Basic/PartialDiagnostic.h
  clang/include/clang/Sema/DelayedDiagnostic.h
  clang/include/clang/Sema/Ownership.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Tooling/Refactoring/RefactoringRuleContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TemplateName.cpp
  clang/lib/Basic/Diagnostic.cpp
  clang/unittests/Basic/DiagnosticTest.cpp

Index: clang/unittests/Basic/DiagnosticTest.cpp
===
--- clang/unittests/Basic/DiagnosticTest.cpp
+++ clang/unittests/Basic/DiagnosticTest.cpp
@@ -74,7 +74,7 @@
 TEST(DiagnosticTest, diagnosticError) {
   DiagnosticsEngine Diags(new DiagnosticIDs(), new DiagnosticOptions,
   new IgnoringDiagConsumer());
-  PartialDiagnostic::StorageAllocator Alloc;
+  PartialDiagnostic::DiagStorageAllocator Alloc;
   llvm::Expected> Value = DiagnosticError::create(
   SourceLocation(), PartialDiagnostic(diag::err_cannot_open_file, Alloc)
 << "file"
Index: clang/lib/Basic/Diagnostic.cpp
===
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -40,8 +40,8 @@
 
 using namespace clang;
 
-const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
-   DiagNullabilityKind nullability) {
+const StreamingDiagnostic &clang::operator<<(const StreamingDiagnostic &DB,
+ DiagNullabilityKind nullability) {
   StringRef string;
   switch (nullability.first) {
   case NullabilityKind::NonNull:
@@ -61,8 +61,8 @@
   return DB;
 }
 
-const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
-   llvm::Error &&E) {
+const StreamingDiagnostic &clang::operator<<(const StreamingDiagnostic &DB,
+ llvm::Error &&E) {
   DB.AddString(toString(std::move(E)));
   return DB;
 }
@@ -481,13 +481,15 @@
 
   CurDiagLoc = storedDiag.getLocation();
   CurDiagID = storedDiag.getID();
-  NumDiagArgs = 0;
+  DiagStorage.NumDiagArgs = 0;
 
-  DiagRanges.clear();
-  DiagRanges.append(storedDiag.range_begin(), storedDiag.range_end());
+  DiagStorage.DiagRanges.clear();
+  DiagStorage.DiagRanges.append(storedDiag.range_begin(),
+storedDiag.range_end());
 
-  DiagFixItHints.clear();
-  DiagFixItHints.append(storedDiag.fixit_begin(), storedDiag.fixit_end());
+  DiagStorage.FixItHints.clear();
+  DiagStorage.FixItHints.append(storedDiag.fixit_begin(),
+storedDiag.fixit_end());
 
   assert(Client && "DiagnosticConsumer not set!");
   Level DiagLevel = storedDiag.getLevel();
@@ -1140,13 +1142,13 @@
   return Target.IncludeInDiagnosticCounts();
 }
 
-PartialDiagnostic::StorageAllocator::StorageAllocator() {
+PartialDiagnostic::DiagStorageAllocator::DiagStorageAllocator() {
   for (unsigned I = 0; I != NumCached; ++I)
 FreeList[I] = Cached + I;
   NumFreeListEntries = NumCached;
 }
 
-PartialDiagnostic::StorageAllocator::~StorageAllocator() {
+PartialDiagnostic::DiagStorageAllocator::~DiagStorageAllocator() {
   // Don't assert if we are in a CrashRecovery context, as this invariant may
   // be invalidated during a crash.
   assert((NumFreeListEntries == NumCached ||
Index: clang/lib/AST/TemplateName.cpp
===
--- clang/lib/AST/TemplateName.cpp
+++ clang/lib/AST/TemplateName.cpp
@@ -254,8 +254,8 @@
   }
 }
 
-const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
-   TemplateName N) {
+const StreamingDiagnostic &clang::operator<<(const StreamingDiagnostic &DB,
+ TemplateName N) {
   std::string NameStr;
   llvm::raw_string_ostream OS(NameStr);
   LangOptions LO;
@@ -268,20 +268,6 @@
   return DB << NameStr;
 }
 
-const PartialDiagnostic&clang::operator<<(const PartialDiagnostic &PD,
-

[PATCH] D79388: [clang-format] Fix AlignConsecutive on PP blocks

2020-10-15 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD added a comment.

Belated 'sounds good to me'.

Other things have been keeping me busy, sorry for the delayed response on this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79388/new/

https://reviews.llvm.org/D79388

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


[PATCH] D89464: Revert "[clang-format] Fix AlignConsecutive on PP blocks"

2020-10-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:12255
Alignment);
-
-  // Bug 25167

Passing-by comment: you probably want to keep the tests though?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89464/new/

https://reviews.llvm.org/D89464

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


[PATCH] D84362: [NFC] Refactor DiagnosticBuilder and PartialDiagnostic

2020-10-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/Diagnostic.h:1065
+///
+class StreamableDiagnosticBase {
+public:

rjmccall wrote:
> I think I would prefer `StreamingDiagnostic` as the class name here.
renamed



Comment at: clang/include/clang/Basic/PartialDiagnostic.h:66
+return *this;
+  }
+

rjmccall wrote:
> Why are these template operators necessary?  The LHS of the `<<` should 
> convert to a base reference type just fine.
There are lots of usage patterns expecting the derived class after streaming, 
e.g.

```
void foo(PartialDiagnostic& PD);
foo(PD << X << Y);
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84362/new/

https://reviews.llvm.org/D84362

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


[PATCH] D88498: [FPEnv] Evaluate initializers in constant rounding mode

2020-10-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 298375.
sepavloff added a comment.

Remade the patch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88498/new/

https://reviews.llvm.org/D88498

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/const-fpfeatures-strict.c
  clang/test/CodeGenCXX/rounding-math.cpp
  clang/test/SemaCXX/rounding-math-diag.cpp
  clang/test/SemaCXX/rounding-math.cpp

Index: clang/test/SemaCXX/rounding-math.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/rounding-math.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-linux -verify -frounding-math -Wno-unknown-pragmas %s
+// expected-no-diagnostics
+
+// nextUp(1.F) == 0x1.02p0F
+
+static_assert(1.0F + 0x0.01p0F == 0x1.0p0F, "");
+
+char Arr01[1 + (1.0F + 0x0.01p0F > 1.0F)];
+static_assert(sizeof(Arr01) == 1, "");
+
+struct S1 {
+  int : (1.0F + 0x0.01p0F > 1.0F);
+  int f;
+};
+static_assert(sizeof(S1) == sizeof(int), "");
+
+#pragma STDC FENV_ROUND FE_UPWARD
+static_assert(1.0F + 0x0.01p0F == 0x1.02p0F, "");
+
+char Arr01u[1 + (1.0F + 0x0.01p0F > 1.0F)];
+static_assert(sizeof(Arr01u) == 2, "");
+
+struct S1u {
+  int : (1.0F + 0x0.01p0F > 1.0F);
+  int f;
+};
+static_assert(sizeof(S1u) > sizeof(int), "");
+
+#pragma STDC FENV_ROUND FE_DOWNWARD
+static_assert(1.0F + 0x0.01p0F == 1.0F, "");
+
+char Arr01d[1 + (1.0F + 0x0.01p0F > 1.0F)];
+static_assert(sizeof(Arr01d) == 1, "");
+
+struct S1d {
+  int : (1.0F + 0x0.01p0F > 1.0F);
+  int f;
+};
+static_assert(sizeof(S1d) == sizeof(int), "");
Index: clang/test/SemaCXX/rounding-math-diag.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/rounding-math-diag.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-linux -verify -frounding-math %s
+
+void func_01() {
+  const float C1 = 1.0F + 0x0.01p0F; // expected-note{{declared here}}
+ // expected-note@-1{{cannot evaluate this expression if rounding mode is dynamic}}
+  static_assert(C1 == 1.0F, ""); // expected-error{{static_assert expression is not an integral constant expression}}
+ // expected-note@-1{{initializer of 'C1' is not a constant expression}}
+}
Index: clang/test/CodeGenCXX/rounding-math.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/rounding-math.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -S -emit-llvm -triple i386-linux -Wno-unknown-pragmas -frounding-math %s -o - | FileCheck %s
+
+constexpr float func_01(float x, float y) {
+  return x + y;
+}
+
+float V1 = func_01(1.0F, 0x0.01p0F);
+float V2 = 1.0F + 0x0.01p0F;
+float V3 = func_01(1.0F, 2.0F);
+
+// CHECK: @V1 = {{.*}}global float 0.00e+00, align 4
+// CHECK: @V2 = {{.*}}global float 1.00e+00, align 4
+// CHECK: @V3 = {{.*}}global float 3.00e+00, align 4
+
+// CHECK-LABEL: define internal void @__cxx_global_var_init()
+// CHECK:   call float @_Z7func_01ff(float 1.00e+00, float 0x3E70)
+// CHECK:   store {{.*}}, float* @V1, align 4
+// CHECK:   ret void
+
+// CHECK-LABEL: define {{.*}} float @_Z7func_01ff(float %x, float %y)
+// CHECK:   call float @llvm.experimental.constrained.fadd.f32({{.*}}, metadata !"round.dynamic", metadata !"fpexcept.ignore")
+// CHECK:   ret float
Index: clang/test/AST/const-fpfeatures-strict.c
===
--- /dev/null
+++ clang/test/AST/const-fpfeatures-strict.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -S -emit-llvm -ffp-exception-behavior=strict -Wno-unknown-pragmas %s -o - | FileCheck %s
+
+float PR47807 = -8.6563630030e-03;
+
+// nextUp(1.F) == 0x1.02p0F
+
+struct S {
+  float f;
+};
+
+static struct S var_01 = {0x1.01p0};
+struct S *func_01() {
+  return &var_01;
+}
+
+struct S var_02 = {0x1.01p0};
+
+struct S *func_03() {
+  static struct S var_03 = {0x1.01p0};
+  return &var_03;
+}
+
+// CHECK: @var_01 = {{.*}} %struct.S { float 1.00e+00 }
+// CHECK: @var_02 = {{.*}} %struct.S { float 1.00e+00 }
+// CHECK: @func_03.var_03 = {{.*}} %struct.S { float 1.00e+00 }
+
+#pragma STDC FENV_ROUND FE_UPWARD
+
+static struct S var_04 = {0x1.01p0};
+struct S *func_04() {
+  return &var_04;
+}
+
+struct S var_05 = {0x1.01p0};
+
+struct S *func_06() {
+  static struct S var_06 = {0x1.01p0};
+  return &var_06;
+}
+
+// CHECK: @var_04 = {{.*}} %struct.S { float 0x3FF02000 }
+// CHECK: @var_05 = {{.*}} %struct.S { float 0x3FF02000 }
+// CHECK: @func_06.var_06 = {{.*}} %struct.S { float 0x3FF02000 }
Index: clang/lib/Sema/SemaDecl.cpp
===

[PATCH] D86097: [OpenMP][AMDGCN] Generate global variables and attributes for AMDGCN

2020-10-15 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 298377.
saiislam added a comment.

1. Removed unnecessary formatting of untouched code.
2. Encapsulated addFieldToRecordDecl and createGlobalStruct methods in a class 
and made them static (triggered change at all calling sites).
3. Marked most of the member methods of CGOpenMPRuntimeAMDGCN as private 
(forgot to do same change in nvptx)
4. Fixed the memory leak
5. Marked appropriate member variables as protected in CGOpenMPRuntimeGPU


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86097/new/

https://reviews.llvm.org/D86097

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  clang/test/OpenMP/amdgcn_target_codegen.cpp

Index: clang/test/OpenMP/amdgcn_target_codegen.cpp
===
--- clang/test/OpenMP/amdgcn_target_codegen.cpp
+++ clang/test/OpenMP/amdgcn_target_codegen.cpp
@@ -8,6 +8,29 @@
 
 #define N 1000
 
+// CHECK: @"_openmp_kernel_static_glob_rd$ptr" = weak addrspace(3) externally_initialized global i8* undef
+
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_tid_threadsv_l[[LINE1:.+]]_kern_desc = weak constant %struct.__tgt_attribute_struct { i16 2, i16 9, i16 0, i8 1, i8 1, i8 0 }, align 2
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_tid_threadsv_l[[LINE1]]_exec_mode = weak constant i8 1
+
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_tid_threads_simdv_l[[LINE2:.+]]_kern_desc = weak constant %struct.__tgt_attribute_struct { i16 2, i16 9, i16 0, i8 0, i8 1, i8 0 }, align 2
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_tid_threads_simdv_l[[LINE2]]_exec_mode = weak constant i8 0
+
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_max_parallel_levelv_l[[LINE3:.+]]_kern_desc = weak constant %struct.__tgt_attribute_struct { i16 2, i16 9, i16 0, i8 0, i8 1, i8 3 }, align 2
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_max_parallel_levelv_l[[LINE3]]_exec_mode = weak constant i8 0
+
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_attributes_spmdv_l[[LINE4:.+]]_wg_size = weak addrspace(1) constant i16 10
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_attributes_spmdv_l[[LINE4]]_kern_desc = weak constant %struct.__tgt_attribute_struct { i16 2, i16 9, i16 10, i8 0, i8 1, i8 0 }, align 2
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_attributes_spmdv_l[[LINE4]]_exec_mode = weak constant i8 0
+
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_attributes_non_spmdv_l[[LINE5:.+]]_wg_size = weak addrspace(1) constant i16 74
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_attributes_non_spmdv_l[[LINE5]]_kern_desc = weak constant %struct.__tgt_attribute_struct { i16 2, i16 9, i16 74, i8 1, i8 1, i8 0 }, align 2
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_attributes_non_spmdv_l[[LINE5]]_exec_mode = weak constant i8 1
+
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_attributes_max_work_group_sizev_l[[LINE6:.+]]_wg_size = weak addrspace(1) constant i16 1024
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_attributes_max_work_group_sizev_l[[LINE6]]_kern_desc = weak constant %struct.__tgt_attribute_struct { i16 2, i16 9, i16 1024, i8 1, i8 1, i8 0 }, align 2
+// CHECK: @__omp_offloading_{{.*}}test_amdgcn_target_attributes_max_work_group_sizev_l[[LINE6]]_exec_mode = weak constant i8 1
+
 int test_amdgcn_target_tid_threads() {
 // CHECK-LABEL: define weak void @{{.*}}test_amdgcn_target_tid_threads
 
@@ -40,4 +63,65 @@
   return arr[0];
 }
 
+int test_amdgcn_target_max_parallel_level() {
+  // CHECK-LABEL: define weak void @{{.*}}test_amdgcn_target_max_parallel_level
+  int arr[N];
+
+#pragma omp target parallel for
+  for (int i = 0; i < N; i++)
+#pragma omp parallel for
+for (int j = 0; j < N; j++)
+#pragma omp parallel for
+  for (int k = 0; k < N; k++)
+for (int l = 0; l < N; l++)
+#pragma omp parallel for
+  for (int m = 0; m < N; m++)
+arr[m] = 0;
+
+  return arr[0];
+}
+
+int test_amdgcn_target_attributes_spmd() {
+  int arr[N];
+
+// CHECK: {{.*}}"amdgpu-flat-work-group-size"="10,10"
+#pragma omp target parallel num_threads(10)
+  for (int i = 0; i < N; i++) {
+arr[i] = 1;
+  }
+
+  return arr[0];
+}
+
+int test_amdgcn_target_attributes_non_spmd() {
+  int arr[N];
+
+// CHECK: {{.*}}"amdgpu-flat-work-group-size"="74,74"
+#pragma omp target teams thread_limit(10)
+  for (int i = 0; i < N; i++) {
+arr[i] = 1;
+  }
+
+  return arr[0];
+}
+
+int test_amdgcn_target_attributes_max_work_group_size() {
+  int arr[N];
+
+// CHECK: {{.*}}"amdgpu-flat-work-group-size"="1024,1024"
+#pragma omp target teams thread_limit(1500)
+  for (int i = 0; i < N; i++) {
+

[PATCH] D89360: Treat constant contexts as being in the default rounding mode.

2020-10-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D89360#2330522 , @rsmith wrote:

> In D89360#2329856 , @sepavloff wrote:
>
>> I would propose to consider solution in D88498 
>> . It tries to fix the real reason of the 
>> malfunction - using dynamic rounding mode for evaluation of global variable 
>> initializers.
>
> That is not the real reason for the malfunction. If you narrowly look at C, 
> you can convince yourself otherwise, but that's only because global variable 
> initializers are the only place where we need to evaluate floating-point 
> constant expressions in C. In C++, this problem affects all contexts where 
> constant evaluation might happen (array bounds, bit-field widths, and a whole 
> host of others).

You are right, the solution in D88498  was 
more a workaround, as it was focused on initializers only. The updated version 
applies dynamic rounding to function bodies only, I hope it could solve the 
problem of other contexts.




Comment at: clang/test/SemaCXX/rounding-math.cpp:9
+
+constexpr int f(int n) { return int(n * (1.0 / 3.0)); }
+

rsmith wrote:
> rsmith wrote:
> > sepavloff wrote:
> > > This code requires additional solution. The function body is built using 
> > > dynamic rounding mode, which breaks its constexprness. We can avoid this 
> > > kind of errors if we assume that body of a constexpr function is parsed 
> > > using constant rounding mode (in this example it is the default mode). It 
> > > makes parsing constexpr function different from non-constexpr ones, but 
> > > enables convenient use:
> > > ```
> > > constexpr int add(float x, float y) { return x + y; }
> > > 
> > > #pragma STDC FENV_ROUND FE_UPWARD
> > > int a2 = add(2.0F, 0x1.02p0F);
> > > 
> > > #pragma STDC FENV_ROUND FE_DOWNWARD
> > > int a3 = add(2.0F, 0x1.02p0F);
> > > ```
> > > If calls of constexpr functions are processes with FP options acting in 
> > > the call site, a call to constexpr function becomes equivalent to 
> > > execution of statements of its body.
> > I don't understand what you mean by "breaks its constexprness". Using a 
> > dynamic rounding mode for the body of the function is exactly what we want 
> > here. When the function is called in a manifestly constant evaluated 
> > context, we should use the default rounding mode, and when it's called at 
> > runtime, we use the appropriate dynamic rounding mode; if we try to 
> > constant evaluate it outside of a manifestly constant evaluated constant, 
> > we deem it non-constant.
> > 
> > When `constexpr` function is called at runtime, it's a completely normal 
> > function with normal semantics. It would be wrong to use the default 
> > rounding mode when parsing its body.
> To be clear: in your example with `add`, both `a2` and `a3` should be 
> initialized to the same value, which should be rounded with the default 
> rounding mode. Per ISO18661, `FENV_ROUND` only affects operations in its 
> lexical scope, not functions called within those operations, and per the 
> regular C++ rules, `constexpr` functions behave like regular functions, not 
> like macros.
I incorrectly identified the reason why some call was rejected in constant 
evaluated context. Please ignore this statement. I am sorry.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89360/new/

https://reviews.llvm.org/D89360

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


[PATCH] D89468: [libTooling] Change `after` range-selector to operate only on source ranges

2020-10-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: tdl-g.
Herald added a project: clang.
ymandel requested review of this revision.

Currently, `after` fails when applied to locations in macro arguments.  This
change projects the subrange into a file source range and then applies `after`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89468

Files:
  clang/lib/Tooling/Transformer/RangeSelector.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp


Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -193,6 +193,51 @@
HasValue(EqualsCharSourceRange(ExpectedAfter)));
 }
 
+static void testAfterMacroArg(StringRef Code) {
+  const std::string Ref = "ref";
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind(Ref));
+  const auto *E = Match.Result.Nodes.getNodeAs(Ref);
+  assert(E != nullptr);
+  // `E` is the variable `y`, and so is one character wide. So advance by one,
+  // bringing us to the next character.
+  SourceLocation Next =
+  Match.Result.SourceManager->getSpellingLoc(E->getBeginLoc())
+  .getLocWithOffset(1);
+  const auto ExpectedAfter = CharSourceRange::getCharRange(Next, Next);
+
+  EXPECT_THAT_EXPECTED(after(node(Ref))(Match.Result),
+   HasValue(EqualsCharSourceRange(ExpectedAfter)));
+}
+
+// Test with a range that is the entire macro arg, but does not end the
+// expansion itself.
+TEST(RangeSelectorTest, AfterOpInMacroArg) {
+  StringRef Code = R"cc(
+#define ISNULL(x) x == nullptr
+bool g() { int* y; return ISNULL(y); }
+  )cc";
+  testAfterMacroArg(Code);
+}
+
+// Test with a range that is the entire macro arg and ends the expansion 
itself.
+TEST(RangeSelectorTest, AfterOpInMacroArgEndsExpansion) {
+  StringRef Code = R"cc(
+#define ISNULL(x) nullptr == x
+bool g() { int* y; return ISNULL(y); }
+  )cc";
+  testAfterMacroArg(Code);
+}
+
+TEST(RangeSelectorTest, AfterOpInPartOfMacroArg) {
+  StringRef Code = R"cc(
+#define ISNULL(x) x == nullptr
+int* f(int*);
+bool g() { int* y; return ISNULL(f(y)); }
+  )cc";
+  testAfterMacroArg(Code);
+}
+
 TEST(RangeSelectorTest, BetweenOp) {
   StringRef Code = R"cc(
 int f(int x, int y, int z) { return 3; }
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -116,11 +116,24 @@
 Expected SelectedRange = Selector(Result);
 if (!SelectedRange)
   return SelectedRange.takeError();
-if (SelectedRange->isCharRange())
-  return CharSourceRange::getCharRange(SelectedRange->getEnd());
-return CharSourceRange::getCharRange(Lexer::getLocForEndOfToken(
-SelectedRange->getEnd(), 0, Result.Context->getSourceManager(),
-Result.Context->getLangOpts()));
+SourceLocation End = SelectedRange->getEnd();
+if (SelectedRange->isTokenRange()) {
+  // We need to find the actual (exclusive) end location from which to
+  // create a new source range. However, that's not guaranteed to be valid,
+  // even if the token location itself is valid. So, we create a token 
range
+  // consisting only of the last token, then map that range back to the
+  // source file. If that succeeds, we have a valid location for the end of
+  // the generated range.
+  CharSourceRange Range = Lexer::makeFileCharRange(
+  CharSourceRange::getTokenRange(SelectedRange->getEnd()),
+  *Result.SourceManager, Result.Context->getLangOpts());
+  if (Range.isInvalid())
+return invalidArgumentError(
+"after: can't resolve sub-range to valid source range");
+  End = Range.getEnd();
+}
+
+return CharSourceRange::getCharRange(End);
   };
 }
 


Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -193,6 +193,51 @@
HasValue(EqualsCharSourceRange(ExpectedAfter)));
 }
 
+static void testAfterMacroArg(StringRef Code) {
+  const std::string Ref = "ref";
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind(Ref));
+  const auto *E = Match.Result.Nodes.getNodeAs(Ref);
+  assert(E != nullptr);
+  // `E` is the variable `y`, and so is one character wide. So advance by one,
+  // bringing us to the next character.
+  SourceLocation Next =
+  Match.Result.SourceManager->getSpellingLoc(E->getBeginLoc())
+  .getLocWithOffset(1);
+  const auto ExpectedAfter = CharSourceRange::getCharRange(Next, Next);
+
+  EXPECT_THAT_EXPECTED(after(node(Ref))(Match.Result),
+   

[PATCH] D89469: FileManager: Test FileManager::getFileRef

2020-10-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: arphaman.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Add a test demonstrating `getFileRef`'s behaviour, which isn't obvious
from code inspection when it's handling a redirected file.


https://reviews.llvm.org/D89469

Files:
  clang/unittests/Basic/FileManagerTest.cpp

Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -28,17 +28,28 @@
   // not in this map is considered to not exist in the file system.
   llvm::StringMap StatCalls;
 
-  void InjectFileOrDirectory(const char *Path, ino_t INode, bool IsFile) {
+  void InjectFileOrDirectory(const char *Path, ino_t INode, bool IsFile,
+ const char *StatPath) {
 #ifndef _WIN32
 SmallString<128> NormalizedPath(Path);
 llvm::sys::path::native(NormalizedPath);
 Path = NormalizedPath.c_str();
+
+SmallString<128> NormalizedStatPath;
+if (StatPath) {
+  NormalizedStatPath = StatPath;
+  llvm::sys::path::native(NormalizedStatPath);
+  StatPath = NormalizedStatPath.c_str();
+}
 #endif
 
+if (!StatPath)
+  StatPath = Path;
+
 auto fileType = IsFile ?
   llvm::sys::fs::file_type::regular_file :
   llvm::sys::fs::file_type::directory_file;
-llvm::vfs::Status Status(Path, llvm::sys::fs::UniqueID(1, INode),
+llvm::vfs::Status Status(StatPath, llvm::sys::fs::UniqueID(1, INode),
  /*MTime*/{}, /*User*/0, /*Group*/0,
  /*Size*/0, fileType,
  llvm::sys::fs::perms::all_all);
@@ -47,13 +58,14 @@
 
 public:
   // Inject a file with the given inode value to the fake file system.
-  void InjectFile(const char *Path, ino_t INode) {
-InjectFileOrDirectory(Path, INode, /*IsFile=*/true);
+  void InjectFile(const char *Path, ino_t INode,
+  const char *StatPath = nullptr) {
+InjectFileOrDirectory(Path, INode, /*IsFile=*/true, StatPath);
   }
 
   // Inject a directory with the given inode value to the fake file system.
   void InjectDirectory(const char *Path, ino_t INode) {
-InjectFileOrDirectory(Path, INode, /*IsFile=*/false);
+InjectFileOrDirectory(Path, INode, /*IsFile=*/false, nullptr);
   }
 
   // Implement FileSystemStatCache::getStat().
@@ -249,6 +261,57 @@
 
   EXPECT_EQ(f1 ? *f1 : nullptr,
 f2 ? *f2 : nullptr);
+
+  // Check that getFileRef also does the right thing.
+  auto r1 = manager.getFileRef("abc/foo.cpp");
+  auto r2 = manager.getFileRef("abc/bar.cpp");
+  ASSERT_FALSE(!r1);
+  ASSERT_FALSE(!r2);
+
+  EXPECT_EQ("abc/foo.cpp", r1->getName());
+  EXPECT_EQ("abc/bar.cpp", r2->getName());
+  EXPECT_EQ((f1 ? *f1 : nullptr), &r1->getFileEntry());
+  EXPECT_EQ((f2 ? *f2 : nullptr), &r2->getFileEntry());
+}
+
+TEST_F(FileManagerTest, getFileRefReturnsCorrectNameForDifferentStatPath) {
+  // Inject files with the same inode, but where some files have a stat that
+  // gives a different name.
+  auto StatCache = std::make_unique();
+  StatCache->InjectDirectory("dir", 40);
+  StatCache->InjectFile("dir/f1.cpp", 41);
+  StatCache->InjectFile("dir/f1-alias.cpp", 41, "dir/f1.cpp");
+  StatCache->InjectFile("dir/f2.cpp", 42);
+  StatCache->InjectFile("dir/f2-alias.cpp", 42, "dir/f2.cpp");
+  manager.setStatCache(std::move(StatCache));
+
+  // With F2, test accessing the non-redirected name first.
+  auto F1 = manager.getFileRef("dir/f1.cpp");
+  auto F1Alias = manager.getFileRef("dir/f1-alias.cpp");
+  auto F1Alias2 = manager.getFileRef("dir/f1-alias.cpp");
+  ASSERT_FALSE(!F1);
+  ASSERT_FALSE(!F1Alias);
+  ASSERT_FALSE(!F1Alias2);
+  EXPECT_EQ("dir/f1.cpp", F1->getName());
+  EXPECT_EQ("dir/f1.cpp", F1->getFileEntry().getName());
+  EXPECT_EQ("dir/f1.cpp", F1Alias->getName());
+  EXPECT_EQ("dir/f1.cpp", F1Alias2->getName());
+  EXPECT_EQ(&F1->getFileEntry(), &F1Alias->getFileEntry());
+  EXPECT_EQ(&F1->getFileEntry(), &F1Alias2->getFileEntry());
+
+  // With F2, test accessing the redirected name first.
+  auto F2Alias = manager.getFileRef("dir/f2-alias.cpp");
+  auto F2 = manager.getFileRef("dir/f2.cpp");
+  auto F2Alias2 = manager.getFileRef("dir/f2-alias.cpp");
+  ASSERT_FALSE(!F2);
+  ASSERT_FALSE(!F2Alias);
+  ASSERT_FALSE(!F2Alias2);
+  EXPECT_EQ("dir/f2.cpp", F2->getName());
+  EXPECT_EQ("dir/f2.cpp", F2->getFileEntry().getName());
+  EXPECT_EQ("dir/f2.cpp", F2Alias->getName());
+  EXPECT_EQ("dir/f2.cpp", F2Alias2->getName());
+  EXPECT_EQ(&F2->getFileEntry(), &F2Alias->getFileEntry());
+  EXPECT_EQ(&F2->getFileEntry(), &F2Alias2->getFileEntry());
 }
 
 // getFile() returns the same FileEntry for virtual files that have
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89468: [libTooling] Change `after` range-selector to operate only on source ranges

2020-10-15 Thread Tom Lokovic via Phabricator via cfe-commits
tdl-g requested changes to this revision.
tdl-g added a comment.
This revision now requires changes to proceed.

Just one comment about the tests.




Comment at: clang/unittests/Tooling/RangeSelectorTest.cpp:196
 
+static void testAfterMacroArg(StringRef Code) {
+  const std::string Ref = "ref";

If this helper function took an "expected" parameter I might consider it 
self-explanatory, but as it is, it's extremely non-obvious what it does without 
reading the body in detail--which means the tests that use it are not 
particularly readable either.  (Each test reads like "here's the input data, 
make sure something unspecified is true about it.")  Specifically, this 
function searches for a reference to the variable "y" and ensures that after() 
finds the character after it.  So at a minimum, document that.

I'm also trying to decide if this helper is too similar to the 
implementation--tests should not just restate what the production code does, 
they should find some other way to validate the behavior.  Do you think this is 
sufficiently different from the prod implementation to be meaningful?  If so, 
that's fine.  If not, maybe the helper should just take an expected byte 
offset, be renamed to "afterYHasByteOffset", and then each test would be a bit 
more readable?

Up to you.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89468/new/

https://reviews.llvm.org/D89468

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


[PATCH] D89464: Revert "[clang-format] Fix AlignConsecutive on PP blocks"

2020-10-15 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:12255
Alignment);
-
-  // Bug 25167

lebedev.ri wrote:
> Passing-by comment: you probably want to keep the tests though?
Sure, i will keep that
and add a test case to avoid breaking what we did



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89464/new/

https://reviews.llvm.org/D89464

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


[PATCH] D89055: [analyzer] Wrong type cast occures during pointer dereferencing after type punning

2020-10-15 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 298388.
ASDenysPetrov added a comment.

Updated. Moved `castRegion()` to `SValBuilder`.

Actually it wasn't so hard as I thought :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89055/new/

https://reviews.llvm.org/D89055

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/test/Analysis/casts.c
  clang/test/Analysis/string.c

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,14 @@
 strcpy(x, y); // no-warning
 }
 
+// PR37503
+void *get_void_ptr();
+char ***type_punned_ptr;
+void strcpy_no_assertion(char c) {
+  *(unsigned char **)type_punned_ptr = (unsigned char *)(get_void_ptr());
+  strcpy(**type_punned_ptr, &c); // no-crash
+}
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/test/Analysis/casts.c
===
--- clang/test/Analysis/casts.c
+++ clang/test/Analysis/casts.c
@@ -245,3 +245,8 @@
   return a * a;
 }
 
+void no_crash_reinterpret_char_as_uchar(char ***a, int *b) {
+  *(unsigned char **)a = (unsigned char *)b;
+  if (**a == 0) // no-crash
+;
+}
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -57,13 +57,6 @@
   return Store;
 }
 
-const ElementRegion *StoreManager::MakeElementRegion(const SubRegion *Base,
- QualType EleTy,
- uint64_t index) {
-  NonLoc idx = svalBuilder.makeArrayIndex(index);
-  return MRMgr.getElementRegion(EleTy, idx, Base, svalBuilder.getContext());
-}
-
 const ElementRegion *StoreManager::GetElementZeroRegion(const SubRegion *R,
 QualType T) {
   NonLoc idx = svalBuilder.makeZeroArrayIndex();
@@ -71,161 +64,6 @@
   return MRMgr.getElementRegion(T, idx, R, Ctx);
 }
 
-const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy) {
-  ASTContext &Ctx = StateMgr.getContext();
-
-  // Handle casts to Objective-C objects.
-  if (CastToTy->isObjCObjectPointerType())
-return R->StripCasts();
-
-  if (CastToTy->isBlockPointerType()) {
-// FIXME: We may need different solutions, depending on the symbol
-// involved.  Blocks can be casted to/from 'id', as they can be treated
-// as Objective-C objects.  This could possibly be handled by enhancing
-// our reasoning of downcasts of symbolic objects.
-if (isa(R) || isa(R))
-  return R;
-
-// We don't know what to make of it.  Return a NULL region, which
-// will be interpreted as UnknownVal.
-return nullptr;
-  }
-
-  // Now assume we are casting from pointer to pointer. Other cases should
-  // already be handled.
-  QualType PointeeTy = CastToTy->getPointeeType();
-  QualType CanonPointeeTy = Ctx.getCanonicalType(PointeeTy);
-
-  // Handle casts to void*.  We just pass the region through.
-  if (CanonPointeeTy.getLocalUnqualifiedType() == Ctx.VoidTy)
-return R;
-
-  // Handle casts from compatible types.
-  if (R->isBoundable())
-if (const auto *TR = dyn_cast(R)) {
-  QualType ObjTy = Ctx.getCanonicalType(TR->getValueType());
-  if (CanonPointeeTy == ObjTy)
-return R;
-}
-
-  // Process region cast according to the kind of the region being cast.
-  switch (R->getKind()) {
-case MemRegion::CXXThisRegionKind:
-case MemRegion::CodeSpaceRegionKind:
-case MemRegion::StackLocalsSpaceRegionKind:
-case MemRegion::StackArgumentsSpaceRegionKind:
-case MemRegion::HeapSpaceRegionKind:
-case MemRegion::UnknownSpaceRegionKind:
-case MemRegion::StaticGlobalSpaceRegionKind:
-case MemRegion::GlobalInternalSpaceRegionKind:
-case MemRegion::GlobalSystemSpaceRegionKind:
-case MemRegion::GlobalImmutableSpaceRegionKind: {
-  llvm_unreachable("Invalid region cast");
-}
-
-case MemRegion::FunctionCodeRegionKind:
-case MemRegion::BlockCodeRegionKind:
-case MemRegion::BlockDataRegionKind:
-case MemRegion::StringRegionKind:
-  // FIXME: Need to handle arbitrary downcasts.
-case MemRegion::SymbolicRegionKind:
-case MemRegion::AllocaRegionKind:
-case MemRegion::CompoundLiteralRegionKind:
-case MemRegion::FieldRegionKind:
-case MemRegion::ObjCIvarRegionKind:
-case MemRegion::ObjCStringRegionKind:
-case MemRegion::NonParamVarRegionKind:
-case MemReg

[PATCH] D89475: [SemaObjC] Fix composite pointer type calculation for `void*` and pointer to lifetime qualified ObjC pointer type

2020-10-15 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, rjmccall.
Herald added subscribers: ributzka, dexonsmith, jkorous.
erik.pilkington requested review of this revision.

This fixes a regression introduced in 9a6f4d451ca7aa06b94a407015fbadb456bc09ef 
:

  void f() {
NSString *__strong* sptr;
void *vptr;
vptr == sptr; // new error: incompatible pointer types
  }

We're now erroring out on this code because `FindCompositePointerType` is 
rejecting the qualifier mismatch between `void` and `NSString *__strong` after 
stripping one level of pointer types.

rdar://70101809


https://reviews.llvm.org/D89475

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaObjCXX/arc-ptr-comparison.mm


Index: clang/test/SemaObjCXX/arc-ptr-comparison.mm
===
--- clang/test/SemaObjCXX/arc-ptr-comparison.mm
+++ clang/test/SemaObjCXX/arc-ptr-comparison.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-fobjc-runtime-has-weak -fobjc-arc -verify %s
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-verify -DNOARC %s
 #ifdef NOARC
 // expected-no-diagnostics
@@ -51,3 +51,17 @@
   return a == cv;
   return ca == v;
 }
+
+#ifndef NOARC
+int testDoublePtr(void *pv, void **ppv, A *__strong* pspa, A *__weak* pwpa, A 
*__strong** ppspa) {
+  return pv == pspa;
+  return pspa == pv;
+  return pv == pspa;
+  return pv == pwpa;
+  return pspa == pwpa; // expected-error {{comparison of distinct pointer 
types}}
+  return ppv == pspa; // expected-error {{comparison of distinct pointer 
types}}
+  return pspa == ppv; // expected-error {{comparison of distinct pointer 
types}}
+  return pv == ppspa;
+  return ppv == ppspa; // expected-error{{comparison of distinct pointer 
types}}
+}
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6552,12 +6552,16 @@
   // FIXME: In C, we merge __strong and none to __strong at the top level.
   if (Q1.getObjCGCAttr() == Q2.getObjCGCAttr())
 Quals.setObjCGCAttr(Q1.getObjCGCAttr());
+  else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+assert(Steps.size() == 1);
   else
 return QualType();
 
   // Mismatched lifetime qualifiers never compatibly include each other.
   if (Q1.getObjCLifetime() == Q2.getObjCLifetime())
 Quals.setObjCLifetime(Q1.getObjCLifetime());
+  else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+assert(Steps.size() == 1);
   else
 return QualType();
 


Index: clang/test/SemaObjCXX/arc-ptr-comparison.mm
===
--- clang/test/SemaObjCXX/arc-ptr-comparison.mm
+++ clang/test/SemaObjCXX/arc-ptr-comparison.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -verify %s
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -verify -DNOARC %s
 #ifdef NOARC
 // expected-no-diagnostics
@@ -51,3 +51,17 @@
   return a == cv;
   return ca == v;
 }
+
+#ifndef NOARC
+int testDoublePtr(void *pv, void **ppv, A *__strong* pspa, A *__weak* pwpa, A *__strong** ppspa) {
+  return pv == pspa;
+  return pspa == pv;
+  return pv == pspa;
+  return pv == pwpa;
+  return pspa == pwpa; // expected-error {{comparison of distinct pointer types}}
+  return ppv == pspa; // expected-error {{comparison of distinct pointer types}}
+  return pspa == ppv; // expected-error {{comparison of distinct pointer types}}
+  return pv == ppspa;
+  return ppv == ppspa; // expected-error{{comparison of distinct pointer types}}
+}
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6552,12 +6552,16 @@
   // FIXME: In C, we merge __strong and none to __strong at the top level.
   if (Q1.getObjCGCAttr() == Q2.getObjCGCAttr())
 Quals.setObjCGCAttr(Q1.getObjCGCAttr());
+  else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+assert(Steps.size() == 1);
   else
 return QualType();
 
   // Mismatched lifetime qualifiers never compatibly include each other.
   if (Q1.getObjCLifetime() == Q2.getObjCLifetime())
 Quals.setObjCLifetime(Q1.getObjCLifetime());
+  else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+assert(Steps.size() == 1);
   else
 return QualType();
 

[PATCH] D89468: [libTooling] Change `after` range-selector to operate only on source ranges

2020-10-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 298392.
ymandel added a comment.

cleaned up test code


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89468/new/

https://reviews.llvm.org/D89468

Files:
  clang/lib/Tooling/Transformer/RangeSelector.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp

Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -193,6 +193,65 @@
HasValue(EqualsCharSourceRange(ExpectedAfter)));
 }
 
+// Gets the spelling location `Length` characters after the start of AST node
+// `Id`.
+static SourceLocation getSpellingLocAfter(const MatchResult &Result,
+  StringRef Id, int Length) {
+  const auto *E = Result.Nodes.getNodeAs(Id);
+  assert(E != nullptr);
+  return Result.SourceManager->getSpellingLoc(E->getBeginLoc())
+  .getLocWithOffset(Length);
+}
+
+// Test with a range that is the entire macro arg, but does not end the
+// expansion itself.
+TEST(RangeSelectorTest, AfterOpInMacroArg) {
+  StringRef Code = R"cc(
+#define ISNULL(x) x == nullptr
+bool g() { int* y; return ISNULL(y); }
+  )cc";
+
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind("yvar"));
+  int YVarLen = 1;
+  SourceLocation After = getSpellingLocAfter(Match.Result, "yvar", YVarLen);
+  CharSourceRange Expected = CharSourceRange::getCharRange(After, After);
+  EXPECT_THAT_EXPECTED(after(node("yvar"))(Match.Result),
+   HasValue(EqualsCharSourceRange(Expected)));
+}
+
+// Test with a range that is the entire macro arg and ends the expansion itself.
+TEST(RangeSelectorTest, AfterOpInMacroArgEndsExpansion) {
+  StringRef Code = R"cc(
+#define ISNULL(x) nullptr == x
+bool g() { int* y; return ISNULL(y); }
+  )cc";
+
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind("yvar"));
+  int YVarLen = 1;
+  SourceLocation After = getSpellingLocAfter(Match.Result, "yvar", YVarLen);
+  CharSourceRange Expected = CharSourceRange::getCharRange(After, After);
+  EXPECT_THAT_EXPECTED(after(node("yvar"))(Match.Result),
+   HasValue(EqualsCharSourceRange(Expected)));
+}
+
+TEST(RangeSelectorTest, AfterOpInPartOfMacroArg) {
+  StringRef Code = R"cc(
+#define ISNULL(x) x == nullptr
+int* f(int*);
+bool g() { int* y; return ISNULL(f(y)); }
+  )cc";
+
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind("yvar"));
+  int YVarLen = 1;
+  SourceLocation After = getSpellingLocAfter(Match.Result, "yvar", YVarLen);
+  CharSourceRange Expected = CharSourceRange::getCharRange(After, After);
+  EXPECT_THAT_EXPECTED(after(node("yvar"))(Match.Result),
+   HasValue(EqualsCharSourceRange(Expected)));
+}
+
 TEST(RangeSelectorTest, BetweenOp) {
   StringRef Code = R"cc(
 int f(int x, int y, int z) { return 3; }
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -116,11 +116,24 @@
 Expected SelectedRange = Selector(Result);
 if (!SelectedRange)
   return SelectedRange.takeError();
-if (SelectedRange->isCharRange())
-  return CharSourceRange::getCharRange(SelectedRange->getEnd());
-return CharSourceRange::getCharRange(Lexer::getLocForEndOfToken(
-SelectedRange->getEnd(), 0, Result.Context->getSourceManager(),
-Result.Context->getLangOpts()));
+SourceLocation End = SelectedRange->getEnd();
+if (SelectedRange->isTokenRange()) {
+  // We need to find the actual (exclusive) end location from which to
+  // create a new source range. However, that's not guaranteed to be valid,
+  // even if the token location itself is valid. So, we create a token range
+  // consisting only of the last token, then map that range back to the
+  // source file. If that succeeds, we have a valid location for the end of
+  // the generated range.
+  CharSourceRange Range = Lexer::makeFileCharRange(
+  CharSourceRange::getTokenRange(SelectedRange->getEnd()),
+  *Result.SourceManager, Result.Context->getLangOpts());
+  if (Range.isInvalid())
+return invalidArgumentError(
+"after: can't resolve sub-range to valid source range");
+  End = Range.getEnd();
+}
+
+return CharSourceRange::getCharRange(End);
   };
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89468: [libTooling] Change `after` range-selector to operate only on source ranges

2020-10-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang/unittests/Tooling/RangeSelectorTest.cpp:196
 
+static void testAfterMacroArg(StringRef Code) {
+  const std::string Ref = "ref";

tdl-g wrote:
> If this helper function took an "expected" parameter I might consider it 
> self-explanatory, but as it is, it's extremely non-obvious what it does 
> without reading the body in detail--which means the tests that use it are not 
> particularly readable either.  (Each test reads like "here's the input data, 
> make sure something unspecified is true about it.")  Specifically, this 
> function searches for a reference to the variable "y" and ensures that 
> after() finds the character after it.  So at a minimum, document that.
> 
> I'm also trying to decide if this helper is too similar to the 
> implementation--tests should not just restate what the production code does, 
> they should find some other way to validate the behavior.  Do you think this 
> is sufficiently different from the prod implementation to be meaningful?  If 
> so, that's fine.  If not, maybe the helper should just take an expected byte 
> offset, be renamed to "afterYHasByteOffset", and then each test would be a 
> bit more readable?
> 
> Up to you.
I reduced the helper to just getting the spelling location at the given offset. 
the rest of the code I've inlined into the tests. That helper is still 
substantially less complicated than what happens in the production code, and I 
don't see any better way to find the location, unless we want to do an offset 
from, say, the braces of the function. that avoids macro-related calculations, 
but also disconnects from the var. So, I think it's just a tradeoff rather than 
an improvement.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89468/new/

https://reviews.llvm.org/D89468

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


[PATCH] D89366: [WebAssembly] v128.load{8, 16, 32, 64}_lane instructions

2020-10-15 Thread Thomas Lively via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c6bfd90ab2d: [WebAssembly] v128.load{8,16,32,64}_lane 
instructions (authored by tlively).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89366/new/

https://reviews.llvm.org/D89366

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-load-lane-offset.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -280,6 +280,30 @@
 # CHECK: v128.bitselect # encoding: [0xfd,0x52]
 v128.bitselect
 
+# CHECK: v128.load8_lane 32, 1 # encoding: [0xfd,0x58,0x00,0x20,0x01]
+v128.load8_lane 32, 1
+
+# CHECK: v128.load16_lane 32, 1 # encoding: [0xfd,0x59,0x01,0x20,0x01]
+v128.load16_lane 32, 1
+
+# CHECK: v128.load32_lane 32, 1 # encoding: [0xfd,0x5a,0x02,0x20,0x01]
+v128.load32_lane 32, 1
+
+# CHECK: v128.load64_lane 32, 1 # encoding: [0xfd,0x5b,0x03,0x20,0x01]
+v128.load64_lane 32, 1
+
+# CHECK: v128.store8_lane 32, 1 # encoding: [0xfd,0x5c,0x00,0x20,0x01]
+v128.store8_lane 32, 1
+
+# CHECK: v128.store16_lane 32, 1 # encoding: [0xfd,0x5d,0x01,0x20,0x01]
+v128.store16_lane 32, 1
+
+# CHECK: v128.store32_lane 32, 1 # encoding: [0xfd,0x5e,0x02,0x20,0x01]
+v128.store32_lane 32, 1
+
+# CHECK: v128.store64_lane 32, 1 # encoding: [0xfd,0x5f,0x03,0x20,0x01]
+v128.store64_lane 32, 1
+
 # CHECK: i8x16.abs # encoding: [0xfd,0x60]
 i8x16.abs
 
Index: llvm/test/CodeGen/WebAssembly/simd-load-lane-offset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/simd-load-lane-offset.ll
@@ -0,0 +1,968 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -verify-machineinstrs -mattr=+simd128 | FileCheck %s
+
+; Test SIMD v128.load{8,16,32,64}_lane instructions.
+
+; TODO: Use the offset field by supporting more patterns. Right now only the
+; equivalents of LoadPatNoOffset/StorePatNoOffset are supported.
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+declare <16 x i8> @llvm.wasm.load8.lane(i8*, <16 x i8>, i32)
+declare <8 x i16> @llvm.wasm.load16.lane(i16*, <8 x i16>, i32)
+declare <4 x i32> @llvm.wasm.load32.lane(i32*, <4 x i32>, i32)
+declare <2 x i64> @llvm.wasm.load64.lane(i64*, <2 x i64>, i32)
+
+declare void @llvm.wasm.store8.lane(i8*, <16 x i8>, i32)
+declare void @llvm.wasm.store16.lane(i16*, <8 x i16>, i32)
+declare void @llvm.wasm.store32.lane(i32*, <4 x i32>, i32)
+declare void @llvm.wasm.store64.lane(i64*, <2 x i64>, i32)
+
+;===
+; v128.load8_lane / v128.store8_lane
+;===
+
+define <16 x i8> @load_lane_i8_no_offset(i8* %p, <16 x i8> %v) {
+; CHECK-LABEL: load_lane_i8_no_offset:
+; CHECK: .functype load_lane_i8_no_offset (i32, v128) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:local.get 1
+; CHECK-NEXT:v128.load8_lane 0, 0
+; CHECK-NEXT:# fallthrough-return
+  %t = tail call <16 x i8> @llvm.wasm.load8.lane(i8* %p, <16 x i8> %v, i32 0)
+  ret <16 x i8> %t
+}
+
+define <16 x i8> @load_lane_i8_with_folded_offset(i8* %p, <16 x i8> %v) {
+; CHECK-LABEL: load_lane_i8_with_folded_offset:
+; CHECK: .functype load_lane_i8_with_folded_offset (i32, v128) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i32.const 24
+; CHECK-NEXT:i32.add
+; CHECK-NEXT:local.get 1
+; CHECK-NEXT:v128.load8_lane 0, 0
+; CHECK-NEXT:# fallthrough-return
+  %q = ptrtoint i8* %p to i32
+  %r = add nuw i32 %q, 24
+  %s = inttoptr i32 %r to i8*
+  %t = tail call <16 x i8> @llvm.wasm.load8.lane(i8* %s, <16 x i8> %v, i32 0)
+  ret <16 x i8> %t
+}
+
+define <16 x i8> @load_lane_i8_with_folded_gep_offset(i8* %p, <16 x i8> %v) {
+; CHECK-LABEL: load_lane_i8_with_folded_gep_offset:
+; CHECK: .functype load_lane_i8_with_folded_gep_offset (i32, v128) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i32.const 6
+; CHECK-NEXT:i32.add
+; CHECK-NEXT:local.get 1
+; CHECK-NEXT:v128.load8_lane 0, 0
+; CHECK-NEXT:# fallthrough-re

[clang] 7c6bfd9 - [WebAssembly] v128.load{8, 16, 32, 64}_lane instructions

2020-10-15 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-10-15T15:33:10Z
New Revision: 7c6bfd90ab2ddaa60de62878c8512db0645e8452

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

LOG: [WebAssembly] v128.load{8,16,32,64}_lane instructions

Prototype the newly proposed load_lane instructions, as specified in
https://github.com/WebAssembly/simd/pull/350. Since these instructions are not
available to origin trial users on Chrome stable, make them opt-in by only
selecting them from intrinsics rather than normal ISel patterns. Since we only
need rough prototypes to measure performance right now, this commit does not
implement all the load and store patterns that would be necessary to make full
use of the offset immediate. However, the full suite of offset tests is included
to make it easy to track improvements in the future.

Since these are the first instructions to have a memarg immediate as well as an
additional immediate, the disassembler needed some additional hacks to be able
to parse them correctly. Making that code more principled is left as future
work.

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

Added: 
llvm/test/CodeGen/WebAssembly/simd-load-lane-offset.ll

Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 45e194c283b6..86348ff5fea7 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -171,8 +171,17 @@ TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, 
"V16UcV8UsV8Us", "nc", "simd
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4UiV4Ui", "nc", 
"simd128")
 
-TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4ii*", "nU", "simd128")
-TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLi*", "nU", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4ii*", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLi*", "n", "simd128")
+
+TARGET_BUILTIN(__builtin_wasm_load8_lane, "V16ScSc*V16ScIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load16_lane, "V8ss*V8sIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load32_lane, "V4ii*V4iIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load64_lane, "V2LLiLLi*V2LLiIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_store8_lane, "vSc*V16ScIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_store16_lane, "vs*V8sIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_store32_lane, "vi*V4iIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_store64_lane, "vLLi*V2LLiIi", "n", "simd128")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 157dae2831f2..3f6977e16c4a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -16711,6 +16711,52 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_load64_zero);
 return Builder.CreateCall(Callee, {Ptr});
   }
+  case WebAssembly::BI__builtin_wasm_load8_lane:
+  case WebAssembly::BI__builtin_wasm_load16_lane:
+  case WebAssembly::BI__builtin_wasm_load32_lane:
+  case WebAssembly::BI__builtin_wasm_load64_lane:
+  case WebAssembly::BI__builtin_wasm_store8_lane:
+  case WebAssembly::BI__builtin_wasm_store16_lane:
+  case WebAssembly::BI__builtin_wasm_store32_lane:
+  case WebAssembly::BI__builtin_wasm_store64_lane: {
+Value *Ptr = EmitScalarExpr(E->getArg(0));
+Value *Vec = EmitScalarExpr(E->getArg(1));
+Optional LaneIdxConst =
+E->getArg(2)->getIntegerConstantExpr(getContext());
+assert(LaneIdxConst && "Constant arg isn't actually constant?");
+Value *LaneIdx = llvm::ConstantInt::get(getLLVMContext(), *LaneIdxConst);
+unsigned IntNo;
+switch (BuiltinID) {
+case WebAssembly::BI__builtin_wasm_load8_lane:
+  IntNo = Intrinsic::wasm_load8_lane;
+  break;
+case WebAssembly::BI__builtin_wasm_load16_lane:
+  IntNo = Intrinsic::wasm_load16_lane;
+  break;
+case WebAssembly::BI__builtin_wasm_load32_lane:
+  IntNo = Intrinsic::wasm_load32_lane;
+  break;
+case WebAssembly::BI__builtin_wasm_load64_lane:
+  IntNo = Intrinsi

[clang] 7c8385a - Revert "[WebAssembly] v128.load{8,16,32,64}_lane instructions"

2020-10-15 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-10-15T15:49:36Z
New Revision: 7c8385a352ba21cb388046290d93b53dc273cd9f

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

LOG: Revert "[WebAssembly] v128.load{8,16,32,64}_lane instructions"

This reverts commit 7c6bfd90ab2ddaa60de62878c8512db0645e8452.

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 
llvm/test/CodeGen/WebAssembly/simd-load-lane-offset.ll



diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 86348ff5fea7..45e194c283b6 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -171,17 +171,8 @@ TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, 
"V16UcV8UsV8Us", "nc", "simd
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4UiV4Ui", "nc", 
"simd128")
 
-TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4ii*", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLi*", "n", "simd128")
-
-TARGET_BUILTIN(__builtin_wasm_load8_lane, "V16ScSc*V16ScIi", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_load16_lane, "V8ss*V8sIi", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_load32_lane, "V4ii*V4iIi", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_load64_lane, "V2LLiLLi*V2LLiIi", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_store8_lane, "vSc*V16ScIi", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_store16_lane, "vs*V8sIi", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_store32_lane, "vi*V4iIi", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_store64_lane, "vLLi*V2LLiIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4ii*", "nU", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLi*", "nU", "simd128")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 3f6977e16c4a..157dae2831f2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -16711,52 +16711,6 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_load64_zero);
 return Builder.CreateCall(Callee, {Ptr});
   }
-  case WebAssembly::BI__builtin_wasm_load8_lane:
-  case WebAssembly::BI__builtin_wasm_load16_lane:
-  case WebAssembly::BI__builtin_wasm_load32_lane:
-  case WebAssembly::BI__builtin_wasm_load64_lane:
-  case WebAssembly::BI__builtin_wasm_store8_lane:
-  case WebAssembly::BI__builtin_wasm_store16_lane:
-  case WebAssembly::BI__builtin_wasm_store32_lane:
-  case WebAssembly::BI__builtin_wasm_store64_lane: {
-Value *Ptr = EmitScalarExpr(E->getArg(0));
-Value *Vec = EmitScalarExpr(E->getArg(1));
-Optional LaneIdxConst =
-E->getArg(2)->getIntegerConstantExpr(getContext());
-assert(LaneIdxConst && "Constant arg isn't actually constant?");
-Value *LaneIdx = llvm::ConstantInt::get(getLLVMContext(), *LaneIdxConst);
-unsigned IntNo;
-switch (BuiltinID) {
-case WebAssembly::BI__builtin_wasm_load8_lane:
-  IntNo = Intrinsic::wasm_load8_lane;
-  break;
-case WebAssembly::BI__builtin_wasm_load16_lane:
-  IntNo = Intrinsic::wasm_load16_lane;
-  break;
-case WebAssembly::BI__builtin_wasm_load32_lane:
-  IntNo = Intrinsic::wasm_load32_lane;
-  break;
-case WebAssembly::BI__builtin_wasm_load64_lane:
-  IntNo = Intrinsic::wasm_load64_lane;
-  break;
-case WebAssembly::BI__builtin_wasm_store8_lane:
-  IntNo = Intrinsic::wasm_store8_lane;
-  break;
-case WebAssembly::BI__builtin_wasm_store16_lane:
-  IntNo = Intrinsic::wasm_store16_lane;
-  break;
-case WebAssembly::BI__builtin_wasm_store32_lane:
-  IntNo = Intrinsic::wasm_store32_lane;
-  break;
-case WebAssembly::BI__builtin_wasm_store64_lane:
-  IntNo = Intrinsic::wasm_store64_lane;
-  break;
-default:
-  llvm_unreachable("unexpected builtin ID");
-}
-Function *Callee = CGM.getIntrinsic(IntNo);
-return Builder.CreateCall(Callee, {Ptr, Vec, LaneIdx});
-  }
   case WebAssembly::BI__builtin_wasm_shuffle_v8x16: {
 Value *Ops[18];
 size_t OpIdx = 0;

diff  --git a/clang/test/CodeGen/builtins-wasm.c

[PATCH] D88859: APINotes: add APINotesYAMLCompiler

2020-10-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88859/new/

https://reviews.llvm.org/D88859

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


[PATCH] D86097: [OpenMP][AMDGCN] Generate global variables and attributes for AMDGCN

2020-10-15 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp:175
+
+void CGOpenMPRuntimeAMDGCN::emitSPMDKernelWrapper(
+const OMPExecutableDirective &D, StringRef ParentName,

The nvptx emitSPMDKernelWrapper does nothing and the amdgcn one appends some 
metadata.

How about 'nvptx::generateMetadata(...)' that does nothing and 
'amdgcn::generateMetadata(...)` that does this stuff, called from the end of 
emitSPMDKernel?



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp:197
+
+/// Emit structure descriptor for a kernel
+void CGOpenMPRuntimeAMDGCN::emitStructureKernelDesc(

This metadata generation could be split out from the other changes.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.h:49
+
+  /// Allocate global variable for TransferMedium
+  llvm::GlobalVariable *

I'm not convinced by this abstraction. It looks like amdgcn and nvptx want 
almost exactly the same variable in each case. The difference appears to be 
that nvptx uses internal linkage and amdgcn uses weak + externally initialized, 
in which case we're better off with

`bool nvptx::needsExternalInitialization() {return false;}`
`bool amdgpu::needsExternalInitialization() {return true;}`

Or, if the inline ternary is unappealing, amdgcn::NewGlobalVariable(...) that 
passes the arguments to llvm::GlobalVariable while setting the two fields that 
differ between the two.





Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h:175
 
+  /// Emit outlined function specialized for the Fork-Join
+  /// programming model for applicable target directives on the NVPTX device.

Please put this back to the previous location so we can see whether it changed 
in the diff


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86097/new/

https://reviews.llvm.org/D86097

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


[PATCH] D89177: [cmake] Add support for multiple distributions

2020-10-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Are the runtimes expected to support this multi-distribution configuration? I 
don't think we'd want to move libc++ towards building multiple configurations 
at once in a single CMake invocation -- it's already too complicated to build 
just one configuration.

While I'm very sympathetic to the use case, it looks like this is working 
against the design of CMake. So, as long as the runtimes are not impacted by 
this change (which seems to be the case right now), I don't mind. But as I 
said, I don't think it would be wise to start supporting multiple distributions 
in a single CMake invocation for the runtime libraries. I think it would add 
too much complexity.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89177/new/

https://reviews.llvm.org/D89177

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


[PATCH] D88659: [FE]Split SuitableAlign into two parts

2020-10-15 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added a comment.

ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88659/new/

https://reviews.llvm.org/D88659

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


[PATCH] D89481: [scan-build] Fix clang++ pathname again

2020-10-15 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg created this revision.
sberg added reviewers: aadg, dcoughlin.
Herald added a subscriber: Charusso.
Herald added a project: clang.
sberg requested review of this revision.

e00629f777d9d62875730f40d266727df300dbb2 "[scan-build] Fix clang++ pathname" had
removed the -MAJOR.MINOR suffix, but since presumably LLVM 7 the suffix is only
-MAJOR, so ClangCXX (i.e., the CLANG_CXX environment variable passed to
clang/tools/scan-build/libexec/ccc-analyzer) now contained a non-existing
/path/to/clang-12++ (which apparently went largely unnoticed as
clang/tools/scan-build/libexec/ccc-analyzer falls back to just 'clang++' if the
executable denoted by CLANG_CXX does not exist).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89481

Files:
  clang/tools/scan-build/bin/scan-build


Index: clang/tools/scan-build/bin/scan-build
===
--- clang/tools/scan-build/bin/scan-build
+++ clang/tools/scan-build/bin/scan-build
@@ -1925,7 +1925,7 @@
 $ClangCXX =~ s/.exe$/++.exe/;
   }
   else {
-$ClangCXX =~ s/\-\d+\.\d+$//;
+$ClangCXX =~ s/\-\d+(\.\d+)?$//;
 $ClangCXX .= "++";
   }
 }


Index: clang/tools/scan-build/bin/scan-build
===
--- clang/tools/scan-build/bin/scan-build
+++ clang/tools/scan-build/bin/scan-build
@@ -1925,7 +1925,7 @@
 $ClangCXX =~ s/.exe$/++.exe/;
   }
   else {
-$ClangCXX =~ s/\-\d+\.\d+$//;
+$ClangCXX =~ s/\-\d+(\.\d+)?$//;
 $ClangCXX .= "++";
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89453: Fix hidden-redecls.m test for some environments

2020-10-15 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

Thank you! Are you able to commit it by yourself?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89453/new/

https://reviews.llvm.org/D89453

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


[PATCH] D89177: [cmake] Add support for multiple distributions

2020-10-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D89177#2332547 , @ldionne wrote:

> Are the runtimes expected to support this multi-distribution configuration? I 
> don't think we'd want to move libc++ towards building multiple configurations 
> at once in a single CMake invocation -- it's already too complicated to build 
> just one configuration.

I don’t see why the runtimes wouldn’t be included in this, especially when 
using the runtimes build which already supports building multiple 
configurations of libc++ from a single LLVM CMake invocation which in turn runs 
CMake for the runtimes multiple times. In fact, I think runtimes is basically 
the only place where we can currently cleanly handle building with different 
options.

> While I'm very sympathetic to the use case, it looks like this is working 
> against the design of CMake.

The way Compiler-RT builds for Darwin is certainly against the design of CMake, 
but I don’t think the same is true for how the runtimes build works.

I think the general idea of configure LLVM once, define multiple different 
“distributions” to get different groups of targets that you can install into 
different root directories and package for separate installation makes a lot of 
sense and is useful even if it doesn’t handle distributions that have different 
configurations.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89177/new/

https://reviews.llvm.org/D89177

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


[PATCH] D89177: [cmake] Add support for multiple distributions

2020-10-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D89177#2332626 , @beanz wrote:

> In D89177#2332547 , @ldionne wrote:
>
>> Are the runtimes expected to support this multi-distribution configuration? 
>> I don't think we'd want to move libc++ towards building multiple 
>> configurations at once in a single CMake invocation -- it's already too 
>> complicated to build just one configuration.
>
> I don’t see why the runtimes wouldn’t be included in this, especially when 
> using the runtimes build which already supports building multiple 
> configurations of libc++ from a single LLVM CMake invocation which in turn 
> runs CMake for the runtimes multiple times. In fact, I think runtimes is 
> basically the only place where we can currently cleanly handle building with 
> different options.
>
>> While I'm very sympathetic to the use case, it looks like this is working 
>> against the design of CMake.
>
> The way Compiler-RT builds for Darwin is certainly against the design of 
> CMake, but I don’t think the same is true for how the runtimes build works.
>
> I think the general idea of configure LLVM once, define multiple different 
> “distributions” to get different groups of targets that you can install into 
> different root directories and package for separate installation makes a lot 
> of sense and is useful even if it doesn’t handle distributions that have 
> different configurations.

That isn't what I meant. It's entirely okay for the runtimes to be driven via 
`AddExternalProject` like the runtimes build does, since that's akin to having 
a separate CMake invocation for each configuration. That's okay.

What I'm saying is that if the next logical step is to also add support for 
multiple distributions in libc++'s build itself (e.g. adding 
`LIBCXX__ENABLE_SHARED` & al), then I don't think that's a good 
idea.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89177/new/

https://reviews.llvm.org/D89177

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


[PATCH] D87989: [Flang][Driver] Add infrastructure for basic frontend actions and file I/O

2020-10-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 298407.
awarzynski added a comment.

Address PR comments, clang-format, rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87989/new/

https://reviews.llvm.org/D87989

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/Types.cpp
  clang/test/Driver/immediate-options.c
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/FrontendAction.h
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/include/flang/FrontendTool/Utils.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendAction.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Frontend/FrontendOptions.cpp
  flang/lib/FrontendTool/CMakeLists.txt
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/emit-obj.f90
  flang/test/Frontend/Inputs/hello-world.f90
  flang/test/Frontend/input-output-file.f90
  flang/test/Frontend/multiple-input-files.f90
  flang/test/lit.cfg.py
  flang/tools/flang-driver/fc1_main.cpp
  flang/unittests/Frontend/CMakeLists.txt
  flang/unittests/Frontend/CompilerInstanceTest.cpp
  flang/unittests/Frontend/InputOutputTest.cpp

Index: flang/unittests/Frontend/InputOutputTest.cpp
===
--- /dev/null
+++ flang/unittests/Frontend/InputOutputTest.cpp
@@ -0,0 +1,72 @@
+//===- unittests/Frontend/OutputStreamTest.cpp --- FrontendAction tests --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+#include "flang/Frontend/CompilerInstance.h"
+#include "flang/Frontend/CompilerInvocation.h"
+#include "flang/Frontend/FrontendOptions.h"
+#include "flang/FrontendTool/Utils.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace Fortran::frontend;
+
+namespace {
+
+TEST(FrontendAction, TestInputOutputTestAction) {
+  std::string inputFile = "io-file-test.f";
+  std::error_code ec;
+
+  // 1. Create the input file for the file manager
+  // AllSources (which is used to manage files inside every compiler instance),
+  // works with paths. This means that it requires a physical file. Create one.
+  std::unique_ptr os{
+  new llvm::raw_fd_ostream(inputFile, ec, llvm::sys::fs::OF_None)};
+  if (ec)
+FAIL() << "Failed to create the input file";
+
+  // Populate the input file with the pre-defined input and flush it.
+  *(os) << "End Program arithmetic";
+  os.reset();
+
+  // Get the path of the input file
+  llvm::SmallString<64> cwd;
+  if (std::error_code ec = llvm::sys::fs::current_path(cwd))
+FAIL() << "Failed to obtain the current working directory";
+  std::string testFilePath(cwd.c_str());
+  testFilePath += "/" + inputFile;
+
+  // 2. Prepare the compiler (CompilerInvocation + CompilerInstance)
+  CompilerInstance compInst;
+  compInst.CreateDiagnostics();
+  auto invocation = std::make_shared();
+  invocation->GetFrontendOpts().programAction_ = InputOutputTest;
+  compInst.SetInvocation(std::move(invocation));
+  compInst.GetFrontendOpts().inputs_.push_back(
+  FrontendInputFile(/*File=*/testFilePath, Language::Fortran));
+
+  // 3. Set-up the output stream. Using output buffer wrapped as an output
+  // stream, as opposed to an actual file (or a file descriptor).
+  llvm::SmallVector outputFileBuffer;
+  std::unique_ptr outputFileStream(
+  new llvm::raw_svector_ostream(outputFileBuffer));
+  compInst.SetOutputStream(std::move(outputFileStream));
+
+  // 4. Run the earlier defined FrontendAction
+  bool success = ExecuteCompilerInvocation(&compInst);
+
+  EXPECT_TRUE(success);
+  EXPECT_TRUE(!outputFileBuffer.empty());
+  EXPECT_TRUE(llvm::StringRef(outputFileBuffer.data())
+  .startswith("End Program arithmetic"));
+
+  // 5. Clear the output files. Since we used an output buffer, there are no
+  // physical files to delete.
+  compInst.ClearOutputFiles(/*EraseFiles=*/false);
+}
+} // namespace
Index: flang/unittests/Frontend/CompilerInstanceTest.cpp
===
--- flang/unittests/Frontend/CompilerInstanceTest.cpp
+++ flang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -9,6 +9,7 @@
 #include "flang/Frontend/CompilerInstance.h"
 #include "flang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Basic/DiagnosticOptions

[PATCH] D87989: [Flang][Driver] Add infrastructure for basic frontend actions and file I/O

2020-10-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski commandeered this revision.
awarzynski edited reviewers, added: CarolineConcatto; removed: awarzynski.
awarzynski added a comment.

Thank you for reviewing @SouraVX! I'm just about to submit an updated patch 
with the requested changes.

@CarolineConcatto has recently moved to a different project and so it will be 
mostly me updating this. @CarolineConcatto , thanks for all the effort!




Comment at: clang/include/clang/Driver/Options.td:63
 
+// ClangOption - This option should not be accepted by Clang.
+def NoClangOption : OptionFlag;

SouraVX wrote:
>  `NoClangOption` ? Is this a Typo, or am I missing the intent behind this ?
Yup, a typo, thanks!



Comment at: flang/include/flang/Frontend/CompilerInstance.h:136
+  /// Add an output file onto the list of tracked output files.
+  ///
+  /// \param outFile - The output file info.

SouraVX wrote:
> NIT: Blank line ?
That's the convention for Doxygen, isn't it?



Comment at: flang/lib/Frontend/CompilerInstance.cpp:67
+  // Create the name of the output file
+  if (!outputPath.empty()) {
+outFile = std::string(outputPath);

SouraVX wrote:
> Can this be simplified ? Maybe a switch case ?
Switch statement would be tricky, but I agree that this is unnecessarily 
complex.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87989/new/

https://reviews.llvm.org/D87989

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


[PATCH] D89177: [cmake] Add support for multiple distributions

2020-10-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D89177#2332627 , @ldionne wrote:

> That isn't what I meant. It's entirely okay for the runtimes to be driven via 
> `AddExternalProject` like the runtimes build does, since that's akin to 
> having a separate CMake invocation for each configuration. That's okay.
>
> What I'm saying is that if the next logical step is to also add support for 
> multiple distributions in libc++'s build itself (e.g. adding 
> `LIBCXX__ENABLE_SHARED` & al), then I don't think that's a good 
> idea.

Totally agree. That would be the path compiler-rt’s Darwin build goes, and it 
is a frequent problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89177/new/

https://reviews.llvm.org/D89177

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


[PATCH] D89484: [AMDGPU][HIP] Switch default DWARF version to 5

2020-10-15 Thread Scott Linder via Phabricator via cfe-commits
scott.linder created this revision.
Herald added subscribers: cfe-commits, kerbowa, t-tye, tpr, dstuttard, yaxunl, 
nhaehnle, jvesely, kzhuravl.
Herald added a project: clang.
scott.linder requested review of this revision.
Herald added a subscriber: wdng.

Another attempt at this, see D59008  for 
previous attempt.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89484

Files:
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/HIP.h
  clang/test/Driver/amdgpu-toolchain.c
  clang/test/Driver/hip-toolchain-dwarf.hip


Index: clang/test/Driver/hip-toolchain-dwarf.hip
===
--- clang/test/Driver/hip-toolchain-dwarf.hip
+++ clang/test/Driver/hip-toolchain-dwarf.hip
@@ -6,4 +6,4 @@
 // RUN:   -x hip --cuda-gpu-arch=gfx803 %s \
 // RUN:   -Xarch_gfx803 -g 2>&1 | FileCheck %s -check-prefix=DWARF_VER
 
-// DWARF_VER: "-dwarf-version=4"
+// DWARF_VER: "-dwarf-version=5"
Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -8,7 +8,7 @@
 // AS_LINK: clang{{.*}} "-cc1as"
 // AS_LINK: ld.lld{{.*}} "-shared"
 
-// DWARF_VER: "-dwarf-version=4"
+// DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -flto %s 2>&1 | FileCheck -check-prefix=LTO %s
Index: clang/lib/Driver/ToolChains/HIP.h
===
--- clang/lib/Driver/ToolChains/HIP.h
+++ clang/lib/Driver/ToolChains/HIP.h
@@ -99,7 +99,7 @@
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList &Args) const override;
 
-  unsigned GetDefaultDwarfVersion() const override { return 4; }
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
 
   const ToolChain &HostTC;
 
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -60,7 +60,7 @@
 public:
   AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
-  unsigned GetDefaultDwarfVersion() const override { return 4; }
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
   bool IsMathErrnoDefault() const override { return false; }
 


Index: clang/test/Driver/hip-toolchain-dwarf.hip
===
--- clang/test/Driver/hip-toolchain-dwarf.hip
+++ clang/test/Driver/hip-toolchain-dwarf.hip
@@ -6,4 +6,4 @@
 // RUN:   -x hip --cuda-gpu-arch=gfx803 %s \
 // RUN:   -Xarch_gfx803 -g 2>&1 | FileCheck %s -check-prefix=DWARF_VER
 
-// DWARF_VER: "-dwarf-version=4"
+// DWARF_VER: "-dwarf-version=5"
Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -8,7 +8,7 @@
 // AS_LINK: clang{{.*}} "-cc1as"
 // AS_LINK: ld.lld{{.*}} "-shared"
 
-// DWARF_VER: "-dwarf-version=4"
+// DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -flto %s 2>&1 | FileCheck -check-prefix=LTO %s
Index: clang/lib/Driver/ToolChains/HIP.h
===
--- clang/lib/Driver/ToolChains/HIP.h
+++ clang/lib/Driver/ToolChains/HIP.h
@@ -99,7 +99,7 @@
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList &Args) const override;
 
-  unsigned GetDefaultDwarfVersion() const override { return 4; }
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
 
   const ToolChain &HostTC;
 
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -60,7 +60,7 @@
 public:
   AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
-  unsigned GetDefaultDwarfVersion() const override { return 4; }
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
   bool IsMathErrnoDefault() const override { return false; }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88676: [PPC][AIX] Add vector callee saved registers for AIX extended vector ABI and add clang and llvm option

2020-10-15 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 298409.
ZarkoCA retitled this revision from "[PPC][AIX] Add vector callee saved 
registers for AIX extended vector ABI" to "[PPC][AIX] Add vector callee saved 
registers for AIX extended vector ABI and add clang and llvm option".
ZarkoCA edited the summary of this revision.
ZarkoCA added a comment.
Herald added subscribers: cfe-commits, dang, dmgreen, arphaman.
Herald added a project: clang.

Added `mvecnvol`/`mnovecnvol` options in clang and `vecnvol` option in llc
Addressed other comments related to formatting and test case regex usage. 
Updated test cases that fail when `vecnvol` is enabled.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88676/new/

https://reviews.llvm.org/D88676

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/altivec.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/Target/PowerPC/PPCCallingConv.td
  llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
  llvm/test/CodeGen/PowerPC/aix-AppendingLinkage.ll
  llvm/test/CodeGen/PowerPC/aix-csr-vector.ll
  llvm/test/CodeGen/PowerPC/aix-default-vec-abi.ll
  llvm/test/CodeGen/PowerPC/aix-func-align.ll
  llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll
  llvm/test/CodeGen/PowerPC/aix-internal.ll
  llvm/test/CodeGen/PowerPC/aix-lower-block-address.ll
  llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll
  llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
  llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll
  llvm/test/CodeGen/PowerPC/aix-return55.ll
  llvm/test/CodeGen/PowerPC/aix-space.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-reloc-large.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-textdisassembly.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-toc.ll
  llvm/test/CodeGen/PowerPC/aix32-crsave.mir
  llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
  llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
  llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
  llvm/test/CodeGen/PowerPC/ppc64-crsave.mir

Index: llvm/test/CodeGen/PowerPC/ppc64-crsave.mir
===
--- llvm/test/CodeGen/PowerPC/ppc64-crsave.mir
+++ llvm/test/CodeGen/PowerPC/ppc64-crsave.mir
@@ -7,7 +7,7 @@
 # RUN: FileCheck %s --check-prefixes=CHECK,SAVEALL
 
 
-# RUN: llc -mtriple powerpc64-unknown-aix-xcoff -x mir -mcpu=pwr4 \
+# RUN: llc -mtriple powerpc64-unknown-aix-xcoff -x mir -mcpu=pwr4 -vecnvol \
 # RUN: -run-pass=prologepilog --verify-machineinstrs < %s | \
 # RUN: FileCheck %s --check-prefixes=CHECK,SAVEALL
 
Index: llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
===
--- llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
+++ llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
@@ -1,4 +1,4 @@
-; RUN: llc -verify-machineinstrs < %s -mcpu=pwr4 \
+; RUN: llc -verify-machineinstrs < %s -mcpu=pwr4 -vecnvol \
 ; RUN: -mtriple=powerpc-ibm-aix-xcoff 2>&1 | FileCheck %s
 
 ; RUN: llc -verify-machineinstrs < %s -mcpu=pwr4 \
Index: llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
===
--- llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
+++ llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
@@ -1,7 +1,7 @@
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -vecnvol -mtriple powerpc64-ibm-aix-xcoff \
 ; RUN: -code-model=small < %s | FileCheck %s --check-prefix=SMALL
 
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -vecnvol -mtriple powerpc64-ibm-aix-xcoff \
 ; RUN: -code-model=large < %s | FileCheck %s --check-prefix=LARGE
 
 @a = common global i32 0
Index: llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
===
--- llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
+++ llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
@@ -1,7 +1,7 @@
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -vecnvol -mtriple powerpc-ibm-aix-xcoff \
 ; RUN: -code-model=small < %s | FileCheck %s --check-prefix=SMALL
 
-; RUN: llc -verify-machineinstrs -mcpu=pwr

[PATCH] D88676: [PPC][AIX] Add vector callee saved registers for AIX extended vector ABI and add clang and llvm option

2020-10-15 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA marked 5 inline comments as done.
ZarkoCA added inline comments.



Comment at: llvm/test/CodeGen/PowerPC/aix-csr-vector.ll:4
+; RUN:   FileCheck --check-prefix=MIR32 %s
+
+; RUN: llc -mtriple=powerpc-unknown-aix-xcoff -verify-machineinstrs \

Xiangling_L wrote:
> The comments here let me think should we also implement an equivalent option 
> for `llc` to control which ABI to be enabled in addition to the frontend or 
> driver option?
Yes, good point, I added that as well. 



Comment at: llvm/test/CodeGen/PowerPC/aix-csr-vector.ll:81
+
+; ASM32: li {{[0-9]+}}, -192
+; ASM32-DAG: stxvd2x 52, 1, {{[0-9]+}}   # 16-byte 
Folded Spill

Xiangling_L wrote:
> Xiangling_L wrote:
> > Can we line up all comments?
> I am suggesting to use things like `[[REG1:[0-9]+]]`  to match registers, use 
> `{{[0-9]+}}` to match numerical values if we need to. The same comments apply 
> to all testcases.
I'd rather not use any variables unless we need to use them later. 



Comment at: llvm/test/CodeGen/PowerPC/aix-csr-vector.ll:120
+; MIR32-LABEL:   fixedStack:
+; MIR32-NEXT:- { id: 0, type: spill-slot, offset: -144, size: 16, 
alignment: 16, stack-id: default,
+; MIR32-NEXT:callee-saved-register: '$v31', callee-saved-restored: 
true, debug-info-variable: '',

Xiangling_L wrote:
> Thank you for adding this testcase.  I think it would be better if we also 
> test`r13`/`x14`, `f14`, `v20`, then we can observe the padding added in. 
Good suggestion, I added. 



Comment at: llvm/test/CodeGen/PowerPC/aix-csr-vector.ll:2
+; RUN: llc -mtriple=powerpc-unknown-aix-xcoff -verify-machineinstrs \
+; RUN: -mcpu=pwr7 -mattr=+altivec -stop-after=prologepilog < %s | \
+; RUN: FileCheck --check-prefix=MIR32 %s

hubert.reinterpretcast wrote:
> ZarkoCA wrote:
> > Xiangling_L wrote:
> > > ZarkoCA wrote:
> > > > Xiangling_L wrote:
> > > > > sfertile wrote:
> > > > > > Minor nit: align this with the first argument in the preceeding 
> > > > > > line.
> > > > > The ABI mentioned AIX5.3 is the first AIX release to enable vector 
> > > > > programming, and there are arch like pwr4 is not compatible with 
> > > > > altivec. Since this is our first altivec patch, it looks it's the 
> > > > > right place to add `report_fatal_error` for arch level which doesn't 
> > > > > support altivec.
> > > > While I think that's a good suggestion, none of the other PPC targets 
> > > > do anything similar.  If you choose an arch that doesn't support 
> > > > altivec while selecting a CPU that doesn't support it they quietly 
> > > > don't generate the altivec instructions.  
> > > > 
> > > > Also, as things are, we do have a report fatal error when ever someone 
> > > > tries using vector types in the front end and in the back end.  
> > > I see. The only reason why I raise it up is because XL gives an error 
> > > when using altivec with unsupported arch.
> > I see a warning and xlc and xlclang: 
> > `1506-1162 (W) The altivec option is not supported for the target 
> > architecture and is ignored.` 
> > Additionally with xlclang we get from the altivec.h header included in 
> > xlclang if an unsupported arch is specified.  
> > 
> > But this has me thinking that it is a good idea to follow through with your 
> > suggestion of an error. 
> Since the extended ABI vector-enabled mode is not the safe default (certain 
> call sequences involving functions compiled using the default ABI can bypass 
> restoration of the non-volatile register values), we should 
> `report_fatal_error` unless if the extended ABI is explicitly enabled.
> 
> Example:
> ```
> [ uses non-volatile vector registers ]
> vv   calls
> [ not vector-extended ABI-aware ] -- calls setjmp
> vv   calls
> [ uses non-volatile vector registers ]
> vv   calls
> [ not vector-extended ABI-aware ] -- calls longjmp
> ```
> 
> This follows the precedent for the `llc` default for data sections: Even for 
> `llc`, we do not enable the "unsafe" mode by default.
> 
I added the options to toggle between the two Altivec ABIs. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88676/new/

https://reviews.llvm.org/D88676

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


[PATCH] D87989: [Flang][Driver] Add infrastructure for basic frontend actions and file I/O

2020-10-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

I've added more reviewers for the Clang side of this patch. I choose people who 
most recently changed the functions/files that this patch modifies. Any input 
much appreciated! For more context regarding Clang changes: 
http://lists.llvm.org/pipermail/cfe-dev/2020-October/066953.html


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87989/new/

https://reviews.llvm.org/D87989

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


[PATCH] D89297: [clangd] Add a TestWorkspace utility

2020-10-15 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D89297#2326838 , @nridge wrote:

> In principle, it should be possible to make the same interface work with 
> `FileIndex` under the hood, but I haven't figured out how. (Specifically, I 
> haven't figured out how to get `FileIndex` to resolve `#include`s, because 
> you can't pass a `MockFS` to it the way you can to `BackgroundIndex`.)

I should mention for completeness that the way we did tests like this in 
Eclipse CDT is... we actually wrote the test files to disk :) But I'm guessing, 
given the efforts that have been made to use `MockFS` in the test suite so far, 
that we don't want to do this for clangd.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89297/new/

https://reviews.llvm.org/D89297

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


[PATCH] D88106: [SyntaxTree] Provide iterator-like functions for Lists

2020-10-15 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 298416.
eduucaldas added a comment.

- [SyntaxTree] `ElementAndDelimiterIterator` is polymorphic and supports 
`BeforeBegin` iterator


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88106/new/

https://reviews.llvm.org/D88106

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp

Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -9,6 +9,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include 
@@ -311,91 +312,40 @@
   }
 }
 
-std::vector>
-syntax::List::getElementsAsNodesAndDelimiters() {
-  if (!getFirstChild())
-return {};
-
-  std::vector> Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back({ElementWithoutDelimiter, cast(C)});
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable(
-  "A list can have only elements and delimiters as children.");
-}
-  }
+bool syntax::List::isElement(syntax::Node *N) {
+  return N && N->getRole() == NodeRole::ListElement;
+}
 
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-break;
-  }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back({ElementWithoutDelimiter, nullptr});
-}
-break;
-  }
-  }
+bool syntax::List::isDelimiter(syntax::Node *N) {
+  return N && N->getRole() == NodeRole::ListDelimiter;
+}
 
-  return Children;
+syntax::List::ElementAndDelimiterIterator
+syntax::List::getBeforeBeginNode() {
+  return ElementAndDelimiterIterator::makeBeforeBegin(this);
 }
 
-// Almost the same implementation of `getElementsAsNodesAndDelimiters` but
-// ignoring delimiters
-std::vector syntax::List::getElementsAsNodes() {
-  if (!getFirstChild())
-return {};
+syntax::List::ElementAndDelimiterIterator
+syntax::List::getBeginNode() {
+  return std::next(ElementAndDelimiterIterator::makeBeforeBegin(this));
+}
 
-  std::vector Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back(ElementWithoutDelimiter);
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back(ElementWithoutDelimiter);
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable("A list has only elements or delimiters.");
-}
-  }
+syntax::List::ElementAndDelimiterIterator
+syntax::List::getEndNode() {
+  return ElementAndDelimiterIterator::makeEnd(this);
+}
 
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back(ElementWithoutDelimiter);
-break;
-  }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back(ElementWithoutDelimiter);
-}
-break;
-  }
-  }
+std::vector>
+syntax::List::getElementsAsNodesAndDelimiters() {
+  return std::vector>(
+  getBeginNode(), getEndNode());
+}
 
+std::vector syntax::List::getElementsAsNodes() {
+  std::vector Children;
+  std::transform(
+  getBeginNode(), getEndNode(), std::back_inserter(Children),
+  [](ElementAndDelimiter ED) { return ED.element; });
   return Children;
 }
 
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -230,91 +230,77 @@
 // vector
 std::vector
 syntax::NestedNameSpecifier::getSpecifiers() {
-  auto SpecifiersAsNodes = getElementsAsNodes();
   std::vector Children;
-  for (const auto &Element : SpecifiersAsNodes) {
-Children.push_back(llvm::cast(Element));
-  }
+  for (auto C : getNodeRange())
+Children.push_back(cast(C.element));
+
   return Children;
 }
 
 std::vector>
 syntax::NestedNameSpecifier::getSpecifiersAndDoubleColons() {
-  auto SpecifiersAsNodesAndDou

[PATCH] D86021: [IR] Make nosync, nofree and willreturn default for intrinsics.

2020-10-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.

LGTM. We can change the name later if we need to.
This is now "opt-in" and (IIRC) we addressed all the known issues.




Comment at: llvm/include/llvm/IR/Intrinsics.td:359
 
+class DefaultIntrinsic ret_types,
+list param_types = [],

jdoerfert wrote:
> Add a comment here describing the difference to the class above.
Nit, `= 0`

Also, remove `disable_default_attributes` from the template args and pass 0 
right away. No need to overwrite it by a user, they have `Intrinsic` for that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86021/new/

https://reviews.llvm.org/D86021

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


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2020-10-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D85802#2331403 , @leonardchan wrote:

> Perhaps we can add some mechanism in Clang that determines which ABIs are 
> supported for specific platforms? That is, when targetting Linux, Clang will 
> diagnose an error if using `-fc++-abi=microsoft`. This could cover the case 
> where a specific platform can support multiple ABIs, but those ABIs won't be 
> supported by other platforms.

Right, but the simplest code is the code that doesn't exist: if the option 
doesn't exist, there's no need to diagnose anything. The rest of the "C++ ABIs" 
aren't really their own C++ ABIs, they are just a reflection of the target 
triple.

What is the actual use case? I read the RFC, but ever since I became a manager, 
my reading comprehension level dropped back to grade school, and I apologize 
for that. As I understood it, you need a flag that enables all the Itanium ABI 
extensions (relative vtables, and others) used in Fuchsia, at once. A single 
relative vtable ABI flag isn't sufficient (would it be?).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85802/new/

https://reviews.llvm.org/D85802

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


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2020-10-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D85802#2332766 , @rnk wrote:

> In D85802#2331403 , @leonardchan 
> wrote:
>
>> Perhaps we can add some mechanism in Clang that determines which ABIs are 
>> supported for specific platforms? That is, when targetting Linux, Clang will 
>> diagnose an error if using `-fc++-abi=microsoft`. This could cover the case 
>> where a specific platform can support multiple ABIs, but those ABIs won't be 
>> supported by other platforms.
>
> Right, but the simplest code is the code that doesn't exist: if the option 
> doesn't exist, there's no need to diagnose anything. The rest of the "C++ 
> ABIs" aren't really their own C++ ABIs, they are just a reflection of the 
> target triple.
>
> What is the actual use case? I read the RFC, but ever since I became a 
> manager, my reading comprehension level dropped back to grade school, and I 
> apologize for that. As I understood it, you need a flag that enables all the 
> Itanium ABI extensions (relative vtables, and others) used in Fuchsia, at 
> once. A single relative vtable ABI flag isn't sufficient (would it be?).

We want to use Fuchsia C++ ABI by default when targeting Fuchsia. Fuchsia C++ 
ABI is a derivate of Itanium C++ ABI with various performance optimizations 
(similar to other derivative C++ ABIs like WebAssembly), and we plan on further 
evolving it, for example always using relative vtables. The problem is that we 
occasionally need to integrate code built with Clang with code produced by 
other compilers that don't support Fuchsia C++ ABI like GCC, so we would like 
to have an option to switch back to Itanium C++ ABI as the "legacy compatible" 
C++ ABI.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85802/new/

https://reviews.llvm.org/D85802

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


[PATCH] D84362: [NFC] Refactor DiagnosticBuilder and PartialDiagnostic

2020-10-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/PartialDiagnostic.h:66
+return *this;
+  }
+

yaxunl wrote:
> rjmccall wrote:
> > Why are these template operators necessary?  The LHS of the `<<` should 
> > convert to a base reference type just fine.
> There are lots of usage patterns expecting the derived class after streaming, 
> e.g.
> 
> ```
> void foo(PartialDiagnostic& PD);
> foo(PD << X << Y);
> ```
I see.  You could also just do this in the base operators by just making them 
templates, e.g.

```
template 
std::enable_if_t, const 
Diagnostic &>
operator<<(const Diagnostic &D, ...) {
}
```

That way you'd never have these forwarding problems — but it would be more 
boilerplate for each operator, so maybe it's a wash.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84362/new/

https://reviews.llvm.org/D84362

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


[PATCH] D89475: [SemaObjC] Fix composite pointer type calculation for `void*` and pointer to lifetime qualified ObjC pointer type

2020-10-15 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89475/new/

https://reviews.llvm.org/D89475

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


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2020-10-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Would "f[no-]fuchsia-c++-abi-extensions" (or shorter, -ffuchsia-c++-abi) do the 
trick? I know it doesn't map well onto our current internal option 
representation, but I don't think the internal representation is particularly 
good. I'd rather limit the user-visible driver interface to give us the 
flexibility to change the internal representation in the future.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85802/new/

https://reviews.llvm.org/D85802

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


[PATCH] D88106: [SyntaxTree] Provide iterator-like functions for Lists

2020-10-15 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 298420.
eduucaldas added a comment.

Linting


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88106/new/

https://reviews.llvm.org/D88106

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp

Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -311,91 +311,40 @@
   }
 }
 
-std::vector>
-syntax::List::getElementsAsNodesAndDelimiters() {
-  if (!getFirstChild())
-return {};
-
-  std::vector> Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back({ElementWithoutDelimiter, cast(C)});
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable(
-  "A list can have only elements and delimiters as children.");
-}
-  }
+bool syntax::List::isElement(syntax::Node *N) {
+  return N && N->getRole() == NodeRole::ListElement;
+}
 
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-break;
-  }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back({ElementWithoutDelimiter, nullptr});
-}
-break;
-  }
-  }
+bool syntax::List::isDelimiter(syntax::Node *N) {
+  return N && N->getRole() == NodeRole::ListDelimiter;
+}
 
-  return Children;
+syntax::List::ElementAndDelimiterIterator
+syntax::List::getBeforeBeginWithElementAsNode() {
+  return ElementAndDelimiterIterator::makeBeforeBegin(this);
 }
 
-// Almost the same implementation of `getElementsAsNodesAndDelimiters` but
-// ignoring delimiters
-std::vector syntax::List::getElementsAsNodes() {
-  if (!getFirstChild())
-return {};
+syntax::List::ElementAndDelimiterIterator
+syntax::List::getBeginNode() {
+  return std::next(ElementAndDelimiterIterator::makeBeforeBegin(this));
+}
 
-  std::vector Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back(ElementWithoutDelimiter);
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back(ElementWithoutDelimiter);
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable("A list has only elements or delimiters.");
-}
-  }
+syntax::List::ElementAndDelimiterIterator
+syntax::List::getEndNode() {
+  return ElementAndDelimiterIterator::makeEnd(this);
+}
 
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back(ElementWithoutDelimiter);
-break;
-  }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back(ElementWithoutDelimiter);
-}
-break;
-  }
-  }
+std::vector>
+syntax::List::getElementsAsNodesAndDelimiters() {
+  return std::vector>(
+  getBeginNode(), getEndNode());
+}
 
+std::vector syntax::List::getElementsAsNodes() {
+  std::vector Children;
+  std::transform(
+  getBeginNode(), getEndNode(), std::back_inserter(Children),
+  [](ElementAndDelimiter ED) { return ED.element; });
   return Children;
 }
 
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -230,91 +230,77 @@
 // vector
 std::vector
 syntax::NestedNameSpecifier::getSpecifiers() {
-  auto SpecifiersAsNodes = getElementsAsNodes();
   std::vector Children;
-  for (const auto &Element : SpecifiersAsNodes) {
-Children.push_back(llvm::cast(Element));
-  }
+  for (auto C : getNodeRange())
+Children.push_back(cast(C.element));
+
   return Children;
 }
 
 std::vector>
 syntax::NestedNameSpecifier::getSpecifiersAndDoubleColons() {
-  auto SpecifiersAsNodesAndDoubleColons = getElementsAsNodesAndDelimiters();
   std::vector>
   Children;
-  for (const auto &SpecifierAndDoubleColon : SpecifiersAsNodesAndDoubleColons) {
-Children.push_back(
-{llvm::cast(SpecifierAndDoubleColon.element),
- SpecifierAndDoubleColon.delimiter});
-  }
+  for (auto C : ge

[PATCH] D89478: AMDGPU: Make sure both cc1 and cc1as process -m[no-]code-object-v3

2020-10-15 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG67f189e93ce3: Make sure both cc1 and cc1as process 
-m[no-]code-object-v3 (authored by kzhuravl).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89478/new/

https://reviews.llvm.org/D89478

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/amdgpu-features-as.s
  clang/test/Driver/amdgpu-features.c

Index: clang/test/Driver/amdgpu-features.c
===
--- clang/test/Driver/amdgpu-features.c
+++ clang/test/Driver/amdgpu-features.c
@@ -6,6 +6,10 @@
 // NO-CODE-OBJECT-V3: warning: argument '-mno-code-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=2' instead [-Wdeprecated]
 // NO-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=2"
 
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx700 -mcode-object-v3 -mno-code-object-v3 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=MUL-CODE-OBJECT-V3 %s
+// MUL-CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
+// MUL-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
+
 // RUN: %clang -### -target amdgcn-amdhsa -mcpu=gfx900:xnack+ %s 2>&1 | FileCheck --check-prefix=XNACK %s
 // XNACK: "-target-feature" "+xnack"
 
Index: clang/test/Driver/amdgpu-features-as.s
===
--- /dev/null
+++ clang/test/Driver/amdgpu-features-as.s
@@ -0,0 +1,11 @@
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx900 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=CODE-OBJECT-V3 %s
+// CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
+// CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa amdgcn -mcpu=gfx900 -mno-code-object-v3 %s 2>&1 | FileCheck --check-prefix=NO-CODE-OBJECT-V3 %s
+// NO-CODE-OBJECT-V3: warning: argument '-mno-code-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=2' instead [-Wdeprecated]
+// NO-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=2"
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx900 -mcode-object-v3 -mno-code-object-v3 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=MUL-CODE-OBJECT-V3 %s
+// MUL-CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
+// MUL-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1073,6 +1073,25 @@
   llvm_unreachable("Unknown Reloc::Model kind");
 }
 
+static void HandleAmdgcnLegacyOptions(const Driver &D,
+  const ArgList &Args,
+  ArgStringList &CmdArgs) {
+  if (auto *CodeObjArg = Args.getLastArg(options::OPT_mcode_object_v3_legacy,
+ options::OPT_mno_code_object_v3_legacy)) {
+if (CodeObjArg->getOption().getID() == options::OPT_mcode_object_v3_legacy) {
+  D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3" <<
+"-mllvm --amdhsa-code-object-version=3";
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("--amdhsa-code-object-version=3");
+} else {
+  D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3" <<
+"-mllvm --amdhsa-code-object-version=2";
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("--amdhsa-code-object-version=2");
+}
+  }
+}
+
 void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
 const Driver &D, const ArgList &Args,
 ArgStringList &CmdArgs,
@@ -6122,6 +6141,8 @@
 }
   }
 
+  HandleAmdgcnLegacyOptions(D, Args, CmdArgs);
+
   // For all the host OpenMP offloading compile jobs we need to pass the targets
   // information using -fopenmp-targets= option.
   if (JA.isHostOffloading(Action::OFK_OpenMP)) {
@@ -7085,6 +7106,8 @@
 CmdArgs.push_back(SplitDebugName(JA, Args, Input, Output));
   }
 
+  HandleAmdgcnLegacyOptions(D, Args, CmdArgs);
+
   assert(Input.isFilename() && "Invalid input.");
   CmdArgs.push_back(Input.getFilename());
 
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -525,19 +525,6 @@
 CC1Args.push_back("hidden");
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
-
-  if (Drive

[clang] 67f189e - Make sure both cc1 and cc1as process -m[no-]code-object-v3

2020-10-15 Thread Konstantin Zhuravlyov via cfe-commits

Author: Konstantin Zhuravlyov
Date: 2020-10-15T14:03:26-04:00
New Revision: 67f189e93ce3c25db74697551a77831a72b34929

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

LOG: Make sure both cc1 and cc1as process -m[no-]code-object-v3

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

Added: 
clang/test/Driver/amdgpu-features-as.s

Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/amdgpu-features.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 72ecc8cd9f3b..5df7236f0223 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -525,19 +525,6 @@ void AMDGPUToolChain::addClangTargetOptions(
 CC1Args.push_back("hidden");
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
-
-  if (DriverArgs.hasArg(options::OPT_mcode_object_v3_legacy)) {
-getDriver().Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3" <<
-  "-mllvm --amdhsa-code-object-version=3";
-CC1Args.push_back("-mllvm");
-CC1Args.push_back("--amdhsa-code-object-version=3");
-  }
-  if (DriverArgs.hasArg(options::OPT_mno_code_object_v3_legacy)) {
-getDriver().Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3" <<
-  "-mllvm --amdhsa-code-object-version=2";
-CC1Args.push_back("-mllvm");
-CC1Args.push_back("--amdhsa-code-object-version=2");
-  }
 }
 
 StringRef

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 39fcf240449c..d69dce650d94 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1073,6 +1073,25 @@ static const char 
*RelocationModelName(llvm::Reloc::Model Model) {
   llvm_unreachable("Unknown Reloc::Model kind");
 }
 
+static void HandleAmdgcnLegacyOptions(const Driver &D,
+  const ArgList &Args,
+  ArgStringList &CmdArgs) {
+  if (auto *CodeObjArg = Args.getLastArg(options::OPT_mcode_object_v3_legacy,
+ 
options::OPT_mno_code_object_v3_legacy)) {
+if (CodeObjArg->getOption().getID() == 
options::OPT_mcode_object_v3_legacy) {
+  D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3" <<
+"-mllvm --amdhsa-code-object-version=3";
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("--amdhsa-code-object-version=3");
+} else {
+  D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3" <<
+"-mllvm --amdhsa-code-object-version=2";
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("--amdhsa-code-object-version=2");
+}
+  }
+}
+
 void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
 const Driver &D, const ArgList &Args,
 ArgStringList &CmdArgs,
@@ -6122,6 +6141,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 }
   }
 
+  HandleAmdgcnLegacyOptions(D, Args, CmdArgs);
+
   // For all the host OpenMP offloading compile jobs we need to pass the 
targets
   // information using -fopenmp-targets= option.
   if (JA.isHostOffloading(Action::OFK_OpenMP)) {
@@ -7085,6 +7106,8 @@ void ClangAs::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back(SplitDebugName(JA, Args, Input, Output));
   }
 
+  HandleAmdgcnLegacyOptions(D, Args, CmdArgs);
+
   assert(Input.isFilename() && "Invalid input.");
   CmdArgs.push_back(Input.getFilename());
 

diff  --git a/clang/test/Driver/amdgpu-features-as.s 
b/clang/test/Driver/amdgpu-features-as.s
new file mode 100644
index ..850afe701740
--- /dev/null
+++ b/clang/test/Driver/amdgpu-features-as.s
@@ -0,0 +1,11 @@
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx900 -mcode-object-v3 %s 
2>&1 | FileCheck --check-prefix=CODE-OBJECT-V3 %s
+// CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use 
'-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
+// CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa amdgcn -mcpu=gfx900 
-mno-code-object-v3 %s 2>&1 | FileCheck --check-prefix=NO-CODE-OBJECT-V3 %s
+// NO-CODE-OBJECT-V3: warning: argument '-mno-code-object-v3' is deprecated, 
use '-mllvm --amdhsa-code-object-version=2' instead [-Wdeprecated]
+// NO-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=2"
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx900 -mcode-object-v3 
-mno-code-object-v3 -mcode-object-v3 %s 2>&1 | FileCheck 
--check-prefix=MUL-CODE-OBJECT-V3 %s
+// MUL-CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use 
'-mllv

[PATCH] D89297: [clangd] Add a TestWorkspace utility

2020-10-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

This looks like a useful infra to have indeed, we currently don't have an easy 
way to setup a testcase that would require interactions between multiple files 
(e.g. a workspace), as you've noticed while working on callhierarchy tests 
(sorry for that).

A couple of suggestions from my side:

- Rather than enforcing files to come in header/source pairs, why not have a 
`isTU` flag. That way we can use the infra in a more flexible way.
- Instead of having a MockFS, maybe have a single `TestTU` with all the 
workspace files put into `AdditionalFiles`.  Later on when building an AST, you 
can just replace the `TestTU::Code` and build the source as if it is in the 
`workspace`.
- Background or FileIndex is not the point handling include resolution (or AST 
build process). In theory during the construction time, after populating all 
the `AdditionalFiles` in a `TestTU`, you can have a single `FileIndex` and 
populated it for each TU using the AST coming from `TestTU::build()` and 
preamble from `TestTU::preamble()`. Currently `TestTU::preamble()` doesn't take 
a callback, but you can change that to populate the `FileIndex` using preamble 
information.
- In addition to having a constructor that takes all the files(or just some 
base files) at once, it might be better to have an interface like:

  struct WorkspaceTest {
void addSource(FilePath, Code);  // These are just sourcefiles, ASTs can be 
built for them, but they won't be MainFiles during indexing.
void addMainFile(FilePath, Code); // These are entrypoints, will be marked 
as TU, and would be used for index builds.
std::unique_ptr index(); // Builds the index for whole 
forkspace, by indexing all the MainFiles and merging them under a single 
FileIndex.
ParsedAST ast(FilePath);
  };


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89297/new/

https://reviews.llvm.org/D89297

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


[PATCH] D89372: [OpenCL] Remove unused extensions

2020-10-15 Thread Jan Vesely via Phabricator via cfe-commits
jvesely added a comment.

`cl_khr_byte_addressable_stores` changes language semantics. without it, 
pointer dereferences of types smaller than 32 bits are illegal.
Even if all clang targets support this the macro should still be defined for 
backward compatibility.

it would be useful if the commit message or the description of this revision 
included a justification for each removed extension why it doesn't impact 
language semantics with spec references.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89372/new/

https://reviews.llvm.org/D89372

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


[PATCH] D88498: [FPEnv] Apply dynamic rounding to function body only

2020-10-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Actually this solution also behaves wrong in some cases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88498/new/

https://reviews.llvm.org/D88498

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


[PATCH] D89360: Treat constant contexts as being in the default rounding mode.

2020-10-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

As C++ case is much more complicated and we need a ruleset based on essential 
properties rather than implementation viewpoint, I am convinced that the 
solution based on manifestly constant-evaluated property is the best. 
Thank you for the discussion!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89360/new/

https://reviews.llvm.org/D89360

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


[PATCH] D57265: [PM/CC1] Add -f[no-]split-cold-code CC1 options to toggle splitting

2020-10-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 298425.
compnerd added a comment.
Herald added a subscriber: arichardson.

Passes locally now


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57265/new/

https://reviews.llvm.org/D57265

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/split-cold-code.c
  clang/test/Frontend/split-cold-code.c
  llvm/include/llvm/Transforms/IPO/HotColdSplitting.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/HotColdSplitting.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Other/X86/lto-hot-cold-split.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-pgo.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Other/opt-hot-cold-split.ll
  llvm/test/Other/pass-pipelines.ll
  llvm/test/Transforms/CodeExtractor/extract-assume.ll
  llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
  llvm/test/Transforms/HotColdSplit/addr-taken.ll
  llvm/test/Transforms/HotColdSplit/apply-noreturn-bonus.ll
  llvm/test/Transforms/HotColdSplit/apply-penalty-for-inputs.ll
  llvm/test/Transforms/HotColdSplit/apply-penalty-for-outputs.ll
  llvm/test/Transforms/HotColdSplit/apply-successor-penalty.ll
  llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll
  llvm/test/Transforms/HotColdSplit/coldentrycount.ll
  llvm/test/Transforms/HotColdSplit/delete-use-without-def-dbg-val.ll
  llvm/test/Transforms/HotColdSplit/duplicate-phi-preds-crash.ll
  llvm/test/Transforms/HotColdSplit/eh-pads.ll
  llvm/test/Transforms/HotColdSplit/eh-typeid-for.ll
  llvm/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll
  llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-1.ll
  llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-2.ll
  llvm/test/Transforms/HotColdSplit/mark-the-whole-func-cold.ll
  llvm/test/Transforms/HotColdSplit/minsize.ll
  llvm/test/Transforms/HotColdSplit/multiple-exits.ll
  llvm/test/Transforms/HotColdSplit/noreturn.ll
  llvm/test/Transforms/HotColdSplit/outline-cold-asm.ll
  llvm/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll
  llvm/test/Transforms/HotColdSplit/outline-if-then-else.ll
  llvm/test/Transforms/HotColdSplit/outline-multiple-entry-region.ll
  llvm/test/Transforms/HotColdSplit/outline-while-loop.ll
  llvm/test/Transforms/HotColdSplit/phi-with-distinct-outlined-values.ll
  llvm/test/Transforms/HotColdSplit/region-overlap.ll
  llvm/test/Transforms/HotColdSplit/resume.ll
  llvm/test/Transforms/HotColdSplit/retain-section.ll
  llvm/test/Transforms/HotColdSplit/section-splitting-custom.ll
  llvm/test/Transforms/HotColdSplit/section-splitting-default.ll
  llvm/test/Transforms/HotColdSplit/split-cold-2.ll
  llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll
  llvm/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll
  llvm/test/Transforms/HotColdSplit/split-phis-in-exit-blocks.ll
  llvm/test/Transforms/HotColdSplit/stale-assume-in-original-func.ll
  llvm/test/Transforms/HotColdSplit/succ-block-with-self-edge.ll
  llvm/test/Transforms/HotColdSplit/swifterror.ll
  llvm/test/Transforms/HotColdSplit/transfer-debug-info.ll
  llvm/test/Transforms/HotColdSplit/unwind.ll
  llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.expected

Index: llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.expected
===
--- llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.expected
+++ llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.expected
@@ -3,13 +3,13 @@
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
 
-define void @foo(i32) {
+define void @foo(i32) "hot-cold-split" {
 ; CHECK-LABEL: @foo(
 ; CHECK-NEXT:[[TMP2:%.*]] = icmp eq i32 [[TMP0:%.*]], 0
 ; CHECK-NEXT:tail call void @_Z10sideeffectv()
 ; CHECK-NEXT:br i1 [[TMP2]], label [[CODEREPL:%.*]], label [[EXIT:%.*]]
 ; CHECK:   codeRepl:
-; CHECK-NEXT:call void @foo.cold.1() [[ATTR2:#.*]]
+; CHECK-NEXT:call void 

[PATCH] D89453: Fix hidden-redecls.m test for some environments

2020-10-15 Thread Konstantin Schwarz via Phabricator via cfe-commits
kschwarz added a comment.

Yes, I'll commit it tomorrow, thanks for the review @akyrtzi!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89453/new/

https://reviews.llvm.org/D89453

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


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2020-10-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D85802#2332808 , @rnk wrote:

> Would "f[no-]fuchsia-c++-abi-extensions" (or shorter, -ffuchsia-c++-abi) do 
> the trick? I know it doesn't map well onto our current internal option 
> representation, but I don't think the internal representation is particularly 
> good. I'd rather limit the user-visible driver interface to give us the 
> flexibility to change the internal representation in the future.

For our use case yes, we could have `-f[no-]fuchsia-c++-abi` which would be 
enabled by default when the target is Fuchsia.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85802/new/

https://reviews.llvm.org/D85802

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


[PATCH] D89488: WIP: FileManager: Shrink FileEntryRef to the size of a pointer

2020-10-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: arphaman.
Herald added subscribers: usaxena95, ributzka, kadircet.
dexonsmith requested review of this revision.

This is a WIP patch to shrink FileEntryRef to the size of a pointer,
posting for early feedback in case someone has some. This pulled in more
changes than I expected, and I'll try to find some things to split off
and commit incrementally, but I think this concept is sound
(`BasicTests` passes, still have to build and test the rest of clang).


https://reviews.llvm.org/D89488

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/unittests/Basic/FileManagerTest.cpp
  clang/unittests/Basic/SourceManagerTest.cpp

Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -496,23 +496,26 @@
 
   std::unique_ptr Buf =
   llvm::MemoryBuffer::getMemBuffer(Source);
-  const FileEntry *SourceFile =
-  FileMgr.getVirtualFile("mainFile.cpp", Buf->getBufferSize(), 0);
-  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+  auto SourceFile =
+  FileMgr.getVirtualFileRef("mainFile.cpp", Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(&SourceFile.getFileEntry(), std::move(Buf));
 
   std::unique_ptr Buf2 =
   llvm::MemoryBuffer::getMemBuffer(Source);
-  const FileEntry *SecondFile =
-  FileMgr.getVirtualFile("file2.cpp", Buf2->getBufferSize(), 0);
-  SourceMgr.overrideFileContents(SecondFile, std::move(Buf2));
+  auto SecondFile =
+  FileMgr.getVirtualFileRef("file2.cpp", Buf2->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(&SecondFile.getFileEntry(), std::move(Buf2));
 
-  FileID MainFileID = SourceMgr.getOrCreateFileID(SourceFile, SrcMgr::C_User);
+  FileID MainFileID =
+  SourceMgr.getOrCreateFileID(&SourceFile.getFileEntry(), SrcMgr::C_User);
   SourceMgr.setMainFileID(MainFileID);
 
-  EXPECT_TRUE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", *SourceFile)));
-  EXPECT_TRUE(
-  SourceMgr.isMainFile(FileEntryRef("anotherName.cpp", *SourceFile)));
-  EXPECT_FALSE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", *SecondFile)));
+  auto MainAlias =
+  FileMgr.addAliasForFile("anotherName.cpp", SourceFile.getFileEntry());
+
+  EXPECT_TRUE(SourceMgr.isMainFile(SourceFile));
+  EXPECT_TRUE(SourceMgr.isMainFile(*MainAlias));
+  EXPECT_FALSE(SourceMgr.isMainFile(SecondFile));
 }
 
 #endif
Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -485,29 +485,34 @@
   // Set up a virtual file with a different size than FakeStatCache uses.
   const FileEntry *File = Manager.getVirtualFile("/tmp/test", /*Size=*/10, 0);
   ASSERT_TRUE(File);
-  FileEntryRef Ref("/tmp/test", *File);
-  EXPECT_TRUE(Ref.isValid());
-  EXPECT_EQ(Ref.getSize(), 10);
+  const FileEntry &FE = *File;
+  EXPECT_TRUE(FE.isValid());
+  EXPECT_EQ(FE.getSize(), 10);
 
   // Calling a second time should not affect the UID or size.
-  unsigned VirtualUID = Ref.getUID();
-  EXPECT_EQ(*expectedToOptional(Manager.getFileRef("/tmp/test")), Ref);
-  EXPECT_EQ(Ref.getUID(), VirtualUID);
-  EXPECT_EQ(Ref.getSize(), 10);
+  unsigned VirtualUID = FE.getUID();
+  EXPECT_EQ(
+  &FE,
+  &expectedToOptional(Manager.getFileRef("/tmp/test"))->getFileEntry());
+  EXPECT_EQ(FE.getUID(), VirtualUID);
+  EXPECT_EQ(FE.getSize(), 10);
 
   // Bypass the file.
-  llvm::Optional BypassRef = Manager.getBypassFile(Ref);
+  llvm::Optional BypassRef =
+  Manager.getBypassFile(File->getLastRef());
   ASSERT_TRUE(BypassRef);
   EXPECT_TRUE(BypassRef->isValid());
-  EXPECT_EQ(BypassRef->getName(), Ref.getName());
+  EXPECT_EQ("/tmp/test", BypassRef->getName());
 
   // Check that it's different in the right ways.
   EXPECT_NE(&BypassRef->getFileEntry(), File);
   EXPECT_NE(BypassRef->getUID(), VirtualUID);
-  EXPECT_NE(BypassRef->getSize(), Ref.getSize());
+  EXPECT_NE(BypassRef->getSize(), FE.getSize());
 
   // The virtual file should still be returned when searching.
-  EXPECT_EQ(*expectedToOptional(Manager.getFileRef("/tmp/test")), Ref);
+  EXPECT_EQ(
+  &FE,
+  &expectedToOptional(Manager.getFileRef("/tmp/test"))->getFileEntry());
 }
 
 } // anonymous namespace
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -77,8 

[PATCH] D57265: [PM/CC1] Add -f[no-]split-cold-code CC1 options to toggle splitting

2020-10-15 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.

Thank you! LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57265/new/

https://reviews.llvm.org/D57265

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


[PATCH] D89276: Support ObjC in IncludeInserter

2020-10-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89276/new/

https://reviews.llvm.org/D89276

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


[PATCH] D89490: Introduce __attribute__((darwin_abi))

2020-10-15 Thread Adrien Guinet via Phabricator via cfe-commits
aguinet created this revision.
aguinet added reviewers: t.p.northover, mstorsjo, thegameg.
Herald added subscribers: llvm-commits, cfe-commits, arphaman, dexonsmith, 
steven_wu, hiraditya, kristof.beyls, krytarowski.
Herald added a reviewer: aaron.ballman.
Herald added projects: clang, LLVM.
aguinet requested review of this revision.

This patch introduces the "darwin_abi" function attribute, to be able to 
compile functions for the Apple ARM64 ABI when targeting other ARM64 OSes. For 
now, only Linux/ARM64 is supported/tested.

I explained the motivation behind this and some limitations in this mail on 
llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2020-October/145680.html . 
Please note that, in this mail, I call this attribute "apple_abi". I decided to 
change it to "darwin_abi", because everything Apple-related is called "darwin" 
in clang/llvm. That being said, I don't have any strong opinion on this, and 
will be willing to hear any argument in favoir of one or the other.

It does not allow to target all the differences that exist in the Darwin ARM64 
ABI against the standard AAPCS one (see [1] for the exhaustive list).

What I beleive is implemented:

- targeting the Darwin AAPCS ABI for C functions, especially those with 
variadic arguments. This means everything in section "Pass Arguments to 
Functions Correctly" and "Update Code that Passes Arguments to Variadic 
Functions" in [1].

- "The ABI requires the complete object (C1) and base-object (C2) constructors 
to return this to their callers. Similarly, the complete object (D1 
) and base-object (D2 
) destructors return this. This behavior matches 
the ARM 32-bit C++ ABI." (quoting [1]). I am not sure this would be useful to 
anyone, but that was not that hard to implement it, so I put it. The C++ 
support isn't complete in this patch though (see below), so maybe it's better 
to remove it.

- "When passing parameters to a function, Apple platforms ignore empty 
structures unless those structures have a nontrivial destructor or copy 
constructor. When passing such nontrivial structures, treat them as aggregates 
with one byte member in the generic manner." (quoting [1])

- properly forwarding variadic arguments from a "darwin_abi function" to a 
linux one using va_list, by zeroing the relevant fields in the linux va_list 
structure to make sure only stack arguments will be used (cf. discussions in 
the aforementioned ML thread)

What isn't implemented and isn't supported (quoting [1]):

- "The ABI provides a fixed layout of two size_t words for array cookies, with 
no extra alignment requirements. This behavior matches the ARM 32-bit C++ ABI." 
=> this would require allowing the "darwin_abi" to be set on class types, and I 
think the overall feature would make a non-trivial patch. I prefer doing the C 
ABI right and eventually implement this afterwards.

- "A pointer to a function declared as extern “C” isn’t interchangeable with a 
function declared as extern “c++”. This behavior differs from the ARM64 ABI, in 
which the functions are interchangeable." => I'm not sure to find where this is 
tested in clang, let alone this would be possible to be tested.

- My understanding is that we should keep the Itanium mangling, even for 
functions with the "darwin_abi" attributes, so I didn't implemented the 
mangling differences. For instance, if I understood correctly, setting the 
"ms_abi" on a C++ function doesn't use the MSVC mangling.

- Everything remaining in the "Handle C++ Differences" section in [1]

[1] 
https://developer.apple.com/documentation/xcode/writing_arm64_code_for_apple_platforms
 for reference


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89490

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/Specifiers.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/darwin_abi.c
  clang/test/CodeGen/darwin_abi_empty_structs.cpp
  clang/test/CodeGen/darwin_abi_vaarg.c
  clang/test/CodeGen/debug-info-cc.c
  clang/test/CodeGenCXX/darwinabi-returnthis.cpp
  clang/tools/libclang/CXType.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/IR/CallingConv.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/Target/AArch64/AArch64CallingConvention.cpp
  llvm/lib/Target/AArch64/AArch64FastISel.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
  llvm

[PATCH] D89372: [OpenCL] Remove unused extensions

2020-10-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D89372#2332853 , @jvesely wrote:

> `cl_khr_byte_addressable_stores` changes language semantics. without it, 
> pointer dereferences of types smaller than 32 bits are illegal.

Ok, does it mean that we are missing to diagnose this in the frontend? Btw I do 
acknowledge that what you say makes sense but I don't think the documentation 
support that:
https://www.khronos.org/registry/OpenCL/sdk/2.2/docs/man/html/cl_khr_byte_addressable_store.html

Am I just looking in the wrong place?

> Even if all clang targets support this the macro should still be defined for 
> backward compatibility.

Ok, are you saying that all targets currently support this and we sould always 
define it? In this case I would be more happy if we move them into the internal 
header that we add implicitly anyway...

> it would be useful if the commit message or the description of this revision 
> included a justification for each removed extension why it doesn't impact 
> language semantics with spec references.

Yes, this is a good suggestion in principle and we should try our best. However 
I am not sure it is feasible for all of those, in particular this documentation 
doesn't contain anything:
https://man.opencl.org/cl_khr_context_abort.html

Are you suggesting to leave this out? However I don't see any evidence that 
this require either macro or pragma. I feel this is in rather incomplete state. 
So I don't feel we can accomodate for all of these.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89372/new/

https://reviews.llvm.org/D89372

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


[PATCH] D89488: WIP: FileManager: Shrink FileEntryRef to the size of a pointer

2020-10-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith planned changes to this revision.
dexonsmith added a comment.

I'd still appreciate feedback on the direction, but 
`clang/test/ClangScanDeps/modules-full.cpp` is failing (getting `""` 
listed twice under `"file-deps"` for each translation unit) so I'm marking this 
as needing changes.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89488/new/

https://reviews.llvm.org/D89488

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


[PATCH] D86097: [OpenMP][AMDGCN] Generate global variables and attributes for AMDGCN

2020-10-15 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam marked 3 inline comments as done.
saiislam added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp:175
+
+void CGOpenMPRuntimeAMDGCN::emitSPMDKernelWrapper(
+const OMPExecutableDirective &D, StringRef ParentName,

JonChesterfield wrote:
> The nvptx emitSPMDKernelWrapper does nothing and the amdgcn one appends some 
> metadata.
> 
> How about 'nvptx::generateMetadata(...)' that does nothing and 
> 'amdgcn::generateMetadata(...)` that does this stuff, called from the end of 
> emitSPMDKernel?
It will be then difficult to track what all things are being done differently 
in the two. So, the common code has been generalized and (no change in nvptx + 
some changes in amdgcn) has been used as specialization.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.h:49
+
+  /// Allocate global variable for TransferMedium
+  llvm::GlobalVariable *

JonChesterfield wrote:
> I'm not convinced by this abstraction. It looks like amdgcn and nvptx want 
> almost exactly the same variable in each case. The difference appears to be 
> that nvptx uses internal linkage and amdgcn uses weak + externally 
> initialized, in which case we're better off with
> 
> `bool nvptx::needsExternalInitialization() {return false;}`
> `bool amdgpu::needsExternalInitialization() {return true;}`
> 
> Or, if the inline ternary is unappealing, amdgcn::NewGlobalVariable(...) that 
> passes the arguments to llvm::GlobalVariable while setting the two fields 
> that differ between the two.
> 
> 
I understand what you are suggesting. But, there are multiple such variables 
where linkage between nvptx and amdgcn are different. Also current style gives 
flexibility to a future implementation to define these variables in their own 
way.
What do you think?



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h:175
 
+  /// Emit outlined function specialized for the Fork-Join
+  /// programming model for applicable target directives on the NVPTX device.

JonChesterfield wrote:
> Please put this back to the previous location so we can see whether it 
> changed in the diff
This movement changes them from private to protected.
I could have just added access specifiers and not move the definitions. It 
would have simplified the review, but it would have decreased the readability 
for future.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h:217-249
+  /// Allocate global variable for TransferMedium
+  virtual llvm::GlobalVariable *
+  allocateTransferMediumGlobal(CodeGenModule &CGM, llvm::ArrayType *Ty,
+   StringRef TransferMediumName) = 0;
+
+  /// Allocate global variable for SharedStaticRD
+  virtual llvm::GlobalVariable *

ABataev wrote:
> Are all these required to be public?
Yes, they are being called from outside class.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86097/new/

https://reviews.llvm.org/D86097

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


[PATCH] D89445: clang/Basic: Remove ContentCache::getRawBuffer, NFC

2020-10-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 298434.
dexonsmith added a comment.

Fix a compile error (I forgot to run `check-clang-tools` before).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89445/new/

https://reviews.llvm.org/D89445

Files:
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1468,7 +1468,7 @@
 if (PP->getHeaderSearchInfo()
 .getHeaderSearchOpts()
 .ValidateASTInputFilesContent) {
-  auto *MemBuff = Cache->getRawBuffer();
+  auto MemBuff = Cache->getBufferIfLoaded();
   if (MemBuff)
 ContentHash = hash_value(MemBuff->getBuffer());
   else
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1542,7 +1542,7 @@
   = SourceMgr.getOrCreateContentCache(File, isSystem(FileCharacter));
 if (OverriddenBuffer && !ContentCache->BufferOverridden &&
 ContentCache->ContentsEntry == ContentCache->OrigEntry &&
-!ContentCache->getRawBuffer()) {
+!ContentCache->getBufferIfLoaded()) {
   auto Buffer = ReadBuffer(SLocEntryCursor, File->getName());
   if (!Buffer)
 return true;
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -153,7 +153,7 @@
 
   // Check that the file's size is the same as in the file entry (which may
   // have come from a stat cache).
-  if (getRawBuffer()->getBufferSize() != (size_t)ContentsEntry->getSize()) {
+  if (Buffer->getBufferSize() != (size_t)ContentsEntry->getSize()) {
 if (Diag.isDiagnosticInFlight())
   Diag.SetDelayedDiagnostic(diag::err_file_modified,
 ContentsEntry->getName());
@@ -361,7 +361,7 @@
 Clone->BufferOverridden = Cache->BufferOverridden;
 Clone->IsFileVolatile = Cache->IsFileVolatile;
 Clone->IsTransient = Cache->IsTransient;
-Clone->setUnownedBuffer(Cache->getRawBuffer());
+Clone->setUnownedBuffer(Cache->getBufferIfLoaded());
 return Clone;
   };
 
@@ -474,7 +474,8 @@
 SourceManager::getFakeContentCacheForRecovery() const {
   if (!FakeContentCacheForRecovery) {
 FakeContentCacheForRecovery = std::make_unique();
-FakeContentCacheForRecovery->setUnownedBuffer(getFakeBufferForRecovery());
+FakeContentCacheForRecovery->setUnownedBuffer(
+getFakeBufferForRecovery()->getMemBufferRef());
   }
   return FakeContentCacheForRecovery.get();
 }
@@ -749,10 +750,7 @@
   if (!SLoc.isFile() || MyInvalid)
 return None;
 
-  if (const llvm::MemoryBuffer *Buf =
-  SLoc.getFile().getContentCache()->getRawBuffer())
-return Buf->getBuffer();
-  return None;
+  return SLoc.getFile().getContentCache()->getBufferDataIfLoaded();
 }
 
 llvm::Optional SourceManager::getBufferDataOrNone(FileID FID) const {
Index: clang/include/clang/Basic/SourceManager.h
===
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -194,9 +194,23 @@
 /// this content cache.  This is used for performance analysis.
 llvm::MemoryBuffer::BufferKind getMemoryBufferKind() const;
 
-/// Get the underlying buffer, returning NULL if the buffer is not
-/// yet available.
-const llvm::MemoryBuffer *getRawBuffer() const { return Buffer.get(); }
+/// Return the buffer, only if it has been loaded.
+/// specified FileID, returning None if it's not yet loaded.
+///
+/// \param FID The file ID whose contents will be returned.
+llvm::Optional getBufferIfLoaded() const {
+  if (Buffer)
+return Buffer->getMemBufferRef();
+  return None;
+}
+
+/// Return a StringRef to the source buffer data, only if it has already
+/// been loaded.
+llvm::Optional getBufferDataIfLoaded() const {
+  if (Buffer)
+return Buffer->getBuffer();
+  return None;
+}
 
 /// Set the buffer.
 void setBuffer(std::unique_ptr B) {
@@ -207,10 +221,10 @@
 /// Set the buffer to one that's not owned (or to nullptr).
 ///
 /// \pre Buffer cannot already be set.
-void setUnownedBuffer(const llvm::MemoryBuffer *B) {
+void setUnownedBuffer(llvm::Optional B) {
   assert(!Buffer && "Expected to be called right after construction");
   if (B)
-setBuffer(llvm::MemoryBuffer::getMemBuffer(B->getMemBufferRef()));
+setBuffer(llvm::MemoryBuffer::getMemBuffer(*B));
 }
 
   

[PATCH] D88712: [CGBuiltin] Respect asm labels and redefine_extname for builtins with specialized emitting

2020-10-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I worry that we're chasing after the implementation details of GCC here. It 
seems self-contradictory to say all three of these things at once:

1. The frontend function `foo` has known, builtin semantics X. (Eg, we'll use 
those semantics in the frontend.)
2. The symbol `foo` has known, builtin semantics X. (Eg, we'll synthesize calls 
to `foo` from the middle-end.)
3. It's not correct to lower a call to the frontend function `foo` to the 
symbol `foo`.

So, from a principled standpoint, which of the above do we not consider to be 
correct in this situation?

- If we don't consider (1) to be correct, then we need to stop treating `foo` 
as a builtin everywhere -- we shouldn't be constant-evaluating calls to it, in 
particular. That's problematic in principle, because the `asm` label might be 
added after we've already seen the first declaration and added a `BuiltinAttr` 
to it. If we want to go in this direction, I think we should require a build 
that attaches an `asm` label to a builtin to also pass `-fno-builtin-foo` 
rather than trying to un-builtin a builtin function after the fact.
- If we don't consider (2) to be correct, then we need to stop the middle-end 
from inserting calls to the symbol `foo`, and get it to use the new symbol 
instead. That'd be the "teach the target libcall info about this" approach, 
which (as you point out) would be quite complex.
- The status quo is that we don't consider (3) to be correct. If we take this 
path, I suppose we could say that we make a best effort to use the renamed 
symbol, but provide no guarantees. That seems unprincipled and will likely 
continue to cause problems down the line, but maybe this gets us closest to the 
observed GCC behavior?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88712/new/

https://reviews.llvm.org/D88712

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


[clang] 3513171 - [SemaObjC] Fix composite pointer type calculation for `void*` and pointer to lifetime qualified ObjC pointer type

2020-10-15 Thread Erik Pilkington via cfe-commits

Author: Erik Pilkington
Date: 2020-10-15T15:21:01-04:00
New Revision: 351317167e2b28aad03f8e45e0ed0acbbff18c61

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

LOG: [SemaObjC] Fix composite pointer type calculation for `void*` and pointer 
to lifetime qualified ObjC pointer type

Fixes a regression introduced in 9a6f4d451ca7. rdar://70101809

Differential revision: https://reviews.llvm.org/D89475

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaObjCXX/arc-ptr-comparison.mm

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 8d5dccc19726..b96649597274 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -6552,12 +6552,16 @@ QualType Sema::FindCompositePointerType(SourceLocation 
Loc,
   // FIXME: In C, we merge __strong and none to __strong at the top level.
   if (Q1.getObjCGCAttr() == Q2.getObjCGCAttr())
 Quals.setObjCGCAttr(Q1.getObjCGCAttr());
+  else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+assert(Steps.size() == 1);
   else
 return QualType();
 
   // Mismatched lifetime qualifiers never compatibly include each other.
   if (Q1.getObjCLifetime() == Q2.getObjCLifetime())
 Quals.setObjCLifetime(Q1.getObjCLifetime());
+  else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+assert(Steps.size() == 1);
   else
 return QualType();
 

diff  --git a/clang/test/SemaObjCXX/arc-ptr-comparison.mm 
b/clang/test/SemaObjCXX/arc-ptr-comparison.mm
index b3af26c1f847..0ea66c6643bd 100644
--- a/clang/test/SemaObjCXX/arc-ptr-comparison.mm
+++ b/clang/test/SemaObjCXX/arc-ptr-comparison.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-fobjc-runtime-has-weak -fobjc-arc -verify %s
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-verify -DNOARC %s
 #ifdef NOARC
 // expected-no-diagnostics
@@ -51,3 +51,17 @@ int testMixedQualComparisonRules(void *v, const void *cv, A 
*a, const A *ca) {
   return a == cv;
   return ca == v;
 }
+
+#ifndef NOARC
+int testDoublePtr(void *pv, void **ppv, A *__strong* pspa, A *__weak* pwpa, A 
*__strong** ppspa) {
+  return pv == pspa;
+  return pspa == pv;
+  return pv == pspa;
+  return pv == pwpa;
+  return pspa == pwpa; // expected-error {{comparison of distinct pointer 
types}}
+  return ppv == pspa; // expected-error {{comparison of distinct pointer 
types}}
+  return pspa == ppv; // expected-error {{comparison of distinct pointer 
types}}
+  return pv == ppspa;
+  return ppv == ppspa; // expected-error{{comparison of distinct pointer 
types}}
+}
+#endif



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


[PATCH] D89475: [SemaObjC] Fix composite pointer type calculation for `void*` and pointer to lifetime qualified ObjC pointer type

2020-10-15 Thread Erik Pilkington via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG351317167e2b: [SemaObjC] Fix composite pointer type 
calculation for `void*` and pointer to… (authored by erik.pilkington).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89475/new/

https://reviews.llvm.org/D89475

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaObjCXX/arc-ptr-comparison.mm


Index: clang/test/SemaObjCXX/arc-ptr-comparison.mm
===
--- clang/test/SemaObjCXX/arc-ptr-comparison.mm
+++ clang/test/SemaObjCXX/arc-ptr-comparison.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-fobjc-runtime-has-weak -fobjc-arc -verify %s
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-verify -DNOARC %s
 #ifdef NOARC
 // expected-no-diagnostics
@@ -51,3 +51,17 @@
   return a == cv;
   return ca == v;
 }
+
+#ifndef NOARC
+int testDoublePtr(void *pv, void **ppv, A *__strong* pspa, A *__weak* pwpa, A 
*__strong** ppspa) {
+  return pv == pspa;
+  return pspa == pv;
+  return pv == pspa;
+  return pv == pwpa;
+  return pspa == pwpa; // expected-error {{comparison of distinct pointer 
types}}
+  return ppv == pspa; // expected-error {{comparison of distinct pointer 
types}}
+  return pspa == ppv; // expected-error {{comparison of distinct pointer 
types}}
+  return pv == ppspa;
+  return ppv == ppspa; // expected-error{{comparison of distinct pointer 
types}}
+}
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6552,12 +6552,16 @@
   // FIXME: In C, we merge __strong and none to __strong at the top level.
   if (Q1.getObjCGCAttr() == Q2.getObjCGCAttr())
 Quals.setObjCGCAttr(Q1.getObjCGCAttr());
+  else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+assert(Steps.size() == 1);
   else
 return QualType();
 
   // Mismatched lifetime qualifiers never compatibly include each other.
   if (Q1.getObjCLifetime() == Q2.getObjCLifetime())
 Quals.setObjCLifetime(Q1.getObjCLifetime());
+  else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+assert(Steps.size() == 1);
   else
 return QualType();
 


Index: clang/test/SemaObjCXX/arc-ptr-comparison.mm
===
--- clang/test/SemaObjCXX/arc-ptr-comparison.mm
+++ clang/test/SemaObjCXX/arc-ptr-comparison.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -verify %s
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -verify -DNOARC %s
 #ifdef NOARC
 // expected-no-diagnostics
@@ -51,3 +51,17 @@
   return a == cv;
   return ca == v;
 }
+
+#ifndef NOARC
+int testDoublePtr(void *pv, void **ppv, A *__strong* pspa, A *__weak* pwpa, A *__strong** ppspa) {
+  return pv == pspa;
+  return pspa == pv;
+  return pv == pspa;
+  return pv == pwpa;
+  return pspa == pwpa; // expected-error {{comparison of distinct pointer types}}
+  return ppv == pspa; // expected-error {{comparison of distinct pointer types}}
+  return pspa == ppv; // expected-error {{comparison of distinct pointer types}}
+  return pv == ppspa;
+  return ppv == ppspa; // expected-error{{comparison of distinct pointer types}}
+}
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6552,12 +6552,16 @@
   // FIXME: In C, we merge __strong and none to __strong at the top level.
   if (Q1.getObjCGCAttr() == Q2.getObjCGCAttr())
 Quals.setObjCGCAttr(Q1.getObjCGCAttr());
+  else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+assert(Steps.size() == 1);
   else
 return QualType();
 
   // Mismatched lifetime qualifiers never compatibly include each other.
   if (Q1.getObjCLifetime() == Q2.getObjCLifetime())
 Quals.setObjCLifetime(Q1.getObjCLifetime());
+  else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+assert(Steps.size() == 1);
   else
 return QualType();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3f738d1 - Reland "[WebAssembly] v128.load{8,16,32,64}_lane instructions"

2020-10-15 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-10-15T19:32:34Z
New Revision: 3f738d1f5e2d657993a51ca3fe56585268025d89

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

LOG: Reland "[WebAssembly] v128.load{8,16,32,64}_lane instructions"

This reverts commit 7c8385a352ba21cb388046290d93b53dc273cd9f with a typing fix
to an instruction selection pattern.

Added: 
llvm/test/CodeGen/WebAssembly/simd-load-lane-offset.ll

Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 45e194c283b6..86348ff5fea7 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -171,8 +171,17 @@ TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, 
"V16UcV8UsV8Us", "nc", "simd
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4UiV4Ui", "nc", 
"simd128")
 
-TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4ii*", "nU", "simd128")
-TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLi*", "nU", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4ii*", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLi*", "n", "simd128")
+
+TARGET_BUILTIN(__builtin_wasm_load8_lane, "V16ScSc*V16ScIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load16_lane, "V8ss*V8sIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load32_lane, "V4ii*V4iIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load64_lane, "V2LLiLLi*V2LLiIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_store8_lane, "vSc*V16ScIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_store16_lane, "vs*V8sIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_store32_lane, "vi*V4iIi", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_store64_lane, "vLLi*V2LLiIi", "n", "simd128")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 157dae2831f2..3f6977e16c4a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -16711,6 +16711,52 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_load64_zero);
 return Builder.CreateCall(Callee, {Ptr});
   }
+  case WebAssembly::BI__builtin_wasm_load8_lane:
+  case WebAssembly::BI__builtin_wasm_load16_lane:
+  case WebAssembly::BI__builtin_wasm_load32_lane:
+  case WebAssembly::BI__builtin_wasm_load64_lane:
+  case WebAssembly::BI__builtin_wasm_store8_lane:
+  case WebAssembly::BI__builtin_wasm_store16_lane:
+  case WebAssembly::BI__builtin_wasm_store32_lane:
+  case WebAssembly::BI__builtin_wasm_store64_lane: {
+Value *Ptr = EmitScalarExpr(E->getArg(0));
+Value *Vec = EmitScalarExpr(E->getArg(1));
+Optional LaneIdxConst =
+E->getArg(2)->getIntegerConstantExpr(getContext());
+assert(LaneIdxConst && "Constant arg isn't actually constant?");
+Value *LaneIdx = llvm::ConstantInt::get(getLLVMContext(), *LaneIdxConst);
+unsigned IntNo;
+switch (BuiltinID) {
+case WebAssembly::BI__builtin_wasm_load8_lane:
+  IntNo = Intrinsic::wasm_load8_lane;
+  break;
+case WebAssembly::BI__builtin_wasm_load16_lane:
+  IntNo = Intrinsic::wasm_load16_lane;
+  break;
+case WebAssembly::BI__builtin_wasm_load32_lane:
+  IntNo = Intrinsic::wasm_load32_lane;
+  break;
+case WebAssembly::BI__builtin_wasm_load64_lane:
+  IntNo = Intrinsic::wasm_load64_lane;
+  break;
+case WebAssembly::BI__builtin_wasm_store8_lane:
+  IntNo = Intrinsic::wasm_store8_lane;
+  break;
+case WebAssembly::BI__builtin_wasm_store16_lane:
+  IntNo = Intrinsic::wasm_store16_lane;
+  break;
+case WebAssembly::BI__builtin_wasm_store32_lane:
+  IntNo = Intrinsic::wasm_store32_lane;
+  break;
+case WebAssembly::BI__builtin_wasm_store64_lane:
+  IntNo = Intrinsic::wasm_store64_lane;
+  break;
+default:
+  llvm_unreachable("unexpected builtin ID");
+}
+Function *Callee = CGM.getIntrinsic(IntNo);
+return Builder.CreateCall(Callee, {Ptr, Vec, LaneIdx});
+  }
   case WebAssembly::BI__builtin_wasm_shuffle_v8x16: {
 Value *Ops[18];
 size_t OpIdx 

[PATCH] D89484: [AMDGPU][HIP] Switch default DWARF version to 5

2020-10-15 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89484/new/

https://reviews.llvm.org/D89484

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


[clang] d1beb95 - [AMDGPU] gfx1032 target

2020-10-15 Thread Stanislav Mekhanoshin via cfe-commits

Author: Stanislav Mekhanoshin
Date: 2020-10-15T12:41:18-07:00
New Revision: d1beb95d1241ec50bdf19db351d273374a146a4a

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

LOG: [AMDGPU] gfx1032 target

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

Added: 


Modified: 
clang/include/clang/Basic/Cuda.h
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/NVPTX.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/test/CodeGenOpenCL/amdgpu-features.cl
clang/test/Driver/amdgpu-macros.cl
clang/test/Driver/amdgpu-mcpu.cl
llvm/docs/AMDGPUUsage.rst
llvm/include/llvm/BinaryFormat/ELF.h
llvm/include/llvm/Support/TargetParser.h
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/lib/Support/TargetParser.cpp
llvm/lib/Target/AMDGPU/GCNProcessors.td
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
llvm/test/CodeGen/AMDGPU/hsa-note-no-func.ll
llvm/test/MC/AMDGPU/gfx1030_err.s
llvm/test/MC/AMDGPU/gfx1030_new.s
llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Cuda.h 
b/clang/include/clang/Basic/Cuda.h
index 417d40c28adf..501e47b0e2c2 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -80,6 +80,7 @@ enum class CudaArch {
   GFX1012,
   GFX1030,
   GFX1031,
+  GFX1032,
   LAST,
 };
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 42db207b9ce5..0b3aebdfa15c 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -174,6 +174,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
   // XXX - What does the member GPU mean if device name string passed here?
   if (isAMDGCN(getTriple())) {
 switch (llvm::AMDGPU::parseArchAMDGCN(CPU)) {
+case GK_GFX1032:
 case GK_GFX1031:
 case GK_GFX1030:
   Features["ci-insts"] = true;

diff  --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 3780f1cc250c..26c5b26beeef 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -205,6 +205,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CudaArch::GFX1012:
   case CudaArch::GFX1030:
   case CudaArch::GFX1031:
+  case CudaArch::GFX1032:
   case CudaArch::LAST:
 break;
   case CudaArch::UNUSED:

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index ab7ee8b33a0c..bcabc5398127 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -4645,6 +4645,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(
   case CudaArch::GFX1012:
   case CudaArch::GFX1030:
   case CudaArch::GFX1031:
+  case CudaArch::GFX1032:
   case CudaArch::UNUSED:
   case CudaArch::UNKNOWN:
 break;
@@ -4710,6 +4711,7 @@ static std::pair 
getSMsBlocksPerSM(CodeGenModule &CGM) {
   case CudaArch::GFX1012:
   case CudaArch::GFX1030:
   case CudaArch::GFX1031:
+  case CudaArch::GFX1032:
   case CudaArch::UNUSED:
   case CudaArch::UNKNOWN:
 break;

diff  --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index 5a814f36e564..a463c061114e 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -16,6 +16,7 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1012 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1012 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1030 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1030 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1031 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1031 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1032 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1032 %s
 
 // GFX600-NOT: "target-features"
 // GFX601-NOT: "target-features"
@@ -30,5 +31,6 @@
 // GFX1012: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
 // GFX1030: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
 // GFX1031: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX1032: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-i

[PATCH] D89490: Introduce __attribute__((darwin_abi))

2020-10-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

I see that the llvm side of the patch lacks tests?




Comment at: llvm/lib/IR/AsmWriter.cpp:379
+Out << "aarch64_darwincc";
+break;
   case CallingConv::SPIR_FUNC: Out << "spir_func"; break;

The new code here has a different indentation than the rest; the same in a 
couple other places throughout the patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89490/new/

https://reviews.llvm.org/D89490

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


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2020-10-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D85802#2332895 , @phosek wrote:

> In D85802#2332808 , @rnk wrote:
>
>> Would "f[no-]fuchsia-c++-abi-extensions" (or shorter, -ffuchsia-c++-abi) do 
>> the trick? I know it doesn't map well onto our current internal option 
>> representation, but I don't think the internal representation is 
>> particularly good. I'd rather limit the user-visible driver interface to 
>> give us the flexibility to change the internal representation in the future.
>
> For our use case yes, we could have `-f[no-]fuchsia-c++-abi` which would be 
> enabled by default when the target is Fuchsia.

Will send out another patch that will use this instead. We can probably revert 
this in the meantime.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85802/new/

https://reviews.llvm.org/D85802

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


[PATCH] D20090: [OPENCL] Fix wrongly vla error for OpenCL array.

2020-10-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: cfe/trunk/lib/Sema/SemaType.cpp:2067
+   S.LangOpts.GNUMode ||
+   S.LangOpts.OpenCL).isInvalid();
 }

This looks wrong to me. The OpenCL rules don't permit arbitrary constant 
folding in array bounds.

If OpenCL intends to permit reading from const globals of integral types in 
constant expressions (as C++ does but C does not), then the right way to handle 
that would be to change `CheckICE` to permit such cases, as it does in C++ 
mode, not to enable arbitrary constant folding in array bounds.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D20090/new/

https://reviews.llvm.org/D20090

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


[PATCH] D88712: [CGBuiltin] Respect asm labels and redefine_extname for builtins with specialized emitting

2020-10-15 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Disabling builtin handling when `asm` is enabled would be a major annoyance for 
NetBSD. The interaction between symbol renaming and TLI is complicated. There 
are cases where it would make perfect sense and others were it would be 
harmful. Example of the latter is the way SSP is implemented by inline 
functions that call a prototype renamed back to the original symbol name.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88712/new/

https://reviews.llvm.org/D88712

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


[PATCH] D89490: Introduce __attribute__((darwin_abi))

2020-10-15 Thread Adrien Guinet via Phabricator via cfe-commits
aguinet added a comment.

In D89490#2333073 , @mstorsjo wrote:

> I see that the llvm side of the patch lacks tests?

Sorry I forgot to add them indeed... I will push a patch with these.

About the formatting, git clang-format HEAD~1 did this, and it looks by the 
automated test that some issues are still there.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89490/new/

https://reviews.llvm.org/D89490

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


[PATCH] D88712: [CGBuiltin] Respect asm labels and redefine_extname for builtins with specialized emitting

2020-10-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a subscriber: zatrazz.
MaskRay added a comment.

In D88712#2333030 , @rsmith wrote:

> I worry that we're chasing after the implementation details of GCC here. It 
> seems self-contradictory to say all three of these things at once:
>
> 1. The frontend function `foo` has known, builtin semantics X. (Eg, we'll use 
> those semantics in the frontend.)
> 2. The symbol `foo` has known, builtin semantics X. (Eg, we'll synthesize 
> calls to `foo` from the middle-end.)
> 3. It's not correct to lower a call to the frontend function `foo` to the 
> symbol `foo`.
>
> So, from a principled standpoint, which of the above do we not consider to be 
> correct in this situation?
>
> - If we don't consider (1) to be correct, then we need to stop treating `foo` 
> as a builtin everywhere -- we shouldn't be constant-evaluating calls to it, 
> in particular. That's problematic in principle, because the `asm` label might 
> be added after we've already seen the first declaration and added a 
> `BuiltinAttr` to it. If we want to go in this direction, I think we should 
> require a build that attaches an `asm` label to a builtin to also pass 
> `-fno-builtin-foo` rather than trying to un-builtin a builtin function after 
> the fact.
> - If we don't consider (2) to be correct, then we need to stop the middle-end 
> from inserting calls to the symbol `foo`, and get it to use the new symbol 
> instead. That'd be the "teach the target libcall info about this" approach, 
> which (as you point out) would be quite complex.
> - The status quo is that we don't consider (3) to be correct. If we take this 
> path, I suppose we could say that we make a best effort to use the renamed 
> symbol, but provide no guarantees. That seems unprincipled and will likely 
> continue to cause problems down the line, but maybe this gets us closest to 
> the observed GCC behavior?

It took me quite a while to understand the "take 2 out of the 3 guarantees" 
theorem;-)

I think people do want to keep (1) (if it is profitable to expand a memcpy, do 
it). This also means that people do not want to add -fno-builtin-memcpy.

People do want (3): that is why they use an `asm("__GI_memcpy")` in the first 
place.
The status quo is "we don't consider (3) to be correct." -> "we ignore 
asm("__GI_memcpy")". This makes the system consistent but it is unexpected.

So unfortunately we are making a compromise on (2): refuting it is difficult in 
both GCC and Clang.
For most libcalls, compilers don't generate them, so it is a small loss. For 
the few glibc cares about, it uses the `asm("memcpy = __GI_memcpy");` GNU as 
feature to make the second level redirection.
D88625  will do it on MC side.

We still have another choice: don't use `memcpy`, use `__memcpy` instead. 
However, that will be a hard hammer and according to @zatrazz people will 
complain 'with gcc this works as intended'...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88712/new/

https://reviews.llvm.org/D88712

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


[clang] 68f116a - PR47864: Fix assertion in pointer-to-member emission if there are

2020-10-15 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-10-15T13:51:51-07:00
New Revision: 68f116aa23434b577743307c487b2edf037fca4c

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

LOG: PR47864: Fix assertion in pointer-to-member emission if there are
multiple declarations of the same base class.

Added: 


Modified: 
clang/include/clang/AST/RecordLayout.h
clang/test/CodeGenCXX/pointers-to-data-members.cpp

Removed: 




diff  --git a/clang/include/clang/AST/RecordLayout.h 
b/clang/include/clang/AST/RecordLayout.h
index 946fbd8f4ce2..dd18f9c49f84 100644
--- a/clang/include/clang/AST/RecordLayout.h
+++ b/clang/include/clang/AST/RecordLayout.h
@@ -248,6 +248,8 @@ class ASTRecordLayout {
   /// getBaseClassOffset - Get the offset, in chars, for the given base class.
   CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const {
 assert(CXXInfo && "Record layout does not have C++ specific info!");
+
+Base = Base->getDefinition();
 assert(CXXInfo->BaseOffsets.count(Base) && "Did not find base!");
 
 return CXXInfo->BaseOffsets[Base];
@@ -256,6 +258,8 @@ class ASTRecordLayout {
   /// getVBaseClassOffset - Get the offset, in chars, for the given base class.
   CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const {
 assert(CXXInfo && "Record layout does not have C++ specific info!");
+
+VBase = VBase->getDefinition();
 assert(CXXInfo->VBaseOffsets.count(VBase) && "Did not find base!");
 
 return CXXInfo->VBaseOffsets[VBase].VBaseOffset;

diff  --git a/clang/test/CodeGenCXX/pointers-to-data-members.cpp 
b/clang/test/CodeGenCXX/pointers-to-data-members.cpp
index f975035d0318..b08cdcc52c5b 100644
--- a/clang/test/CodeGenCXX/pointers-to-data-members.cpp
+++ b/clang/test/CodeGenCXX/pointers-to-data-members.cpp
@@ -258,3 +258,10 @@ union U {
 U u;
 // CHECK-GLOBAL: @_ZN11IndirectPDM1uE = global %"union.IndirectPDM::U" { 
%union.anon { i64 -1 } }, align 8
 }
+
+namespace PR47864 {
+  struct B;
+  struct B {};
+  struct D : B { int m; };
+  auto x = (int B::*)&D::m;
+}



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


[PATCH] D89446: [WebAssembly] Prototype i8x16.popcnt

2020-10-15 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 298457.
tlively added a comment.

- Update builtin function name


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89446/new/

https://reviews.llvm.org/D89446

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -367,6 +367,9 @@
 # CHECK: i8x16.avgr_u # encoding: [0xfd,0x7b]
 i8x16.avgr_u
 
+# CHECK: i8x16.popcnt # encoding: [0xfd,0x7c]
+i8x16.popcnt
+
 # CHECK: i16x8.abs # encoding: [0xfd,0x80,0x01]
 i16x8.abs
 
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -75,6 +75,16 @@
   ret <16 x i8> %a
 }
 
+; CHECK-LABEL: popcnt_v16i8:
+; SIMD128-NEXT: .functype popcnt_v16i8 (v128) -> (v128){{$}}
+; SIMD128-NEXT: i8x16.popcnt $push[[R:[0-9]+]]=, $0{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <16 x i8> @llvm.wasm.popcnt(<16 x i8>)
+define <16 x i8> @popcnt_v16i8(<16 x i8> %x) {
+ %a = call <16 x i8> @llvm.wasm.popcnt(<16 x i8> %x)
+ ret <16 x i8> %a
+}
+
 ; CHECK-LABEL: any_v16i8:
 ; SIMD128-NEXT: .functype any_v16i8 (v128) -> (i32){{$}}
 ; SIMD128-NEXT: i8x16.any_true $push[[R:[0-9]+]]=, $0{{$}}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -785,6 +785,9 @@
 // All lanes true: all_true
 defm ALLTRUE : SIMDReduce;
 
+// Population count: popcnt
+defm POPCNT : SIMDUnary;
+
 // Reductions already return 0 or 1, so and 1, setne 0, and seteq 1
 // can be folded out
 foreach reduction =
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -254,6 +254,11 @@
 [IntrWriteMem, IntrArgMemOnly],
 "", [SDNPMemOperand]>;
 
+// TODO: Replace this intrinsic with normal ISel patterns once popcnt is merged
+// to the proposal.
+def int_wasm_popcnt :
+  Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem, IntrSpeculatable]>;
+
 //===--===//
 // Thread-local storage intrinsics
 //===--===//
Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -538,6 +538,12 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
+i8x16 popcnt(i8x16 x) {
+  return __builtin_wasm_popcnt_i8x16(x);
+  // WEBASSEMBLY: call <16 x i8> @llvm.wasm.popcnt(<16 x i8> %x)
+  // WEBASSEMBLY-NEXT: ret
+}
+
 int any_true_i8x16(i8x16 x) {
   return __builtin_wasm_any_true_i8x16(x);
   // WEBASSEMBLY: call i32 @llvm.wasm.anytrue.v16i8(<16 x i8> %x)
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -16606,6 +16606,11 @@
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_dot);
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_popcnt_i8x16: {
+Value *Vec = EmitScalarExpr(E->getArg(0));
+Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_popcnt);
+return Builder.CreateCall(Callee, {Vec});
+  }
   case WebAssembly::BI__builtin_wasm_any_true_i8x16:
   case WebAssembly::BI__builtin_wasm_any_true_i16x8:
   case WebAssembly::BI__builtin_wasm_any_true_i32x4:
Index: clang/include/clang/Basic/BuiltinsWebAssembly.def
===
--- clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -114,6 +114,8 @@
 TARGET_BUILTIN(__builtin_wasm_avgr_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_avgr_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128")
 
+TARGET_BUILTIN(__builtin_wasm_popcnt_i8x16, "V16ScV16Sc", "nc", "simd128")
+
 TARGET_BUILTIN(__builtin_wasm_q15mulr_saturate_s_i8x16, "V8sV8sV8s", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_bitselect, "V4iV4iV4iV4i", "nc", "simd128")
___
cfe-commits mailing list
cf

[PATCH] D89446: [WebAssembly] Prototype i8x16.popcnt

2020-10-15 Thread Thomas Lively via Phabricator via cfe-commits
tlively marked an inline comment as done.
tlively added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:117
 
+TARGET_BUILTIN(__builtin_wasm_popcnt, "V16ScV16Sc", "nc", "simd128")
+

aheejin wrote:
> - Even if there's only one vector type for a builtin, it seems others still 
> have type postfix attached.
> - Is the result also a vector? Does that mean this instruction count each 16 
> slot separately?
Yes, the it does a popcnt on each 1-byte lane individually.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89446/new/

https://reviews.llvm.org/D89446

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


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-10-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/Parse/ParsePragma.cpp:1096
   static_cast(Tok.getAnnotationValue());
-
   IdentifierInfo *PragmaNameInfo = Info->PragmaName.getIdentifierInfo();

nit: unrelated change?



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:144
+  assert(ValueExpr && "Attribute must have a valid value expression.");
+  if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
+return nullptr;

Is there a way to only accept `fixed_width/scalable` for targets that support 
it? Not sure if we have enough information here, but we might be able to reject 
it eg per target basis or something


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89031/new/

https://reviews.llvm.org/D89031

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


[clang] 65cb4fd - [libTooling] Change `after` range-selector to operate only on source ranges

2020-10-15 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-10-15T20:58:30Z
New Revision: 65cb4fdd69f43b6c39a8e4ca27b509284b11d807

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

LOG: [libTooling] Change `after` range-selector to operate only on source ranges

Currently, `after` fails when applied to locations in macro arguments.  This
change projects the subrange into a file source range and then applies `after`.

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

Added: 


Modified: 
clang/lib/Tooling/Transformer/RangeSelector.cpp
clang/unittests/Tooling/RangeSelectorTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Transformer/RangeSelector.cpp 
b/clang/lib/Tooling/Transformer/RangeSelector.cpp
index 29b1a5b0372e..ce6f5fb9b444 100644
--- a/clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ b/clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -116,11 +116,24 @@ RangeSelector transformer::after(RangeSelector Selector) {
 Expected SelectedRange = Selector(Result);
 if (!SelectedRange)
   return SelectedRange.takeError();
-if (SelectedRange->isCharRange())
-  return CharSourceRange::getCharRange(SelectedRange->getEnd());
-return CharSourceRange::getCharRange(Lexer::getLocForEndOfToken(
-SelectedRange->getEnd(), 0, Result.Context->getSourceManager(),
-Result.Context->getLangOpts()));
+SourceLocation End = SelectedRange->getEnd();
+if (SelectedRange->isTokenRange()) {
+  // We need to find the actual (exclusive) end location from which to
+  // create a new source range. However, that's not guaranteed to be valid,
+  // even if the token location itself is valid. So, we create a token 
range
+  // consisting only of the last token, then map that range back to the
+  // source file. If that succeeds, we have a valid location for the end of
+  // the generated range.
+  CharSourceRange Range = Lexer::makeFileCharRange(
+  CharSourceRange::getTokenRange(SelectedRange->getEnd()),
+  *Result.SourceManager, Result.Context->getLangOpts());
+  if (Range.isInvalid())
+return invalidArgumentError(
+"after: can't resolve sub-range to valid source range");
+  End = Range.getEnd();
+}
+
+return CharSourceRange::getCharRange(End);
   };
 }
 

diff  --git a/clang/unittests/Tooling/RangeSelectorTest.cpp 
b/clang/unittests/Tooling/RangeSelectorTest.cpp
index 64ddee7894eb..499c9a8cc666 100644
--- a/clang/unittests/Tooling/RangeSelectorTest.cpp
+++ b/clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -193,6 +193,65 @@ TEST(RangeSelectorTest, AfterOp) {
HasValue(EqualsCharSourceRange(ExpectedAfter)));
 }
 
+// Gets the spelling location `Length` characters after the start of AST node
+// `Id`.
+static SourceLocation getSpellingLocAfter(const MatchResult &Result,
+  StringRef Id, int Length) {
+  const auto *E = Result.Nodes.getNodeAs(Id);
+  assert(E != nullptr);
+  return Result.SourceManager->getSpellingLoc(E->getBeginLoc())
+  .getLocWithOffset(Length);
+}
+
+// Test with a range that is the entire macro arg, but does not end the
+// expansion itself.
+TEST(RangeSelectorTest, AfterOpInMacroArg) {
+  StringRef Code = R"cc(
+#define ISNULL(x) x == nullptr
+bool g() { int* y; return ISNULL(y); }
+  )cc";
+
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind("yvar"));
+  int YVarLen = 1;
+  SourceLocation After = getSpellingLocAfter(Match.Result, "yvar", YVarLen);
+  CharSourceRange Expected = CharSourceRange::getCharRange(After, After);
+  EXPECT_THAT_EXPECTED(after(node("yvar"))(Match.Result),
+   HasValue(EqualsCharSourceRange(Expected)));
+}
+
+// Test with a range that is the entire macro arg and ends the expansion 
itself.
+TEST(RangeSelectorTest, AfterOpInMacroArgEndsExpansion) {
+  StringRef Code = R"cc(
+#define ISNULL(x) nullptr == x
+bool g() { int* y; return ISNULL(y); }
+  )cc";
+
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind("yvar"));
+  int YVarLen = 1;
+  SourceLocation After = getSpellingLocAfter(Match.Result, "yvar", YVarLen);
+  CharSourceRange Expected = CharSourceRange::getCharRange(After, After);
+  EXPECT_THAT_EXPECTED(after(node("yvar"))(Match.Result),
+   HasValue(EqualsCharSourceRange(Expected)));
+}
+
+TEST(RangeSelectorTest, AfterOpInPartOfMacroArg) {
+  StringRef Code = R"cc(
+#define ISNULL(x) x == nullptr
+int* f(int*);
+bool g() { int* y; return ISNULL(f(y)); }
+  )cc";
+
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind("yvar"));
+  int YVarLen = 1;
+  SourceLocation After = getSpellingLocAfter(Match.Result,

[PATCH] D89468: [libTooling] Change `after` range-selector to operate only on source ranges

2020-10-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG65cb4fdd69f4: [libTooling] Change `after` range-selector to 
operate only on source ranges (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89468/new/

https://reviews.llvm.org/D89468

Files:
  clang/lib/Tooling/Transformer/RangeSelector.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp

Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -193,6 +193,65 @@
HasValue(EqualsCharSourceRange(ExpectedAfter)));
 }
 
+// Gets the spelling location `Length` characters after the start of AST node
+// `Id`.
+static SourceLocation getSpellingLocAfter(const MatchResult &Result,
+  StringRef Id, int Length) {
+  const auto *E = Result.Nodes.getNodeAs(Id);
+  assert(E != nullptr);
+  return Result.SourceManager->getSpellingLoc(E->getBeginLoc())
+  .getLocWithOffset(Length);
+}
+
+// Test with a range that is the entire macro arg, but does not end the
+// expansion itself.
+TEST(RangeSelectorTest, AfterOpInMacroArg) {
+  StringRef Code = R"cc(
+#define ISNULL(x) x == nullptr
+bool g() { int* y; return ISNULL(y); }
+  )cc";
+
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind("yvar"));
+  int YVarLen = 1;
+  SourceLocation After = getSpellingLocAfter(Match.Result, "yvar", YVarLen);
+  CharSourceRange Expected = CharSourceRange::getCharRange(After, After);
+  EXPECT_THAT_EXPECTED(after(node("yvar"))(Match.Result),
+   HasValue(EqualsCharSourceRange(Expected)));
+}
+
+// Test with a range that is the entire macro arg and ends the expansion itself.
+TEST(RangeSelectorTest, AfterOpInMacroArgEndsExpansion) {
+  StringRef Code = R"cc(
+#define ISNULL(x) nullptr == x
+bool g() { int* y; return ISNULL(y); }
+  )cc";
+
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind("yvar"));
+  int YVarLen = 1;
+  SourceLocation After = getSpellingLocAfter(Match.Result, "yvar", YVarLen);
+  CharSourceRange Expected = CharSourceRange::getCharRange(After, After);
+  EXPECT_THAT_EXPECTED(after(node("yvar"))(Match.Result),
+   HasValue(EqualsCharSourceRange(Expected)));
+}
+
+TEST(RangeSelectorTest, AfterOpInPartOfMacroArg) {
+  StringRef Code = R"cc(
+#define ISNULL(x) x == nullptr
+int* f(int*);
+bool g() { int* y; return ISNULL(f(y)); }
+  )cc";
+
+  TestMatch Match =
+  matchCode(Code, declRefExpr(to(namedDecl(hasName("y".bind("yvar"));
+  int YVarLen = 1;
+  SourceLocation After = getSpellingLocAfter(Match.Result, "yvar", YVarLen);
+  CharSourceRange Expected = CharSourceRange::getCharRange(After, After);
+  EXPECT_THAT_EXPECTED(after(node("yvar"))(Match.Result),
+   HasValue(EqualsCharSourceRange(Expected)));
+}
+
 TEST(RangeSelectorTest, BetweenOp) {
   StringRef Code = R"cc(
 int f(int x, int y, int z) { return 3; }
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -116,11 +116,24 @@
 Expected SelectedRange = Selector(Result);
 if (!SelectedRange)
   return SelectedRange.takeError();
-if (SelectedRange->isCharRange())
-  return CharSourceRange::getCharRange(SelectedRange->getEnd());
-return CharSourceRange::getCharRange(Lexer::getLocForEndOfToken(
-SelectedRange->getEnd(), 0, Result.Context->getSourceManager(),
-Result.Context->getLangOpts()));
+SourceLocation End = SelectedRange->getEnd();
+if (SelectedRange->isTokenRange()) {
+  // We need to find the actual (exclusive) end location from which to
+  // create a new source range. However, that's not guaranteed to be valid,
+  // even if the token location itself is valid. So, we create a token range
+  // consisting only of the last token, then map that range back to the
+  // source file. If that succeeds, we have a valid location for the end of
+  // the generated range.
+  CharSourceRange Range = Lexer::makeFileCharRange(
+  CharSourceRange::getTokenRange(SelectedRange->getEnd()),
+  *Result.SourceManager, Result.Context->getLangOpts());
+  if (Range.isInvalid())
+return invalidArgumentError(
+"after: can't resolve sub-range to valid source range");
+  End = Range.getEnd();
+}
+
+return CharSourceRange::getCharRange(End);
   };
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89277: [clangd] Add $/dumpMemoryTree LSP extension

2020-10-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 298460.
kadircet added a comment.

- As discussed offline moving with compact version of the output, while 
preserving names starting with an `_` to be leaves.

This is also ready for an implementation-wise review now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89277/new/

https://reviews.llvm.org/D89277

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/test/memory_tree.test

Index: clang-tools-extra/clangd/test/memory_tree.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/memory_tree.test
@@ -0,0 +1,81 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void func() {}"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"$/dumpMemoryTree","params":{}}
+# CHECK:"id": 1,
+# CHECK-NEXT:   "jsonrpc": "2.0",
+# CHECK-NEXT:   "result": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}},
+# CHECK-NEXT: "clangd_server": {
+# CHECK-NEXT:   "_self": {{[0-9]+}},
+# CHECK-NEXT:   "_total": {{[0-9]+}},
+# CHECK-NEXT:   "dynamic_index": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}},
+# CHECK-NEXT: "main_file": {
+# CHECK-NEXT:   "_self": {{[0-9]+}},
+# CHECK-NEXT:   "_total": {{[0-9]+}},
+# CHECK-NEXT:   "index": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT: "{{.*}}main.cpp": {
+# CHECK-NEXT:   "_self": {{[0-9]+}},
+# CHECK-NEXT:   "_total": {{[0-9]+}},
+# CHECK-NEXT:   "references": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "relations": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   }
+# CHECK-NEXT: },
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   }
+# CHECK-NEXT: },
+# CHECK-NEXT: "preamble": {
+# CHECK-NEXT:   "_self": {{[0-9]+}},
+# CHECK-NEXT:   "_total": {{[0-9]+}},
+# CHECK-NEXT:   "index": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   }
+# CHECK-NEXT: }
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "tuscheduler": {
+# CHECK-NEXT: "{{.*}}main.cpp": {
+# CHECK-NEXT:   "_self": {{[0-9]+}},
+# CHECK-NEXT:   "_total": {{[0-9]+}},
+# CHECK-NEXT:   "ast": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "preamble": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   }
+# CHECK-NEXT: },
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   }
+# CHECK-NEXT: }
+# CHECK-NEXT:   }
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
+
Index: clang-tools-extra/clangd/ClangdLSPServer.h
===
--- clang-tools-extra/clangd/ClangdLSPServer.h
+++ clang-tools-extra/clangd/ClangdLSPServer.h
@@ -24,6 +24,7 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/JSON.h"
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -141,6 +142,27 @@
   void onSemanticTokens(const SemanticTokensParams &, Callback);
   void onSemanticTokensDelta(const SemanticTokensDeltaParams &,
  Callback);
+  /// This is a clangd extension. Provides a json tree representing memory usage
+  /// hierarchy. Keys starting with an underscore(_) represent leaves, e.g.
+  /// _total or _self for memory usage of whole subtree or only that specific
+  /// node in bytes. All other keys represents children. An example:
+  ///   {
+  /// "_self": 0,
+  /// "_total": 8,
+  /// "child1": {
+  ///

[PATCH] D89490: Introduce __attribute__((darwin_abi))

2020-10-15 Thread Adrien Guinet via Phabricator via cfe-commits
aguinet updated this revision to Diff 298461.
aguinet added a comment.

Update format + llvm tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89490/new/

https://reviews.llvm.org/D89490

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/Specifiers.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/darwin_abi.c
  clang/test/CodeGen/darwin_abi_empty_structs.cpp
  clang/test/CodeGen/darwin_abi_vaarg.c
  clang/test/CodeGen/debug-info-cc.c
  clang/test/CodeGenCXX/darwinabi-returnthis.cpp
  clang/tools/libclang/CXType.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/IR/CallingConv.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/Target/AArch64/AArch64CallingConvention.cpp
  llvm/lib/Target/AArch64/AArch64FastISel.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
  llvm/test/CodeGen/AArch64/darwin_abi.ll
  llvm/test/CodeGen/AArch64/darwin_abi_vararg.ll

Index: llvm/test/CodeGen/AArch64/darwin_abi_vararg.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/darwin_abi_vararg.ll
@@ -0,0 +1,39 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=aarch64-pc-linux | FileCheck %s
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-pc-linux"
+
+%struct.__va_list = type { i8*, i8*, i8*, i32, i32 }
+
+define dso_local aarch64_darwincc void @foo(i32 %n, ...) local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sub sp, sp, #48 // =48
+; CHECK-NEXT:stp x29, x30, [sp, #32] // 16-byte Folded Spill
+; CHECK-NEXT:add x29, sp, #32 // =32
+; CHECK-NEXT:add x8, x29, #16 // =16
+; CHECK-NEXT:mov x1, sp
+; CHECK-NEXT:str xzr, [sp, #24]
+; CHECK-NEXT:str x8, [sp]
+; CHECK-NEXT:bl vfoo
+; CHECK-NEXT:ldp x29, x30, [sp, #32] // 16-byte Folded Reload
+; CHECK-NEXT:add sp, sp, #48 // =48
+; CHECK-NEXT:ret
+entry:
+  %va = alloca %struct.__va_list, align 8
+  %0 = bitcast %struct.__va_list* %va to i8*
+  call void @llvm.va_start(i8* nonnull %0)
+  call void @vfoo(i32 %n, %struct.__va_list* nonnull %va) #1
+  call void @llvm.va_end(i8* nonnull %0)
+  ret void
+}
+
+declare void @llvm.va_start(i8*) #1
+
+declare dso_local void @vfoo(i32, %struct.__va_list*) local_unnamed_addr #0
+
+declare void @llvm.va_end(i8*) #1
+
+attributes #0 = { nounwind "disable-tail-calls"="false" "frame-pointer"="non-leaf" "target-cpu"="generic" }
+attributes #1 = { nounwind }
Index: llvm/test/CodeGen/AArch64/darwin_abi.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/darwin_abi.ll
@@ -0,0 +1,29 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=aarch64-pc-linux | FileCheck %s
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-pc-linux"
+
+define dso_local aarch64_darwincc signext i16 @f1(i16 signext %a) local_unnamed_addr #0 {
+; CHECK-LABEL: f1:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:add w8, w0, #1 // =1
+; CHECK-NEXT:sxth w0, w8
+; CHECK-NEXT:ret
+entry:
+  %add = add i16 %a, 1
+  ret i16 %add
+}
+
+define dso_local aarch64_darwincc zeroext i16 @f2(i16 zeroext %a) local_unnamed_addr #0 {
+; CHECK-LABEL: f2:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:add w8, w0, #1 // =1
+; CHECK-NEXT:and w0, w8, #0x
+; CHECK-NEXT:ret
+entry:
+  %add = add i16 %a, 1
+  ret i16 %add
+}
+
+attributes #0 = { norecurse nounwind readnone "disable-tail-calls"="false" "frame-pointer"="non-leaf" "target-cpu"="generic" }
Index: llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
===
--- llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
+++ llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
@@ -474,8 +474,8 @@
   uint64_t StackOffset = Handler.StackUsed;
   if (F.isVarArg()) {
 auto &Subtarget = MF.getSubtarget();
-if (!Subtarget.isTargetDarwin()) {
-// FIXME: we need to reimplement saveVarArgsRegisters from
+if (!Subtarget.isCallingConvDarwin(MF.getFunct

[PATCH] D89496: [Format/ObjC] Correctly handle base class with lightweight generics and protocol

2020-10-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: sammccall, MyDeveloperDay.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
benhamilton requested review of this revision.

ClangFormat does not correctly handle an Objective-C interface declaration
with both lightweight generics and a protocol conformance.

This simple example:

  @interface Foo : Bar  
  
  @end

means `Foo` extends `Bar` (a lightweight generic class whose type
parameter is `Baz`) and also conforms to the protocol `Blech`.

ClangFormat should not apply any changes to the above example, but
instead it currently formats it quite poorly:

  @interface Foo : Bar 
  
  
  @end
  

The bug is that `UnwrappedLineParser` assumes an open-angle bracket
after a base class name is a protocol list, but it can also be a
lightweight generic specification.

This diff fixes the bug by factoring out the logic to parse
lightweight generics so it can apply both to the declared class
as well as the base class.

Test Plan: New tests added. Ran tests with:

  % ninja FormatTests && ./tools/clang/unittests/Format/FormatTests
  Confirmed tests failed before diff and passed after diff.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89496

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTestObjC.cpp

Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -328,6 +328,18 @@
"+ (id)init;\n"
"@end");
 
+  verifyFormat("@interface Foo> : Xyzzy   {\n"
+   "  int _i;\n"
+   "}\n"
+   "+ (id)init;\n"
+   "@end");
+
+  verifyFormat("@interface Foo : Bar  \n"
+   "@end");
+
+  verifyFormat("@interface Foo : Bar  \n"
+   "@end");
+
   verifyFormat("@interface Foo (HackStuff) {\n"
"  int _i;\n"
"}\n"
@@ -413,6 +425,10 @@
"f,\n"
"f> {\n"
"}");
+  verifyFormat("@interface g\n"
+   ": g \n"
+   "  \n"
+   "@end");
 }
 
 TEST_F(FormatTestObjC, FormatObjCImplementation) {
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -118,6 +118,7 @@
   // parses the record as a child block, i.e. if the class declaration is an
   // expression.
   void parseRecord(bool ParseAsExpr = false);
+  void parseObjCLightweightGenerics();
   void parseObjCMethod();
   void parseObjCProtocolList();
   void parseObjCUntilAtEnd();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2612,32 +2612,15 @@
   // @interface can be followed by a lightweight generic
   // specialization list, then either a base class or a category.
   if (FormatTok->Tok.is(tok::less)) {
-// Unlike protocol lists, generic parameterizations support
-// nested angles:
-//
-// @interface Foo> :
-// NSObject 
-//
-// so we need to count how many open angles we have left.
-unsigned NumOpenAngles = 1;
-do {
-  nextToken();
-  // Early exit in case someone forgot a close angle.
-  if (FormatTok->isOneOf(tok::semi, tok::l_brace) ||
-  FormatTok->Tok.isObjCAtKeyword(tok::objc_end))
-break;
-  if (FormatTok->Tok.is(tok::less))
-++NumOpenAngles;
-  else if (FormatTok->Tok.is(tok::greater)) {
-assert(NumOpenAngles > 0 && "'>' makes NumOpenAngles negative");
---NumOpenAngles;
-  }
-} while (!eof() && NumOpenAngles != 0);
-nextToken(); // Skip '>'.
+parseObjCLightweightGenerics();
   }
   if (FormatTok->Tok.is(tok::colon)) {
 nextToken();
 nextToken(); // base class name
+// The base class can also have lightweight generics applied to it.
+if (FormatTok->Tok.is(tok::less)) {
+  parseObjCLightweightGenerics();
+}
   } else if (FormatTok->Tok.is(tok::l_paren))
 // Skip category, if present.
 parseParens();
@@ -2658,6 +2641,32 @@
   parseObjCUntilAtEnd();
 }
 
+void UnwrappedLineParser::parseObjCLightweightGenerics() {
+  assert(FormatTok->Tok.is(tok::less));
+  // Unlike protocol lists, generic parameterizations support
+  // nested angles:
+  //
+  // @interface Foo> :
+  // NSObject 
+  //
+  // so we need to count how many open angles we have left.
+  unsigned NumOpenAngles = 1;
+  do {
+nextToken();
+// Early exit in case someone forgot a close angle.
+if (FormatTok->isOneOf(tok::semi, tok::l_brace) ||
+  

  1   2   >