[PATCH] D99447: [OpenMP] Define omp_is_initial_device() variants in omp.h

2021-04-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG, thanks




Comment at: openmp/runtime/src/include/omp.h.var:479
+#   endif
+
 #   undef __KAI_KMPC_CONVENTION

hbae wrote:
> jdoerfert wrote:
> > Do we want them to be static? I would have expected odr linkage instead.
> > 
> > 
> > 
> Current clang fails to link two files that include omp.h, so I think we need 
> static here.
I would expect this to cause "unused function" warnings if you include omp.h.
That said, given that clang might be the only impl. so far for begin/end 
declare variant and it doesn't warn, we can go ahead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99447

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


[clang] 2458aa0 - Add missing override to clang tblgen AttrEmitter

2021-04-02 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-04-02T20:47:49-07:00
New Revision: 2458aa0b9136e7616f529b027d1d478cf699340f

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

LOG: Add missing override to clang tblgen AttrEmitter

Added: 


Modified: 
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index bddda1fe47f7..0d8439b697c8 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3677,7 +3677,7 @@ static void GenerateMutualExclusionsChecks(const Record 
,
   if (!DeclAttrs.empty()) {
 // Generate the ParsedAttrInfo subclass logic for declarations.
 OS << "  bool diagMutualExclusion(Sema , const ParsedAttr , "
-   << "const Decl *D) const {\n";
+   << "const Decl *D) const override {\n";
 for (const std::string  : DeclAttrs) {
   OS << "if (const auto *A = D->getAttr<" << A << ">()) {\n";
   OS << "  S.Diag(AL.getLoc(), 
diag::err_attributes_are_not_compatible)"
@@ -3714,7 +3714,7 @@ static void GenerateMutualExclusionsChecks(const Record 
,
   if (!StmtAttrs.empty()) {
 // Generate the ParsedAttrInfo subclass logic for statements.
 OS << "  bool diagMutualExclusion(Sema , const ParsedAttr , "
-   << "const Stmt *St) const {\n";
+   << "const Stmt *St) const override {\n";
 OS << "if (const auto *AS = dyn_cast(St)) {\n";
 OS << "  const ArrayRef  = AS->getAttrs();\n";
 for (const std::string  : StmtAttrs) {



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


[PATCH] D99225: [clang] tests: cleanup, update and add some new ones

2021-04-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 335055.
mizvekov added a comment.

Just rebased, removing trailing whitespace noise.

Other review points to be addressed later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99225

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-cxx14.cpp
  clang/test/CXX/special/class.copy/p3-cxx11.cpp
  clang/test/CXX/special/class.copy/p33-0x.cpp
  clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
  clang/test/CodeGen/nrvo-tracking.cpp
  clang/test/SemaCXX/P1155.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/constant-expression-cxx1y.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp
  clang/test/SemaCXX/return-stack-addr.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp

Index: clang/test/SemaCXX/warn-return-std-move.cpp
===
--- clang/test/SemaCXX/warn-return-std-move.cpp
+++ clang/test/SemaCXX/warn-return-std-move.cpp
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++20 -verify=cxx20 %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
 
 // definitions for std::move
 namespace std {
@@ -76,8 +78,8 @@
 Base test2() {
 Derived d2;
 return d2;  // e1
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
 }
 ConstructFromDerived test3() {
@@ -87,22 +89,22 @@
 ConstructFromBase test4() {
 Derived d4;
 return d4;  // e3
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
 }
 ConvertFromDerived test5() {
 Derived d5;
 return d5;  // e4
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
 }
 ConvertFromBase test6() {
 Derived d6;
 return d6;  // e5
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid 

[PATCH] D99826: [clang] NFC: remove trailing white spaces from some tests

2021-04-02 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbac74a50e99f: [clang] NFC: remove trailing white spaces from 
some tests (authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99826

Files:
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
  clang/test/CXX/special/class.copy/p33-0x.cpp
  clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp

Index: clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
===
--- clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
+++ clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
@@ -377,7 +377,7 @@
   return 5;
 }
 template operator T() { return T{}; }
-operator auto() { return _foo; } 
+operator auto() { return _foo; }
   };
   struct N : M {
 using M::foo;
@@ -385,7 +385,7 @@
 using M::static_foo;
 using M::operator auto;
   };
-  
+
   template  int test() {
 int i = T{}.foo(3);
 T m = T{}.foo(M{});
@@ -400,7 +400,7 @@
   }
   int Minst = test();
   int Ninst = test();
-  
+
 }
 }
 
@@ -451,11 +451,11 @@
 auto f(); // expected-note {{here}}
 int g() { return f(); } // expected-error {{cannot be used before it is defined}}
  #else
-auto f(); 
-int g() { return f(); } 
+auto f();
+int g() { return f(); }
  #endif
   };
- #ifndef DELAYED_TEMPLATE_PARSING 
+ #ifndef DELAYED_TEMPLATE_PARSING
   template int U::g(); // expected-note {{in instantiation of}}
  #else
   template int U::g();
Index: clang/test/SemaCXX/conversion-function.cpp
===
--- clang/test/SemaCXX/conversion-function.cpp
+++ clang/test/SemaCXX/conversion-function.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify %s 
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++98 %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++11 %s
 
-class X { 
+class X {
 public:
   operator bool();
   operator int() const;
@@ -31,11 +31,11 @@
   // expected-error{{conversion function cannot have any parameters}}
 
   operator bool(int a = 4, int b = 6) const; // expected-error{{conversion function cannot have any parameters}}
-  
-  
+
+
   operator float(...) const;  // expected-error{{conversion function cannot be variadic}}
-  
-  
+
+
   operator func_type(); // expected-error{{conversion function cannot convert to a function type}}
   operator array_type(); // expected-error{{conversion function cannot convert to an array type}}
 };
@@ -44,10 +44,10 @@
 typedef int INT;
 typedef INT* INT_PTR;
 
-class Z { 
+class Z {
   operator int(); // expected-note {{previous declaration is here}}
   operator int**(); // expected-note {{previous declaration is here}}
-  
+
   operator INT();  // expected-error{{conversion function cannot be redeclared}}
   operator INT_PTR*(); // expected-error{{conversion function cannot be redeclared}}
 };
@@ -103,12 +103,12 @@
 }
 
 // Test. Conversion in base class is visible in derived class.
-class XB { 
+class XB {
 public:
   operator int(); // expected-note {{candidate function}}
 };
 
-class Yb : public XB { 
+class Yb : public XB {
 public:
   operator char(); // expected-note {{candidate function}}
 };
@@ -124,11 +124,11 @@
 
 class AutoPtr {
   AutoPtr(AutoPtr &); // expected-note{{declared private here}}
-  
+
 public:
   AutoPtr();
   AutoPtr(AutoPtrRef);
-  
+
   operator AutoPtrRef();
 };
 
@@ -136,11 +136,11 @@
 
 AutoPtr test_auto_ptr(bool Cond) {
   AutoPtr p1( make_auto_ptr() );
-  
+
   AutoPtr p;
   if (Cond)
 return p; // expected-error{{calling a private constructor}}
-  
+
   return AutoPtr();
 }
 
@@ -185,7 +185,7 @@
 const A  = E();
   }
 
-  // Check 
+  // Check
   template
   struct E2 {
 operator T
@@ -212,7 +212,7 @@
 }
 
 namespace smart_ptr {
-  class Y { 
+  class Y {
 class YRef { };
 
 Y(Y&);
@@ -246,7 +246,7 @@
 };
 
 struct Other {
-  Other(const Other &); 
+  Other(const Other &);
   Other();
 };
 
@@ -289,7 +289,7 @@
   struct Y {
 Y(X);
   };
-  
+
   Y f2(foo());
 }
 
@@ -339,7 +339,7 @@
 
   struct Derived2 : Base { };
 
-  struct SuperDerived : Derived1, Derived2 { 
+  struct SuperDerived : Derived1, Derived2 {
 using Derived1::operator int;
   };
 
@@ -359,7 +359,7 @@
 operator int();
   };
 
-  struct Derived23 : Base2, Base3 { 
+  struct Derived23 : Base2, Base3 {
 

[clang] bac74a5 - [clang] NFC: remove trailing white spaces from some tests

2021-04-02 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2021-04-03T03:18:22+02:00
New Revision: bac74a50e99f3d014d6e5a67272fd3b20eeb7fed

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

LOG: [clang] NFC: remove trailing white spaces from some tests

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

Added: 


Modified: 
clang/test/CXX/drs/dr3xx.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
clang/test/CXX/special/class.copy/p33-0x.cpp
clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
clang/test/SemaCXX/conversion-function.cpp
clang/test/SemaCXX/cxx1y-deduced-return-type.cpp

Removed: 




diff  --git a/clang/test/CXX/drs/dr3xx.cpp b/clang/test/CXX/drs/dr3xx.cpp
index 5eb6e05126295..239a04c685d73 100644
--- a/clang/test/CXX/drs/dr3xx.cpp
+++ b/clang/test/CXX/drs/dr3xx.cpp
@@ -1103,7 +1103,7 @@ namespace dr384 { // dr384: yes
 }
 
 namespace dr385 { // dr385: yes
-  struct A { protected: void f(); }; 
+  struct A { protected: void f(); };
   struct B : A { using A::f; };
   struct C : A { void g(B b) { b.f(); } };
   void h(B b) { b.f(); }

diff  --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
index f2b0e26e29f94..95ae7f7588088 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
@@ -9,7 +9,7 @@ int  = [] (int r) -> decltype(auto) { return r; } (a); // 
expected-error {{can
 int  = [] (int r) -> decltype(auto) { return (r); } (a); // expected-warning 
{{reference to stack}}
 
 
-int test_explicit_auto_return() 
+int test_explicit_auto_return()
 {
 struct X {};
 auto L = [](auto F, auto a) { return F(a); };
@@ -18,32 +18,32 @@ int test_explicit_auto_return()
 auto MPtr = [](auto c) -> auto* { return  }; 
//expected-warning{{address of stack}}
 auto MDeclType = [](auto&& d) -> decltype(auto) { return 
static_cast(d); }; //OK
 M(3);
-
+
 auto & = MDeclType(X{});
 auto & = M(X{});
 auto & = MRef(X{});//expected-note{{in instantiation of}}
 auto & = MPtr(X{}); //expected-note{{in instantiation of}}
-return 0;
+return 0;
 }
 
-int test_implicit_auto_return() 
-{  
+int test_implicit_auto_return()
+{
   {
 auto M = [](auto a) { return a; };
 struct X {};
 X x = M(X{});
-
+
   }
 }
- 
+
 int test_multiple_returns()  {
-auto M = [](auto a) { 
+auto M = [](auto a) {
   bool k;
   if (k)
 return a;
   else
 return 5; //expected-error{{deduced as 'int' here}}
-}; 
+};
 M(3); // OK
 M('a'); //expected-note{{in instantiation of}}
   return 0;
@@ -60,7 +60,7 @@ int test_no_parameter_list()
 }
 
 int test_conditional_in_return() {
-  auto Fac = [](auto f, auto n) { 
+  auto Fac = [](auto f, auto n) {
 return n <= 0 ? n : f(f, n - 1) * n;
   };
   // FIXME: this test causes a recursive limit - need to error more gracefully.

diff  --git a/clang/test/CXX/special/class.copy/p33-0x.cpp 
b/clang/test/CXX/special/class.copy/p33-0x.cpp
index 28cd4f33a8aa6..ab6be4782e17d 100644
--- a/clang/test/CXX/special/class.copy/p33-0x.cpp
+++ b/clang/test/CXX/special/class.copy/p33-0x.cpp
@@ -22,7 +22,7 @@ void throw_move_only(X x) {
   throw x;
   throw x2;
 }
-  
+
 namespace PR10142 {
   struct X {
 X();

diff  --git a/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp 
b/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
index a41ea6b5e109e..10f4988ec5a73 100644
--- a/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
@@ -1,15 +1,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-struct A { 
+struct A {
   template  operator T*();
-}; 
+};
 
 template  A::operator T*() { return 0; }
 template <> A::operator char*(){ return 0; } // specialization
 template A::operator void*(); // explicit instantiation
 
-int main() { 
+int main() {
   A a;
-  int *ip; 
+  int *ip;
   ip = a.operator int*();
 }
 
@@ -33,7 +33,7 @@ namespace PR5742 {
 class Foo {
  public:
   template  operator T();
-  
+
   template 
   T As() {
 return this->operator T();
@@ -43,7 +43,7 @@ class Foo {
   T As2() {
 return operator T();
   }
-  
+
   int AsInt() {
 return this->operator int();
   }
@@ -58,9 +58,9 @@ struct X0 {
 T x = 1; // expected-note{{variable 'x' declared const here}}
 x = 17; // expected-error{{cannot assign to variable 'x' with 
const-qualified type 'const int'}}
   }
-  
+
   template operator T*() const; // expected-note{{explicit 
instantiation refers here}}
-  
+
   template operator const T*() const {
 T x = T();
 return x; // expected-error{{cannot initialize return object of type 
'const char *' with an lvalue of type 'char'}} \

diff  --git 

[PATCH] D99826: [clang] NFC: remove trailing white spaces from some tests

2021-04-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99826

Files:
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
  clang/test/CXX/special/class.copy/p33-0x.cpp
  clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp

Index: clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
===
--- clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
+++ clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
@@ -377,7 +377,7 @@
   return 5;
 }
 template operator T() { return T{}; }
-operator auto() { return _foo; } 
+operator auto() { return _foo; }
   };
   struct N : M {
 using M::foo;
@@ -385,7 +385,7 @@
 using M::static_foo;
 using M::operator auto;
   };
-  
+
   template  int test() {
 int i = T{}.foo(3);
 T m = T{}.foo(M{});
@@ -400,7 +400,7 @@
   }
   int Minst = test();
   int Ninst = test();
-  
+
 }
 }
 
@@ -451,11 +451,11 @@
 auto f(); // expected-note {{here}}
 int g() { return f(); } // expected-error {{cannot be used before it is defined}}
  #else
-auto f(); 
-int g() { return f(); } 
+auto f();
+int g() { return f(); }
  #endif
   };
- #ifndef DELAYED_TEMPLATE_PARSING 
+ #ifndef DELAYED_TEMPLATE_PARSING
   template int U::g(); // expected-note {{in instantiation of}}
  #else
   template int U::g();
Index: clang/test/SemaCXX/conversion-function.cpp
===
--- clang/test/SemaCXX/conversion-function.cpp
+++ clang/test/SemaCXX/conversion-function.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify %s 
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++98 %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++11 %s
 
-class X { 
+class X {
 public:
   operator bool();
   operator int() const;
@@ -31,11 +31,11 @@
   // expected-error{{conversion function cannot have any parameters}}
 
   operator bool(int a = 4, int b = 6) const; // expected-error{{conversion function cannot have any parameters}}
-  
-  
+
+
   operator float(...) const;  // expected-error{{conversion function cannot be variadic}}
-  
-  
+
+
   operator func_type(); // expected-error{{conversion function cannot convert to a function type}}
   operator array_type(); // expected-error{{conversion function cannot convert to an array type}}
 };
@@ -44,10 +44,10 @@
 typedef int INT;
 typedef INT* INT_PTR;
 
-class Z { 
+class Z {
   operator int(); // expected-note {{previous declaration is here}}
   operator int**(); // expected-note {{previous declaration is here}}
-  
+
   operator INT();  // expected-error{{conversion function cannot be redeclared}}
   operator INT_PTR*(); // expected-error{{conversion function cannot be redeclared}}
 };
@@ -103,12 +103,12 @@
 }
 
 // Test. Conversion in base class is visible in derived class.
-class XB { 
+class XB {
 public:
   operator int(); // expected-note {{candidate function}}
 };
 
-class Yb : public XB { 
+class Yb : public XB {
 public:
   operator char(); // expected-note {{candidate function}}
 };
@@ -124,11 +124,11 @@
 
 class AutoPtr {
   AutoPtr(AutoPtr &); // expected-note{{declared private here}}
-  
+
 public:
   AutoPtr();
   AutoPtr(AutoPtrRef);
-  
+
   operator AutoPtrRef();
 };
 
@@ -136,11 +136,11 @@
 
 AutoPtr test_auto_ptr(bool Cond) {
   AutoPtr p1( make_auto_ptr() );
-  
+
   AutoPtr p;
   if (Cond)
 return p; // expected-error{{calling a private constructor}}
-  
+
   return AutoPtr();
 }
 
@@ -185,7 +185,7 @@
 const A  = E();
   }
 
-  // Check 
+  // Check
   template
   struct E2 {
 operator T
@@ -212,7 +212,7 @@
 }
 
 namespace smart_ptr {
-  class Y { 
+  class Y {
 class YRef { };
 
 Y(Y&);
@@ -246,7 +246,7 @@
 };
 
 struct Other {
-  Other(const Other &); 
+  Other(const Other &);
   Other();
 };
 
@@ -289,7 +289,7 @@
   struct Y {
 Y(X);
   };
-  
+
   Y f2(foo());
 }
 
@@ -339,7 +339,7 @@
 
   struct Derived2 : Base { };
 
-  struct SuperDerived : Derived1, Derived2 { 
+  struct SuperDerived : Derived1, Derived2 {
 using Derived1::operator int;
   };
 
@@ -359,7 +359,7 @@
 operator int();
   };
 
-  struct Derived23 : Base2, Base3 { 
+  struct Derived23 : Base2, Base3 {
 using Base2::operator int;
   };
 
@@ -404,7 +404,7 @@
   {
 template
 operator Container()
-{ 
+{
   Container ar;
   T* i;
   ar[0]=*i;
Index: clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp

[PATCH] D99225: [clang] tests: cleanup, update and add some new ones

2021-04-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

@Quuxplusone Thank you for the review. All your points are good ones and will 
be addressed in time!

The new NRVO propagation `clang/test/CodeGen/nrvo-tracking.cpp` is also 
breaking on the buildbot, but it works on my machine.
Will also take a look at that one.




Comment at: clang/test/SemaCXX/conversion-function.cpp:160
+  return "Hello"; // cxx98_14-error {{calling a private constructor}}
 #if __cplusplus <= 199711L
   // expected-warning@-2 {{an accessible copy constructor}}

Quuxplusone wrote:
> When is this condition true?
> (Honestly I'm surprised that the `expected-warning` parser understands `#if` 
> in the first place.)
Too bad you can't also define macros for these expected declarations :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99225

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


[PATCH] D99225: [clang] tests: cleanup, update and add some new ones

2021-04-02 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

LGTM (just a bunch of style comments from me), but I think you'll have to get 
someone else's attention if you're expecting to get signoff from someone to 
land this.

I also think it would make sense for you to land the absolutely trivial 
trailing-whitespace diffs right now without review, and then rebase this PR on 
top, so that those trivial whitespace diffs don't show up as distractions in 
this review. (In case it's useful to anyone reading: I use detab -R 
 to strip trailing 
spaces and convert hard tabs.)




Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:1907-1908
   constexpr X *p = const_cast>*>();
-  static_assert(p->f() == sizeof(X), ""); // expected-error {{constant 
expression}} expected-note {{virtual function}}
+  static_assert(p->f() == sizeof(X), ""); // cxx11-error {{constant 
expression}} cxx11-note {{virtual function}}
+  // cxx20_2b-error@-1 {{static_assert failed}}
 

I guess you're keeping the existing style here, but the existing style is not 
great.

Incidentally, I don't understand why Clang's error message is so dramatically 
different between C++11 and C++14 modes — in C++14 through 20 we get 
"static_assert failed" but in C++11 it wants specifically to talk about that 
virtual function call.
https://godbolt.org/z/1e8nqTbsb



Comment at: clang/test/SemaCXX/constant-expression-cxx14.cpp:230
   constexpr bool check(D ) { return d.c.a.y == 3; }
+  // cxx20_2b-note@-1 {{read of member 'y' of union with active member 'x' is 
not allowed in a constant expression}}
 

Many of the existing snippets are IMHO too brief, but this new snippet was IMHO 
too verbose.



Comment at: clang/test/SemaCXX/constant-expression-cxx14.cpp:292-295
+  static_assert(++ref(false), ""); // cxx14-warning {{deprecated}}
+  // cxx20_2b-error@-1 {{ISO C++17 does not allow incrementing expression of 
type bool}}
+  static_assert(++ref(true), ""); // cxx14-warning {{deprecated}}
+  // cxx20_2b-error@-1 {{ISO C++17 does not allow incrementing expression of 
type bool}}

Here's an example of "existing too brief" //plus// "new too verbose." The most 
important snippet of the diagnostic actually doesn't change between 14 and 20!



Comment at: clang/test/SemaCXX/conversion-function.cpp:144
   if (Cond)
-return p; // expected-error{{calling a private constructor}}
-  
+return p; // cxx98_14-error{{calling a private constructor}}
+

Oh this is a fun one. I almost want to ask for a code comment here, but I 
suppose anyone who breaks this test should be prepared to do the archeology 
anyway. :)

Prior to C++20 this didn't consider using `AutoPtr(AutoPtrRef)` to construct 
the return value, and so the first overload resolution (as rvalue) failed to 
find any candidates, and the second overload resolution (as lvalue) found the 
private ctor. Then in C++20 and later, we //do// consider `AutoPtr(AutoPtrRef)` 
during the first overload resolution, and it works fine, so the second overload 
resolution never happens.



Comment at: clang/test/SemaCXX/conversion-function.cpp:160
+  return "Hello"; // cxx98_14-error {{calling a private constructor}}
 #if __cplusplus <= 199711L
   // expected-warning@-2 {{an accessible copy constructor}}

When is this condition true?
(Honestly I'm surprised that the `expected-warning` parser understands `#if` in 
the first place.)



Comment at: clang/test/SemaCXX/coroutine-rvo.cpp:41-45
 struct MoveOnly {
-  MoveOnly() {};
+  MoveOnly() = default;
   MoveOnly(const MoveOnly&) = delete;
-  MoveOnly(MoveOnly&&) noexcept {};
-  ~MoveOnly() {};
+  MoveOnly(MoveOnly &&) = default;
+};

This change makes `is_trivial_v` true, where before it was false.
I don't know whether this matters to the coroutine machinery. Ideally, 
@aaronpuchert would weigh in; I don't know, and am just raising the issue 
because it struck my attention.

(If it //does// matter, then maybe we even want to add test coverage for 
//both// the move-only-trivial case and the move-only-nontrivial case.)



Comment at: clang/test/SemaCXX/coroutine-rvo.cpp:144
+
+template_return_task param2template(MoveOnly value) {
+  co_return value; // We should deduce U = MoveOnly.

Nit: `return_template_task` or `generic_task` would look less confusingly like 
`template return_task...` at first glance. :)



Comment at: clang/test/SemaCXX/coroutines.cpp:1127
   CoroMemberTag test_qual(int *, const float &&, volatile void *volatile) 
const {
+// cxx20_2b-warning@-1 {{volatile-qualified parameter type 'volatile void 
*volatile' is deprecated}}
 auto TC = co_yield 0;

Nit: Here and below, I'd be briefer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  

[PATCH] D99821: [PGO, test] Fix typo in FileCheck var

2021-04-02 Thread Rong Xu via Phabricator via cfe-commits
xur accepted this revision.
xur 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/D99821/new/

https://reviews.llvm.org/D99821

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


[PATCH] D99696: [clang] WIP: NRVO: Improvements and handling of more cases.

2021-04-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 335045.
mizvekov added a comment.

Fixes for auto&, decltype(auto).
Exclude candidates from functions with dependent / undeduced return types which 
are references.
Adjusts the CodeGen tests from D99225 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGen/nrvo-tracking.cpp

Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -29,8 +29,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2l3v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 L(3, t, T);
@@ -45,8 +43,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2l5v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 L(5, t, auto);
@@ -61,8 +57,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2l7v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 L(7, t, decltype(auto));
@@ -113,8 +107,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2f5v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 F(5, t, auto);
@@ -129,8 +121,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2f7v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 F(7, t, decltype(auto));
@@ -152,19 +142,18 @@
   }; }()();\
 }
 
-//B(1, X); // Uncomment this line at your own peril ;)
+// CHECK-LABEL: define{{.*}} void @"___ZZ2b1v
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  ret void
+B(1, X);
 
 // CHECK-LABEL: define{{.*}} void @"___ZZ2b2v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 B(2, T);
 
 // CHECK-LABEL: define{{.*}} void @"___ZZ2b3v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 B(3, );
 
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1052,9 +1052,18 @@
  StartingScope, InstantiatingVarTemplate);
 
   if (D->isNRVOVariable()) {
-QualType ReturnType = cast(DC)->getReturnType();
-if (SemaRef.isCopyElisionCandidate(ReturnType, Var, Sema::CES_Strict))
-  Var->setNRVOVariable(true);
+QualType ReturnType;
+if (auto *F = dyn_cast(DC))
+  ReturnType = F->getReturnType();
+else if (auto *F = dyn_cast(DC))
+  // FIXME: get the return type here somehow...
+  ReturnType = SemaRef.Context.getAutoDeductType();
+else
+  assert(false && "Unknown context type");
+
+Sema::NRVOResult Res = SemaRef.getNRVOResult(Var);
+SemaRef.updNRVOResultWithRetType(Res, ReturnType);
+Var->setNRVOVariable(Res.isCopyElidable());
   }
 
   Var->setImplicit(D->isImplicit());
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3026,99 +3026,157 @@
   return new (Context) BreakStmt(BreakLoc);
 }
 
-/// Determine whether the given expression is a candidate for
-/// copy elision in either a return statement or a throw expression.
+static void downgradeNRVOResult(Sema::NRVOResult , bool CanMove) {
+  Res.S = Res.S != Sema::NRVOResult::None && CanMove
+  ? Sema::NRVOResult::MoveEligible
+  : Sema::NRVOResult::None;
+}
+
+/// Determine whether the given NRVO candidate variable is move-eligible or
+/// copy-elidable, without considering function return type.
 ///
-/// \param ReturnType If we're determining the copy elision candidate for
-/// a return statement, this is the return type of the function. If we're
-/// determining the copy elision candidate for a throw expression, this will
-/// be a NULL type.
+/// \param 

[PATCH] D99225: [clang] cxx tests: cleanup, update and add some new ones

2021-04-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 335044.
mizvekov added a comment.

Includes some new NRVO tests which will be used in D99696 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99225

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-cxx14.cpp
  clang/test/CXX/special/class.copy/p3-cxx11.cpp
  clang/test/CXX/special/class.copy/p33-0x.cpp
  clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
  clang/test/CodeGen/nrvo-tracking.cpp
  clang/test/SemaCXX/P1155.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/constant-expression-cxx1y.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp
  clang/test/SemaCXX/return-stack-addr.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp

Index: clang/test/SemaCXX/warn-return-std-move.cpp
===
--- clang/test/SemaCXX/warn-return-std-move.cpp
+++ clang/test/SemaCXX/warn-return-std-move.cpp
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++20 -verify=cxx20 %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -verify=expected %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
 
 // definitions for std::move
 namespace std {
@@ -76,8 +78,8 @@
 Base test2() {
 Derived d2;
 return d2;  // e1
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
 }
 ConstructFromDerived test3() {
@@ -87,22 +89,22 @@
 ConstructFromBase test4() {
 Derived d4;
 return d4;  // e3
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
 }
 ConvertFromDerived test5() {
 Derived d5;
 return d5;  // e4
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid copying}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
 }
 ConvertFromBase test6() {
 Derived d6;
 return d6;  // e5
-// expected-warning@-1{{will be copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
+// cxx11_17-warning@-1{{will be copied despite being returned by name}}
+// cxx11_17-note@-2{{to avoid 

[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D99517#2667088 , @rsmith wrote:

> In D99517#2667025 , @rjmccall wrote:
>
>> You should structure this code so it's easy to add exceptions for certain 
>> calling conventions that can support tail calls with weaker restrictions 
>> (principally, callee-pop conventions).  Mostly that probably means checking 
>> the calling convention first, or extracting the type restriction checks into 
>> a different function that you can skip.  For example, I believe x86's 
>> `fastcall` convention can logically support any combination of prototypes as 
>> `musttail` as long as the return types are vaguely compatible.
>
> The LLVM `musttail` flag doesn't seem to allow for any target-specific 
> loosening of the rules at the moment, so I don't think we can get any benefit 
> from such restructuring right now; do you think it's OK to defer this 
> restructuring and use the stricter rules across all targets for now?

Right, I wasn't suggesting that we needed to implement weaker rules right now, 
just that it'd be nice if the code didn't have to be totally restructured just 
to do it.  Right now it's one big function that does all the checks.

> I think there is also value in having a target-independent set of 
> restrictions, even if we could actually guarantee tail calls in more 
> circumstances on some (or maybe most!) targets, in order to allow people to 
> make portable use of the attribute and as data towards something that we 
> might be able to standardize. (For example, the people working on coroutines 
> in C++ wanted something like this, but wanted feedback from implementers on 
> what set of restrictions would be necessary in order to portably guarantee a 
> tail call.) In order to strike a balance between portability and usefulness 
> here, maybe we could plan to eventually accept any musttail call we know the 
> target can support, but warn on musttail calls that don't satisfy the 
> stricter rules and therefore may be non-portable?

I agree that we should not start loosening restrictions based on the vagaries 
of the platform CC, e.g. recognizing that a particular set of arguments happens 
to be passed solely in registers.  I was thinking about callee-pop CCs, like 
`fastcall` and `swiftasynccall`, which are generally designed from the start to 
support almost unrestricted tail calls; e.g. the only restriction on tail calls 
between `fastcall` functions is that the return types are compatible.  (IIRC — 
it's possible that highly-aligned arguments would change that.)  Since tail 
calls are part of the designed feature set of these conventions, it seems 
appropriate to think about them when adding a tail-call feature.

Standard C conventions generally don't support unrestricted tail calls (because 
of variadics, unprototyped calls, easier assembly-writing, and history), so 
this would only apply as a target-specific extension when used in conjunction 
with a non-standard CC, which meshes well with your goals for standardization.  
I just want you to write the code so that maintainers can more easily skip some 
of the restrictions to cover a non-standard CC.

I'm not surprised that the C++ coroutine people want unrestricted tail calls; 
this is all pretty predictable, and it's essentially the point I made about 
generic coroutine lowering several years ago at LLVM dev.  Really, they need to 
be asking for a standard calling convention that guarantees unrestricted tail 
calls.  Of course, that would require the standard to admit the existence of 
calling conventions (other than language linkage :)).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

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


[PATCH] D99821: [PGO, test] Fix typo in FileCheck var

2021-04-02 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added reviewers: bogner, xur, davidxl.
Herald added a subscriber: wenlei.
thopre requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99821

Files:
  clang/test/Profile/c-unreachable-after-switch.c


Index: clang/test/Profile/c-unreachable-after-switch.c
===
--- clang/test/Profile/c-unreachable-after-switch.c
+++ clang/test/Profile/c-unreachable-after-switch.c
@@ -11,5 +11,5 @@
 return;
   }
   // We shouldn't emit the unreachable counter. This used to crash in 
GlobalDCE.
-  // CHECK-NOT: store {{.*}} @[[SWC]], i64 0, i64 1}
+  // CHECK-NOT: store {{.*}} @[[C]], i64 0, i64 1}
 }


Index: clang/test/Profile/c-unreachable-after-switch.c
===
--- clang/test/Profile/c-unreachable-after-switch.c
+++ clang/test/Profile/c-unreachable-after-switch.c
@@ -11,5 +11,5 @@
 return;
   }
   // We shouldn't emit the unreachable counter. This used to crash in GlobalDCE.
-  // CHECK-NOT: store {{.*}} @[[SWC]], i64 0, i64 1}
+  // CHECK-NOT: store {{.*}} @[[C]], i64 0, i64 1}
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D99517#2667025 , @rjmccall wrote:

> You should structure this code so it's easy to add exceptions for certain 
> calling conventions that can support tail calls with weaker restrictions 
> (principally, callee-pop conventions).  Mostly that probably means checking 
> the calling convention first, or extracting the type restriction checks into 
> a different function that you can skip.  For example, I believe x86's 
> `fastcall` convention can logically support any combination of prototypes as 
> `musttail` as long as the return types are vaguely compatible.

The LLVM `musttail` flag doesn't seem to allow for any target-specific 
loosening of the rules at the moment, so I don't think we can get any benefit 
from such restructuring right now; do you think it's OK to defer this 
restructuring and use the stricter rules across all targets for now?

I think there is also value in having a target-independent set of restrictions, 
even if we could actually guarantee tail calls in more circumstances on some 
(or maybe most!) targets, in order to allow people to make portable use of the 
attribute and as data towards something that we might be able to standardize. 
(For example, the people working on coroutines in C++ wanted something like 
this, but wanted feedback from implementers on what set of restrictions would 
be necessary in order to portably guarantee a tail call.) In order to strike a 
balance between portability and usefulness here, maybe we could plan to 
eventually accept any musttail call we know the target can support, but warn on 
musttail calls that don't satisfy the stricter rules and therefore may be 
non-portable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

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


[PATCH] D99447: [OpenMP] Define omp_is_initial_device() variants in omp.h

2021-04-02 Thread Hansang Bae via Phabricator via cfe-commits
hbae added inline comments.



Comment at: openmp/runtime/src/include/omp.h.var:479
+#   endif
+
 #   undef __KAI_KMPC_CONVENTION

jdoerfert wrote:
> Do we want them to be static? I would have expected odr linkage instead.
> 
> 
> 
Current clang fails to link two files that include omp.h, so I think we need 
static here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99447

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


[PATCH] D99447: [OpenMP] Define omp_is_initial_device() variants in omp.h

2021-04-02 Thread Hansang Bae via Phabricator via cfe-commits
hbae updated this revision to Diff 335034.
hbae added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Removed omp_is_initial_device() from clang built-ins.
Added a new test under openmp/libomptarget.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99447

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/test/OpenMP/is_initial_device.c
  openmp/libomptarget/test/api/is_initial_device.c
  openmp/runtime/src/include/omp.h.var

Index: openmp/runtime/src/include/omp.h.var
===
--- openmp/runtime/src/include/omp.h.var
+++ openmp/runtime/src/include/omp.h.var
@@ -468,6 +468,15 @@
 /* OpenMP 5.1 Display Environment */
 extern void omp_display_env(int verbose);
 
+#   if defined(_OPENMP) && _OPENMP >= 201811
+#pragma omp begin declare variant match(device={kind(host)})
+static int omp_is_initial_device(void) { return 1; }
+#pragma omp end declare variant
+#pragma omp begin declare variant match(device={kind(nohost)})
+static int omp_is_initial_device(void) { return 0; }
+#pragma omp end declare variant
+#   endif
+
 #   undef __KAI_KMPC_CONVENTION
 #   undef __KMP_IMP
 
Index: openmp/libomptarget/test/api/is_initial_device.c
===
--- /dev/null
+++ openmp/libomptarget/test/api/is_initial_device.c
@@ -0,0 +1,25 @@
+// RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu
+
+#include 
+#include 
+
+int main() {
+  int host = omp_is_initial_device();
+  int device = 1;
+  int errors = 0;
+#pragma omp target map(tofrom : device)
+  { device = omp_is_initial_device(); }
+  if (!host) {
+printf("omp_is_initial_device() returned false on host\n");
+errors++;
+  }
+  if (device) {
+printf("omp_is_initial_device() returned true on device\n");
+errors++;
+  }
+
+  // CHECK: PASS
+  printf("%s\n", errors ? "FAIL" : "PASS");
+
+  return errors;
+}
Index: clang/test/OpenMP/is_initial_device.c
===
--- clang/test/OpenMP/is_initial_device.c
+++ /dev/null
@@ -1,41 +0,0 @@
-// REQUIRES: powerpc-registered-target
-
-// RUN: %clang_cc1 -verify -fopenmp -x c -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown \
-// RUN:-emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x ir -triple powerpc64le-unknown-unknown -emit-llvm \
-// RUN: %t-ppc-host.bc -o - | FileCheck %s -check-prefixes HOST,OUTLINED
-// RUN: %clang_cc1 -verify -fopenmp -x c -triple powerpc64le-unknown-unknown -emit-llvm -fopenmp-is-device \
-// RUN: %s -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s -check-prefixes DEVICE,OUTLINED
-
-// RUN: %clang_cc1 -verify -fopenmp-simd -x c -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp-simd -x ir -triple powerpc64le-unknown-unknown -emit-llvm %t-ppc-host.bc -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -x c -triple powerpc64le-unknown-unknown -emit-llvm -fopenmp-is-device %s -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
-
-// expected-no-diagnostics
-int check() {
-  int host = omp_is_initial_device();
-  int device;
-#pragma omp target map(tofrom: device)
-  {
-device = omp_is_initial_device();
-  }
-
-  return host + device;
-}
-
-// The host should get a value of 1:
-// HOST: define{{.*}} @check()
-// HOST: [[HOST:%.*]] = alloca i32
-// HOST: store i32 1, i32* [[HOST]]
-
-// OUTLINED: define{{.*}} @{{.*}}omp_offloading{{.*}}(i32*{{.*}} [[DEVICE_ARGUMENT:%.*]])
-// OUTLINED: [[DEVICE_ADDR_STORAGE:%.*]] = alloca i32*
-// OUTLINED: store i32* [[DEVICE_ARGUMENT]], i32** [[DEVICE_ADDR_STORAGE]]
-// OUTLINED: [[DEVICE_ADDR:%.*]] = load i32*, i32** [[DEVICE_ADDR_STORAGE]]
-
-// The outlined function that is called as fallback also runs on the host:
-// HOST: store i32 1, i32* [[DEVICE_ADDR]]
-
-// The device should get a value of 0:
-// DEVICE: store i32 0, i32* [[DEVICE_ADDR]]
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -12010,9 +12010,6 @@
 return BuiltinOp == Builtin::BI__atomic_always_lock_free ?
 Success(0, E) : Error(E);
   }
-  case Builtin::BIomp_is_initial_device:
-// We can decide statically which value the runtime would return if called.
-return Success(Info.getLangOpts().OpenMPIsDevice ? 0 : 1, E);
   case Builtin::BI__builtin_add_overflow:
   case Builtin::BI__builtin_sub_overflow:
   case Builtin::BI__builtin_mul_overflow:
Index: 

[PATCH] D99791: [CGCall] Annotate pointer argument with alignment

2021-04-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

This feels scary: the C standard technically allows this, but we haven't done 
it in the past, and it could break otherwise functioning code.  (We've only 
assumed alignment about pointers that are dereferenced/dereferenceable.)

For D99790 , we're already marking the pointer 
dereferenceable, so also marking the alignment seems like a small extra step.  
(Really, it's a regression fix; we used to treat dereferenceable as implying 
alignment. I guess I missed a spot when I was fixing that.)  But here, we're 
not assuming it's dereferenceable at the moment.  So there's more potential to 
break code, and also the potential benefit is small.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99791

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


[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a reviewer: varungandhi-apple.
rjmccall added a comment.

CC'ing Varun Gandhi.

Is `musttail` actually supported generically on all LLVM backends, or does this 
need a target restriction?

You should structure this code so it's easy to add exceptions for certain 
calling conventions that can support tail calls with weaker restrictions 
(principally, callee-pop conventions).  Mostly that probably means checking the 
calling convention first, or extracting the type restriction checks into a 
different function that you can skip.  For example, I believe x86's `fastcall` 
convention can logically support any combination of prototypes as `musttail` as 
long as the return types are vaguely compatible.




Comment at: clang/lib/CodeGen/CGCall.cpp:5318-5319
+  EHCleanupScope *Cleanup = dyn_cast(&*it);
+  assert(Cleanup && Cleanup->getCleanup()->isCallLifetimeEnd() &&
+ "found unexpected cleanup generating musttail exit");
+}

rsmith wrote:
> Given the potential for mismatch between the JumpDiagnostics checks and this 
> one, especially as new more exotic kinds of cleanup are added, I wonder if we 
> should use an `ErrorUnsupported` here instead of an `assert`.
> 
> I strongly suspect we can still reach the problematic case here for a tail 
> call in a statement expression. I don't think it's feasible to check for all 
> the ways that an arbitrary expression context can have pending cleanups, 
> which we'd need in order to produce precise `Sema` diagnostics for that, so 
> either we handle that here or we blanket reject all `musttail` returns in 
> statement expressions. I think either approach is probably acceptable.
Yes, I think ErrorUnsupported is a much better idea.



Comment at: clang/lib/Sema/SemaStmt.cpp:631
+// Caller is an Obj-C block decl: ^(void) { /* ... */ }
+assert(dyn_cast(CurContext) && "unexpected decl context");
+Diag(St->getBeginLoc(), diag::err_musttail_from_block_forbidden) << 

rsmith wrote:
> There are a couple of other contexts that can include a return statement: the 
> caller could also be an `ObjCMethodDecl` (an Objective-C method) or a 
> `CapturedDecl` (the body of a `#pragma omp` parallel region). I'd probably 
> use a specific diagnostic ("cannot be used from a block" / "cannot be used 
> from an Objective-C function") for the block and ObjCMethod case, and a 
> nonsepcific-but-correct "cannot be used from this context" for anything else.
Blocks ought to be extremely straightforward to support.  Just validate that 
the tail call is to a block pointer and then compare the underlying function 
types line up in the same way.  You will need to be able to verify that there 
isn't a non-trivial conversion on the return types, even if the return type 
isn't known at this point in the function, but that's a problem in C++ as well 
due to lambdas and `auto` deduced return types.

Also, you can use `isa<...>` for checks like this instead of `dyn_cast<...>`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

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


Re: [clang] 9320ac9 - [Clang] Only run test when X86 backend is built.

2021-04-02 Thread David Blaikie via cfe-commits
On Thu, Apr 1, 2021 at 1:29 PM Florian Hahn  wrote:
>
>
>
> On Thu, Apr 1, 2021 at 8:11 PM David Blaikie  wrote:
>>
>> On Thu, Apr 1, 2021 at 1:16 AM Florian Hahn  wrote:
>> >
>> > Hi,
>> >
>> > On Tue, Mar 30, 2021 at 7:52 PM David Blaikie  wrote:
>> >>
>> >> Is there a more reliable remark that could be tested for? (Clang 
>> >> shouldn't be testing all remarks - just that the remark infrastructure in 
>> >> general is wired up (specific remarks should be tested in llvm) - so 
>> >> picking some really stable remark would be great)
>> >>
>> >> maybe there's a remark for "this always_inline thing can't be inlined 
>> >> because it's recursive" for instance?
>> >>
>> >
>> > That's a great point, there certainly are more stable remarks, e.g. 
>> > inlining as you suggested or GVN. I can add a separate test for that, so 
>> > we can still keep testing the vectorization remark. WDYT?
>>
>> Actually my goal was to stop testing the vectorization remark in
>> clang, if it's not an especially stable remark - the remark should be
>> tested in LLVM in any case (even if it's also tested in Clang). So
>> ideally we'd test some really simple, stable, reliable remark in clang
>> that validates that the remark infrastructure works with clang - and
>> we'd test all the nitty gritty specific remarks down in LLVM only.
>
>
> Ah, got it!
>
> I think this test specifically tests the vectorization remark, because Clang 
> adds some extra information to the remark. I'm not really familiar with the 
> code myself, but the suggestion about using the pragma is Clang specific I 
> think. Some of the relevant code should be 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenAction.cpp#L751

Ah, thanks for explaining/pointing that out - that does complicate
things. Yeah, that invalidates my suggestion/not sure how to stabilize
the test and make it more portable/reliable - short of writing a mock
LLVM pass that is just designed for testing clang by being able to be
configured to emit certain remarks, but that's likely overkill.

Thanks for helping me understand!

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


[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:5315-5317
+// TODO(haberman): insert checks/assertions to verify that this early exit
+// is safe. We tried to verify this in Sema but we should double-check
+// here.

rsmith wrote:
> haberman wrote:
> > rsmith wrote:
> > > haberman wrote:
> > > > aaron.ballman wrote:
> > > > > Are you planning to handle this TODO in the patch? If not, can you 
> > > > > switch to a FIXME without a name associated with it?
> > > > I am interested in feedback on the best way to proceed here.
> > > > 
> > > >   - Is my assessment correct that we should have an assertion that 
> > > > validates this?
> > > >   - Is such an assertion reasonably feasible to implement?
> > > >   - Is it ok to defer with FIXME, or should I try to fix it in this 
> > > > patch?
> > > > 
> > > > I've changed it to a FIXME for now.
> > > Yes, I think we should validate this by an assertion if we can. We can 
> > > check this by walking the cleanup scope stack (walk from 
> > > `CurrentCleanupScopeDepth` to `EHScopeStack::stable_end()`) and making 
> > > sure that there is no "problematic" enclosing cleanup scope. Here, 
> > > "problematic" would mean any scope other than an `EHCleanupScope` 
> > > containing only `CallLifetimeEnd` cleanups.
> > > 
> > > Looking at the kinds of cleanups that we might encounter here, I think 
> > > there may be a few more things that Sema needs to check in order to not 
> > > get in the way of exception handling. In particular, I think we should 
> > > reject if the callee is potentially-throwing and the musttail call is 
> > > inside a try block or a function that's either noexcept or has a dynamic 
> > > exception specification.
> > > 
> > > Oh, also, we should disallow musttail calls inside statement expressions, 
> > > in order to defend against cleanups that exist transiently within an 
> > > expression.
> > I'm having trouble implementing the check because there doesn't appear to 
> > be any discriminator in `EHScopeStack::Cleanup` that will let you test if 
> > it is a `CallLifetimeEnd`. (The actual code just does virtual dispatch 
> > through `EHScopeStack::Cleanup::Emit()`.
> > 
> > I temporarily implemented this by adding an extra virtual function to act 
> > as discriminator. The check fires if a VLA is in scope:
> > 
> > ```
> > int Func14(int x) {
> >   int vla[x];
> >   [[clang::musttail]] return Bar(x);
> > }
> > ```
> > 
> > Do we need to forbid VLAs or do I need to refine the check?
> > 
> > It appears that `JumpDiagnostics.cpp` is already diagnosing statement 
> > expressions and `try`. However I could not get testing to work. I tried 
> > adding a test with `try`  but even with `-fexceptions` I am getting:
> > 
> > ```
> > cannot use 'try' with exceptions disabled
> > ```
> > Do we need to forbid VLAs or do I need to refine the check?
> 
> Assuming that LLVM supports musttail calls from functions where a dynamic 
> alloca is in scope, I think we should allow VLAs. The `musttail` 
> documentation doesn't mention this, so I think its OK, and I can't think of a 
> good reason why you wouldn't be able to `musttail` call due to a 
> variably-sized frame.
> 
> Perhaps a good model would be to add a virtual function to permit asking a 
> cleanup whether it's optional / skippable.
> 
> > I could not get testing to work.
> 
> You need `-fcxx-exceptions` to use `try`. At the `-cc1` level, we have 
> essentially-orthogonal settings for "it's valid for exceptions to unwind 
> through this code" (`-fexceptions`) and "C++ exception handling syntax is 
> permitted" (`-fcxx-exceptions`), and you usually need to enable both for 
> CodeGen tests involving exceptions.
Or maybe instead of "is optional / skippable", the right question is, "is this 
redundant if we're about to return?" That way we could potentially one day 
reuse the same mechanism to also skip emitting such cleanups when emitting a 
cleanup path into the return block.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

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


[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks, I think this is looking really good.

@rjmccall, no explicit need to review; I just wanted to make sure you'd seen 
this and had a chance to express any concerns before we go ahead.




Comment at: clang/include/clang/Basic/AttrDocs.td:452
+optimizations are disabled. This guarantees that the call will not cause
+unbounded stack growth if it is part of a recursive cycle in the call graph.
+

One thing I'd add:

> If the callee is a virtual function that is implemented by a thunk, there is 
> no guarantee in general that the thunk tail-calls the implementation of the 
> virtual function, so such a call in a recursive cycle can still result in 
> unbounded stack growth.



Comment at: clang/lib/CodeGen/CGCall.cpp:5318-5319
+  EHCleanupScope *Cleanup = dyn_cast(&*it);
+  assert(Cleanup && Cleanup->getCleanup()->isCallLifetimeEnd() &&
+ "found unexpected cleanup generating musttail exit");
+}

Given the potential for mismatch between the JumpDiagnostics checks and this 
one, especially as new more exotic kinds of cleanup are added, I wonder if we 
should use an `ErrorUnsupported` here instead of an `assert`.

I strongly suspect we can still reach the problematic case here for a tail call 
in a statement expression. I don't think it's feasible to check for all the 
ways that an arbitrary expression context can have pending cleanups, which we'd 
need in order to produce precise `Sema` diagnostics for that, so either we 
handle that here or we blanket reject all `musttail` returns in statement 
expressions. I think either approach is probably acceptable.



Comment at: clang/lib/CodeGen/CGCall.cpp:5315-5317
+// TODO(haberman): insert checks/assertions to verify that this early exit
+// is safe. We tried to verify this in Sema but we should double-check
+// here.

haberman wrote:
> rsmith wrote:
> > haberman wrote:
> > > aaron.ballman wrote:
> > > > Are you planning to handle this TODO in the patch? If not, can you 
> > > > switch to a FIXME without a name associated with it?
> > > I am interested in feedback on the best way to proceed here.
> > > 
> > >   - Is my assessment correct that we should have an assertion that 
> > > validates this?
> > >   - Is such an assertion reasonably feasible to implement?
> > >   - Is it ok to defer with FIXME, or should I try to fix it in this patch?
> > > 
> > > I've changed it to a FIXME for now.
> > Yes, I think we should validate this by an assertion if we can. We can 
> > check this by walking the cleanup scope stack (walk from 
> > `CurrentCleanupScopeDepth` to `EHScopeStack::stable_end()`) and making sure 
> > that there is no "problematic" enclosing cleanup scope. Here, "problematic" 
> > would mean any scope other than an `EHCleanupScope` containing only 
> > `CallLifetimeEnd` cleanups.
> > 
> > Looking at the kinds of cleanups that we might encounter here, I think 
> > there may be a few more things that Sema needs to check in order to not get 
> > in the way of exception handling. In particular, I think we should reject 
> > if the callee is potentially-throwing and the musttail call is inside a try 
> > block or a function that's either noexcept or has a dynamic exception 
> > specification.
> > 
> > Oh, also, we should disallow musttail calls inside statement expressions, 
> > in order to defend against cleanups that exist transiently within an 
> > expression.
> I'm having trouble implementing the check because there doesn't appear to be 
> any discriminator in `EHScopeStack::Cleanup` that will let you test if it is 
> a `CallLifetimeEnd`. (The actual code just does virtual dispatch through 
> `EHScopeStack::Cleanup::Emit()`.
> 
> I temporarily implemented this by adding an extra virtual function to act as 
> discriminator. The check fires if a VLA is in scope:
> 
> ```
> int Func14(int x) {
>   int vla[x];
>   [[clang::musttail]] return Bar(x);
> }
> ```
> 
> Do we need to forbid VLAs or do I need to refine the check?
> 
> It appears that `JumpDiagnostics.cpp` is already diagnosing statement 
> expressions and `try`. However I could not get testing to work. I tried 
> adding a test with `try`  but even with `-fexceptions` I am getting:
> 
> ```
> cannot use 'try' with exceptions disabled
> ```
> Do we need to forbid VLAs or do I need to refine the check?

Assuming that LLVM supports musttail calls from functions where a dynamic 
alloca is in scope, I think we should allow VLAs. The `musttail` documentation 
doesn't mention this, so I think its OK, and I can't think of a good reason why 
you wouldn't be able to `musttail` call due to a variably-sized frame.

Perhaps a good model would be to add a virtual function to permit asking a 
cleanup whether it's optional / skippable.

> I could not get testing to work.

You need `-fcxx-exceptions` to use `try`. At the `-cc1` level, we have 

[clang] 0fe8af9 - Fix build bot problem with missing OMPC_novariants in switch.

2021-04-02 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2021-04-02T13:58:39-07:00
New Revision: 0fe8af94688aa03c01913c2001d6a1a911f42ce6

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

LOG: Fix build bot problem with missing OMPC_novariants in switch.

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 02d4f6b3c315..acc3261a1fe6 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -5612,6 +5612,7 @@ static void emitOMPAtomicExpr(CodeGenFunction , 
OpenMPClauseKind Kind,
   case OMPC_notinbranch:
   case OMPC_link:
   case OMPC_use:
+  case OMPC_novariants:
 llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
 }



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


[PATCH] D99809: Use tablegen to diagnose mutually exclusive attributes

2021-04-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Committed in 4be8a26951da9a6e04de327b38dd158f4c8e3280 



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

https://reviews.llvm.org/D99809

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


[PATCH] D99809: Use tablegen to diagnose mutually exclusive attributes

2021-04-02 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.

Accepting on my own authority so I can close in a moment.


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

https://reviews.llvm.org/D99809

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


[clang] 4be8a26 - Use tablegen to diagnose mutually exclusive attributes

2021-04-02 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-04-02T16:34:42-04:00
New Revision: 4be8a26951da9a6e04de327b38dd158f4c8e3280

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

LOG: Use tablegen to diagnose mutually exclusive attributes

Currently, when one or more attributes are mutually exclusive, the
developer adding the attribute has to manually emit diagnostics. In
practice, this is highly error prone, especially for declaration
attributes, because such checking is not trivial. Redeclarations
require you to write a "merge" function to diagnose mutually exclusive
attributes and most attributes get this wrong.

This patch introduces a table-generated way to specify that a group of
two or more attributes are mutually exclusive:

def : MutualExclusions<[Attr1, Attr2, Attr3]>;

This works for both statement and declaration attributes (but not type
attributes) and the checking is done either from the common attribute
diagnostic checking code or from within mergeDeclAttribute() when
merging redeclarations.

Added: 


Modified: 
clang/docs/InternalsManual.rst
clang/include/clang/Basic/Attr.td
clang/include/clang/Sema/ParsedAttr.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/ParsedAttr.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaStmtAttr.cpp
clang/test/Sema/attr-coldhot.c
clang/test/Sema/attr-disable-tail-calls.c
clang/test/Sema/internal_linkage.c
clang/test/SemaCXX/attr-speculative-load-hardening.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index a547154721e9..c1e45569a816 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -3033,6 +3033,13 @@ If additional functionality is desired for the semantic 
form of the attribute,
 the ``AdditionalMembers`` field specifies code to be copied verbatim into the
 semantic attribute class object, with ``public`` access.
 
+If two or more attributes cannot be used in combination on the same declaration
+or statement, a ``MutualExclusions`` definition can be supplied to 
automatically
+generate diagnostic code. This will disallow the attribute combinations
+regardless of spellings used. Additionally, it will diagnose combinations 
within
+the same attribute list, 
diff erent attribute list, and redeclarations, as
+appropriate.
+
 Boilerplate
 ^^^
 All semantic processing of declaration attributes happens in 
`lib/Sema/SemaDeclAttr.cpp

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index b832d1df7172..d9c2422536d0 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -554,6 +554,11 @@ class Attr {
   list Documentation;
 }
 
+/// Used to define a set of mutually exclusive attributes.
+class MutualExclusions Ex> {
+  list Exclusions = Ex;
+}
+
 /// A type attribute is not processed on a declaration or a statement.
 class TypeAttr : Attr;
 
@@ -918,6 +923,7 @@ def CFAuditedTransfer : InheritableAttr {
   let Spellings = [Clang<"cf_audited_transfer">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
+  let SimpleHandler = 1;
 }
 
 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
@@ -927,7 +933,9 @@ def CFUnknownTransfer : InheritableAttr {
   let Spellings = [Clang<"cf_unknown_transfer">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
+  let SimpleHandler = 1;
 }
+def : MutualExclusions<[CFAuditedTransfer, CFUnknownTransfer]>;
 
 def CFReturnsRetained : InheritableAttr {
   let Spellings = [Clang<"cf_returns_retained">];
@@ -1009,6 +1017,7 @@ def Cold : InheritableAttr {
   let Spellings = [GCC<"cold">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [Undocumented];
+  let SimpleHandler = 1;
 }
 
 def Common : InheritableAttr {
@@ -1094,6 +1103,7 @@ def CUDADeviceBuiltinSurfaceType : InheritableAttr {
   let Subjects = SubjectList<[CXXRecord]>;
   let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs];
   let MeaningfulToClassTemplateDefinition = 1;
+  let SimpleHandler = 1;
 }
 
 def CUDADeviceBuiltinTextureType : InheritableAttr {
@@ -1103,7 +1113,10 @@ def CUDADeviceBuiltinTextureType : InheritableAttr {
   let Subjects = SubjectList<[CXXRecord]>;
   let Documentation = [CUDADeviceBuiltinTextureTypeDocs];
   let MeaningfulToClassTemplateDefinition = 1;
+  let SimpleHandler = 1;
 }
+def : MutualExclusions<[CUDADeviceBuiltinSurfaceType,
+CUDADeviceBuiltinTextureType]>;
 
 def CUDAGlobal : InheritableAttr {
   let Spellings = [GNU<"global">, Declspec<"__global__">];
@@ -,13 +1124,16 @@ 

[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 closed this revision.
jyu2 added a comment.

cb424fee3d6b27dbd38de666382b702100935286 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[clang] cb424fe - [OPENMP5.1]Initial support for novariants clause.

2021-04-02 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2021-04-02T13:19:01-07:00
New Revision: cb424fee3d6b27dbd38de666382b702100935286

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

LOG: [OPENMP5.1]Initial support for novariants clause.
Added basic parsing/sema/serialization support for the 'novariants' clause.

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/dispatch_ast_print.cpp
clang/test/OpenMP/dispatch_messages.cpp
clang/tools/libclang/CIndex.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index f71eb15feea2..4d5cdffba891 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7649,6 +7649,77 @@ class OMPDestroyClause final : public OMPClause {
   }
 };
 
+/// This represents 'novariants' clause in the '#pragma omp ...' directive.
+///
+/// \code
+/// #pragma omp dispatch novariants(a > 5)
+/// \endcode
+/// In this example directive '#pragma omp dispatch' has simple 'novariants'
+/// clause with condition 'a > 5'.
+class OMPNovariantsClause final : public OMPClause,
+  public OMPClauseWithPreInit {
+  friend class OMPClauseReader;
+
+  /// Location of '('.
+  SourceLocation LParenLoc;
+
+  /// Condition of the 'if' clause.
+  Stmt *Condition = nullptr;
+
+  /// Set condition.
+  void setCondition(Expr *Cond) { Condition = Cond; }
+
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+
+public:
+  /// Build 'novariants' clause with condition \a Cond.
+  ///
+  /// \param Cond Condition of the clause.
+  /// \param HelperCond Helper condition for the construct.
+  /// \param CaptureRegion Innermost OpenMP region where expressions in this
+  /// clause must be captured.
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  OMPNovariantsClause(Expr *Cond, Stmt *HelperCond,
+  OpenMPDirectiveKind CaptureRegion,
+  SourceLocation StartLoc, SourceLocation LParenLoc,
+  SourceLocation EndLoc)
+  : OMPClause(llvm::omp::OMPC_novariants, StartLoc, EndLoc),
+OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond) {
+setPreInitStmt(HelperCond, CaptureRegion);
+  }
+
+  /// Build an empty clause.
+  OMPNovariantsClause()
+  : OMPClause(llvm::omp::OMPC_novariants, SourceLocation(),
+  SourceLocation()),
+OMPClauseWithPreInit(this) {}
+
+  /// Returns the location of '('.
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+
+  /// Returns condition.
+  Expr *getCondition() const { return cast_or_null(Condition); }
+
+  child_range children() { return child_range(,  + 1); }
+
+  const_child_range children() const {
+return const_child_range(,  + 1);
+  }
+
+  child_range used_children();
+  const_child_range used_children() const {
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == llvm::omp::OMPC_novariants;
+  }
+};
+
 /// This represents 'detach' clause in the '#pragma omp task' directive.
 ///
 /// \code

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 23864819bc07..cdedbe22f9ed 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3218,6 +3218,14 @@ bool 
RecursiveASTVisitor::VisitOMPDestroyClause(OMPDestroyClause *C) {
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPNovariantsClause(
+OMPNovariantsClause *C) {
+  TRY_TO(VisitOMPClauseWithPreInit(C));
+  TRY_TO(TraverseStmt(C->getCondition()));
+  return true;
+}
+
 template 
 template 
 bool RecursiveASTVisitor::VisitOMPClauseList(T *Node) {

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b5c8d3d292fc..5f514d5f6a1d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11017,7 +11017,11 @@ class Sema final {
   SourceLocation LParenLoc,

[PATCH] D99809: Use tablegen to diagnose mutually exclusive attributes

2021-04-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 335021.
aaron.ballman added a comment.

Correcting lint warnings, adding documentation for the new feature.


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

https://reviews.llvm.org/D99809

Files:
  clang/docs/InternalsManual.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/ParsedAttr.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/Sema/attr-coldhot.c
  clang/test/Sema/attr-disable-tail-calls.c
  clang/test/Sema/internal_linkage.c
  clang/test/SemaCXX/attr-speculative-load-hardening.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3627,6 +3627,114 @@
   }
 }
 
+// Generates the mutual exclusion checks. The checks for parsed attributes are
+// written into OS and the checks for merging declaration attributes are
+// written into MergeOS.
+static void GenerateMutualExclusionsChecks(const Record ,
+   const RecordKeeper ,
+   raw_ostream ,
+   raw_ostream ) {
+  // Find all of the definitions that inherit from MutualExclusions and include
+  // the given attribute in the list of exclusions to generate the
+  // diagMutualExclusion() check.
+  std::vector ExclusionsList =
+  Records.getAllDerivedDefinitions("MutualExclusions");
+
+  // We don't do any of this magic for type attributes yet.
+  if (Attr.isSubClassOf("TypeAttr"))
+return;
+
+  // This means the attribute is either a statement attribute or a decl
+  // attribute, find out which.
+  bool CurAttrIsStmtAttr =
+  Attr.isSubClassOf("StmtAttr") || Attr.isSubClassOf("DeclOrStmtAttr");
+
+  std::vector DeclAttrs, StmtAttrs;
+
+  for (const Record *Exclusion : ExclusionsList) {
+std::vector MutuallyExclusiveAttrs =
+Exclusion->getValueAsListOfDefs("Exclusions");
+auto IsCurAttr = [Attr](const Record *R) {
+  return R->getName() == Attr.getName();
+};
+if (llvm::any_of(MutuallyExclusiveAttrs, IsCurAttr)) {
+  // This list of exclusions includes the attribute we're looking for, so
+  // add the exclusive attributes to the proper list for checking.
+  for (const Record *AttrToExclude : MutuallyExclusiveAttrs) {
+if (IsCurAttr(AttrToExclude))
+  continue;
+
+if (CurAttrIsStmtAttr)
+  StmtAttrs.push_back((AttrToExclude->getName() + "Attr").str());
+else
+  DeclAttrs.push_back((AttrToExclude->getName() + "Attr").str());
+  }
+}
+  }
+
+  // If we discovered any decl or stmt attributes to test for, generate the
+  // predicates for them now.
+  if (!DeclAttrs.empty()) {
+// Generate the ParsedAttrInfo subclass logic for declarations.
+OS << "  bool diagMutualExclusion(Sema , const ParsedAttr , "
+   << "const Decl *D) const {\n";
+for (const std::string  : DeclAttrs) {
+  OS << "if (const auto *A = D->getAttr<" << A << ">()) {\n";
+  OS << "  S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible)"
+ << " << AL << A;\n";
+  OS << "  S.Diag(A->getLocation(), diag::note_conflicting_attribute);";
+  OS << "  \nreturn false;\n";
+  OS << "}\n";
+}
+OS << "return true;\n";
+OS << "  }\n\n";
+
+// Also generate the declaration attribute merging logic if the current
+// attribute is one that can be inheritted on a declaration. It is assumed
+// this code will be executed in the context of a function with parameters:
+// Sema , Decl *D, Attr *A and that returns a bool (false on diagnostic,
+// true on success).
+if (Attr.isSubClassOf("InheritableAttr")) {
+  MergeOS << "  if (const auto *Second = dyn_cast<"
+  << (Attr.getName() + "Attr").str() << ">(A)) {\n";
+  for (const std::string  : DeclAttrs) {
+MergeOS << "if (const auto *First = D->getAttr<" << A << ">()) {\n";
+MergeOS << "  S.Diag(First->getLocation(), "
+<< "diag::err_attributes_are_not_compatible) << First << "
+<< "Second;\n";
+MergeOS << "  S.Diag(Second->getLocation(), "
+<< "diag::note_conflicting_attribute);\n";
+MergeOS << "  return false;\n";
+MergeOS << "}\n";
+  }
+  MergeOS << "return true;\n";
+  MergeOS << "  }\n";
+}
+  }
+  if (!StmtAttrs.empty()) {
+// Generate the ParsedAttrInfo subclass logic for statements.
+OS << "  bool diagMutualExclusion(Sema , const ParsedAttr , "
+   << "const Stmt *St) const {\n";
+OS << "if (const auto *AS = dyn_cast(St)) 

[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@steakhal thanks for the approval.




Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:564-565
   }
-
-  llvm_unreachable("Unknown SVal kind");
 }

steakhal wrote:
> You probably don't want to remove this. The same applies to similar ones.
Yep. I'd keep it here, beacuse of compiler warnings of no-return function.


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

https://reviews.llvm.org/D96090

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


[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@vsavchenko FYI.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:112-113
+RangeSet RangeSet::Factory::add(RangeSet LHS, RangeSet RHS) {
+  if (LHS.isEmpty())
+return RHS;
+  for (const Range  : RHS)

Also optimized this particular case.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:138-139
 
-  return makePersistent(std::move(Result));
-}
+  if (!Original.pin(From, To))
+return getEmptySet();
 

This allows to add a RangeSet of any type. E.g. RangeSet(uchar) + RangeSet(int) 
= valid, because of `pin`

I'm wondering whether we really need it here in practice?



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:166
 RawRangeSet RawExpected) {
-wrap(::checkAddImpl, RawRHS, RawLHS, RawExpected);
+wrap(::checkAddImpl, RawLHS, RawRHS, RawExpected);
   }

Fixed the misprint.


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

https://reviews.llvm.org/D99797

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/test/CodeGen/matrix-cast.c:15
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4

fhahn wrote:
> SaurabhJha wrote:
> > fhahn wrote:
> > > This doesn't seem right. We are casting between 2 signed types, so the 
> > > sign should get preserved, right? Shouldn't this be `sext`? See 
> > > https://godbolt.org/z/zWznYdnKW for the scalar case.
> > > 
> > > I think you also need tests for casts with different bitwidths with 
> > > unsigned, unsigned -> signed & signed -> unsigned.
> > This is happening because we are always passing inSigned argument to 
> > `Builder.CreateIntCast` as false here 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1348.
> >  IfI change it to `true`, it generates `sext` instructions.
> > 
> > I am figuring out how can I determine sign of src and dest type. Because 
> > `SrcTy` and `DestTy` are vectors here, they are unsigned and `SrcElementTy` 
> > and `DestElementTy` have no method like `isSignedIntegerOrEnumerationType`. 
> > Once that's solved, this should be fixed.
> Oh right, I think I see what's going on. I think the code you are referring 
> to is specifically for the vector types in Clang, but it is checking the LLVM 
> type and we also use LLVM IR vector types for matrix values, so the code 
> accidentally also covers matrix values at the moment. 
> 
> I *think* we should probably handled matrix values separately in this 
> function. @rjmccall what do you think?
Yes, I would recommend that you recognize matrix values by their Clang type and 
then call something in the matrix IR-generation library.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 335011.
ASDenysPetrov added a comment.

Updated. Restored complexity to O(N).


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

https://reviews.llvm.org/D99797

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -61,6 +61,9 @@
   static constexpr BaseType getMax() {
 return std::numeric_limits::max();
   }
+  // MID is a value in the middle of the range
+  // which unary minus does not affect on,
+  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   static constexpr BaseType getMid() {
 return isSigned() ? 0 : ~(fromInt(-1) / fromInt(2));
   }
@@ -160,7 +163,7 @@
 
   void checkAdd(RawRangeSet RawLHS, RawRangeSet RawRHS,
 RawRangeSet RawExpected) {
-wrap(::checkAddImpl, RawRHS, RawLHS, RawExpected);
+wrap(::checkAddImpl, RawLHS, RawRHS, RawExpected);
   }
 
   void checkAdd(RawRangeSet RawLHS, BaseType RawRHS, RawRangeSet RawExpected) {
@@ -195,9 +198,6 @@
 
   constexpr TypeParam MIN = TestFixture::getMin();
   constexpr TypeParam MAX = TestFixture::getMax();
-  // MID is a value in the middle of the range
-  // which unary minus does not affect on,
-  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   constexpr TypeParam MID = TestFixture::getMid();
   constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
   constexpr TypeParam B = MID - TestFixture::fromInt(42);
@@ -310,24 +310,124 @@
 }
 
 TYPED_TEST(RangeSetTest, RangeSetAddTest) {
-  // Check adding single points
-  this->checkAdd({}, 10, {{10, 10}});
-  this->checkAdd({{0, 5}}, 10, {{0, 5}, {10, 10}});
-  this->checkAdd({{0, 5}, {30, 40}}, 10, {{0, 5}, {10, 10}, {30, 40}});
-
-  // Check adding single ranges.
-  this->checkAdd({}, {10, 20}, {{10, 20}});
-  this->checkAdd({{0, 5}}, {10, 20}, {{0, 5}, {10, 20}});
-  this->checkAdd({{0, 5}, {30, 40}}, {10, 20}, {{0, 5}, {10, 20}, {30, 40}});
-
-  // Check adding whole sets of ranges.
-  this->checkAdd({{0, 5}}, {{10, 20}}, {{0, 5}, {10, 20}});
-  // Check that ordering of ranges is as expected.
-  this->checkAdd({{0, 5}, {30, 40}}, {{10, 20}}, {{0, 5}, {10, 20}, {30, 40}});
-  this->checkAdd({{0, 5}, {30, 40}}, {{10, 20}, {50, 60}},
- {{0, 5}, {10, 20}, {30, 40}, {50, 60}});
-  this->checkAdd({{10, 20}, {50, 60}}, {{0, 5}, {30, 40}, {70, 80}},
- {{0, 5}, {10, 20}, {30, 40}, {50, 60}, {70, 80}});
+
+  // Use next values of the range {MIN, A, B, MID, C, D, MAX}.
+  constexpr TypeParam MIN = TestFixture::getMin();
+  constexpr TypeParam MAX = TestFixture::getMax();
+  constexpr TypeParam MID = TestFixture::getMid();
+  constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
+  constexpr TypeParam B = MID - TestFixture::fromInt(42);
+  constexpr TypeParam C = -B;
+  constexpr TypeParam D = -A;
+
+  // LHS and RHS is empty.
+  // RHS =>
+  // LHS => =
+  //___   ___
+  this->checkAdd({}, {}, {});
+
+  // RHS is empty.
+  // RHS =>
+  // LHS =>_=_
+  //__/_\__   __/_\__
+  this->checkAdd({{A, B}}, {}, {{A, B}});
+  this->checkAdd({{A, B}, {C, D}}, {}, {{A, B}, {C, D}});
+
+  // LHS is empty.
+  // RHS => ___
+  // LHS =>/   \=_
+  //__/_\__   __/_\__
+  this->checkAdd({}, B, {{B, B}});
+  this->checkAdd({}, {B, C}, {{B, C}});
+  this->checkAdd({}, {{MIN, B}, {C, MAX}}, {{MIN, B}, {C, MAX}});
+
+  // RHS is detached from LHS.
+  // RHS => ___
+  // LHS =>___ /   \=___ _
+  //__/___\___/_\__   __/___\___/_\__
+  this->checkAdd({{A, C}}, D, {{A, C}, {D, D}});
+  this->checkAdd({{MID, C}, {D, MAX}}, A, {{A, A}, {MID, C}, {D, MAX}});
+  this->checkAdd({{A, B}}, {MID, D}, {{A, B}, {MID, D}});
+  this->checkAdd({{MIN, A}, {D, MAX}}, {B, C}, {{MIN, A}, {B, C}, {D, MAX}});
+  this->checkAdd({{B, MID}, {D, MAX}}, {{MIN, A}, {C, C}},
+ {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+  this->checkAdd({{MIN, A}, {C, C}}, {{B, MID}, {D, MAX}},
+ {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+
+  // RHS is inside LHS.
+  // RHS => ___
+  // LHS => ___/___\___ = ___
+  //___/__/_\__\___   ___/___\___
+  this->checkAdd({{A, C}}, MID, {{A, C}});
+  this->checkAdd({{A, D}}, {B, C}, {{A, D}});
+
+  // RHS wraps LHS.
+  // RHS =>  _
+  // LHS => /  _  \ = ___
+  //___/__/_\__\___   ___/___\___
+  this->checkAdd({{MID, MID}}, {A, D}, {{A, D}});
+ 

[PATCH] D75844: [clang] Set begin loc on GNU attribute parsed attrs

2021-04-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 335016.

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

https://reviews.llvm.org/D75844

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough.cpp

Index: clang/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- clang/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ clang/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -185,9 +185,12 @@
   return 1;
   [[clang::fallthrough]];  // expected-warning{{fallthrough annotation in unreachable code}}
 case 222:
+  return 2;
+  __attribute__((fallthrough)); // expected-warning{{fallthrough annotation in unreachable code}}
+case 223:
   n += 400;
-case 223:  // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
-  ;
+case 224: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
+;
   }
 
   long p = static_cast(n) * n;
Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat -Wc++14-extensions -Wc++17-extensions %s
+// RUN: %clang_cc1 -fcxx-exceptions -fdeclspec -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat -Wc++14-extensions -Wc++17-extensions %s
 
 // Need std::initializer_list
 namespace std {
@@ -368,6 +368,22 @@
   return n;
 }
 
+template struct TemplateStruct {};
+class FriendClassesWithAttributes {
+  // We allow GNU-style attributes here
+  template  friend class __attribute__((__type_visibility__("default"))) vector;
+  template  friend class __declspec(code_seg("whatever")) vector2;
+  // But not C++11 ones
+  template  friend class[[]] vector3; // expected-error {{an attribute list cannot appear here}}
+  template  friend class [[clang::__type_visibility__(("default"))]] vector4; // expected-error {{an attribute list cannot appear here}}
+
+  // Also allowed
+  friend struct __attribute__((__type_visibility__("default"))) TemplateStruct;
+  friend struct __declspec(code_seg("whatever")) TemplateStruct;
+  friend struct[[]] TemplateStruct;   // expected-error {{an attribute list cannot appear here}}
+  friend struct [[clang::__type_visibility__("default")]] TemplateStruct; // expected-error {{an attribute list cannot appear here}}
+};
+
 #define attr_name bitand
 #define attr_name_2(x) x
 #define attr_name_3(x, y) x##y
Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,24 @@
   }
 }
 
+// CHECK-1Z: NamespaceDecl {{.*}} attributed_case
+namespace attributed_case {
+void f(int n) {
+  switch (n) {
+  case 0:
+n--;
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: FallThroughAttr {{.*}} 
+__attribute__((fallthrough))
+// CHECK: FallThroughAttr {{.*}} 
+  __attribute__((fallthrough));
+  case 1:
+n++;
+break;
+  }
+}
+} // namespace attributed_case
+
 // CHECK: NamespaceDecl {{.*}} attributed_stmt
 namespace attributed_stmt {
   // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1852,7 +1852,8 @@
 } else if (TUK == Sema::TUK_Reference ||
(TUK == Sema::TUK_Friend &&
 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+  /*DiagnoseEmptyAttrs=*/true);
   TypeResult = Actions.ActOnTagTemplateIdType(TUK, TagType, StartLoc,
   SS,
   TemplateId->TemplateKWLoc,
@@ -1924,7 +1925,8 @@
 TagType, StartLoc, SS, Name, NameLoc, attrs);
   } else if (TUK == Sema::TUK_Friend &&
  TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
-ProhibitAttributes(attrs);
+ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+/*DiagnoseEmptyAttrs=*/true);
 
 

[PATCH] D99009: [RISCV] [1/2] Add intrinsic for Zbr extension

2021-04-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D99009#2666797 , @jrtc27 wrote:

> In D99009#2666793 , @thakis wrote:
>
>> Looks like this doesn't build on windows: 
>> http://45.33.8.238/win/36271/step_4.txt
>>
>> Please take a look and revert for now if it takes a while to fix.
>
> Hopefully fixed in 1bd4986e7cdc 
> 

Yup, better now. Thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[PATCH] D89013: [libcxx] Support per-target __config_site in per-target runtime build

2021-04-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> This layout matches the layout use by other compilers like GCC.

Clarification: this is similar but not match GCC's layout, where the multiarch 
path component (e.g. `/x86_64-linux-gnu`) is appended to `.../include`

  % clang++ --target=aarch64-pc-linux-gnu a.cc '-###' |& sed -E 's/ 
"?-[LiI]/\n&/g'
  clang version 13.0.0
  Target: aarch64-pc-linux-gnu
  Thread model: posix
  InstalledDir: /tmp/RelA/bin
   "/tmp/RelA/bin/clang-13" "-cc1" "-triple" "aarch64-pc-linux-gnu" "-emit-obj" 
"-mrelax-all" "--mrelax-relocations" "-disable-free" "-main-file-name" "a.cc" 
"-mrelocation-model" "static" "-mframe-pointer=non-leaf" "-fmath-errno" 
"-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" 
"generic" "-target-feature" "+neon" "-target-abi" "aapcs" 
"-fallow-half-arguments-and-returns" "-debugger-tuning=gdb" 
"-fcoverage-compilation-dir=/tmp/c" "-resource-dir" "/tmp/RelA/lib/clang/13.0.0"
   "-internal-isystem" 
"/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/include/c++/10"
   "-internal-isystem" 
"/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/include/c++/10/aarch64-linux-gnu"
   "-internal-isystem" 
"/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/include/c++/10/backward"
  ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89013

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


[clang] 2165c0d - [OPENMP][DOCS]Update status of the supported constructs, NFC.

2021-04-02 Thread Mike Rice via cfe-commits

Author: Mike Rice
Date: 2021-04-02T12:31:36-07:00
New Revision: 2165c0d389c0b8f7dfd383ea6abd0d9b5d2ee07f

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

LOG: [OPENMP][DOCS]Update status of the supported constructs, NFC.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 6e15716f3bb4..ab4d4d52c736 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -266,7 +266,7 @@ want to help with the implementation.
 
+==+==+==+===+
 | atomic extension | 'compare' and 'fail' clauses on atomic 
construct | :none:`unclaimed`|  
 |
 
+--+--+--+---+
-| base language| C++ attribute specifier syntax
   | :none:`unclaimed`| 
  |
+| base language| C++ attribute specifier syntax
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | device extension | 'present' map type modifier   
   | :good:`done` | D83061, D83062, D84422  
  |
 
+--+--+--+---+
@@ -294,7 +294,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | device extension | allow virtual functions calls for mapped 
object on device| :none:`unclaimed`|
   |
 
+--+--+--+---+
-| device extension | interop construct 
   | :none:`unclaimed`| 
  |
+| device extension | interop construct 
   | :part:`partial`  | parsing/sema done: D98558, D98834, 
D98815 |
 
+--+--+--+---+
 | device extension | assorted routines for querying interoperable 
properties  | :none:`unclaimed`|
   |
 
+--+--+--+---+
@@ -304,7 +304,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | 'reproducible'/'unconstrained' modifiers in 
'order' clause   | :none:`unclaimed`|   
|
 
+--+--+--+---+
-| memory management| alignment extensions for allocate directive 
and clause   | :none:`unclaimed`|   
|
+| memory management| alignment extensions for allocate directive 
and clause   | :part:`worked on`|   
  

[PATCH] D89013: [libcxx] Support per-target __config_site in per-target runtime build

2021-04-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

@ldionne I have update the change description to explain the new layout.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89013

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


[clang] be7358d - Revert "[RISCV] Try using toupper instead of std::toupper to make the build bots happy."

2021-04-02 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-04-02T12:30:23-07:00
New Revision: be7358df1e3066d09171159211b9fa578272585e

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

LOG: Revert "[RISCV] Try using toupper instead of std::toupper to make the 
build bots happy."

This reverts commit 5311abc7a24e4170e5e6d06f1022da87f1413dd7.

jrtc27 included the proper header in 1bd4986e7cdc124fecbf4b4527039a9a845e61f5
while I was trying to figure out what llvm/clang usually used.

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index c92c1b5aa3d1..5b534f871bcc 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3428,7 +3428,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
,
 // Convert features like "zbr" and "experimental-zbr" to "Zbr".
 I.consume_front("experimental-");
 std::string FeatureStr = I.str();
-FeatureStr[0] = toupper(FeatureStr[0]);
+FeatureStr[0] = std::toupper(FeatureStr[0]);
 
 // Error message
 FeatureMissing = true;



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


[PATCH] D99009: [RISCV] [1/2] Add intrinsic for Zbr extension

2021-04-02 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D99009#2666793 , @thakis wrote:

> Looks like this doesn't build on windows: 
> http://45.33.8.238/win/36271/step_4.txt
>
> Please take a look and revert for now if it takes a while to fix.

Hopefully fixed in 1bd4986e7cdc 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[clang] 5311abc - [RISCV] Try using toupper instead of std::toupper to make the build bots happy.

2021-04-02 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-04-02T12:29:07-07:00
New Revision: 5311abc7a24e4170e5e6d06f1022da87f1413dd7

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

LOG: [RISCV] Try using toupper instead of std::toupper to make the build bots 
happy.

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 5b534f871bcc..c92c1b5aa3d1 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3428,7 +3428,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
,
 // Convert features like "zbr" and "experimental-zbr" to "Zbr".
 I.consume_front("experimental-");
 std::string FeatureStr = I.str();
-FeatureStr[0] = std::toupper(FeatureStr[0]);
+FeatureStr[0] = toupper(FeatureStr[0]);
 
 // Error message
 FeatureMissing = true;



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


[clang] 1bd4986 - [Sema] Fix Windows build after b001d574d7d9

2021-04-02 Thread Jessica Clarke via cfe-commits

Author: Jessica Clarke
Date: 2021-04-02T20:27:58+01:00
New Revision: 1bd4986e7cdc124fecbf4b4527039a9a845e61f5

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

LOG: [Sema] Fix Windows build after b001d574d7d9

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 98b37f3c0265..5b534f871bcc 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -91,6 +91,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



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


[PATCH] D99009: [RISCV] [1/2] Add intrinsic for Zbr extension

2021-04-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this doesn't build on windows: 
http://45.33.8.238/win/36271/step_4.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[PATCH] D99711: [RISCV] [1/2] Add intrinsic for Zbc extension

2021-04-02 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf78d932cf23a: [RISCV] Add IR intrinsics for Zbc extension 
(authored by LevyHsu, committed by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D99711?vs=334882=335008#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99711

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbc.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll

Index: llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll
@@ -0,0 +1,53 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IB
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbc -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IBC
+
+declare i64 @llvm.riscv.clmul.i64(i64 %a, i64 %b)
+
+define i64 @clmul64(i64 %a, i64 %b) nounwind {
+; RV64IB-LABEL: clmul64:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:clmul a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBC-LABEL: clmul64:
+; RV64IBC:   # %bb.0:
+; RV64IBC-NEXT:clmul a0, a0, a1
+; RV64IBC-NEXT:ret
+  %tmp = call i64 @llvm.riscv.clmul.i64(i64 %a, i64 %b)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.clmulh.i64(i64 %a, i64 %b)
+
+define i64 @clmul64h(i64 %a, i64 %b) nounwind {
+; RV64IB-LABEL: clmul64h:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:clmulh a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBC-LABEL: clmul64h:
+; RV64IBC:   # %bb.0:
+; RV64IBC-NEXT:clmulh a0, a0, a1
+; RV64IBC-NEXT:ret
+  %tmp = call i64 @llvm.riscv.clmulh.i64(i64 %a, i64 %b)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.clmulr.i64(i64 %a, i64 %b)
+
+define i64 @clmul64r(i64 %a, i64 %b) nounwind {
+; RV64IB-LABEL: clmul64r:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:clmulr a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBC-LABEL: clmul64r:
+; RV64IBC:   # %bb.0:
+; RV64IBC-NEXT:clmulr a0, a0, a1
+; RV64IBC-NEXT:ret
+  %tmp = call i64 @llvm.riscv.clmulr.i64(i64 %a, i64 %b)
+ ret i64 %tmp
+}
Index: llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
@@ -0,0 +1,53 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32IB
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbc -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32IBC
+
+declare i32 @llvm.riscv.clmul.i32(i32 %a, i32 %b)
+
+define i32 @clmul32(i32 %a, i32 %b) nounwind {
+; RV32IB-LABEL: clmul32:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:clmul a0, a0, a1
+; RV32IB-NEXT:ret
+;
+; RV32IBC-LABEL: clmul32:
+; RV32IBC:   # %bb.0:
+; RV32IBC-NEXT:clmul a0, a0, a1
+; RV32IBC-NEXT:ret
+  %tmp = call i32 @llvm.riscv.clmul.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.clmulh.i32(i32 %a, i32 %b)
+
+define i32 @clmul32h(i32 %a, i32 %b) nounwind {
+; RV32IB-LABEL: clmul32h:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:clmulh a0, a0, a1
+; RV32IB-NEXT:ret
+;
+; RV32IBC-LABEL: clmul32h:
+; RV32IBC:   # %bb.0:
+; RV32IBC-NEXT:clmulh a0, a0, a1
+; RV32IBC-NEXT:ret
+  %tmp = call i32 @llvm.riscv.clmulh.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.clmulr.i32(i32 %a, i32 %b)
+
+define i32 @clmul32r(i32 %a, i32 %b) nounwind {
+; RV32IB-LABEL: clmul32r:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:clmulr a0, a0, a1
+; RV32IB-NEXT:ret
+;
+; RV32IBC-LABEL: clmul32r:
+; RV32IBC:   # %bb.0:
+; RV32IBC-NEXT:clmulr a0, a0, a1
+; RV32IBC-NEXT:ret
+  %tmp = call i32 @llvm.riscv.clmulr.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
Index: llvm/lib/Target/RISCV/RISCVInstrInfoB.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -898,6 +898,12 @@
 def : PatGpr;
 } // Predicates = [HasStdExtZbb]
 
+let Predicates = [HasStdExtZbc] in {
+def : PatGprGpr;
+def : PatGprGpr;
+def : PatGprGpr;
+} // Predicates = [HasStdExtZbc]
+
 let Predicates = [HasStdExtZbr] in {
 def : PatGpr;
 def : PatGpr;
Index: llvm/include/llvm/IR/IntrinsicsRISCV.td
===
--- llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ 

[clang] f78d932 - [RISCV] Add IR intrinsics for Zbc extension

2021-04-02 Thread Craig Topper via cfe-commits

Author: Levy Hsu
Date: 2021-04-02T12:09:13-07:00
New Revision: f78d932cf23a6521a1f9a08c539d1a00148ebe54

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

LOG: [RISCV] Add IR intrinsics for Zbc extension

Head files are included in a separate patch in case the name needs to be 
changed.

RV32 / 64:
clmul
clmulh
clmulr

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

Added: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbc.c
llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll

Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 564573ffa746..e0b28011e61a 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -21,6 +21,11 @@
 TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb")
 TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb")
 
+// Zbc extension
+TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "experimental-zbc")
+TARGET_BUILTIN(__builtin_riscv_clmulh, "LiLiLi", "nc", "experimental-zbc")
+TARGET_BUILTIN(__builtin_riscv_clmulr, "LiLiLi", "nc", "experimental-zbc")
+
 // Zbr extension
 TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
 TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 899c7b944ecf..80e48fbceef4 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17884,6 +17884,20 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 IntrinsicTypes = {ResultType};
 break;
 
+  // Zbc
+  case RISCV::BI__builtin_riscv_clmul:
+ID = Intrinsic::riscv_clmul;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_clmulh:
+ID = Intrinsic::riscv_clmulh;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_clmulr:
+ID = Intrinsic::riscv_clmulr;
+IntrinsicTypes = {ResultType};
+break;
+
   // Zbr
   case RISCV::BI__builtin_riscv_crc32_b:
 ID = Intrinsic::riscv_crc32_b;

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
new file mode 100644
index ..c07bd91fb40e
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
@@ -0,0 +1,48 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zbc 
-emit-llvm %s -o - \
+// RUN: | FileCheck %s  -check-prefix=RV32ZBC
+
+// RV32ZBC-LABEL: @clmul(
+// RV32ZBC-NEXT:  entry:
+// RV32ZBC-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.clmul.i32(i32 
[[TMP0]], i32 [[TMP1]])
+// RV32ZBC-NEXT:ret i32 [[TMP2]]
+//
+long clmul(long a, long b) {
+  return __builtin_riscv_clmul(a, b);
+}
+
+// RV32ZBC-LABEL: @clmulh(
+// RV32ZBC-NEXT:  entry:
+// RV32ZBC-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.clmulh.i32(i32 
[[TMP0]], i32 [[TMP1]])
+// RV32ZBC-NEXT:ret i32 [[TMP2]]
+//
+long clmulh(long a, long b) {
+  return __builtin_riscv_clmulh(a, b);
+}
+
+// RV32ZBC-LABEL: @clmulr(
+// RV32ZBC-NEXT:  entry:
+// RV32ZBC-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.clmulr.i32(i32 

[PATCH] D99811: [TextAPI] move source code files out of subdirectory, NFC

2021-04-02 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida created this revision.
cishida added reviewers: steven_wu, ributzka.
Herald added subscribers: hiraditya, mgorny.
Herald added a reviewer: int3.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
cishida requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

TextAPI/ELF has moved out into InterfaceStubs, so theres no longer a
need to seperate out TextAPI between formats.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99811

Files:
  clang/docs/ClangFormattedStatus.rst
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/MachO/DriverUtils.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/InputFiles.h
  lld/lib/ReaderWriter/MachO/File.h
  llvm/include/llvm/Object/TapiFile.h
  llvm/include/llvm/Object/TapiUniversal.h
  llvm/include/llvm/TextAPI/Architecture.def
  llvm/include/llvm/TextAPI/Architecture.h
  llvm/include/llvm/TextAPI/ArchitectureSet.h
  llvm/include/llvm/TextAPI/InterfaceFile.h
  llvm/include/llvm/TextAPI/MachO/Architecture.def
  llvm/include/llvm/TextAPI/MachO/Architecture.h
  llvm/include/llvm/TextAPI/MachO/ArchitectureSet.h
  llvm/include/llvm/TextAPI/MachO/InterfaceFile.h
  llvm/include/llvm/TextAPI/MachO/PackedVersion.h
  llvm/include/llvm/TextAPI/MachO/Platform.h
  llvm/include/llvm/TextAPI/MachO/Symbol.h
  llvm/include/llvm/TextAPI/MachO/Target.h
  llvm/include/llvm/TextAPI/MachO/TextAPIReader.h
  llvm/include/llvm/TextAPI/MachO/TextAPIWriter.h
  llvm/include/llvm/TextAPI/PackedVersion.h
  llvm/include/llvm/TextAPI/Platform.h
  llvm/include/llvm/TextAPI/Symbol.h
  llvm/include/llvm/TextAPI/Target.h
  llvm/include/llvm/TextAPI/TextAPIReader.h
  llvm/include/llvm/TextAPI/TextAPIWriter.h
  llvm/lib/Object/TapiUniversal.cpp
  llvm/lib/TextAPI/Architecture.cpp
  llvm/lib/TextAPI/ArchitectureSet.cpp
  llvm/lib/TextAPI/CMakeLists.txt
  llvm/lib/TextAPI/InterfaceFile.cpp
  llvm/lib/TextAPI/MachO/Architecture.cpp
  llvm/lib/TextAPI/MachO/ArchitectureSet.cpp
  llvm/lib/TextAPI/MachO/InterfaceFile.cpp
  llvm/lib/TextAPI/MachO/PackedVersion.cpp
  llvm/lib/TextAPI/MachO/Platform.cpp
  llvm/lib/TextAPI/MachO/Symbol.cpp
  llvm/lib/TextAPI/MachO/Target.cpp
  llvm/lib/TextAPI/MachO/TextAPIContext.h
  llvm/lib/TextAPI/MachO/TextStub.cpp
  llvm/lib/TextAPI/MachO/TextStubCommon.cpp
  llvm/lib/TextAPI/MachO/TextStubCommon.h
  llvm/lib/TextAPI/PackedVersion.cpp
  llvm/lib/TextAPI/Platform.cpp
  llvm/lib/TextAPI/Symbol.cpp
  llvm/lib/TextAPI/Target.cpp
  llvm/lib/TextAPI/TextAPIContext.h
  llvm/lib/TextAPI/TextStub.cpp
  llvm/lib/TextAPI/TextStubCommon.cpp
  llvm/lib/TextAPI/TextStubCommon.h
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/unittests/TextAPI/TextStubHelpers.h
  llvm/unittests/TextAPI/TextStubV1Tests.cpp
  llvm/unittests/TextAPI/TextStubV2Tests.cpp
  llvm/unittests/TextAPI/TextStubV3Tests.cpp
  llvm/unittests/TextAPI/TextStubV4Tests.cpp

Index: llvm/unittests/TextAPI/TextStubV4Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV4Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV4Tests.cpp
@@ -7,9 +7,9 @@
 //===---===/
 
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV3Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV3Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV3Tests.cpp
@@ -6,9 +6,9 @@
 //
 //===---===/
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV2Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV2Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV2Tests.cpp
@@ -6,9 +6,9 @@
 //
 //===---===/
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV1Tests.cpp

[PATCH] D99809: Use tablegen to diagnose mutually exclusive attributes

2021-04-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

@rsmith -- I am posting the review so that I can see how the CI pipeline likes 
the functionality (because this impacts so many different attributes), but I 
intend to commit it on my own authority once CI passes. Feel free to review it 
if you'd like and I'll address any concerns you have post-commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99809

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


[PATCH] D99809: Use tablegen to diagnose mutually exclusive attributes

2021-04-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.
aaron.ballman requested review of this revision.
Herald added a project: clang.

Currently, when one or more attributes are mutually exclusive, the developer 
adding the attribute has to manually emit diagnostics. In practice, this is 
highly error prone, especially for declaration attributes, because such 
checking is not trivial. Redeclarations require you to write a "merge" function 
to diagnose mutually exclusive attributes and most attributes get this wrong.

This patch introduces a table-generated way to specify that a group of two or 
more attributes are mutually exclusive: `def : MutualExclusions<[Attr1, Attr2, 
Attr3]>;`

This works for both statement and declaration attributes (but not type 
attributes) and the checking is done either from the common attribute 
diagnostic checking code or from within `mergeDeclAttribute()` when merging 
redeclarations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99809

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/ParsedAttr.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/Sema/attr-coldhot.c
  clang/test/Sema/attr-disable-tail-calls.c
  clang/test/Sema/internal_linkage.c
  clang/test/SemaCXX/attr-speculative-load-hardening.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3627,6 +3627,114 @@
   }
 }
 
+// Generates the mutual exclusion checks. The checks for parsed attributes are
+// written into OS and the checks for merging declaration attributes are
+// written into MergeOS.
+static void GenerateMutualExclusionsChecks(const Record ,
+   const RecordKeeper ,
+   raw_ostream ,
+   raw_ostream ) {
+  // Find all of the definitions that inherit from MutualExclusions and include
+  // the given attribute in the list of exclusions to generate the
+  // diagMutualExclusion() check.
+  std::vector ExclusionsList =
+  Records.getAllDerivedDefinitions("MutualExclusions");
+
+  // We don't do any of this magic for type attributes yet.
+  if (Attr.isSubClassOf("TypeAttr"))
+return;
+
+  // This means the attribute is either a statement attribute or a decl
+  // attribute, find out which.
+  bool CurAttrIsStmtAttr =
+  Attr.isSubClassOf("StmtAttr") || Attr.isSubClassOf("DeclOrStmtAttr");
+
+  std::vector DeclAttrs, StmtAttrs;
+
+  for (const Record *Exclusion : ExclusionsList) {
+std::vector MutuallyExclusiveAttrs =
+Exclusion->getValueAsListOfDefs("Exclusions");
+auto IsCurAttr = [Attr](const Record *R) {
+  return R->getName() == Attr.getName();
+};
+if (llvm::any_of(MutuallyExclusiveAttrs, IsCurAttr)) {
+  // This list of exclusions includes the attribute we're looking for, so
+  // add the exclusive attributes to the proper list for checking.
+  for (const Record *AttrToExclude : MutuallyExclusiveAttrs) {
+if (IsCurAttr(AttrToExclude))
+  continue;
+
+if (CurAttrIsStmtAttr)
+  StmtAttrs.push_back((AttrToExclude->getName() + "Attr").str());
+else
+  DeclAttrs.push_back((AttrToExclude->getName() + "Attr").str());
+  }
+}
+  }
+
+  // If we discovered any decl or stmt attributes to test for, generate the
+  // predicates for them now.
+  if (!DeclAttrs.empty()) {
+// Generate the ParsedAttrInfo subclass logic for declarations.
+OS << "  bool diagMutualExclusion(Sema , const ParsedAttr , "
+   << "const Decl *D) const {\n";
+for (const std::string  : DeclAttrs) {
+  OS << "if (const auto *A = D->getAttr<" << A << ">()) {\n";
+  OS << "  S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible)"
+ << " << AL << A;\n";
+  OS << "  S.Diag(A->getLocation(), diag::note_conflicting_attribute);";
+  OS << "  \nreturn false;\n";
+  OS << "}\n";
+}
+OS << "return true;\n";
+OS << "  }\n\n";
+
+// Also generate the declaration attribute merging logic if the current
+// attribute is one that can be inheritted on a declaration. It is assumed
+// this code will be executed in the context of a function with parameters:
+// Sema , Decl *D, Attr *A and that returns a bool (false on diagnostic,
+// true on success).
+if (Attr.isSubClassOf("InheritableAttr")) {
+  MergeOS << "  if (const auto *Second = dyn_cast<"
+  << (Attr.getName() + "Attr").str() << ">(A)) {\n";
+  for (const std::string  : DeclAttrs) {
+MergeOS << "if (const auto *First 

[PATCH] D99320: [RISCV] [1/2] Add intrinsic for Zbb extension

2021-04-02 Thread Craig Topper 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 rG944adbf28550: Recommit [RISCV] Add IR intrinsic for 
Zbb extension (authored by LevyHsu, committed by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D99320?vs=334322=335001#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99320

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll

Index: llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll
@@ -0,0 +1,37 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IB
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbb -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IBB
+
+declare i32 @llvm.riscv.orc.b.i32(i32)
+
+define i32 @orcb32(i32 %a) nounwind {
+; RV64IB-LABEL: orcb32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:orc.b a0, a0
+; RV64IB-NEXT:ret
+;
+; RV64IBB-LABEL: orcb32:
+; RV64IBB:   # %bb.0:
+; RV64IBB-NEXT:orc.b a0, a0
+; RV64IBB-NEXT:ret
+  %tmp = call i32 @llvm.riscv.orc.b.i32(i32 %a)
+ ret i32 %tmp
+}
+
+declare i64 @llvm.riscv.orc.b.i64(i64)
+
+define i64 @orcb64(i64 %a) nounwind {
+; RV64IB-LABEL: orcb64:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:orc.b a0, a0
+; RV64IB-NEXT:ret
+;
+; RV64IBB-LABEL: orcb64:
+; RV64IBB:   # %bb.0:
+; RV64IBB-NEXT:orc.b a0, a0
+; RV64IBB-NEXT:ret
+  %tmp = call i64 @llvm.riscv.orc.b.i64(i64 %a)
+ ret i64 %tmp
+}
Index: llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32IB
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbb -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32IBB
+
+declare i32 @llvm.riscv.orc.b.i32(i32)
+
+define i32 @orcb(i32 %a) nounwind {
+; RV32IB-LABEL: orcb:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:orc.b a0, a0
+; RV32IB-NEXT:ret
+;
+; RV32IBB-LABEL: orcb:
+; RV32IBB:   # %bb.0:
+; RV32IBB-NEXT:orc.b a0, a0
+; RV32IBB-NEXT:ret
+  %tmp = call i32 @llvm.riscv.orc.b.i32(i32 %a)
+ ret i32 %tmp
+}
Index: llvm/lib/Target/RISCV/RISCVInstrInfoB.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -894,6 +894,10 @@
   (PACKUW GPR:$rs1, GPR:$rs2)>;
 } // Predicates = [HasStdExtZbp, IsRV64]
 
+let Predicates = [HasStdExtZbb] in {
+def : PatGpr;
+} // Predicates = [HasStdExtZbb]
+
 let Predicates = [HasStdExtZbr] in {
 def : PatGpr;
 def : PatGpr;
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -198,6 +198,9 @@
 setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16, Expand);
   }
 
+  if (Subtarget.hasStdExtZbb() && Subtarget.is64Bit())
+setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i32, Custom);
+
   if (Subtarget.is64Bit()) {
 setOperationAction(ISD::ADD, MVT::i32, Custom);
 setOperationAction(ISD::SUB, MVT::i32, Custom);
@@ -4198,6 +4201,14 @@
 default:
   llvm_unreachable(
   "Don't know how to custom type legalize this intrinsic!");
+case Intrinsic::riscv_orc_b: {
+  SDValue Newop1 =
+  DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(1));
+  SDValue Res = 
+  DAG.getNode(N->getOpcode(), DL, MVT::i64, N->getOperand(0), Newop1);
+  Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, Res));
+  return;
+}
 case Intrinsic::riscv_vmv_x_s: {
   EVT VT = N->getValueType(0);
   MVT XLenVT = Subtarget.getXLenVT();
Index: llvm/include/llvm/IR/IntrinsicsRISCV.td
===
--- llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ 

[clang] 944adbf - Recommit "[RISCV] Add IR intrinsic for Zbb extension"

2021-04-02 Thread Craig Topper via cfe-commits

Author: Levy Hsu
Date: 2021-04-02T11:50:19-07:00
New Revision: 944adbf285505ac481551157c4ee3cc3c0724900

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

LOG: Recommit "[RISCV] Add IR intrinsic for Zbb extension"

Forgot to amend the Author.

Original commit message:

Header files are included in a separate patch in case the name needs to be 
changed.

RV32 / 64:
orc.b

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

Added: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll

Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 7197b3df2621..564573ffa746 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -17,6 +17,10 @@
 
 #include "clang/Basic/riscv_vector_builtins.inc"
 
+// Zbb extension
+TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb")
+TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb")
+
 // Zbr extension
 TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
 TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 91246ccba6fa..2d43f5d3dfa4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11187,5 +11187,5 @@ def warn_tcb_enforcement_violation : Warning<
 
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
-  "builtin requires %0 extension support to be enabled">;
+  "builtin requires '%0' extension support to be enabled">;
 } // end of sema component.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fc5b7ce6bcca..899c7b944ecf 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17877,6 +17877,13 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   switch (BuiltinID) {
 #include "clang/Basic/riscv_vector_builtin_cg.inc"
 
+  // Zbb
+  case RISCV::BI__builtin_riscv_orc_b_32:
+  case RISCV::BI__builtin_riscv_orc_b_64:
+ID = Intrinsic::riscv_orc_b;
+IntrinsicTypes = {ResultType};
+break;
+
   // Zbr
   case RISCV::BI__builtin_riscv_crc32_b:
 ID = Intrinsic::riscv_crc32_b;
@@ -17910,10 +17917,8 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 ID = Intrinsic::riscv_crc32c_d;
 IntrinsicTypes = {ResultType};
 break;
-  default: {
+  default:
 llvm_unreachable("unexpected builtin ID");
-return nullptr;
-  } // default
   }
 
   assert(ID != Intrinsic::not_intrinsic);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a128fae78b9d..98b37f3c0265 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3424,7 +3424,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
,
   for (auto  : ReqFeatures) {
 if (TI.hasFeature(I))
   continue;
-// Make message like "experimental-zbr" to "Zbr"
+// Convert features like "zbr" and "experimental-zbr" to "Zbr".
 I.consume_front("experimental-");
 std::string FeatureStr = I.str();
 FeatureStr[0] = std::toupper(FeatureStr[0]);

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
new file mode 100644
index ..593b52698d35
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zbb 
-emit-llvm %s -o - \
+// RUN: | FileCheck %s  -check-prefix=RV32ZBB
+
+// RV32ZBB-LABEL: @orc_b_32(
+// RV32ZBB-NEXT:  entry:
+// RV32ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
+// RV32ZBB-NEXT:ret i32 [[TMP1]]
+//
+int orc_b_32(int a) {
+  return __builtin_riscv_orc_b_32(a);
+}

diff  --git 

[clang] 1f0b309 - Revert "[RISCV] Add IR intrinsic for Zbb extension"

2021-04-02 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-04-02T11:47:02-07:00
New Revision: 1f0b309f24ba7ed144ddcd20cccedc284d990074

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

LOG: Revert "[RISCV] Add IR intrinsic for Zbb extension"

This reverts commit 1808194590dd2b308bc146406425d5d52e46b7e6.

I forgot to change the author.

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll



diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 564573ffa746..7197b3df2621 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -17,10 +17,6 @@
 
 #include "clang/Basic/riscv_vector_builtins.inc"
 
-// Zbb extension
-TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb")
-TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb")
-
 // Zbr extension
 TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
 TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 2d43f5d3dfa4..91246ccba6fa 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11187,5 +11187,5 @@ def warn_tcb_enforcement_violation : Warning<
 
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
-  "builtin requires '%0' extension support to be enabled">;
+  "builtin requires %0 extension support to be enabled">;
 } // end of sema component.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 899c7b944ecf..fc5b7ce6bcca 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17877,13 +17877,6 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   switch (BuiltinID) {
 #include "clang/Basic/riscv_vector_builtin_cg.inc"
 
-  // Zbb
-  case RISCV::BI__builtin_riscv_orc_b_32:
-  case RISCV::BI__builtin_riscv_orc_b_64:
-ID = Intrinsic::riscv_orc_b;
-IntrinsicTypes = {ResultType};
-break;
-
   // Zbr
   case RISCV::BI__builtin_riscv_crc32_b:
 ID = Intrinsic::riscv_crc32_b;
@@ -17917,8 +17910,10 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 ID = Intrinsic::riscv_crc32c_d;
 IntrinsicTypes = {ResultType};
 break;
-  default:
+  default: {
 llvm_unreachable("unexpected builtin ID");
+return nullptr;
+  } // default
   }
 
   assert(ID != Intrinsic::not_intrinsic);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 98b37f3c0265..a128fae78b9d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3424,7 +3424,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
,
   for (auto  : ReqFeatures) {
 if (TI.hasFeature(I))
   continue;
-// Convert features like "zbr" and "experimental-zbr" to "Zbr".
+// Make message like "experimental-zbr" to "Zbr"
 I.consume_front("experimental-");
 std::string FeatureStr = I.str();
 FeatureStr[0] = std::toupper(FeatureStr[0]);

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
deleted file mode 100644
index 4f326fea9e74..
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ /dev/null
@@ -1,15 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zbb 
-emit-llvm %s -o - \
-// RUN: | FileCheck %s  -check-prefix=RV32ZBB
-
-// RV32ZBB-LABEL: @orcb32(
-// RV32ZBB-NEXT:  entry:
-// RV32ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
-// RV32ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
-// RV32ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
-// RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
-// RV32ZBB-NEXT:ret i32 [[TMP1]]
-//
-int orcb32(int a) {
-  return __builtin_riscv_orc_b_32(a);
-}

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
deleted file mode 

[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:13567-13568
+case OMPD_dispatch:
+  CaptureRegion = OMPD_task;
+  break;
+default:

jyu2 wrote:
> ABataev wrote:
> > What about other directives?
> Hi Alexey,
> 
> As of now "novariants" clause only allowed in disapatch directive.  And 
> dispatch directive can have implicit task directive. So for other directives 
> will be unreachable.  Am I missing something here?  
> Thanks.
> Jennifer
No, I just was not aware of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[PATCH] D97462: [clang][cli] Round-trip cc1 arguments in assert builds

2021-04-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D97462#2666485 , @jansvoboda11 
wrote:

> Thanks for reporting that. D99606  fixes one 
> aspect of `-plugin-arg`, but it seems the order of generation is 
> non-deterministic (most likely related to the underlying storage, 
> `std::unordered_map`). I can look into it early next week, but I think simple 
> sort in the generation code should do the trick.

Can/should it just be changed to a `std::map`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97462

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/test/CodeGen/matrix-cast.c:15
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4

SaurabhJha wrote:
> fhahn wrote:
> > This doesn't seem right. We are casting between 2 signed types, so the sign 
> > should get preserved, right? Shouldn't this be `sext`? See 
> > https://godbolt.org/z/zWznYdnKW for the scalar case.
> > 
> > I think you also need tests for casts with different bitwidths with 
> > unsigned, unsigned -> signed & signed -> unsigned.
> This is happening because we are always passing inSigned argument to 
> `Builder.CreateIntCast` as false here 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1348.
>  IfI change it to `true`, it generates `sext` instructions.
> 
> I am figuring out how can I determine sign of src and dest type. Because 
> `SrcTy` and `DestTy` are vectors here, they are unsigned and `SrcElementTy` 
> and `DestElementTy` have no method like `isSignedIntegerOrEnumerationType`. 
> Once that's solved, this should be fixed.
Oh right, I think I see what's going on. I think the code you are referring to 
is specifically for the vector types in Clang, but it is checking the LLVM type 
and we also use LLVM IR vector types for matrix values, so the code 
accidentally also covers matrix values at the moment. 

I *think* we should probably handled matrix values separately in this function. 
@rjmccall what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99808: [Sema] Move 'char-expression-as-unsigned < 0' into a separate diagnostic

2021-04-02 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev created this revision.
AntonBikineev added reviewers: aaron.ballman, thakis.
AntonBikineev requested review of this revision.
Herald added a project: clang.

This change splits '-Wtautological-unsigned-zero-compare' by reporting
char-expressions-interpreted-as-unsigned under a separate diagnostic
'-Wtautological-unsigned-char-zero-compare'. This is beneficial for
projects that want to enable '-Wtautological-unsigned-zero-compare' but at
the same time want to keep code portable for platforms with char being
signed or unsigned, such as Chromium.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99808

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/tautological-unsigned-char-zero-compare.cc

Index: clang/test/Sema/tautological-unsigned-char-zero-compare.cc
===
--- /dev/null
+++ clang/test/Sema/tautological-unsigned-char-zero-compare.cc
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only \
+// RUN:-fno-signed-char \
+// RUN:-Wtautological-unsigned-zero-compare \
+// RUN:-Wtautological-unsigned-char-zero-compare \
+// RUN:-verify=unsigned %s
+// RUN: %clang_cc1 -fsyntax-only \
+// RUN:-Wtautological-unsigned-zero-compare \
+// RUN:-Wtautological-unsigned-char-zero-compare \
+// RUN:-verify=signed %s
+
+void f(char c, unsigned char uc, signed char cc) {
+  if (c < 0)
+return;
+  // unsigned-warning@-2 {{comparison of char expression < 0 is always false, since char is interpreted as unsigned}}
+  if (uc < 0)
+return;
+  // unsigned-warning@-2 {{comparison of unsigned expression < 0 is always false}}
+  // signed-warning@-3 {{comparison of unsigned expression < 0 is always false}}
+  if (cc < 0)
+return;
+  // Promoted to integer expressions should not warn.
+  if (c - 4 < 0)
+return;
+}
+
+void ref(char , unsigned char , signed char ) {
+  if (c < 0)
+return;
+  // unsigned-warning@-2 {{comparison of char expression < 0 is always false, since char is interpreted as unsigned}}
+  if (uc < 0)
+return;
+  // unsigned-warning@-2 {{comparison of unsigned expression < 0 is always false}}
+  // signed-warning@-3 {{comparison of unsigned expression < 0 is always false}}
+  if (cc < 0)
+return;
+  // Promoted to integer expressions should not warn.
+  if (c - 4 < 0)
+return;
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11415,11 +11415,14 @@
 << OtherIsBooleanDespiteType << *Result
 << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange());
   } else {
-unsigned Diag = (isKnownToHaveUnsignedValue(OriginalOther) && Value == 0)
-? (HasEnumType(OriginalOther)
-   ? diag::warn_unsigned_enum_always_true_comparison
-   : diag::warn_unsigned_always_true_comparison)
-: diag::warn_tautological_constant_compare;
+bool IsCharTy = OtherT.withoutLocalFastQualifiers() == S.Context.CharTy;
+unsigned Diag =
+(isKnownToHaveUnsignedValue(OriginalOther) && Value == 0)
+? (HasEnumType(OriginalOther)
+   ? diag::warn_unsigned_enum_always_true_comparison
+   : IsCharTy ? diag::warn_unsigned_char_always_true_comparison
+  : diag::warn_unsigned_always_true_comparison)
+: diag::warn_tautological_constant_compare;
 
 S.Diag(E->getOperatorLoc(), Diag)
 << RhsConstant << OtherT << E->getOpcodeStr() << OS.str() << *Result
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6784,6 +6784,10 @@
   "result of comparison of %select{%3|unsigned expression}0 %2 "
   "%select{unsigned expression|%3}0 is always %4">,
   InGroup, DefaultIgnore;
+def warn_unsigned_char_always_true_comparison : Warning<
+  "result of comparison of %select{%3|char expression}0 %2 "
+  "%select{char expression|%3}0 is always %4, since char is interpreted as "
+  "unsigned">, InGroup, DefaultIgnore;
 def warn_unsigned_enum_always_true_comparison : Warning<
   "result of comparison of %select{%3|unsigned enum expression}0 %2 "
   "%select{unsigned enum expression|%3}0 is always %4">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -591,11 +591,13 @@
 def IntInBoolContext : DiagGroup<"int-in-bool-context">;
 def 

[clang] 1808194 - [RISCV] Add IR intrinsic for Zbb extension

2021-04-02 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-04-02T11:23:57-07:00
New Revision: 1808194590dd2b308bc146406425d5d52e46b7e6

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

LOG: [RISCV] Add IR intrinsic for Zbb extension

Header files are included in a separate patch in case the name needs to be 
changed.

RV32 / 64:
orc.b

Added: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll

Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 7197b3df2621..564573ffa746 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -17,6 +17,10 @@
 
 #include "clang/Basic/riscv_vector_builtins.inc"
 
+// Zbb extension
+TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb")
+TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb")
+
 // Zbr extension
 TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
 TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 91246ccba6fa..2d43f5d3dfa4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11187,5 +11187,5 @@ def warn_tcb_enforcement_violation : Warning<
 
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
-  "builtin requires %0 extension support to be enabled">;
+  "builtin requires '%0' extension support to be enabled">;
 } // end of sema component.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fc5b7ce6bcca..899c7b944ecf 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17877,6 +17877,13 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   switch (BuiltinID) {
 #include "clang/Basic/riscv_vector_builtin_cg.inc"
 
+  // Zbb
+  case RISCV::BI__builtin_riscv_orc_b_32:
+  case RISCV::BI__builtin_riscv_orc_b_64:
+ID = Intrinsic::riscv_orc_b;
+IntrinsicTypes = {ResultType};
+break;
+
   // Zbr
   case RISCV::BI__builtin_riscv_crc32_b:
 ID = Intrinsic::riscv_crc32_b;
@@ -17910,10 +17917,8 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 ID = Intrinsic::riscv_crc32c_d;
 IntrinsicTypes = {ResultType};
 break;
-  default: {
+  default:
 llvm_unreachable("unexpected builtin ID");
-return nullptr;
-  } // default
   }
 
   assert(ID != Intrinsic::not_intrinsic);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a128fae78b9d..98b37f3c0265 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3424,7 +3424,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
,
   for (auto  : ReqFeatures) {
 if (TI.hasFeature(I))
   continue;
-// Make message like "experimental-zbr" to "Zbr"
+// Convert features like "zbr" and "experimental-zbr" to "Zbr".
 I.consume_front("experimental-");
 std::string FeatureStr = I.str();
 FeatureStr[0] = std::toupper(FeatureStr[0]);

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
new file mode 100644
index ..4f326fea9e74
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zbb 
-emit-llvm %s -o - \
+// RUN: | FileCheck %s  -check-prefix=RV32ZBB
+
+// RV32ZBB-LABEL: @orcb32(
+// RV32ZBB-NEXT:  entry:
+// RV32ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
+// RV32ZBB-NEXT:ret i32 [[TMP1]]
+//
+int orcb32(int a) {
+  return __builtin_riscv_orc_b_32(a);
+}

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
new file mode 100644
index 

[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:13567-13568
+case OMPD_dispatch:
+  CaptureRegion = OMPD_task;
+  break;
+default:

ABataev wrote:
> What about other directives?
Hi Alexey,

As of now "novariants" clause only allowed in disapatch directive.  And 
dispatch directive can have implicit task directive. So for other directives 
will be unreachable.  Am I missing something here?  
Thanks.
Jennifer


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-04-02 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok marked an inline comment as done.
alok added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1648
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
+  if (Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))

dblaikie wrote:
> alok wrote:
> > alok wrote:
> > > dblaikie wrote:
> > > > probinson wrote:
> > > > > I think we don't want this enabled by default at -O0.  It doesn't run 
> > > > > any optimizations that should eliminate parameters, so this is going 
> > > > > to increase debug info size for no real benefit to the debugging 
> > > > > experience.
> > > > +1 to @probinson here. That's generally been the thinking behind why 
> > > > this was only enabled when optimizations are enabled. (there's some 
> > > > minor tradeoff here: call site descriptions in unoptimized code can 
> > > > still be useful if they call into optimized code, so this is a bit 
> > > > heuristical - assuming that all code will be compiled with the same 
> > > > optimization level)
> > > > 
> > > > If flang is in a different situation and enables some optimizations at 
> > > > -O0 that make call site parameter descriptions beneficial even there, 
> > > > then maybe we'll need some different way to differentiate optimizations 
> > > > V no optimizations for the purpose of this feature.
> > > Thanks Paul for the comment. I shall probably add an option to enable in 
> > > such cases which should remain off by default, Flang driver can pass that 
> > > to compiler to turn it on.
> > Thanks David for your explanation and thoughts. Please also look at trigger 
> > to this https://reviews.llvm.org/D99160
> > 
> > It is needed in a Fortran case. I shall probably drop to enable it by 
> > default and add an option which by default is disabled and Fortran driver 
> > can pass that to make use of it.
> Sounds like @djtodoro is suggesting in 
> https://reviews.llvm.org/D99160#2666106 that the "Bug" to fix here is the 
> presence of DW_OP_call_value at -O0, it seems that could be an issue for the 
> existing/original use of call_site_parameter/call_value (in C++/clang) as it 
> would be for flang - so the fix should probably not be flang-specific if the 
> issue isn't flang-specific. Understanding why we produce DW_OP_call_values at 
> -O0, whether we can/should avoid that, what it costs (how much larger the 
> debug info gets by adding DW_TAG_call_sites at -O0) would be necessary to 
> determine the right path forward here.
Thanks David for clarification. I shall look at it and get back.


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

https://reviews.llvm.org/D99238

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


[PATCH] D99009: [RISCV] [1/2] Add intrinsic for Zbr extension

2021-04-02 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Thanks, and good point re ordering


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[PATCH] D99009: [RISCV] [1/2] Add intrinsic for Zbr extension

2021-04-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11190
+def err_riscv_builtin_requires_extension : Error<
+  "builtin requires %0 extension support to be enabled">;
 } // end of sema component.

jrtc27 wrote:
> This lost the quotes
I will fix when I rebase Zbb on top of this



Comment at: clang/lib/Sema/SemaChecking.cpp:3427
+  continue;
+// Make message like "experimental-zbr" to "Zbr"
+I.consume_front("experimental-");

jrtc27 wrote:
> both to improve the English and to be clear that this is for non-experimental 
> feature strings too
I will fix when I rebase Zbb on top of this



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:19
+
+class BitMan_GPR_Intrinsics
+: Intrinsic<[llvm_any_ty],

jrtc27 wrote:
> This file, like the rest of LLVM, uses a 2-space indent, not 4.
I will fix when I rebase Zbb on top of this. I'll also move it below atomics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-04-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1648
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
+  if (Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))

alok wrote:
> alok wrote:
> > dblaikie wrote:
> > > probinson wrote:
> > > > I think we don't want this enabled by default at -O0.  It doesn't run 
> > > > any optimizations that should eliminate parameters, so this is going to 
> > > > increase debug info size for no real benefit to the debugging 
> > > > experience.
> > > +1 to @probinson here. That's generally been the thinking behind why this 
> > > was only enabled when optimizations are enabled. (there's some minor 
> > > tradeoff here: call site descriptions in unoptimized code can still be 
> > > useful if they call into optimized code, so this is a bit heuristical - 
> > > assuming that all code will be compiled with the same optimization level)
> > > 
> > > If flang is in a different situation and enables some optimizations at 
> > > -O0 that make call site parameter descriptions beneficial even there, 
> > > then maybe we'll need some different way to differentiate optimizations V 
> > > no optimizations for the purpose of this feature.
> > Thanks Paul for the comment. I shall probably add an option to enable in 
> > such cases which should remain off by default, Flang driver can pass that 
> > to compiler to turn it on.
> Thanks David for your explanation and thoughts. Please also look at trigger 
> to this https://reviews.llvm.org/D99160
> 
> It is needed in a Fortran case. I shall probably drop to enable it by default 
> and add an option which by default is disabled and Fortran driver can pass 
> that to make use of it.
Sounds like @djtodoro is suggesting in https://reviews.llvm.org/D99160#2666106 
that the "Bug" to fix here is the presence of DW_OP_call_value at -O0, it seems 
that could be an issue for the existing/original use of 
call_site_parameter/call_value (in C++/clang) as it would be for flang - so the 
fix should probably not be flang-specific if the issue isn't flang-specific. 
Understanding why we produce DW_OP_call_values at -O0, whether we can/should 
avoid that, what it costs (how much larger the debug info gets by adding 
DW_TAG_call_sites at -O0) would be necessary to determine the right path 
forward here.


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

https://reviews.llvm.org/D99238

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


[PATCH] D99009: [RISCV] [1/2] Add intrinsic for Zbr extension

2021-04-02 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11190
+def err_riscv_builtin_requires_extension : Error<
+  "builtin requires %0 extension support to be enabled">;
 } // end of sema component.

This lost the quotes



Comment at: clang/lib/Sema/SemaChecking.cpp:3427
+  continue;
+// Make message like "experimental-zbr" to "Zbr"
+I.consume_front("experimental-");

both to improve the English and to be clear that this is for non-experimental 
feature strings too



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:19
+
+class BitMan_GPR_Intrinsics
+: Intrinsic<[llvm_any_ty],

This file, like the rest of LLVM, uses a 2-space indent, not 4.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added inline comments.



Comment at: clang/test/CodeGen/matrix-cast.c:15
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4

fhahn wrote:
> This doesn't seem right. We are casting between 2 signed types, so the sign 
> should get preserved, right? Shouldn't this be `sext`? See 
> https://godbolt.org/z/zWznYdnKW for the scalar case.
> 
> I think you also need tests for casts with different bitwidths with unsigned, 
> unsigned -> signed & signed -> unsigned.
This is happening because we are always passing inSigned argument to 
`Builder.CreateIntCast` as false here 
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1348.
 IfI change it to `true`, it generates `sext` instructions.

I am figuring out how can I determine sign of src and dest type. Because 
`SrcTy` and `DestTy` are vectors here, they are unsigned and `SrcElementTy` and 
`DestElementTy` have no method like `isSignedIntegerOrEnumerationType`. Once 
that's solved, this should be fixed.



Comment at: clang/test/CodeGen/matrix-cast.c:39
+
+  f = (fx5x5)i;
+}

fhahn wrote:
> SaurabhJha wrote:
> > I tried adding a float -> int conversion too but it failed because of this 
> > assertion 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1339-L1344
> >  Hopefully that's intended.
> Clang should never run into an assertion. If that should not be allowed, then 
> Clang should emit an error during Sema. I'm not sure why there is such a 
> restriction for vector types, but I am not sure that this shouldn't be 
> allowed for matrixes. Perhaps @rjmccall has more thoughts on this, but 
> conversion between scalar ints to floats is allowed AFAIKT.
I can probably try removing that assert and see if some other unit or lit tests 
are failing. We can then make a decision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99009: [RISCV] [1/2] Add intrinsic for Zbr extension

2021-04-02 Thread Craig Topper 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 rGb001d574d7d9: [RISCV] Add IR intrinsic for Zbr extension 
(authored by LevyHsu, committed by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D99009?vs=334331=334990#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbr.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbr.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zbr.ll
  llvm/test/CodeGen/RISCV/rv64zbr.ll

Index: llvm/test/CodeGen/RISCV/rv64zbr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv64zbr.ll
@@ -0,0 +1,91 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=experimental-zbr -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64ZBR
+
+declare i64 @llvm.riscv.crc32.b.i64(i64)
+
+define i64 @crc32b(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32b:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32.b a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32.b.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32.h.i64(i64)
+
+define i64 @crc32h(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32h:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32.h a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32.h.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32.w.i64(i64)
+
+define i64 @crc32w(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32w:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32.w a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32.w.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32c.b.i64(i64)
+
+define i64 @crc32cb(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32cb:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32c.b a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32c.b.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32c.h.i64(i64)
+
+define i64 @crc32ch(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32ch:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32c.h a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32c.h.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32c.w.i64(i64)
+
+define i64 @crc32cw(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32cw:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32c.w a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32c.w.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32.d.i64(i64)
+
+define i64 @crc32d(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32d:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32.d a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32.d.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32c.d.i64(i64)
+
+define i64 @crc32cd(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32cd:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32c.d a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32c.d.i64(i64 %a)
+ ret i64 %tmp
+}
Index: llvm/test/CodeGen/RISCV/rv32zbr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv32zbr.ll
@@ -0,0 +1,69 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=experimental-zbr -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32ZBR
+
+declare i32 @llvm.riscv.crc32.b.i32(i32)
+
+define i32 @crc32b(i32 %a) nounwind {
+; RV32ZBR-LABEL: crc32b:
+; RV32ZBR:   # %bb.0:
+; RV32ZBR-NEXT:crc32.b a0, a0
+; RV32ZBR-NEXT:ret
+  %tmp = call i32 @llvm.riscv.crc32.b.i32(i32 %a)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.crc32.h.i32(i32)
+
+define i32 @crc32h(i32 %a) nounwind {
+; RV32ZBR-LABEL: crc32h:
+; RV32ZBR:   # %bb.0:
+; RV32ZBR-NEXT:crc32.h a0, a0
+; RV32ZBR-NEXT:ret
+  %tmp = call i32 @llvm.riscv.crc32.h.i32(i32 %a)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.crc32.w.i32(i32)
+
+define i32 @crc32w(i32 %a) nounwind {
+; RV32ZBR-LABEL: crc32w:
+; RV32ZBR:   # %bb.0:
+; RV32ZBR-NEXT:crc32.w a0, a0
+; RV32ZBR-NEXT:ret
+  %tmp = call i32 @llvm.riscv.crc32.w.i32(i32 %a)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.crc32c.b.i32(i32)
+
+define i32 @crc32cb(i32 %a) nounwind {
+; RV32ZBR-LABEL: crc32cb:
+; RV32ZBR:   # %bb.0:
+; RV32ZBR-NEXT:crc32c.b a0, a0
+; RV32ZBR-NEXT:ret
+  %tmp = call i32 @llvm.riscv.crc32c.b.i32(i32 %a)
+ ret i32 %tmp
+}
+
+declare i32 

[clang] b001d57 - [RISCV] Add IR intrinsic for Zbr extension

2021-04-02 Thread Craig Topper via cfe-commits

Author: Levy Hsu
Date: 2021-04-02T10:58:45-07:00
New Revision: b001d574d7d94bcf1508fa4cdc22e02a0bf4adea

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

LOG: [RISCV] Add IR intrinsic for Zbr extension

Implementation for RISC-V Zbr extension intrinsic.

Header files are included in separate patch in case the name needs to be changed

RV32 / 64:
crc32b
crc32h
crc32w
crc32cb
crc32ch
crc32cw

RV64 Only:
crc32d
crc32cd

Reviewed By: craig.topper

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

Added: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbr.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbr.c
llvm/test/CodeGen/RISCV/rv32zbr.ll
llvm/test/CodeGen/RISCV/rv64zbr.ll

Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index c91b3d1b1f5c1..7197b3df26212 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -17,5 +17,15 @@
 
 #include "clang/Basic/riscv_vector_builtins.inc"
 
+// Zbr extension
+TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32_w, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32c_b, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32c_h, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32c_w, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32_d, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32c_d, "LiLi", "nc", "experimental-zbr")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d51a01837fc93..91246ccba6fa0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11185,7 +11185,7 @@ def warn_tcb_enforcement_violation : Warning<
   "calling %0 is a violation of trusted computing base '%1'">,
   InGroup>;
 
-// RISC-V V-extension
-def err_riscvv_builtin_requires_v : Error<
-   "builtin requires 'V' extension support to be enabled">;
+// RISC-V builtin required extension warning
+def err_riscv_builtin_requires_extension : Error<
+  "builtin requires %0 extension support to be enabled">;
 } // end of sema component.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 86ea4ac28ae86..fc5b7ce6bcca2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17876,6 +17876,44 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   llvm::SmallVector IntrinsicTypes;
   switch (BuiltinID) {
 #include "clang/Basic/riscv_vector_builtin_cg.inc"
+
+  // Zbr
+  case RISCV::BI__builtin_riscv_crc32_b:
+ID = Intrinsic::riscv_crc32_b;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32_h:
+ID = Intrinsic::riscv_crc32_h;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32_w:
+ID = Intrinsic::riscv_crc32_w;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32_d:
+ID = Intrinsic::riscv_crc32_d;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32c_b:
+ID = Intrinsic::riscv_crc32c_b;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32c_h:
+ID = Intrinsic::riscv_crc32c_h;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32c_w:
+ID = Intrinsic::riscv_crc32c_w;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32c_d:
+ID = Intrinsic::riscv_crc32c_d;
+IntrinsicTypes = {ResultType};
+break;
+  default: {
+llvm_unreachable("unexpected builtin ID");
+return nullptr;
+  } // default
   }
 
   assert(ID != Intrinsic::not_intrinsic);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 305fcd574a373..a128fae78b9d0 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3415,13 +3415,27 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const 
TargetInfo ,
  CallExpr *TheCall) {
   // CodeGenFunction can also 

[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-04-02 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok marked 2 inline comments as done.
alok added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1648
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
+  if (Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))

dblaikie wrote:
> probinson wrote:
> > I think we don't want this enabled by default at -O0.  It doesn't run any 
> > optimizations that should eliminate parameters, so this is going to 
> > increase debug info size for no real benefit to the debugging experience.
> +1 to @probinson here. That's generally been the thinking behind why this was 
> only enabled when optimizations are enabled. (there's some minor tradeoff 
> here: call site descriptions in unoptimized code can still be useful if they 
> call into optimized code, so this is a bit heuristical - assuming that all 
> code will be compiled with the same optimization level)
> 
> If flang is in a different situation and enables some optimizations at -O0 
> that make call site parameter descriptions beneficial even there, then maybe 
> we'll need some different way to differentiate optimizations V no 
> optimizations for the purpose of this feature.
Thanks Paul for the comment. I shall probably add an option to enable in such 
cases which should remain off by default, Flang driver can pass that to 
compiler to turn it on.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1648
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
+  if (Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))

alok wrote:
> dblaikie wrote:
> > probinson wrote:
> > > I think we don't want this enabled by default at -O0.  It doesn't run any 
> > > optimizations that should eliminate parameters, so this is going to 
> > > increase debug info size for no real benefit to the debugging experience.
> > +1 to @probinson here. That's generally been the thinking behind why this 
> > was only enabled when optimizations are enabled. (there's some minor 
> > tradeoff here: call site descriptions in unoptimized code can still be 
> > useful if they call into optimized code, so this is a bit heuristical - 
> > assuming that all code will be compiled with the same optimization level)
> > 
> > If flang is in a different situation and enables some optimizations at -O0 
> > that make call site parameter descriptions beneficial even there, then 
> > maybe we'll need some different way to differentiate optimizations V no 
> > optimizations for the purpose of this feature.
> Thanks Paul for the comment. I shall probably add an option to enable in such 
> cases which should remain off by default, Flang driver can pass that to 
> compiler to turn it on.
Thanks David for your explanation and thoughts. Please also look at trigger to 
this https://reviews.llvm.org/D99160

It is needed in a Fortran case. I shall probably drop to enable it by default 
and add an option which by default is disabled and Fortran driver can pass that 
to make use of it.


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

https://reviews.llvm.org/D99238

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


[PATCH] D75844: [clang] Set begin loc on GNU attribute parsed attrs

2021-04-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Parser/cxx0x-attributes.cpp:377
+  template  friend class[[]] vector2; 
// expected-error {{an attribute list cannot appear 
here}}
+  template  friend class 
[[clang::__type_visibility__(("default"))]] vector3; // expected-error {{an 
attribute list cannot appear here}}
+

Can you also add a test for `__declspec` attributes, like `template  friend class __declspec(code_seg("whatever")) vector4;`? That is 
accepted by MSVC: https://godbolt.org/z/b8Gc3Y4Tr


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

https://reviews.llvm.org/D75844

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


[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-04-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1648
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
+  if (Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))

probinson wrote:
> I think we don't want this enabled by default at -O0.  It doesn't run any 
> optimizations that should eliminate parameters, so this is going to increase 
> debug info size for no real benefit to the debugging experience.
+1 to @probinson here. That's generally been the thinking behind why this was 
only enabled when optimizations are enabled. (there's some minor tradeoff here: 
call site descriptions in unoptimized code can still be useful if they call 
into optimized code, so this is a bit heuristical - assuming that all code will 
be compiled with the same optimization level)

If flang is in a different situation and enables some optimizations at -O0 that 
make call site parameter descriptions beneficial even there, then maybe we'll 
need some different way to differentiate optimizations V no optimizations for 
the purpose of this feature.


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

https://reviews.llvm.org/D99238

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


[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@vsavchenko
OK, what do you think of ***adjacency*** feature? I mean it simplifies such 
ranges `[1,2][3,4][5,6]` to `[1,6]`. Is it worth for implementation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99797

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


[PATCH] D98856: Always emit error for wrong interfaces to scalable vectors, unless cmdline flag is passed.

2021-04-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5066
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-treat-scalable-fixed-error-as-warning");
+  }

Does this introduce an option in the CC1 command line for most cases? We should 
shorten the CC1 command line for common cases...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98856

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


[PATCH] D70094: [clang-tidy] new altera ID dependent backward branch check

2021-04-02 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/altera-id-dependent-backward-branch.rst:9
+
+Based on the `Altera SDK for OpenCL: Best Practices Guide
+`_.

Usually link to external documentation is placed at the end. See other checks 
documentation as example.


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

https://reviews.llvm.org/D70094

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


[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-02 Thread Josh Haberman via Phabricator via cfe-commits
haberman updated this revision to Diff 334985.
haberman added a comment.

- Fixed unit test by running `opt` in a separate invocation.
- Formatting fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/EHScopeStack.h
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/CodeGen/attr-musttail.cpp
  clang/test/Sema/attr-musttail.c
  clang/test/Sema/attr-musttail.cpp
  clang/test/Sema/attr-musttail.m

Index: clang/test/Sema/attr-musttail.m
===
--- /dev/null
+++ clang/test/Sema/attr-musttail.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+void TestObjcBlock(void) {
+  void (^x)(void) = ^(void) {
+__attribute__((musttail)) return TestObjcBlock(); // expected-error{{'musttail' attribute cannot be used from Objective-C blocks}}
+  };
+  __attribute__((musttail)) return x();
+}
Index: clang/test/Sema/attr-musttail.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-musttail.cpp
@@ -0,0 +1,189 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fms-extensions -fexceptions %s
+
+int ReturnsInt1();
+int Func1() {
+  [[clang::musttail]] ReturnsInt1();   // expected-error {{'musttail' attribute only applies to return statements}}
+  [[clang::musttail(1, 2)]] return ReturnsInt1(); // expected-error {{'musttail' attribute takes no arguments}}
+  [[clang::musttail]] return 5;// expected-error {{'musttail' attribute requires that the return value is the result of a function call}}
+  [[clang::musttail]] return ReturnsInt1();
+}
+
+[[clang::musttail]] static int int_val = ReturnsInt1(); // expected-error {{'musttail' attribute cannot be applied to a declaration}}
+
+void NoParams(); // expected-note {{target function has different number of parameters (expected 1 but has 0)}}
+void TestParamArityMismatch(int x) {
+  [[clang::musttail]] return NoParams(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+void LongParam(long x); // expected-note {{target function has type mismatch at 1st parameter (expected 'long' but has 'int')}}
+void TestParamTypeMismatch(int x) {
+  [[clang::musttail]] return LongParam(x); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+long ReturnsLong(); // expected-note {{target function has different return type ('int' expected but has 'long')}}
+int TestReturnTypeMismatch() {
+  [[clang::musttail]] return ReturnsLong(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+struct Struct1 {
+  void MemberFunction(); // expected-note {{target function is a member of different class (expected 'void' but has 'Struct1')}}
+};
+void TestNonMemberToMember() {
+  Struct1 st;
+  [[clang::musttail]] return st.MemberFunction(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+void ReturnsVoid(); // expected-note {{target function is a member of different class (expected 'Struct2' but has 'void')}}
+struct Struct2 {
+  void TestMemberToNonMember() {
+[[clang::musttail]] return ReturnsVoid(); // expected-error{{'musttail' attribute requires that caller and callee have compatible function signatures}}
+  }
+};
+
+class HasNonTrivialDestructor {
+public:
+  ~HasNonTrivialDestructor() {}
+  int ReturnsInt();
+};
+
+void ReturnsVoid2();
+void TestNonTrivialDestructorInScope() {
+  HasNonTrivialDestructor foo;  // expected-note {{jump exits scope of variable with non-trivial destructor}}
+  [[clang::musttail]] return ReturnsVoid(); // expected-error {{'musttail' attribute requires that all variables in scope are trivially destructible}}
+}
+
+int NonTrivialParam(HasNonTrivialDestructor x);
+int TestNonTrivialParam(HasNonTrivialDestructor x) {
+  [[clang::musttail]] return NonTrivialParam(x); // expected-error {{'musttail' attribute requires that the return value, all parameters, and any temporaries created by the expression are trivially destructible and do not require ARC}}
+}
+
+HasNonTrivialDestructor ReturnsNonTrivialValue();
+HasNonTrivialDestructor TestReturnsNonTrivialValue() {
+  [[clang::musttail]] return (ReturnsNonTrivialValue()); // expected-error {{'musttail' attribute requires that 

[PATCH] D70094: [clang-tidy] new altera ID dependent backward branch check

2021-04-02 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 334979.
ffrankies added a comment.

- Rebased on top of latest changes in main branch
- The diagnostic that identifies the code location where an ID-dependent 
variable/field is assigned has been changed from a warning to a note
- Changes addressing code style


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

https://reviews.llvm.org/D70094

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
  clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/altera-id-dependent-backward-branch.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
@@ -0,0 +1,86 @@
+// RUN: %check_clang_tidy %s altera-id-dependent-backward-branch %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h
+
+typedef struct ExampleStruct {
+  int IDDepField;
+} ExampleStruct;
+
+void error() {
+  //  Conditional Expressions 
+  int accumulator = 0;
+  for (int i = 0; i < get_local_id(0); i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  int j = 0;
+  while (j < get_local_id(0)) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < get_local_id(0));
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+
+  //  Assignments 
+  int ThreadID = get_local_id(0);
+
+  while (j < ThreadID) {
+// CHECK-NOTES: :[[@LINE-3]]:3: note: assignment of ID-dependent variable ThreadID
+// CHECK-NOTES: :[[@LINE-2]]:10: warning: backward branch (while loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  ExampleStruct Example;
+  Example.IDDepField = get_local_id(0);
+
+  //  Inferred Assignments 
+  int ThreadID2 = ThreadID * get_local_size(0);
+
+  int ThreadID3 = Example.IDDepField; // OK: not used in any loops
+
+  ExampleStruct UnusedStruct = {
+  ThreadID * 2 // OK: not used in any loops
+  };
+
+  for (int i = 0; i < ThreadID2; i++) {
+// CHECK-NOTES: :[[@LINE-9]]:3: note: inferred assignment of ID-dependent value from ID-dependent variable ThreadID
+// CHECK-NOTES: :[[@LINE-2]]:19: warning: backward branch (for loop) is ID-dependent due to variable reference to 'ThreadID2' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < ThreadID);
+  // CHECK-NOTES: :[[@LINE-29]]:3: note: assignment of ID-dependent variable ThreadID
+  // CHECK-NOTES: :[[@LINE-2]]:12: warning: backward branch (do loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+
+  for (int i = 0; i < Example.IDDepField; i++) {
+// CHECK-NOTES: :[[@LINE-24]]:3: note: assignment of ID-dependent field IDDepField
+// CHECK-NOTES: :[[@LINE-2]]:19: warning: backward branch (for loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  while (j < Example.IDDepField) {
+// CHECK-NOTES: :[[@LINE-30]]:3: note: assignment of ID-dependent field IDDepField
+// CHECK-NOTES: :[[@LINE-2]]:10: warning: backward branch (while loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < Example.IDDepField);
+  // CHECK-NOTES: :[[@LINE-38]]:3: note: assignment of ID-dependent field IDDepField
+  // CHECK-NOTES: :[[@LINE-2]]:12: warning: backward branch (do loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+}
+
+void success() {
+  int accumulator = 0;
+
+  for (int i = 0; i < 1000; i++) {
+if (i < get_local_id(0)) {
+  accumulator++;
+}
+  }
+}
Index: 

[PATCH] D97462: [clang][cli] Round-trip cc1 arguments in assert builds

2021-04-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D97462#2666366 , @akhuang wrote:

> In Chrome we noticed that plugin flags are not being roundtripped (and build 
> fails with `error: Generated arguments do not match in round-trip`):
>
> example of the differing args:
>
>   "-plugin-arg-blink-gc-plugin"
>   "no-members-in-stack-allocated"
>   "-plugin-arg-find-bad-constructs"
>   "checked-ptr-as-trivial-member"
>   "-plugin-arg-find-bad-constructs"
>   "check-ipc"
>
> vs
>
>   "-plugin-arg-find-bad-constructs"
>   "checked-ptr-as-trivial-member"
>   "-plugin-arg-find-bad-constructs"
>   "check-ipc"
>   "-plugin-arg-blink-gc-plugin"
>   "no-members-in-stack-allocated"

Thanks for reporting that. D99606  fixes one 
aspect of `-plugin-arg`, but it seems the order of generation is 
non-deterministic (most likely related to the underlying storage, 
`std::unordered_map`). I can look into it early next week, but I think simple 
sort in the generation code should do the trick.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97462

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


[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:13567-13568
+case OMPD_dispatch:
+  CaptureRegion = OMPD_task;
+  break;
+default:

What about other directives?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D99797#2666358 , @vsavchenko wrote:

> Thanks for working on improvements of the solver and constraints!  However, I 
> have some tough questions about this patch.
>
> What I really want to understand here is motivation.  Why do we need to have 
> `add` operation semantics like this in the first place?  My guess is that 
> "the user" will be in the following patch.
> Additionally, I don't really like the idea of replacing something simple and 
> fast (old `add` methods`) with something more complex unconditionally.  Old 
> users still don't need this additional logic.  C++ has always been the 
> language where we "pay for what we use".
> So, with good motivation, I'd still prefer methods like `add` and 
> `addUnchecked` or smith similar.

My motivation is that I'm currently working on some bigger improvement 
(symbolic integral cast) and stucked here of the lack of handling 
intersections. Would you mind of accepting this revision in case if I restore 
complexity to O(N+M)?




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:128
 ///
-/// Complexity: O(N + M)
+/// Complexity: O(N + Mlog(N))
 /// where N = size(LHS), M = size(RHS)

vsavchenko wrote:
> This most certainly can be done in `O(N + M)` the same way the intersection 
> is done.
Actually yes, it can. And it was, when I played with different solutions. But 
the code was poor readable. So I decided make it easier to understand to bring 
to review. Of couse I can move further to improve it and retain readability. 
I'll do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99797

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


[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 334969.
jyu2 added a comment.

Thank you, Alexey for the review!!!
This changes have been addressed as you suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/dispatch_ast_print.cpp
  clang/test/OpenMP/dispatch_messages.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -276,6 +276,10 @@
 def OMPC_Destroy : Clause<"destroy"> {
   let clangClass = "OMPDestroyClause";
 }
+def OMPC_Novariants : Clause<"novariants"> {
+  let clangClass = "OMPNovariantsClause";
+  let flangClass = "ScalarLogicalExpr";
+}
 def OMPC_Detach : Clause<"detach"> {
   let clangClass = "OMPDetachClause";
 }
@@ -1660,7 +1664,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Unknown : Directive<"unknown"> {
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -729,6 +729,7 @@
 CHECK_SIMPLE_CLAUSE(Write, OMPC_write)
 CHECK_SIMPLE_CLAUSE(Init, OMPC_init)
 CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
+CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Allocator, OMPC_allocator)
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2291,6 +2291,10 @@
 Visitor->AddStmt(C->getInteropVar());
 }
 
+void OMPClauseEnqueue::VisitOMPNovariantsClause(const OMPNovariantsClause *C) {
+  Visitor->AddStmt(C->getCondition());
+}
+
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
 
Index: clang/test/OpenMP/dispatch_messages.cpp
===
--- clang/test/OpenMP/dispatch_messages.cpp
+++ clang/test/OpenMP/dispatch_messages.cpp
@@ -28,6 +28,24 @@
   // expected-error@+1 {{cannot contain more than one 'nowait' clause}}
   #pragma omp dispatch nowait device(dnum) nowait
   disp_call();
+
+  // expected-error@+1 {{expected '(' after 'novariants'}}
+  #pragma omp dispatch novariants
+  disp_call();
+
+  // expected-error@+3 {{expected expression}}
+  // expected-error@+2 {{expected ')'}}
+  // expected-note@+1 {{to match this '('}}
+  #pragma omp dispatch novariants (
+  disp_call();
+
+  // expected-error@+1 {{cannot contain more than one 'novariants' clause}}
+  #pragma omp dispatch novariants(dnum> 4) novariants(3)
+  disp_call();
+
+  // expected-error@+1 {{use of undeclared identifier 'x'}}
+  #pragma omp dispatch novariants(x)
+  disp_call();
 }
 
 void testit_two() {
Index: clang/test/OpenMP/dispatch_ast_print.cpp
===
--- clang/test/OpenMP/dispatch_ast_print.cpp
+++ clang/test/OpenMP/dispatch_ast_print.cpp
@@ -51,20 +51,22 @@
 void test_one()
 {
   int aaa, bbb, var;
-  //PRINT: #pragma omp dispatch depend(in : var) nowait
+  //PRINT: #pragma omp dispatch depend(in : var) nowait novariants(aaa > 5)
   //DUMP: OMPDispatchDirective
   //DUMP: OMPDependClause
   //DUMP: OMPNowaitClause
-  #pragma omp dispatch depend(in:var) nowait
+  //DUMP: OMPNovariantsClause
+  #pragma omp dispatch depend(in:var) nowait novariants(aaa > 5)
   foo(aaa, );
 
   int *dp = get_device_ptr();
   int dev = get_device();
-  //PRINT: #pragma omp dispatch device(dev) is_device_ptr(dp)
+  //PRINT: #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10)
   //DUMP: OMPDispatchDirective
   //DUMP: OMPDeviceClause
   //DUMP: OMPIs_device_ptrClause
-  #pragma omp dispatch device(dev) is_device_ptr(dp)
+  //DUMP: OMPNovariantsClause
+  #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10)
   foo(aaa, dp);
 
   //PRINT: #pragma omp dispatch
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6237,6 +6237,12 @@
   

[PATCH] D99537: [OPENMP51]Initial support for the dispatch directive

2021-04-02 Thread Mike Rice via Phabricator via cfe-commits
mikerice added a comment.

@jyu2 is currently working on the novariants and nocontext clauses.  We are 
still working on the overall construct so I'm not sure yet what more we will 
have to contribute.

I'll look into updating the support doc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99537

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


[PATCH] D97462: [clang][cli] Round-trip cc1 arguments in assert builds

2021-04-02 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

In Chrome we noticed that plugin flags are not being roundtripped (and build 
fails with `error: Generated arguments do not match in round-trip`):

example of the differing args:

  "-plugin-arg-blink-gc-plugin"
  "no-members-in-stack-allocated"
  "-plugin-arg-find-bad-constructs"
  "checked-ptr-as-trivial-member"
  "-plugin-arg-find-bad-constructs"
  "check-ipc"

vs

  "-plugin-arg-find-bad-constructs"
  "checked-ptr-as-trivial-member"
  "-plugin-arg-find-bad-constructs"
  "check-ipc"
  "-plugin-arg-blink-gc-plugin"
  "no-members-in-stack-allocated"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97462

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


[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Thanks for working on improvements of the solver and constraints!  However, I 
have some tough questions about this patch.

What I really want to understand here is motivation.  Why do we need to have 
`add` operation semantics like this in the first place?  My guess is that "the 
user" will be in the following patch.
Additionally, I don't really like the idea of replacing something simple and 
fast (old `add` methods`) with something more complex unconditionally.  Old 
users still don't need this additional logic.  C++ has always been the language 
where we "pay for what we use".
So, with good motivation, I'd still prefer methods like `add` and 
`addUnchecked` or smith similar.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:128
 ///
-/// Complexity: O(N + M)
+/// Complexity: O(N + Mlog(N))
 /// where N = size(LHS), M = size(RHS)

This most certainly can be done in `O(N + M)` the same way the intersection is 
done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99797

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


[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: vsavchenko, steakhal, NoQ, xazax.hun, dcoughlin, 
Szelethus.
ASDenysPetrov added a project: clang.
Herald added subscribers: martong, Charusso, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
ASDenysPetrov requested review of this revision.
Herald added a subscriber: cfe-commits.

Handle **intersected** and **adjacent** ranges uniting them into a single one.
Example:
intersection `[0, 10] U [5, 20] = [0, 20]`
adjacency `[0, 10] U [11, 20] = [0, 20]`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99797

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -61,6 +61,9 @@
   static constexpr BaseType getMax() {
 return std::numeric_limits::max();
   }
+  // MID is a value in the middle of the range
+  // which unary minus does not affect on,
+  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   static constexpr BaseType getMid() {
 return isSigned() ? 0 : ~(fromInt(-1) / fromInt(2));
   }
@@ -160,7 +163,7 @@
 
   void checkAdd(RawRangeSet RawLHS, RawRangeSet RawRHS,
 RawRangeSet RawExpected) {
-wrap(::checkAddImpl, RawRHS, RawLHS, RawExpected);
+wrap(::checkAddImpl, RawLHS, RawRHS, RawExpected);
   }
 
   void checkAdd(RawRangeSet RawLHS, BaseType RawRHS, RawRangeSet RawExpected) {
@@ -195,9 +198,6 @@
 
   constexpr TypeParam MIN = TestFixture::getMin();
   constexpr TypeParam MAX = TestFixture::getMax();
-  // MID is a value in the middle of the range
-  // which unary minus does not affect on,
-  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   constexpr TypeParam MID = TestFixture::getMid();
   constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
   constexpr TypeParam B = MID - TestFixture::fromInt(42);
@@ -310,24 +310,124 @@
 }
 
 TYPED_TEST(RangeSetTest, RangeSetAddTest) {
-  // Check adding single points
-  this->checkAdd({}, 10, {{10, 10}});
-  this->checkAdd({{0, 5}}, 10, {{0, 5}, {10, 10}});
-  this->checkAdd({{0, 5}, {30, 40}}, 10, {{0, 5}, {10, 10}, {30, 40}});
-
-  // Check adding single ranges.
-  this->checkAdd({}, {10, 20}, {{10, 20}});
-  this->checkAdd({{0, 5}}, {10, 20}, {{0, 5}, {10, 20}});
-  this->checkAdd({{0, 5}, {30, 40}}, {10, 20}, {{0, 5}, {10, 20}, {30, 40}});
-
-  // Check adding whole sets of ranges.
-  this->checkAdd({{0, 5}}, {{10, 20}}, {{0, 5}, {10, 20}});
-  // Check that ordering of ranges is as expected.
-  this->checkAdd({{0, 5}, {30, 40}}, {{10, 20}}, {{0, 5}, {10, 20}, {30, 40}});
-  this->checkAdd({{0, 5}, {30, 40}}, {{10, 20}, {50, 60}},
- {{0, 5}, {10, 20}, {30, 40}, {50, 60}});
-  this->checkAdd({{10, 20}, {50, 60}}, {{0, 5}, {30, 40}, {70, 80}},
- {{0, 5}, {10, 20}, {30, 40}, {50, 60}, {70, 80}});
+
+  // Use next values of the range {MIN, A, B, MID, C, D, MAX}.
+  constexpr TypeParam MIN = TestFixture::getMin();
+  constexpr TypeParam MAX = TestFixture::getMax();
+  constexpr TypeParam MID = TestFixture::getMid();
+  constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
+  constexpr TypeParam B = MID - TestFixture::fromInt(42);
+  constexpr TypeParam C = -B;
+  constexpr TypeParam D = -A;
+
+  // LHS and RHS is empty.
+  // RHS =>
+  // LHS => =
+  //___   ___
+  this->checkAdd({}, {}, {});
+
+  // RHS is empty.
+  // RHS =>
+  // LHS =>_=_
+  //__/_\__   __/_\__
+  this->checkAdd({{A, B}}, {}, {{A, B}});
+  this->checkAdd({{A, B}, {C, D}}, {}, {{A, B}, {C, D}});
+
+  // LHS is empty.
+  // RHS => ___
+  // LHS =>/   \=_
+  //__/_\__   __/_\__
+  this->checkAdd({}, B, {{B, B}});
+  this->checkAdd({}, {B, C}, {{B, C}});
+  this->checkAdd({}, {{MIN, B}, {C, MAX}}, {{MIN, B}, {C, MAX}});
+
+  // RHS is detached from LHS.
+  // RHS => ___
+  // LHS =>___ /   \=___ _
+  //__/___\___/_\__   __/___\___/_\__
+  this->checkAdd({{A, C}}, D, {{A, C}, {D, D}});
+  this->checkAdd({{MID, C}, {D, MAX}}, A, {{A, A}, {MID, C}, {D, MAX}});
+  this->checkAdd({{A, B}}, {MID, D}, {{A, B}, {MID, D}});
+  this->checkAdd({{MIN, A}, {D, MAX}}, {B, C}, {{MIN, A}, {B, C}, {D, MAX}});
+  this->checkAdd({{B, MID}, {D, MAX}}, {{MIN, A}, {C, C}},
+ {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+  this->checkAdd({{MIN, A}, {C, C}}, {{B, MID}, {D, MAX}},
+ {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+
+  // RHS is inside LHS.
+  // RHS =>

[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-02 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D99426#2666141 , 
@abhina.sreeskantharajan wrote:

> In D99426#2665361 , @aganea wrote:
>
>> I am still concerned by the fact that this patch doesn't fix the issue 
>> mentionned in https://reviews.llvm.org/D96363#2650460
>> Was the intention to fix that issue? Will the fix be done in a subsequent 
>> patch?
>
> I was fairly confident that if https://reviews.llvm.org/D96363 was the patch 
> that was causing the issue for you

That is the case! I've confirmed that `git checkout 
fdb640ea30d416368b76b68b106deda580c6aced~1 && ninja clang -C build` generates a 
`clang-cl.exe` that works with my above test case. `git revert 
fdb640ea30d416368b76b68b106deda580c6aced` locally over ToT fixes the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision.
ASDenysPetrov added a comment.
This revision is now accepted and ready to land.

In D95246#2606343 , 
@abhina.sreeskantharajan wrote:

> This issue has been fixed in https://reviews.llvm.org/D97472.
> @ASDenysPetrov I'm unable to close this revision and the other one 
> https://reviews.llvm.org/D95808. Do you know what the appropriate action is 
> here? To abandon this, or accept it again and close it?

Done. Sorry for the delay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95808: [test] Use host platform specific error message substitution in lit tests - continued

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision.
ASDenysPetrov added a comment.
This revision is now accepted and ready to land.

In D95808#2657744 , @jhenderson wrote:

> @ASDenysPetrov, I think you need to mark this patch as Accepted so that 
> someone can close this review.

Done. Sorry for the delay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95808

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


[PATCH] D37624: add support for -fno-instrument-functions and -finstrument-functions-exclude-{file,function}-list= to match gcc options.

2021-04-02 Thread Oliver Browne via Phabricator via cfe-commits
oliverbrowne added a comment.

Hi Folks, don't know if this review is still active but I can provide some 
context on the GCC behavior with respect to namespaces, template params and 
function arguments, they were bugs, fixed in 2019.

Associated bug reports for namespace/class, and template parameter and argument 
mishandling: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90816
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90809


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

https://reviews.llvm.org/D37624

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D99037#2666230 , @SaurabhJha wrote:

> Update commit message to more accurately reflect the patch

Just FYI, `arc diff ` does not update the patch description on Phabricator. I 
think you have to edit it via the web-interface.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99537: [OPENMP51]Initial support for the dispatch directive

2021-04-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a subscriber: jyu2.
jdoerfert added a comment.

Cool, are you expecting to hook this up to the variant selection logic as well? 
@jyu2 similarly do you intend to hook up `novariant`?

We should also update https://clang.llvm.org/docs/OpenMPSupport.html to claim 
parts you are working on (upstreaming).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99537

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


[clang] 3ebfa36 - Remove attribute handling code for simple attributes; NFC

2021-04-02 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-04-02T11:35:10-04:00
New Revision: 3ebfa363f356eff744b73885023cc1fc62fad973

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

LOG: Remove attribute handling code for simple attributes; NFC

Attributes that set the SimpleHandler flag in Attr.td don't need to be
explicitly handled in SemaDeclAttr.cpp.

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index c7b68856aab0..b832d1df7172 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2113,6 +2113,7 @@ def ObjCNonRuntimeProtocol : Attr {
   let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
   let LangOpts = [ObjC];
   let Documentation = [ObjCNonRuntimeProtocolDocs];
+  let SimpleHandler = 1;
 }
 
 def ObjCRuntimeName : Attr {
@@ -2247,12 +2248,14 @@ def SwiftBridgedTypedef : InheritableAttr {
   let Spellings = [GNU<"swift_bridged_typedef">];
   let Subjects = SubjectList<[TypedefName], ErrorDiag>;
   let Documentation = [SwiftBridgedTypedefDocs];
+  let SimpleHandler = 1;
 }
 
 def SwiftObjCMembers : Attr {
   let Spellings = [GNU<"swift_objc_members">];
   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
   let Documentation = [SwiftObjCMembersDocs];
+  let SimpleHandler = 1;
 }
 
 def SwiftError : InheritableAttr {
@@ -2284,6 +2287,7 @@ def SwiftNewType : InheritableAttr {
 def SwiftPrivate : InheritableAttr {
   let Spellings = [GNU<"swift_private">];
   let Documentation = [SwiftPrivateDocs];
+  let SimpleHandler = 1;
 }
 
 def NoDeref : TypeAttr {
@@ -3667,6 +3671,7 @@ def LoaderUninitialized : Attr {
   let Spellings = [Clang<"loader_uninitialized">];
   let Subjects = SubjectList<[GlobalVar]>;
   let Documentation = [LoaderUninitializedDocs];
+  let SimpleHandler = 1;
 }
 
 def ObjCExternallyRetained : InheritableAttr {

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index b39460d33214..23b488c527b1 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2650,11 +2650,6 @@ static void handleVisibilityAttr(Sema , Decl *D, const 
ParsedAttr ,
 D->addAttr(newAttr);
 }
 
-static void handleObjCNonRuntimeProtocolAttr(Sema , Decl *D,
- const ParsedAttr ) {
-  handleSimpleAttribute(S, D, AL);
-}
-
 static void handleObjCDirectAttr(Sema , Decl *D, const ParsedAttr ) {
   // objc_direct cannot be set on methods declared in the context of a protocol
   if (isa(D->getDeclContext())) {
@@ -7957,9 +7952,6 @@ static void ProcessDeclAttribute(Sema , Scope *scope, 
Decl *D,
   case ParsedAttr::AT_AnyX86NoCfCheck:
 handleNoCfCheckAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_Leaf:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_NoThrow:
 if (!AL.isUsedAsTypeAttr())
   handleSimpleAttribute(S, D, AL);
@@ -8093,9 +8085,6 @@ static void ProcessDeclAttribute(Sema , Scope *scope, 
Decl *D,
   case ParsedAttr::AT_ObjCDirect:
 handleObjCDirectAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_ObjCNonRuntimeProtocol:
-handleObjCNonRuntimeProtocolAttr(S, D, AL);
-break;
   case ParsedAttr::AT_ObjCDirectMembers:
 handleObjCDirectMembersAttr(S, D, AL);
 handleSimpleAttribute(S, D, AL);
@@ -8114,9 +8103,6 @@ static void ProcessDeclAttribute(Sema , Scope *scope, 
Decl *D,
 handleSimpleAttributeWithExclusions(S, D,
  AL);
 break;
-  case ParsedAttr::AT_NoMerge:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_Visibility:
 handleVisibilityAttr(S, D, AL, false);
 break;
@@ -8324,9 +8310,6 @@ static void ProcessDeclAttribute(Sema , Scope *scope, 
Decl *D,
   case ParsedAttr::AT_SwiftBridge:
 handleSwiftBridge(S, D, AL);
 break;
-  case ParsedAttr::AT_SwiftBridgedTypedef:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_SwiftError:
 handleSwiftError(S, D, AL);
 break;
@@ -8336,12 +8319,6 @@ static void ProcessDeclAttribute(Sema , Scope *scope, 
Decl *D,
   case ParsedAttr::AT_SwiftNewType:
 handleSwiftNewType(S, D, AL);
 break;
-  case ParsedAttr::AT_SwiftObjCMembers:
-handleSimpleAttribute(S, D, AL);
-break;
-  case ParsedAttr::AT_SwiftPrivate:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_SwiftAsync:
 handleSwiftAsyncAttr(S, D, AL);
 break;
@@ -8367,10 +8344,6 @@ static void ProcessDeclAttribute(Sema , Scope *scope, 
Decl *D,
 handleUninitializedAttr(S, D, AL);
 break;
 
-  case ParsedAttr::AT_LoaderUninitialized:
-handleSimpleAttribute(S, D, AL);
-  

[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/OpenMPClause.h:7659
+/// clause with condition 'a > 5'.
+class OMPNovariantsClause : public OMPClause, public OMPClauseWithPreInit {
+  friend class OMPClauseReader;

`final`



Comment at: clang/include/clang/AST/OpenMPClause.h:7696-7698
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+

Can you make it private?



Comment at: clang/lib/AST/OpenMPClause.cpp:1830
+  OS << "novariants(";
+  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
+  OS << ")";

I would add a check for non-nullptr `Node->getCondition()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[PATCH] D99755: Remove clang/runtime and `COMPILER_RT_INSTALL_PATH`

2021-04-02 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

So unfortunately it seems the `clang/runtime`'s use was triggered by 
`LLVM_BUILD_EXTERNAL_COMPILER_RT`, which is in use in a few places still? (And 
not just Apple ones.)

On the other hand, since this is doing an *external* CMake for compiler-rt, I 
fail to see why `COMPILER_RT_INSTALL_PATH` is needed; why not just pass a 
different `CMAKE_INSTALL_PREFIX`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99755

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


[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 334956.
jyu2 added a comment.

Fix format problem as suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/dispatch_ast_print.cpp
  clang/test/OpenMP/dispatch_messages.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -276,6 +276,10 @@
 def OMPC_Destroy : Clause<"destroy"> {
   let clangClass = "OMPDestroyClause";
 }
+def OMPC_Novariants : Clause<"novariants"> {
+  let clangClass = "OMPNovariantsClause";
+  let flangClass = "ScalarLogicalExpr";
+}
 def OMPC_Detach : Clause<"detach"> {
   let clangClass = "OMPDetachClause";
 }
@@ -1660,7 +1664,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Unknown : Directive<"unknown"> {
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -729,6 +729,7 @@
 CHECK_SIMPLE_CLAUSE(Write, OMPC_write)
 CHECK_SIMPLE_CLAUSE(Init, OMPC_init)
 CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
+CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Allocator, OMPC_allocator)
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2291,6 +2291,10 @@
 Visitor->AddStmt(C->getInteropVar());
 }
 
+void OMPClauseEnqueue::VisitOMPNovariantsClause(const OMPNovariantsClause *C) {
+  Visitor->AddStmt(C->getCondition());
+}
+
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
 
Index: clang/test/OpenMP/dispatch_messages.cpp
===
--- clang/test/OpenMP/dispatch_messages.cpp
+++ clang/test/OpenMP/dispatch_messages.cpp
@@ -28,6 +28,24 @@
   // expected-error@+1 {{cannot contain more than one 'nowait' clause}}
   #pragma omp dispatch nowait device(dnum) nowait
   disp_call();
+
+  // expected-error@+1 {{expected '(' after 'novariants'}}
+  #pragma omp dispatch novariants
+  disp_call();
+
+  // expected-error@+3 {{expected expression}}
+  // expected-error@+2 {{expected ')'}}
+  // expected-note@+1 {{to match this '('}}
+  #pragma omp dispatch novariants (
+  disp_call();
+
+  // expected-error@+1 {{cannot contain more than one 'novariants' clause}}
+  #pragma omp dispatch novariants(dnum> 4) novariants(3)
+  disp_call();
+
+  // expected-error@+1 {{use of undeclared identifier 'x'}}
+  #pragma omp dispatch novariants(x)
+  disp_call();
 }
 
 void testit_two() {
Index: clang/test/OpenMP/dispatch_ast_print.cpp
===
--- clang/test/OpenMP/dispatch_ast_print.cpp
+++ clang/test/OpenMP/dispatch_ast_print.cpp
@@ -51,20 +51,22 @@
 void test_one()
 {
   int aaa, bbb, var;
-  //PRINT: #pragma omp dispatch depend(in : var) nowait
+  //PRINT: #pragma omp dispatch depend(in : var) nowait novariants(aaa > 5)
   //DUMP: OMPDispatchDirective
   //DUMP: OMPDependClause
   //DUMP: OMPNowaitClause
-  #pragma omp dispatch depend(in:var) nowait
+  //DUMP: OMPNovariantsClause
+  #pragma omp dispatch depend(in:var) nowait novariants(aaa > 5)
   foo(aaa, );
 
   int *dp = get_device_ptr();
   int dev = get_device();
-  //PRINT: #pragma omp dispatch device(dev) is_device_ptr(dp)
+  //PRINT: #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10)
   //DUMP: OMPDispatchDirective
   //DUMP: OMPDeviceClause
   //DUMP: OMPIs_device_ptrClause
-  #pragma omp dispatch device(dev) is_device_ptr(dp)
+  //DUMP: OMPNovariantsClause
+  #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10)
   foo(aaa, dp);
 
   //PRINT: #pragma omp dispatch
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6237,6 +6237,12 @@
   Record.AddSourceLocation(C->getVarLoc());
 }
 
+void 

[PATCH] D99755: Remove clang/runtime and `COMPILER_RT_INSTALL_PATH`

2021-04-02 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 334955.
Ericson2314 added a comment.

Remove add_subdirectory(runtime) for deleted dir


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99755

Files:
  clang/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  clang/runtime/compiler-rt/clang_linux_test_input.c
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/include/CMakeLists.txt
  compiler-rt/lib/dfsan/CMakeLists.txt
  llvm/runtimes/CMakeLists.txt

Index: llvm/runtimes/CMakeLists.txt
===
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -1,6 +1,6 @@
 # TODO: This file assumes the Clang toolchain so it'd be better if it lived in
-# Clang, except there already is clang/runtime directory which contains
-# similar although simpler functionality. We should figure out how to merge
+# Clang, except there already is runtimes directory which contains
+# similar functionality. We should figure out how to merge
 # the two files.
 
 # TODO: Selecting runtimes should be always performed inside the runtimes
Index: compiler-rt/lib/dfsan/CMakeLists.txt
===
--- compiler-rt/lib/dfsan/CMakeLists.txt
+++ compiler-rt/lib/dfsan/CMakeLists.txt
@@ -62,4 +62,4 @@
DEPENDS done_abilist.txt libc_ubuntu1404_abilist.txt)
 add_dependencies(dfsan dfsan_abilist)
 install(FILES ${dfsan_abilist_filename}
-DESTINATION ${COMPILER_RT_INSTALL_PATH}/share)
+DESTINATION share)
Index: compiler-rt/include/CMakeLists.txt
===
--- compiler-rt/include/CMakeLists.txt
+++ compiler-rt/include/CMakeLists.txt
@@ -69,22 +69,22 @@
 install(FILES ${SANITIZER_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/sanitizer)
+  DESTINATION include/sanitizer)
 # Install fuzzer headers.
 install(FILES ${FUZZER_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/fuzzer)
+  DESTINATION include/fuzzer)
 # Install xray headers.
 install(FILES ${XRAY_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/xray)
+  DESTINATION include/xray)
 # Install profile headers.
 install(FILES ${PROFILE_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/profile)
+  DESTINATION include/profile)
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDEs.
   add_custom_target(install-compiler-rt-headers
Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -92,12 +92,12 @@
   set(COMPILER_RT_LIBRARY_OUTPUT_DIR
 ${COMPILER_RT_OUTPUT_DIR})
   set(COMPILER_RT_LIBRARY_INSTALL_DIR
-${COMPILER_RT_INSTALL_PATH})
+"")
 else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
   set(COMPILER_RT_LIBRARY_OUTPUT_DIR
 ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
   set(COMPILER_RT_LIBRARY_INSTALL_DIR
-${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
+lib/${COMPILER_RT_OS_DIR})
 endif()
 
 if(APPLE)
Index: compiler-rt/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -386,7 +386,7 @@
 function(get_compiler_rt_install_dir arch install_dir)
   if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
 get_compiler_rt_target(${arch} target)
-set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/lib/${target} PARENT_SCOPE)
+set(${install_dir} lib/${target} PARENT_SCOPE)
   else()
 set(${install_dir} ${COMPILER_RT_LIBRARY_INSTALL_DIR} PARENT_SCOPE)
   endif()
Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -508,7 +508,7 @@
 set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR
   ${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded)
 set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
-  ${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded)
+  lib/macho_embedded)
   
 set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi")
 set(CFLAGS_i386 "-march=pentium")
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake

[PATCH] D75844: [clang] Set begin loc on GNU attribute parsed attrs

2021-04-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 334954.
tbaeder added a comment.
Herald added a subscriber: jdoerfert.

A little earlier than expected. Happy Easter  :P


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

https://reviews.llvm.org/D75844

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough.cpp

Index: clang/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- clang/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ clang/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -185,9 +185,12 @@
   return 1;
   [[clang::fallthrough]];  // expected-warning{{fallthrough annotation in unreachable code}}
 case 222:
+  return 2;
+  __attribute__((fallthrough)); // expected-warning{{fallthrough annotation in unreachable code}}
+case 223:
   n += 400;
-case 223:  // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
-  ;
+case 224: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
+;
   }
 
   long p = static_cast(n) * n;
Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -368,6 +368,20 @@
   return n;
 }
 
+template struct TemplateStruct {};
+class FriendClassesWithAttributes {
+  // We allow GNU-style attributes here
+  template  friend class __attribute__((__type_visibility__("default"))) vector;
+  // But not C++11 ones
+  template  friend class[[]] vector2; // expected-error {{an attribute list cannot appear here}}
+  template  friend class [[clang::__type_visibility__(("default"))]] vector3; // expected-error {{an attribute list cannot appear here}}
+
+  // Also allowed
+  friend struct __attribute__((__type_visibility__("default"))) TemplateStruct;
+  friend struct[[]] TemplateStruct;   // expected-error {{an attribute list cannot appear here}}
+  friend struct [[clang::__type_visibility__("default")]] TemplateStruct; // expected-error {{an attribute list cannot appear here}}
+};
+
 #define attr_name bitand
 #define attr_name_2(x) x
 #define attr_name_3(x, y) x##y
Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,24 @@
   }
 }
 
+// CHECK-1Z: NamespaceDecl {{.*}} attributed_case
+namespace attributed_case {
+void f(int n) {
+  switch (n) {
+  case 0:
+n--;
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: FallThroughAttr {{.*}} 
+__attribute__((fallthrough))
+// CHECK: FallThroughAttr {{.*}} 
+  __attribute__((fallthrough));
+  case 1:
+n++;
+break;
+  }
+}
+} // namespace attributed_case
+
 // CHECK: NamespaceDecl {{.*}} attributed_stmt
 namespace attributed_stmt {
   // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1852,7 +1852,8 @@
 } else if (TUK == Sema::TUK_Reference ||
(TUK == Sema::TUK_Friend &&
 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+  /*DiagnoseEmptyAttrs=*/true);
   TypeResult = Actions.ActOnTagTemplateIdType(TUK, TagType, StartLoc,
   SS,
   TemplateId->TemplateKWLoc,
@@ -1924,7 +1925,8 @@
 TagType, StartLoc, SS, Name, NameLoc, attrs);
   } else if (TUK == Sema::TUK_Friend &&
  TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
-ProhibitAttributes(attrs);
+ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+/*DiagnoseEmptyAttrs=*/true);
 
 TagOrTempResult = Actions.ActOnTemplatedFriendTag(
 getCurScope(), DS.getFriendSpecLoc(), TagType, StartLoc, SS, Name,
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -162,15 +162,19 @@
 ///',' or ')' are ignored, otherwise they produce a 

[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-04-02 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 334952.
kamleshbhalui added a comment.

Making changes effective only for windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-preprocessed-file.i
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/CodeGenCXX/debug-info-mingw.cpp
  clang/test/CodeGenCXX/linetable-fnbegin.cpp
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/stdin-input.c
  clang/test/Modules/module-debuginfo-prefix.m
  clang/test/PCH/debug-info-pch-container-path.c

Index: clang/test/PCH/debug-info-pch-container-path.c
===
--- clang/test/PCH/debug-info-pch-container-path.c
+++ clang/test/PCH/debug-info-pch-container-path.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Frontend/stdin-input.c
===
--- clang/test/Frontend/stdin-input.c
+++ clang/test/Frontend/stdin-input.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: cat %s | %clang -emit-llvm -g -S \
 // RUN: -Xclang -main-file-name -Xclang test/foo.c -x c - -o - | FileCheck %s
 // CHECK: ; ModuleID = 'test/foo.c'
Index: clang/test/Frontend/optimization-remark-line-directive.c
===
--- clang/test/Frontend/optimization-remark-line-directive.c
+++ clang/test/Frontend/optimization-remark-line-directive.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // This file tests -Rpass diagnostics together with #line
 // directives. We cannot map #line directives back to
 // a SourceLocation.
Index: clang/test/CodeGenCXX/linetable-fnbegin.cpp
===
--- clang/test/CodeGenCXX/linetable-fnbegin.cpp
+++ clang/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
 // Test that the line table info for Foo::bar() is pointing to the
 // right header file.
@@ -11,7 +12,6 @@
 // We shouldn't need a lexical block for this function.
 // CHECK: [[DBG]] = !DILocation(line: 23, column: 3, scope: [[SP]])
 
-
 # 1 "./template.h" 1
 template 
 class Foo {
Index: clang/test/CodeGenCXX/debug-info-mingw.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-mingw.cpp
@@ -0,0 +1,9 @@
+// UNSUPPORTED: !system-windows
+// RUN: rm -rf %t/UNIQUE_DIR && mkdir -p %t/UNIQUE_DIR
+// RUN: cp %s %t/UNIQUE_DIR/debug-info-mingw.cpp
+// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -debug-info-kind=limited \
+// RUN: -main-file-name debug-info-mingw.cpp %t/UNIQUE_DIR/debug-info-mingw.cpp \
+// RUN: -emit-llvm -o - | FileCheck %s
+int main() {
+}
+// CHECK: !DIFile(filename: "{{.+}}\\UNIQUE_DIR\\debug-info-mingw.cpp",
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-EVIL
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name debug-prefix-map.c | FileCheck %s
Index: clang/test/CodeGen/debug-info-preprocessed-file.i
===
--- clang/test/CodeGen/debug-info-preprocessed-file.i
+++ clang/test/CodeGen/debug-info-preprocessed-file.i
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 # 1 "/foo/bar/preprocessed-input.c"
 # 1 "" 1
 # 1 "" 3
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,6 +444,12 @@
   StringRef Dir;
   StringRef File;
   std::string RemappedFile = remapDIPath(FileName);
+  // Convert RemappedFile to native style when Windows
+  if (CGM.getTarget().getTriple().isOSWindows()) {
+SmallString<128> NativeFileName = StringRef(RemappedFile);
+llvm::sys::path::native(NativeFileName);
+RemappedFile = 

[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha updated this revision to Diff 334951.
SaurabhJha added a comment.

Update commit message to more accurately reflect the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Edit/RewriteObjCFoundationAPI.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/CodeGen/matrix-cast.c
  clang/test/Sema/matrix-cast.c

Index: clang/test/Sema/matrix-cast.c
===
--- /dev/null
+++ clang/test/Sema/matrix-cast.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fenable-matrix -fsyntax-only %s -verify
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));
+typedef short sx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+
+void f1() {
+  cx4x4 m1;
+  ix4x4 m2;
+  sx4x4 m3;
+  ix5x5 m4;
+  fx5x5 m5;
+
+  m2 = (ix4x4)m1;
+  m3 = (sx4x4)m2;
+  m4 = (ix5x5)m3; // expected-error {{invalid conversion between matrix type \
+'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))') and 'sx4x4' \
+(aka 'short __attribute__((matrix_type(4, 4)))') of different size}}
+  m5 = (ix5x5)m4; // expected-error {{assigning to 'fx5x5' (aka \
+'float __attribute__((matrix_type(5, 5)))') from incompatible type 'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))')}}
+  m4 = (ix5x5)m5;
+}
+
+typedef float float2_8x8 __attribute__((matrix_type(8, 8)));
+typedef double double_10x10 __attribute__((matrix_type(10, 10)));
+typedef double double_8x8 __attribute__((matrix_type(8, 8)));
+typedef signed int signed_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_10x10 __attribute__((matrix_type(10, 10)));
+
+void f2() {
+  float2_8x8 m1;
+  double_10x10 m2;
+  double_8x8 m3;
+  signed_int_12x12 m4;
+  unsigned_int_12x12 m5;
+  unsigned_int_10x10 m6;
+
+  m2 = (double_10x10)m1; // expected-error {{invalid conversion between matrix type \
+'double_10x10' (aka 'double __attribute__((matrix_type(10, 10)))') and 'float2_8x8' \
+(aka 'float __attribute__((matrix_type(8, 8)))') of different size}}
+  m3 = (double_8x8)m1;
+
+  m5 = (unsigned_int_12x12)m4;
+  m4 = (signed_int_12x12)m5;
+  m6 = (unsigned_int_10x10)m4; // expected-error {{invalid conversion between matrix type \
+'unsigned_int_10x10' (aka 'unsigned int __attribute__((matrix_type(10, 10)))') and 'signed_int_12x12' \
+(aka 'int __attribute__((matrix_type(12, 12)))') of different size}}
+}
\ No newline at end of file
Index: clang/test/CodeGen/matrix-cast.c
===
--- /dev/null
+++ clang/test/CodeGen/matrix-cast.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef char cx5x5 __attribute__((matrix_type(5, 5)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef short sx5x5 __attribute__((matrix_type(5, 5)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+typedef double dx5x5 __attribute__((matrix_type(5, 5)));
+typedef signed int signed_int_5x5 __attribute__((matrix_type(5, 5)));
+typedef unsigned int unsigned_int_5x5 __attribute__((matrix_type(5, 5)));
+
+void cast_char_matrix_to_int(cx5x5 c, ix5x5 i) {
+  // CHECK-LABEL: define{{.*}} void @cast_char_matrix_to_int(<25 x i8> %c, <25 x i32> %i)
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  i = (ix5x5)c;
+}
+
+void cast_int_matrix_to_short(ix5x5 i, sx5x5 s) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_short(<25 x i32> %i, <25 x i16> %s)
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  [[CONV:%.*]] = trunc <25 x i32> [[I]] to <25 x i16>
+  // CHECK-NEXT:  store <25 x i16> [[CONV]], <25 x i16>* {{.*}}, align 2
+  // CHECK-NEXT:  ret void
+
+  s = (sx5x5)i;
+}
+
+void cast_int_matrix_to_float(ix5x5 i, fx5x5 f) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_float(<25 x i32> %i, <25 x float> %f)
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  

[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:7400
+  } else {
+return Diag(R.getBegin(),
+diag::err_invalid_conversion_between_matrix_and_scalar)

When we get here, `SrcTy` may not necessarily be a scalar I think (see my 
earlier note about adding more invalid cast tests for some additional cases 
that might reach this code)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:2916
 
   // Require the operand to be a scalar or vector.
+  if (!SrcType->isScalarType() && !SrcType->isVectorType() &&

` ... or a matrix`?



Comment at: clang/test/Sema/matrix-cast.c:3
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));

I think it would be good to add additional test coverage casting between matrix 
types and other types, e.g.  vector types, pointer types and struct types.

It would also be good to have C++ tests that test casting with matrix types 
where some of the dimensions are template arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:547
+  case CK_MatrixCast: {
+// TODO: Handle MatrixCast here.
+  }

SaurabhJha wrote:
> I thought doing changes here is is outside the scope of casting so I just 
> left a TODO here. Please let me know if we want to do something else here.
I think that's fair,  but you should probably add `continue;` rather than 
falling through.



Comment at: clang/test/CodeGen/matrix-cast.c:15
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4

This doesn't seem right. We are casting between 2 signed types, so the sign 
should get preserved, right? Shouldn't this be `sext`? See 
https://godbolt.org/z/zWznYdnKW for the scalar case.

I think you also need tests for casts with different bitwidths with unsigned, 
unsigned -> signed & signed -> unsigned.



Comment at: clang/test/CodeGen/matrix-cast.c:39
+
+  f = (fx5x5)i;
+}

SaurabhJha wrote:
> I tried adding a float -> int conversion too but it failed because of this 
> assertion 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1339-L1344
>  Hopefully that's intended.
Clang should never run into an assertion. If that should not be allowed, then 
Clang should emit an error during Sema. I'm not sure why there is such a 
restriction for vector types, but I am not sure that this shouldn't be allowed 
for matrixes. Perhaps @rjmccall has more thoughts on this, but conversion 
between scalar ints to floats is allowed AFAIKT.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

Added some inline comments on where I have some doubts.




Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:547
+  case CK_MatrixCast: {
+// TODO: Handle MatrixCast here.
+  }

I thought doing changes here is is outside the scope of casting so I just left 
a TODO here. Please let me know if we want to do something else here.



Comment at: clang/test/CodeGen/matrix-cast.c:39
+
+  f = (fx5x5)i;
+}

I tried adding a float -> int conversion too but it failed because of this 
assertion 
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1339-L1344
 Hopefully that's intended.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha updated this revision to Diff 334945.
SaurabhJha added a comment.

Updating D99037 : [Matrix] Implement explicit 
type conversions for matrix types
Removed unused variables and includes and fix codegen lit tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Edit/RewriteObjCFoundationAPI.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/CodeGen/matrix-cast.c
  clang/test/Sema/matrix-cast.c

Index: clang/test/Sema/matrix-cast.c
===
--- /dev/null
+++ clang/test/Sema/matrix-cast.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fenable-matrix -fsyntax-only %s -verify
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));
+typedef short sx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+
+void f1() {
+  cx4x4 m1;
+  ix4x4 m2;
+  sx4x4 m3;
+  ix5x5 m4;
+  fx5x5 m5;
+
+  m2 = (ix4x4)m1;
+  m3 = (sx4x4)m2;
+  m4 = (ix5x5)m3; // expected-error {{invalid conversion between matrix type \
+'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))') and 'sx4x4' \
+(aka 'short __attribute__((matrix_type(4, 4)))') of different size}}
+  m5 = (ix5x5)m4; // expected-error {{assigning to 'fx5x5' (aka \
+'float __attribute__((matrix_type(5, 5)))') from incompatible type 'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))')}}
+  m4 = (ix5x5)m5;
+}
+
+typedef float float2_8x8 __attribute__((matrix_type(8, 8)));
+typedef double double_10x10 __attribute__((matrix_type(10, 10)));
+typedef double double_8x8 __attribute__((matrix_type(8, 8)));
+typedef signed int signed_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_10x10 __attribute__((matrix_type(10, 10)));
+
+void f2() {
+  float2_8x8 m1;
+  double_10x10 m2;
+  double_8x8 m3;
+  signed_int_12x12 m4;
+  unsigned_int_12x12 m5;
+  unsigned_int_10x10 m6;
+
+  m2 = (double_10x10)m1; // expected-error {{invalid conversion between matrix type \
+'double_10x10' (aka 'double __attribute__((matrix_type(10, 10)))') and 'float2_8x8' \
+(aka 'float __attribute__((matrix_type(8, 8)))') of different size}}
+  m3 = (double_8x8)m1;
+
+  m5 = (unsigned_int_12x12)m4;
+  m4 = (signed_int_12x12)m5;
+  m6 = (unsigned_int_10x10)m4; // expected-error {{invalid conversion between matrix type \
+'unsigned_int_10x10' (aka 'unsigned int __attribute__((matrix_type(10, 10)))') and 'signed_int_12x12' \
+(aka 'int __attribute__((matrix_type(12, 12)))') of different size}}
+}
\ No newline at end of file
Index: clang/test/CodeGen/matrix-cast.c
===
--- /dev/null
+++ clang/test/CodeGen/matrix-cast.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef char cx5x5 __attribute__((matrix_type(5, 5)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef short sx5x5 __attribute__((matrix_type(5, 5)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+typedef double dx5x5 __attribute__((matrix_type(5, 5)));
+typedef signed int signed_int_5x5 __attribute__((matrix_type(5, 5)));
+typedef unsigned int unsigned_int_5x5 __attribute__((matrix_type(5, 5)));
+
+void cast_char_matrix_to_int(cx5x5 c, ix5x5 i) {
+  // CHECK-LABEL: define{{.*}} void @cast_char_matrix_to_int(<25 x i8> %c, <25 x i32> %i)
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  i = (ix5x5)c;
+}
+
+void cast_int_matrix_to_short(ix5x5 i, sx5x5 s) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_short(<25 x i32> %i, <25 x i16> %s)
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  [[CONV:%.*]] = trunc <25 x i32> [[I]] to <25 x i16>
+  // CHECK-NEXT:  store <25 x i16> [[CONV]], <25 x i16>* {{.*}}, align 2
+  // CHECK-NEXT:  ret void
+
+  s = (sx5x5)i;
+}
+
+void cast_int_matrix_to_float(ix5x5 i, fx5x5 f) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_float(<25 x 

  1   2   >