[PATCH] D116262: [clang] adds `__remove_reference` as a compiler built-in

2021-12-23 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Missing description / motivation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116262

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


[PATCH] D116262: [clang] adds `__remove_reference` as a compiler built-in

2021-12-23 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
Herald added a subscriber: dexonsmith.
cjdb 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/D116262

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/remove_cvref.cpp

Index: clang/test/SemaCXX/remove_cvref.cpp
===
--- clang/test/SemaCXX/remove_cvref.cpp
+++ clang/test/SemaCXX/remove_cvref.cpp
@@ -1,5 +1,24 @@
 // RUN: %clang_cc1 -std=c++11 %s
 
+template
+struct check_remove_reference {
+  constexpr check_remove_reference() {
+static_assert(__is_same(__remove_reference(T&), T), "");
+static_assert(__is_same(__remove_reference(const T&), const T), "");
+static_assert(__is_same(__remove_reference(volatile T&), volatile T), "");
+static_assert(__is_same(__remove_reference(const volatile T&), const volatile T), "");
+
+static_assert(__is_same(__remove_reference(T&&), T), "");
+static_assert(__is_same(__remove_reference(const T&&), const T), "");
+static_assert(__is_same(__remove_reference(volatile T&&), volatile T), "");
+static_assert(__is_same(__remove_reference(const volatile T&&), const volatile T), "");
+  }
+};
+
+template<> struct check_remove_reference {};
+template struct check_remove_reference {};
+template struct check_remove_reference {};
+
 template 
 constexpr bool check_remove_qualifiers() {
   static_assert(__is_same(__remove_const(const T), T), "");
@@ -13,6 +32,9 @@
   static_assert(__is_same(__remove_cv(const T), T), "");
   static_assert(__is_same(__remove_cv(volatile T), T), "");
   static_assert(__is_same(__remove_cv(const volatile T), T), "");
+
+  check_remove_reference();
+
   return true;
 }
 
@@ -26,6 +48,10 @@
 static_assert(check_remove_qualifiers(), "");
 static_assert(check_remove_qualifiers(), "");
 static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
 static_assert(check_remove_qualifiers(), "");
 static_assert(check_remove_qualifiers(), "");
 static_assert(check_remove_qualifiers(), "");
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1271,6 +1271,8 @@
 return UnaryTransformType::RemoveConst;
   case TST_remove_cv:
 return UnaryTransformType::RemoveCV;
+  case TST_remove_reference:
+return UnaryTransformType::RemoveReference;
   case TST_remove_volatile:
 return UnaryTransformType::RemoveVolatile;
   case TST_underlyingType:
@@ -1668,6 +1670,7 @@
   case DeclSpec::TST_add_volatile:
   case DeclSpec::TST_remove_const:
   case DeclSpec::TST_remove_cv:
+  case DeclSpec::TST_remove_reference:
   case DeclSpec::TST_remove_volatile:
 Result = S.GetTypeFromParser(DS.getRepAsType());
 assert(!Result.isNull() && "Didn't get a type for the transformation?");
@@ -9096,6 +9099,11 @@
   return Context.getUnaryTransformType(BaseType, Underlying,
 UnaryTransformType::EnumUnderlyingType);
 }
+  case UnaryTransformType::RemoveReference: {
+QualType Underlying = BaseType.getNonReferenceType();
+return Context.getUnaryTransformType(BaseType, Underlying,
+ UnaryTransformType::RemoveReference);
+  }
   case UnaryTransformType::AddConst:
   case UnaryTransformType::AddCV:
   case UnaryTransformType::AddVolatile:
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -866,6 +866,7 @@
   case TST_add_volatile:
   case TST_remove_const:
   case TST_remove_cv:
+  case TST_remove_reference:
   case TST_remove_volatile:
   case TST_atomic: {
 QualType T = DS.getRepAsType().get();
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -150,6 +150,7 @@
   case tok::kw___add_volatile:
   case tok::kw___remove_const:
   case tok::kw___remove_cv:
+  case tok::kw___remove_reference:
   case tok::kw___remove_volatile:
   case tok::kw___auto_type:
 

[PATCH] D116204: [C++20] [Coroutines] Allow promise_type to not define return_void or return_value

2021-12-23 Thread Chuanqi Xu 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 rG097208dbf077: [C++20] [Coroutines] Allow promise_type to not 
define return_void or… (authored by ChuanqiXu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116204

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/SemaCXX/coroutines-exp-namespace.cpp
  clang/test/SemaCXX/coroutines.cpp

Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -970,19 +970,36 @@
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
 
-struct bad_promise_no_return_func { // expected-note {{'bad_promise_no_return_func' defined here}}
-  coro get_return_object();
+struct promise_no_return_func {
+  coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend() noexcept;
   void unhandled_exception();
 };
-// FIXME: The PDTS currently specifies this as UB, technically forbidding a
-// diagnostic.
-coro no_return_value_or_return_void() {
-  // expected-error@-1 {{'bad_promise_no_return_func' must declare either 'return_value' or 'return_void'}}
+// [dcl.fct.def.coroutine]/p6
+// If searches for the names return_­void and return_­value in the scope of
+// the promise type each find any declarations, the program is ill-formed.
+// [Note 1: If return_­void is found, flowing off the end of a coroutine is
+// equivalent to a co_­return with no operand. Otherwise, flowing off the end
+// of a coroutine results in undefined behavior ([stmt.return.coroutine]). —
+// end note]
+//
+// So it isn't ill-formed if the promise doesn't define return_value and return_void.
+// It is just a potential UB.
+coro no_return_value_or_return_void() {
   co_await a;
 }
 
+// The following two tests that it would emit correct diagnostic message
+// if we co_return in `promise_no_return_func`.
+coro no_return_value_or_return_void_2() {
+  co_return; // expected-error {{no member named 'return_void'}}
+}
+
+coro no_return_value_or_return_void_3() {
+  co_return 43; // expected-error {{no member named 'return_value'}}
+}
+
 struct bad_await_suspend_return {
   bool await_ready();
   // expected-error@+1 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'char')}}
Index: clang/test/SemaCXX/coroutines-exp-namespace.cpp
===
--- clang/test/SemaCXX/coroutines-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutines-exp-namespace.cpp
@@ -978,19 +978,6 @@
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
 
-struct bad_promise_no_return_func { // expected-note {{'bad_promise_no_return_func' defined here}}
-  coro get_return_object();
-  suspend_always initial_suspend();
-  suspend_always final_suspend() noexcept;
-  void unhandled_exception();
-};
-// FIXME: The PDTS currently specifies this as UB, technically forbidding a
-// diagnostic.
-coro no_return_value_or_return_void() {
-  // expected-error@-1 {{'bad_promise_no_return_func' must declare either 'return_value' or 'return_void'}}
-  co_await a;
-}
-
 struct bad_await_suspend_return {
   bool await_ready();
   // expected-error@+1 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'char')}}
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -1432,9 +1432,13 @@
   assert(!IsPromiseDependentType &&
  "cannot make statement while the promise type is dependent");
 
-  // [dcl.fct.def.coroutine]/4
-  // The unqualified-ids 'return_void' and 'return_value' are looked up in
-  // the scope of class P. If both are found, the program is ill-formed.
+  // [dcl.fct.def.coroutine]/p6
+  // If searches for the names return_­void and return_­value in the scope of
+  // the promise type each find any declarations, the program is ill-formed.
+  // [Note 1: If return_­void is found, flowing off the end of a coroutine is
+  // equivalent to a co_­return with no operand. Otherwise, flowing off the end
+  // of a coroutine results in undefined behavior ([stmt.return.coroutine]). —
+  // end note]
   bool HasRVoid, HasRValue;
   LookupResult LRVoid =
   lookupMember(S, "return_void", PromiseRecordDecl, Loc, HasRVoid);
@@ -1455,18 +1459,20 @@
 << LRValue.getLookupName();
 return false;
   } else if (!HasRVoid && !HasRValue) {
-// FIXME: The PDTS currently specifies this case as UB, not ill-formed.
-// However we still diagnose this as an error since until the PDTS is fixed.
-S.Diag(FD.getLocation(),
-   

[clang] 097208d - [C++20] [Coroutines] Allow promise_type to not define return_void or return_value

2021-12-23 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2021-12-24T13:37:51+08:00
New Revision: 097208dbf07786f3da84aec5b5f571c6e95a10e2

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

LOG: [C++20] [Coroutines] Allow promise_type to not define return_void or 
return_value

According to [dcl.fct.def.coroutine]p6, the promise_type is allowed to
not define return_void nor return_value:

> If searches for the names return_­void and return_­value in the scope
> of the promise type each find any declarations, the program is
> ill-formed.
> [Note 1: If return_­void is found, flowing off the end of a coroutine is
> equivalent to a co_­return with no operand. Otherwise, flowing off the
> end of a coroutine results in
> undefined behavior ([stmt.return.coroutine]). — end note]

So the program isn't ill-formed if the promise_type doesn't define
return_void nor return_value. It is just a potential UB. So the program
should be allowed to compile.

Reviewed By: urnathan

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCoroutine.cpp
clang/test/SemaCXX/coroutines-exp-namespace.cpp
clang/test/SemaCXX/coroutines.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f50c5a0c711ad..3b6341d2232d8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11071,8 +11071,6 @@ def err_coroutine_type_missing_specialization : Error<
   "specialization %0">;
 def err_coroutine_promise_incompatible_return_functions : Error<
   "the coroutine promise type %0 declares both 'return_value' and 
'return_void'">;
-def err_coroutine_promise_requires_return_function : Error<
-  "the coroutine promise type %0 must declare either 'return_value' or 
'return_void'">;
 def note_coroutine_promise_implicit_await_transform_required_here : Note<
   "call to 'await_transform' implicitly required by 'co_await' here">;
 def note_coroutine_promise_suspend_implicitly_required : Note<

diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 336e0c5f1d465..e89cecd08ccae 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1432,9 +1432,13 @@ bool CoroutineStmtBuilder::makeOnFallthrough() {
   assert(!IsPromiseDependentType &&
  "cannot make statement while the promise type is dependent");
 
-  // [dcl.fct.def.coroutine]/4
-  // The unqualified-ids 'return_void' and 'return_value' are looked up in
-  // the scope of class P. If both are found, the program is ill-formed.
+  // [dcl.fct.def.coroutine]/p6
+  // If searches for the names return_­void and return_­value in the scope of
+  // the promise type each find any declarations, the program is ill-formed.
+  // [Note 1: If return_­void is found, flowing off the end of a coroutine is
+  // equivalent to a co_­return with no operand. Otherwise, flowing off the end
+  // of a coroutine results in undefined behavior ([stmt.return.coroutine]). —
+  // end note]
   bool HasRVoid, HasRValue;
   LookupResult LRVoid =
   lookupMember(S, "return_void", PromiseRecordDecl, Loc, HasRVoid);
@@ -1455,18 +1459,20 @@ bool CoroutineStmtBuilder::makeOnFallthrough() {
 << LRValue.getLookupName();
 return false;
   } else if (!HasRVoid && !HasRValue) {
-// FIXME: The PDTS currently specifies this case as UB, not ill-formed.
-// However we still diagnose this as an error since until the PDTS is 
fixed.
-S.Diag(FD.getLocation(),
-   diag::err_coroutine_promise_requires_return_function)
-<< PromiseRecordDecl;
-S.Diag(PromiseRecordDecl->getLocation(), diag::note_defined_here)
-<< PromiseRecordDecl;
-return false;
+// We need to set 'Fallthrough'. Otherwise the other analysis part might
+// think the coroutine has defined a return_value method. So it might emit
+// **false** positive warning. e.g.,
+//
+//promise_without_return_func foo() {
+//co_await something();
+//}
+//
+// Then AnalysisBasedWarning would emit a warning about `foo()` lacking a
+// co_return statements, which isn't correct.
+Fallthrough = S.ActOnNullStmt(PromiseRecordDecl->getLocation());
+if (Fallthrough.isInvalid())
+  return false;
   } else if (HasRVoid) {
-// If the unqualified-id return_void is found, flowing off the end of a
-// coroutine is equivalent to a co_return with no operand. Otherwise,
-// flowing off the end of a coroutine results in undefined behavior.
 Fallthrough = S.BuildCoreturnStmt(FD.getLocation(), nullptr,
   /*IsImplicit*/false);
   

[clang] f3d4e16 - [C++20] Conform coroutine's comments in clang (NFC-ish)

2021-12-23 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2021-12-24T12:41:44+08:00
New Revision: f3d4e168dbc7e736ef535c673ee635a40feb2037

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

LOG: [C++20] Conform coroutine's comments in clang (NFC-ish)

The comments for coroutine in clang wrote for coroutine-TS. Now
coroutine is merged into standard. Try to conform the comments.

Added: 


Modified: 
clang/lib/CodeGen/CGCoroutine.cpp
clang/lib/Sema/SemaCoroutine.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCoroutine.cpp 
b/clang/lib/CodeGen/CGCoroutine.cpp
index ca071d3d2e80f..2041d2a5b4c95 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -597,6 +597,10 @@ void CodeGenFunction::EmitCoroutineBody(const 
CoroutineBodyStmt ) {
   CGM.getIntrinsic(llvm::Intrinsic::coro_begin), {CoroId, Phi});
   CurCoro.Data->CoroBegin = CoroBegin;
 
+  // We need to emit `get_­return_­object` first. According to:
+  // [dcl.fct.def.coroutine]p7
+  // The call to get_­return_­object is sequenced before the call to
+  // initial_­suspend and is invoked at most once.
   GetReturnObjectManager GroManager(*this, S);
   GroManager.EmitGroAlloca();
 

diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 27ba49fb001c0..336e0c5f1d465 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -237,9 +237,9 @@ static bool isValidCoroutineContext(Sema , SourceLocation 
Loc,
   // placeholder type shall not be a coroutine."
   if (FD->getReturnType()->isUndeducedType())
 DiagInvalid(DiagAutoRet);
-  // [dcl.fct.def.coroutine]p1: "The parameter-declaration-clause of the
-  // coroutine shall not terminate with an ellipsis that is not part of a
-  // parameter-declaration."
+  // [dcl.fct.def.coroutine]p1
+  // The parameter-declaration-clause of the coroutine shall not terminate with
+  // an ellipsis that is not part of a parameter-declaration.
   if (FD->isVariadic())
 DiagInvalid(DiagVarargs);
 
@@ -579,8 +579,12 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) {
/*TopLevelOfInitList=*/false,
/*TreatUnavailableAsInvalid=*/false);
 
-// Attempt to initialize the promise type with the arguments.
-// If that fails, fall back to the promise type's default constructor.
+// [dcl.fct.def.coroutine]5.7
+// promise-constructor-arguments is determined as follows: overload
+// resolution is performed on a promise constructor call created by
+// assembling an argument list  q_1 ... q_n . If a viable constructor is
+// found ([over.match.viable]), then promise-constructor-arguments is ( q_1
+// , ...,  q_n ), otherwise promise-constructor-arguments is empty.
 if (InitSeq) {
   ExprResult Result = InitSeq.Perform(*this, Entity, Kind, CtorArgExprs);
   if (Result.isInvalid()) {
@@ -648,6 +652,10 @@ static void checkNoThrow(Sema , const Stmt *E,
   return;
   }
   if (ThrowingDecls.empty()) {
+// [dcl.fct.def.coroutine]p15
+//   The expression co_­await promise.final_­suspend() shall not be
+//   potentially-throwing ([except.spec]).
+//
 // First time seeing an error, emit the error message.
 S.Diag(cast(S.CurContext)->getLocation(),
diag::err_coroutine_promise_final_suspend_requires_nothrow);
@@ -995,9 +1003,8 @@ static Expr *buildStdNoThrowDeclRef(Sema , 
SourceLocation Loc) {
   LookupResult Result(S, ().get("nothrow"), Loc,
   Sema::LookupOrdinaryName);
   if (!S.LookupQualifiedName(Result, Std)) {
-// FIXME:  should have been included already.
-// If we require it to include  then this diagnostic is no longer
-// needed.
+//  is not requred to include , so we couldn't omit
+// the check here.
 S.Diag(Loc, diag::err_implicit_coroutine_std_nothrow_type_not_found);
 return nullptr;
   }
@@ -1029,9 +1036,21 @@ static FunctionDecl *findDeleteForPromise(Sema , 
SourceLocation Loc,
   auto *PointeeRD = PromiseType->getAsCXXRecordDecl();
   assert(PointeeRD && "PromiseType must be a CxxRecordDecl type");
 
+  // [dcl.fct.def.coroutine]p12
+  // The deallocation function's name is looked up by searching for it in the
+  // scope of the promise type. If nothing is found, a search is performed in
+  // the global scope.
   if (S.FindDeallocationFunction(Loc, PointeeRD, DeleteName, OperatorDelete))
 return nullptr;
 
+  // FIXME: We didn't implement following selection:
+  // [dcl.fct.def.coroutine]p12
+  //   If both a usual deallocation function with only a pointer parameter and 
a
+  //   usual deallocation function with both a pointer parameter and a size
+  //   parameter are 

[PATCH] D116261: [WIP][Clang][OpenMP] Add support for compare capture in parser

2021-12-23 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:10991
+  EncounteredAtomicKinds.contains(OMPC_capture))
+AtomicKind = OMPC_compare_capture;
   // OpenMP 5.0, 2.17.7 atomic Construct, Restrictions

This is the place where the dummy kind `OMPC_compare_capture` is used. We will 
have another use in CodeGen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116261

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


[PATCH] D116261: [WIP][Clang][OpenMP] Add support for compare capture in parser

2021-12-23 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ABataev.
Herald added subscribers: arphaman, guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

This patch adds the support for `atomic compare capture` in parser and part of
sema. For better post-sema operations, a dummy clause `compare_capture` is
created. That is because the spec doesn't say `compare` and `capture` clauses
should be used tightly, we cannot look one more token ahead in the parser. That
being said, there should be no actual AST node created.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116261

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/CodeGen/CGStmtOpenMP.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/tools/libclang/CIndex.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
@@ -181,6 +181,10 @@
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
 def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
+// A dummy clause if compare and capture clauses are present.
+def OMPC_CompareCapture : Clause<"compare_capture"> {
+  let clangClass = "OMPCompareCaptureClause";
+}
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
@@ -283,7 +287,7 @@
 def OMPC_NonTemporal : Clause<"nontemporal"> {
   let clangClass = "OMPNontemporalClause";
   let flangClass = "Name";
-  let isValueList = true; 
+  let isValueList = true;
 }
 
 def OMP_ORDER_concurrent : ClauseVal<"concurrent",1,1> {}
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2277,6 +2277,9 @@
 
 void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
 
+void OMPClauseEnqueue::VisitOMPCompareCaptureClause(
+const OMPCompareCaptureClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6254,6 +6254,8 @@
 
 void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}
 
+void OMPClauseWriter::VisitOMPCompareCaptureClause(OMPCompareCaptureClause *) {}
+
 void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -11768,6 +11768,9 @@
   case llvm::omp::OMPC_compare:
 C = new (Context) OMPCompareClause();
 break;
+  case llvm::omp::OMPC_compare_capture:
+C = new (Context) OMPCompareCaptureClause();
+break;
   case llvm::omp::OMPC_seq_cst:
 C = new (Context) OMPSeqCstClause();
 break;
@@ -12128,6 +12131,8 @@
 
 void OMPClauseReader::VisitOMPCompareClause(OMPCompareClause *) {}
 
+void OMPClauseReader::VisitOMPCompareCaptureClause(OMPCompareCaptureClause *) {}
+
 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseReader::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -9467,6 +9467,13 @@
   return C;
 }
 
+template 
+OMPClause *TreeTransform::TransformOMPCompareCaptureClause(
+OMPCompareCaptureClause *C) {
+  // No need to rebuild this clause, no template-dependent parameters.
+  return C;
+}
+
 template 
 OMPClause *
 TreeTransform::TransformOMPSeqCstClause(OMPSeqCstClause *C) {
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -35,6 +35,7 @@
 #include "llvm/ADT/IndexedMap.h"
 #include "llvm/ADT/PointerEmbeddedInt.h"
 

[PATCH] D116260: [clang] adds `__remove_cv` as a compiler built-in

2021-12-23 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
Herald added a subscriber: dexonsmith.
cjdb 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/D116260

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/remove_cvref.cpp

Index: clang/test/SemaCXX/remove_cvref.cpp
===
--- clang/test/SemaCXX/remove_cvref.cpp
+++ clang/test/SemaCXX/remove_cvref.cpp
@@ -9,6 +9,10 @@
   static_assert(__is_same(__remove_volatile(const T), const T), "");
   static_assert(__is_same(__remove_volatile(volatile T), T), "");
   static_assert(__is_same(__remove_volatile(const volatile T), const T), "");
+
+  static_assert(__is_same(__remove_cv(const T), T), "");
+  static_assert(__is_same(__remove_cv(volatile T), T), "");
+  static_assert(__is_same(__remove_cv(const volatile T), T), "");
   return true;
 }
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1269,6 +1269,8 @@
 return UnaryTransformType::AddVolatile;
   case TST_remove_const:
 return UnaryTransformType::RemoveConst;
+  case TST_remove_cv:
+return UnaryTransformType::RemoveCV;
   case TST_remove_volatile:
 return UnaryTransformType::RemoveVolatile;
   case TST_underlyingType:
@@ -1665,6 +1667,7 @@
   case DeclSpec::TST_add_cv:
   case DeclSpec::TST_add_volatile:
   case DeclSpec::TST_remove_const:
+  case DeclSpec::TST_remove_cv:
   case DeclSpec::TST_remove_volatile:
 Result = S.GetTypeFromParser(DS.getRepAsType());
 assert(!Result.isNull() && "Didn't get a type for the transformation?");
@@ -9097,6 +9100,7 @@
   case UnaryTransformType::AddCV:
   case UnaryTransformType::AddVolatile:
   case UnaryTransformType::RemoveConst:
+  case UnaryTransformType::RemoveCV:
   case UnaryTransformType::RemoveVolatile: {
 SplitQualType Split = BaseType.getSplitUnqualifiedType();
 Qualifiers Quals = BaseType.getQualifiers();
@@ -9115,6 +9119,9 @@
 case UnaryTransformType::RemoveConst:
   Quals.removeConst();
   break;
+case UnaryTransformType::RemoveCV:
+  Quals.removeConst();
+  [[fallthrough]];
 case UnaryTransformType::RemoveVolatile:
   Quals.removeVolatile();
   break;
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -865,6 +865,7 @@
   case TST_add_cv:
   case TST_add_volatile:
   case TST_remove_const:
+  case TST_remove_cv:
   case TST_remove_volatile:
   case TST_atomic: {
 QualType T = DS.getRepAsType().get();
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -149,6 +149,7 @@
   case tok::kw___add_cv:
   case tok::kw___add_volatile:
   case tok::kw___remove_const:
+  case tok::kw___remove_cv:
   case tok::kw___remove_volatile:
   case tok::kw___auto_type:
 return true;
@@ -5608,6 +5609,7 @@
   case DeclSpec::TST_add_cv:
   case DeclSpec::TST_add_volatile:
   case DeclSpec::TST_remove_const:
+  case DeclSpec::TST_remove_cv:
   case DeclSpec::TST_remove_volatile:
   case DeclSpec::TST_atomic: {
 // Grab the type from the parser.
Index: clang/lib/Sema/DeclSpec.cpp
===
--- clang/lib/Sema/DeclSpec.cpp
+++ clang/lib/Sema/DeclSpec.cpp
@@ -395,6 +395,7 @@
 case TST_add_cv:
 case TST_add_volatile:
 case TST_remove_const:
+case TST_remove_cv:
 case TST_remove_volatile:
 case TST_typename:
 case TST_typeofType: {
@@ -591,6 +592,8 @@
 return "__add_volatile";
   case DeclSpec::TST_remove_const:
 return "__remove_const";
+  case DeclSpec::TST_remove_cv:
+return "__remove_cv";
   case DeclSpec::TST_remove_volatile:
 return "__remove_volatile";
   case DeclSpec::TST_unknown_anytype: return "__unknown_anytype";
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1534,7 +1534,7 @@
   tok::kw___is_trivially_assignable,
   tok::kw___is_trivially_constructible, 

[PATCH] D116204: [C++20] [Coroutines] Allow promise_type to not define return_void or return_value

2021-12-23 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/test/SemaCXX/coroutines.cpp:987
+//
+// So it isn't ill-formed if the promise doesn't define return_value and 
return_void. It is just a UB.
+coro no_return_value_or_return_void() {

Quuxplusone wrote:
> It's not UB; it's //potential// UB.
> My understanding is that such a coroutine could still be used:
> - if it exits by throwing an exception instead of `co_return`'ing
> - if it suspends and then its caller `destroy`s it instead of `resume`ing it
> 
> I believe it would be useful to have some actual tests for these scenarios, 
> that would actually run and check that the runtime behavior is correct, or at 
> least check the IR that was generated. Is that possible?
Yes, such a coroutine could still be used. AFAIK, we couldn't make tests which 
would run actually. All the test cases I know is about pattern match. So we 
couldn't make tests in clang to run actually for this. I have tested it 
locally. And I think it is unnecessary to check the IR was generated since this 
patch didn't add new statements except a null statement as marker.

BTW, it shows another big issue for coroutines. We lack test-suite and 
benchmarks now. Now I tested the correctness of the compiler by test it in our 
internal projects. But we need an open source test suites absolutely. This is 
true for benchmarks. I thought to make the two things... but I don't find time 
for it now...


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

https://reviews.llvm.org/D116204

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


[PATCH] D116204: [C++20] [Coroutines] Allow promise_type to not define return_void or return_value

2021-12-23 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 396126.
ChuanqiXu added a comment.

Address comments


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

https://reviews.llvm.org/D116204

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/SemaCXX/coroutines-exp-namespace.cpp
  clang/test/SemaCXX/coroutines.cpp

Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -970,19 +970,36 @@
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
 
-struct bad_promise_no_return_func { // expected-note {{'bad_promise_no_return_func' defined here}}
-  coro get_return_object();
+struct promise_no_return_func {
+  coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend() noexcept;
   void unhandled_exception();
 };
-// FIXME: The PDTS currently specifies this as UB, technically forbidding a
-// diagnostic.
-coro no_return_value_or_return_void() {
-  // expected-error@-1 {{'bad_promise_no_return_func' must declare either 'return_value' or 'return_void'}}
+// [dcl.fct.def.coroutine]/p6
+// If searches for the names return_­void and return_­value in the scope of
+// the promise type each find any declarations, the program is ill-formed.
+// [Note 1: If return_­void is found, flowing off the end of a coroutine is
+// equivalent to a co_­return with no operand. Otherwise, flowing off the end
+// of a coroutine results in undefined behavior ([stmt.return.coroutine]). —
+// end note]
+//
+// So it isn't ill-formed if the promise doesn't define return_value and return_void.
+// It is just a potential UB.
+coro no_return_value_or_return_void() {
   co_await a;
 }
 
+// The following two tests that it would emit correct diagnostic message
+// if we co_return in `promise_no_return_func`.
+coro no_return_value_or_return_void_2() {
+  co_return; // expected-error {{no member named 'return_void'}}
+}
+
+coro no_return_value_or_return_void_3() {
+  co_return 43; // expected-error {{no member named 'return_value'}}
+}
+
 struct bad_await_suspend_return {
   bool await_ready();
   // expected-error@+1 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'char')}}
Index: clang/test/SemaCXX/coroutines-exp-namespace.cpp
===
--- clang/test/SemaCXX/coroutines-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutines-exp-namespace.cpp
@@ -978,19 +978,6 @@
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
 
-struct bad_promise_no_return_func { // expected-note {{'bad_promise_no_return_func' defined here}}
-  coro get_return_object();
-  suspend_always initial_suspend();
-  suspend_always final_suspend() noexcept;
-  void unhandled_exception();
-};
-// FIXME: The PDTS currently specifies this as UB, technically forbidding a
-// diagnostic.
-coro no_return_value_or_return_void() {
-  // expected-error@-1 {{'bad_promise_no_return_func' must declare either 'return_value' or 'return_void'}}
-  co_await a;
-}
-
 struct bad_await_suspend_return {
   bool await_ready();
   // expected-error@+1 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'char')}}
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -1391,9 +1391,13 @@
   assert(!IsPromiseDependentType &&
  "cannot make statement while the promise type is dependent");
 
-  // [dcl.fct.def.coroutine]/4
-  // The unqualified-ids 'return_void' and 'return_value' are looked up in
-  // the scope of class P. If both are found, the program is ill-formed.
+  // [dcl.fct.def.coroutine]/p6
+  // If searches for the names return_­void and return_­value in the scope of
+  // the promise type each find any declarations, the program is ill-formed.
+  // [Note 1: If return_­void is found, flowing off the end of a coroutine is
+  // equivalent to a co_­return with no operand. Otherwise, flowing off the end
+  // of a coroutine results in undefined behavior ([stmt.return.coroutine]). —
+  // end note]
   bool HasRVoid, HasRValue;
   LookupResult LRVoid =
   lookupMember(S, "return_void", PromiseRecordDecl, Loc, HasRVoid);
@@ -1414,18 +1418,20 @@
 << LRValue.getLookupName();
 return false;
   } else if (!HasRVoid && !HasRValue) {
-// FIXME: The PDTS currently specifies this case as UB, not ill-formed.
-// However we still diagnose this as an error since until the PDTS is fixed.
-S.Diag(FD.getLocation(),
-   diag::err_coroutine_promise_requires_return_function)
-<< PromiseRecordDecl;
-S.Diag(PromiseRecordDecl->getLocation(), diag::note_defined_here)
-<< PromiseRecordDecl;
-return false;
+// 

[PATCH] D115561: [Clang][OpenMP] Add the support for atomic compare in parser

2021-12-23 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked 2 inline comments as done.
tianshilei1992 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11398-11400
+// TODO: For now we emit an error here and in emitOMPAtomicExpr we ignore
+// code gen.
+Diag(Body->getBeginLoc(), diag::err_omp_atomic_compare);

ABataev wrote:
> Maybe emit error in codegen instead? Without adding `err_omp_atomic_compare` 
> message in include/clang/Basic/DiagnosticSemaKinds.td, just emit emit 
> directly there:
> ```
>   unsigned DiagID = CGM.getDiags().getCustomDiagID(
>   DiagnosticsEngine::Error, "atomic compare is not supported for 
> now");
>   CGM.getDiags().Report(SLoc, DiagID);
> 
> ```
> 
I think emitting error here sounds better because if we defer it to codegen, 
it's like it already passed Sema but in fact it didn't.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115561

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


[PATCH] D115561: [Clang][OpenMP] Add the support for atomic compare in parser

2021-12-23 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 396122.
tianshilei1992 added a comment.

fix comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115561

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.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/atomic_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
@@ -180,6 +180,7 @@
 def OMPC_Write : Clause<"write"> { let clangClass = "OMPWriteClause"; }
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
+def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
@@ -536,6 +537,7 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
+VersionedClause
   ];
   let allowedOnceClauses = [
 VersionedClause,
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1482,6 +1482,7 @@
 CHECK_SIMPLE_CLAUSE(MemoryOrder, OMPC_memory_order)
 CHECK_SIMPLE_CLAUSE(Bind, OMPC_bind)
 CHECK_SIMPLE_CLAUSE(Align, OMPC_align)
+CHECK_SIMPLE_CLAUSE(Compare, OMPC_compare)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2275,6 +2275,8 @@
 
 void OMPClauseEnqueue::VisitOMPCaptureClause(const OMPCaptureClause *) {}
 
+void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/test/OpenMP/atomic_messages.cpp
===
--- clang/test/OpenMP/atomic_messages.cpp
+++ clang/test/OpenMP/atomic_messages.cpp
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 150 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -ferror-limit 150 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50,omp51 -fopenmp -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
 
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 150 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -ferror-limit 150 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50,omp51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
 
 int foo() {
 L1:
@@ -896,19 +898,19 @@
 template 
 T mixed() {
   T a, b = T();
-// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
 // expected-note@+1 2 {{'read' clause used here}}
 #pragma omp atomic read write
   a = b;
-// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
 // expected-note@+1 2 {{'write' clause used here}}
 #pragma omp atomic write read
   a = b;
-// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
 // expected-note@+1 2 {{'update' clause used here}}
 #pragma omp atomic update read
   a += b;
-// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain 

[PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov 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 rG71b3bfde9cd2: [ASan] Moved optimized callbacks into a 
separate library. (authored by kstoimenov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116182

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/asan_rtl_static.cpp
  compiler-rt/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,6 +261,7 @@
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
+$
 $
 $
 $
@@ -286,6 +287,7 @@
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
+  $
   $
   $
   $
Index: compiler-rt/lib/asan/asan_rtl_static.cpp
===
--- /dev/null
+++ compiler-rt/lib/asan/asan_rtl_static.cpp
@@ -0,0 +1,15 @@
+//===-- asan_static_rtl.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// Main file of the ASan run-time library.
+//===--===//
+
+// This file is empty for now. Main reason to have it is workaround for Windows
+// build, which complains because no files are part of the asan_static lib.
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,7 +34,6 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
-asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -43,6 +42,16 @@
   asan_new_delete.cpp
   )
 
+set(ASAN_STATIC_SOURCES
+  asan_rtl_static.cpp
+  )
+
+if (NOT WIN32 AND NOT APPLE)
+  list(APPEND ASAN_STATIC_SOURCES
+asan_rtl_x86_64.S
+  )
+endif()
+
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -135,6 +144,12 @@
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTAsan_static
+ARCHS ${ASAN_SUPPORTED_ARCH}
+SOURCES ${ASAN_STATIC_SOURCES}
+ADDITIONAL_HEADERS ${ASAN_HEADERS}
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -176,6 +191,14 @@
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
+
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -207,6 +230,14 @@
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
+
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,11 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
+  // Always link the static runtime regardless of DSO or executable.
+  if (SanArgs.needsAsanRt()) {
+

[clang] 71b3bfd - [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov via cfe-commits

Author: Kirill Stoimenov
Date: 2021-12-24T00:40:44Z
New Revision: 71b3bfde9cd296525bbf5b1619e199074156d12b

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

LOG: [ASan] Moved optimized callbacks into a separate library.

This will allow linking in the callbacks directly instead of using PLT.

Reviewed By: vitalybuka

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

Added: 
compiler-rt/lib/asan/asan_rtl_static.cpp

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/sanitizer-ld.c
compiler-rt/lib/asan/CMakeLists.txt
compiler-rt/lib/asan/tests/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 407f81a2ae09a..267625c70b251 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,11 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
+  // Always link the static runtime regardless of DSO or executable.
+  if (SanArgs.needsAsanRt()) {
+HelperStaticRuntimes.push_back("asan_static");
+  }
+
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index d62e19fd4021b..ea8c49f2384ad 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address 
-shared-libsan \

diff  --git a/compiler-rt/lib/asan/CMakeLists.txt 
b/compiler-rt/lib/asan/CMakeLists.txt
index 2e63c8d051688..b79b7278f6dbb 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -34,7 +34,6 @@ set(ASAN_SOURCES
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
-asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -43,6 +42,16 @@ set(ASAN_CXX_SOURCES
   asan_new_delete.cpp
   )
 
+set(ASAN_STATIC_SOURCES
+  asan_rtl_static.cpp
+  )
+
+if (NOT WIN32 AND NOT APPLE)
+  list(APPEND ASAN_STATIC_SOURCES
+asan_rtl_x86_64.S
+  )
+endif()
+
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -135,6 +144,12 @@ if(NOT APPLE)
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTAsan_static
+ARCHS ${ASAN_SUPPORTED_ARCH}
+SOURCES ${ASAN_STATIC_SOURCES}
+ADDITIONAL_HEADERS ${ASAN_HEADERS}
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -176,6 +191,14 @@ if(APPLE)
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
+
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -207,6 +230,14 @@ else()
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
+
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}

diff  --git a/compiler-rt/lib/asan/asan_rtl_static.cpp 
b/compiler-rt/lib/asan/asan_rtl_static.cpp
new file mode 100644
index 0..74e6eb0ddf1cf
--- /dev/null
+++ b/compiler-rt/lib/asan/asan_rtl_static.cpp
@@ -0,0 +1,15 @@
+//===-- asan_static_rtl.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// Main file of the ASan run-time library.
+//===--===//
+
+// This file is empty for 

[PATCH] D113718: Don't append the working directory to absolute paths

2021-12-23 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a subscriber: thakis.
dblaikie added a comment.

@thakis - I think you folks over in Chrome land implemented/use 
`-fdebug-prefix-map` (or do you use `-fdebug-compilation-dir`?) so might be 
interested in this change.


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

https://reviews.llvm.org/D113718

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


[PATCH] D116256: [-fms-extensions] Make some exception specification warnings/errors compatible with what cl.exe does

2021-12-23 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added reviewers: hans, thakis.
akhuang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Make clang-cl error when a function definition is missing 'noexcept',
and succeed without warnings when missing '__declspec(nothrow)' or 'throw'.

Fixes pr52860


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116256

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/test/SemaCXX/MicrosoftCompatibility.cpp


Index: clang/test/SemaCXX/MicrosoftCompatibility.cpp
===
--- clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -377,14 +377,14 @@
 #endif
 };
 
-}
+void f4() throw();
+void f4() {}
 
-namespace PR25265 {
-struct S {
-  int fn() throw(); // expected-note {{previous declaration is here}}
-};
+__declspec(nothrow) void f5();
+void f5() {}
 
-int S::fn() { return 0; } // expected-warning {{is missing exception 
specification}}
+void f6() noexcept; // expected-note {{previous declaration is here}}
+void f6() {}// expected-error {{'f6' is missing exception 
specification 'noexcept'}}
 }
 
 namespace PR43265 {
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/lib/Sema/SemaExceptionSpec.cpp
+++ clang/lib/Sema/SemaExceptionSpec.cpp
@@ -391,10 +391,11 @@
 NewProto->getExtProtoInfo().withExceptionSpec(ESI)));
   }
 
-  if (getLangOpts().MSVCCompat && ESI.Type != EST_DependentNoexcept) {
-// Allow missing exception specifications in redeclarations as an 
extension.
-DiagID = diag::ext_ms_missing_exception_specification;
-ReturnValueOnError = false;
+  if (getLangOpts().MSVCCompat &&
+  !(ESI.Type == EST_DependentNoexcept || ESI.Type == EST_BasicNoexcept)) {
+// Allow missing exception specifications in redeclarations as an extension
+// without a warning.
+return false;
   } else if (New->isReplaceableGlobalAllocationFunction() &&
  ESI.Type != EST_DependentNoexcept) {
 // Allow missing exception specifications in redeclarations as an 
extension,
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1695,9 +1695,6 @@
 def ext_missing_exception_specification : ExtWarn<
   err_missing_exception_specification.Text>,
   InGroup>;
-def ext_ms_missing_exception_specification : ExtWarn<
-  err_missing_exception_specification.Text>,
-  InGroup;
 def err_noexcept_needs_constant_expression : Error<
   "argument to noexcept specifier must be a constant expression">;
 def err_exception_spec_not_parsed : Error<


Index: clang/test/SemaCXX/MicrosoftCompatibility.cpp
===
--- clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -377,14 +377,14 @@
 #endif
 };
 
-}
+void f4() throw();
+void f4() {}
 
-namespace PR25265 {
-struct S {
-  int fn() throw(); // expected-note {{previous declaration is here}}
-};
+__declspec(nothrow) void f5();
+void f5() {}
 
-int S::fn() { return 0; } // expected-warning {{is missing exception specification}}
+void f6() noexcept; // expected-note {{previous declaration is here}}
+void f6() {}// expected-error {{'f6' is missing exception specification 'noexcept'}}
 }
 
 namespace PR43265 {
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/lib/Sema/SemaExceptionSpec.cpp
+++ clang/lib/Sema/SemaExceptionSpec.cpp
@@ -391,10 +391,11 @@
 NewProto->getExtProtoInfo().withExceptionSpec(ESI)));
   }
 
-  if (getLangOpts().MSVCCompat && ESI.Type != EST_DependentNoexcept) {
-// Allow missing exception specifications in redeclarations as an extension.
-DiagID = diag::ext_ms_missing_exception_specification;
-ReturnValueOnError = false;
+  if (getLangOpts().MSVCCompat &&
+  !(ESI.Type == EST_DependentNoexcept || ESI.Type == EST_BasicNoexcept)) {
+// Allow missing exception specifications in redeclarations as an extension
+// without a warning.
+return false;
   } else if (New->isReplaceableGlobalAllocationFunction() &&
  ESI.Type != EST_DependentNoexcept) {
 // Allow missing exception specifications in redeclarations as an extension,
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1695,9 +1695,6 @@
 def ext_missing_exception_specification : ExtWarn<
   err_missing_exception_specification.Text>,
   InGroup>;
-def 

[clang] a67c0fc - [Hexagon] Revamp HVX flag verification in driver

2021-12-23 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2021-12-23T15:18:08-08:00
New Revision: a67c0fc1fbe8479eb5b3d7c189395bfe6cb98086

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

LOG: [Hexagon] Revamp HVX flag verification in driver

Generalize warning/error messages (for reuse), refactor flag verification
code, rewrite HVX flag driver testcase.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/test/Driver/hexagon-hvx-ieee-fp.c
clang/test/Driver/hexagon-hvx-qfloat.c
clang/test/Driver/hexagon-hvx.c
clang/test/Driver/hexagon-vectorize.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index c623aeff11f05..a7fd2f26478cf 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -443,16 +443,13 @@ def err_analyzer_checker_option_invalid_input : Error<
 def err_analyzer_checker_incompatible_analyzer_option : Error<
   "checker cannot be enabled with analyzer option '%0' == %1">;
 
-def err_drv_invalid_hvx_length : Error<
-  "-mhvx-length is not supported without a -mhvx/-mhvx= flag">;
-def warn_drv_vectorize_needs_hvx : Warning<
-  "auto-vectorization requires HVX, use -mhvx to enable it">,
+def warn_drv_needs_hvx : Warning<
+  "%0 requires HVX, use -mhvx/-mhvx= to enable it">,
   InGroup;
-
-def err_drv_invalid_hvx_qfloat : Error<
-  "-mhvx-qfloat is not supported without a -mhvx/-mhvx= flag.">;
-def err_drv_invalid_arch_hvx_qfloat : Error<
-  "-mhvx-qfloat is not supported on HVX %0.">;
+def err_drv_needs_hvx : Error<
+  "%0 requires HVX, use -mhvx/-mhvx= to enable it">;
+def err_drv_needs_hvx_version : Error<
+  "%0 is not supported on HVX %1">;
 
 def err_drv_module_header_wrong_kind : Error<
   "header file '%0' input type '%1' does not match type of prior input "

diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index f9785e42025cc..ba3040636604f 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -26,8 +26,8 @@ using namespace clang;
 using namespace llvm::opt;
 
 // Default hvx-length for various versions.
-static StringRef getDefaultHvxLength(StringRef Cpu) {
-  return llvm::StringSwitch(Cpu)
+static StringRef getDefaultHvxLength(StringRef HvxVer) {
+  return llvm::StringSwitch(HvxVer)
   .Case("v60", "64b")
   .Case("v62", "64b")
   .Case("v65", "64b")
@@ -51,63 +51,107 @@ static void handleHVXTargetFeatures(const Driver , const 
ArgList ,
   // Handle HVX warnings.
   handleHVXWarnings(D, Args);
 
-  // Add the +hvx* features based on commandline flags.
-  StringRef HVXFeature, HVXLength;
-
-  // Handle -mhvx, -mhvx=, -mno-hvx.
-  if (Arg *A = Args.getLastArg(options::OPT_mno_hexagon_hvx,
-   options::OPT_mhexagon_hvx,
-   options::OPT_mhexagon_hvx_EQ)) {
-if (A->getOption().matches(options::OPT_mno_hexagon_hvx))
-  return;
-if (A->getOption().matches(options::OPT_mhexagon_hvx_EQ)) {
-  HasHVX = true;
-  HVXFeature = Cpu = A->getValue();
-  HVXFeature = Args.MakeArgString(llvm::Twine("+hvx") + 
HVXFeature.lower());
-} else if (A->getOption().matches(options::OPT_mhexagon_hvx)) {
-  HasHVX = true;
-  HVXFeature = Args.MakeArgString(llvm::Twine("+hvx") + Cpu);
+  auto makeFeature = [](Twine T, bool Enable) -> StringRef {
+const std::string  = T.str();
+StringRef Opt(S);
+if (Opt.endswith("="))
+  Opt = Opt.drop_back(1);
+if (Opt.startswith("mno-"))
+  Opt = Opt.drop_front(4);
+else if (Opt.startswith("m"))
+  Opt = Opt.drop_front(1);
+return Args.MakeArgString(Twine(Enable ? "+" : "-") + Twine(Opt));
+  };
+
+  auto withMinus = [](StringRef S) -> std::string {
+return "-" + S.str();
+  };
+
+  // Drop tiny core suffix for HVX version.
+  std::string HvxVer =
+  (Cpu.back() == 'T' || Cpu.back() == 't' ? Cpu.drop_back(1) : Cpu).str();
+  HasHVX = false;
+
+  // Handle -mhvx, -mhvx=, -mno-hvx. If both present, -mhvx= wins over -mhvx.
+  auto argOrNull = [](auto FlagOn, auto FlagOff) -> Arg* {
+if (Arg *A = Args.getLastArg(FlagOn, FlagOff)) {
+  if (A->getOption().matches(FlagOn))
+return A;
 }
-Features.push_back(HVXFeature);
+return nullptr;
+  };
+
+  Arg *HvxBareA =
+  argOrNull(options::OPT_mhexagon_hvx, options::OPT_mno_hexagon_hvx);
+  Arg *HvxVerA =
+  argOrNull(options::OPT_mhexagon_hvx_EQ, options::OPT_mno_hexagon_hvx);
+
+  if (Arg *A = HvxVerA ? HvxVerA : HvxBareA) {
+if (A->getOption().matches(options::OPT_mhexagon_hvx_EQ))
+  HvxVer = 

[PATCH] D115103: Leak Sanitizer port to Windows

2021-12-23 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D115103#3207867 , @clemenswasser 
wrote:

> @vitalybuka I have now removed all `LSAN_BASE` occurrences.
> However the invocations of the compiled test executables don't seem to work 
> either.
> This doesn't work:
> `// RUN: %env_lsan_opts=use_stacks=0:use_registers=0 not %run %t foo 2>&1 | 
> FileCheck %s --check-prefix=CHECK-do`
> It generates this error:
>
>   [build] $ ":" "RUN: at line 3"
>   [build] $ "env" "LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0" 
> "not" 
> "E:\git\llvm-project\llvm\build\ninja_debug\projects\compiler-rt\test\lsan\X86_64LsanConfig\TestCases\Output\leak_check_at_exit.cpp.tmp.exe"
>  "foo"
>   [build] note: command had no output on stdout or stderr
>   [build] error: command failed with exit status: True

does check-asan work for your setup?


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

https://reviews.llvm.org/D115103

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


[PATCH] D116242: [clang] adds `__remove_volatile` as a compiler built-in

2021-12-23 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
Herald added a subscriber: dexonsmith.
cjdb 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/D116242

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/remove_cvref.cpp

Index: clang/test/SemaCXX/remove_cvref.cpp
===
--- clang/test/SemaCXX/remove_cvref.cpp
+++ clang/test/SemaCXX/remove_cvref.cpp
@@ -3,6 +3,12 @@
 template 
 constexpr bool check_remove_qualifiers() {
   static_assert(__is_same(__remove_const(const T), T), "");
+  static_assert(__is_same(__remove_const(volatile T), volatile T), "");
+  static_assert(__is_same(__remove_const(const volatile T), volatile T), "");
+
+  static_assert(__is_same(__remove_volatile(const T), const T), "");
+  static_assert(__is_same(__remove_volatile(volatile T), T), "");
+  static_assert(__is_same(__remove_volatile(const volatile T), const T), "");
   return true;
 }
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1269,6 +1269,8 @@
 return UnaryTransformType::AddVolatile;
   case TST_remove_const:
 return UnaryTransformType::RemoveConst;
+  case TST_remove_volatile:
+return UnaryTransformType::RemoveVolatile;
   case TST_underlyingType:
 return UnaryTransformType::EnumUnderlyingType;
   default:
@@ -1663,6 +1665,7 @@
   case DeclSpec::TST_add_cv:
   case DeclSpec::TST_add_volatile:
   case DeclSpec::TST_remove_const:
+  case DeclSpec::TST_remove_volatile:
 Result = S.GetTypeFromParser(DS.getRepAsType());
 assert(!Result.isNull() && "Didn't get a type for the transformation?");
 Result = S.BuildUnaryTransformType(
@@ -6000,7 +6003,7 @@
 void VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
   // Make sure it is a unary transform type
   assert(DS.getTypeSpecType() >= DeclSpec::TST_underlyingType &&
- DS.getTypeSpecType() <= DeclSpec::TST_remove_const);
+ DS.getTypeSpecType() <= DeclSpec::TST_remove_volatile);
   TL.setKWLoc(DS.getTypeSpecTypeLoc());
   TL.setParensRange(DS.getTypeofParensRange());
   assert(DS.getRepAsType());
@@ -9093,7 +9096,8 @@
   case UnaryTransformType::AddConst:
   case UnaryTransformType::AddCV:
   case UnaryTransformType::AddVolatile:
-  case UnaryTransformType::RemoveConst: {
+  case UnaryTransformType::RemoveConst:
+  case UnaryTransformType::RemoveVolatile: {
 SplitQualType Split = BaseType.getSplitUnqualifiedType();
 Qualifiers Quals = BaseType.getQualifiers();
 if (BaseType->isReferenceType() || BaseType->isFunctionType())
@@ -9111,6 +9115,9 @@
 case UnaryTransformType::RemoveConst:
   Quals.removeConst();
   break;
+case UnaryTransformType::RemoveVolatile:
+  Quals.removeVolatile();
+  break;
 }
 QualType Underlying(Split.Ty, Quals.getAsOpaqueValue());
 return Context.getUnaryTransformType(BaseType, Underlying, UKind);
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -863,8 +863,9 @@
   case TST_underlyingType:
   case TST_add_const:
   case TST_add_cv:
-  case TST_remove_const:
   case TST_add_volatile:
+  case TST_remove_const:
+  case TST_remove_volatile:
   case TST_atomic: {
 QualType T = DS.getRepAsType().get();
 if (!T.isNull() && T->containsUnexpandedParameterPack())
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -147,8 +147,9 @@
   case tok::kw___underlying_type:
   case tok::kw___add_const:
   case tok::kw___add_cv:
-  case tok::kw___remove_const:
   case tok::kw___add_volatile:
+  case tok::kw___remove_const:
+  case tok::kw___remove_volatile:
   case tok::kw___auto_type:
 return true;
 
@@ -5605,8 +5606,9 @@
   case DeclSpec::TST_underlyingType:
   case DeclSpec::TST_add_const:
   case DeclSpec::TST_add_cv:
-  case DeclSpec::TST_remove_const:
   case DeclSpec::TST_add_volatile:
+  case DeclSpec::TST_remove_const:
+  case DeclSpec::TST_remove_volatile:
   case DeclSpec::TST_atomic: {
 // Grab the type from the parser.
 TypeSourceInfo 

[PATCH] D116233: [clang][ARM] re-use arm::isHardTPSupported for hardware TLS check

2021-12-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3219-3226
   // Check whether the target subarch supports the hardware TLS register
-  if (arm::getARMSubArchVersionNumber(EffectiveTriple) < 7 &&
-  llvm::ARM::parseArch(EffectiveTriple.getArchName()) !=
-  llvm::ARM::ArchKind::ARMV6T2) {
+  if (!arm::isHardTPSupported(EffectiveTriple)) {
 D.Diag(diag::err_target_unsupported_tp_hard)
 << EffectiveTriple.getArchName();
 return;
   }
   // Check whether the user asked for something other than -mtp=cp15

nickdesaulniers wrote:
> nickdesaulniers wrote:
> > If I refactor `arm::getReadTPMode` a little, we might just be able to use 
> > that. Let me see if I can make that work like I'm imagining.
> eh, now that I've tried that, I think this approach is cleaner as is. Sorry 
> for the noise.
https://gist.github.com/nickdesaulniers/402fd60842dafdbc89d43d4e4c3099ee for 
the other approach I was considering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116233

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


[PATCH] D116233: [clang][ARM] re-use arm::isHardTPSupported for hardware TLS check

2021-12-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3219-3226
   // Check whether the target subarch supports the hardware TLS register
-  if (arm::getARMSubArchVersionNumber(EffectiveTriple) < 7 &&
-  llvm::ARM::parseArch(EffectiveTriple.getArchName()) !=
-  llvm::ARM::ArchKind::ARMV6T2) {
+  if (!arm::isHardTPSupported(EffectiveTriple)) {
 D.Diag(diag::err_target_unsupported_tp_hard)
 << EffectiveTriple.getArchName();
 return;
   }
   // Check whether the user asked for something other than -mtp=cp15

nickdesaulniers wrote:
> If I refactor `arm::getReadTPMode` a little, we might just be able to use 
> that. Let me see if I can make that work like I'm imagining.
eh, now that I've tried that, I think this approach is cleaner as is. Sorry for 
the noise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116233

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


[PATCH] D116238: [mips] Add -mfix4300 flag to enable vr4300 mulmul bugfix pass

2021-12-23 Thread Random via Phabricator via cfe-commits
Random06457 created this revision.
Random06457 added a reviewer: atanasyan.
Herald added subscribers: dang, jrtc27, hiraditya, arichardson, mgorny, sdardis.
Random06457 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Early revisions of the VR4300 have a hardware bug where two consecutive 
multiplications can produce an incorrect result in the second multiply.
This revision adds the `-mfix4300` flag to llvm (and clang) which, when passed, 
provides a software fix for this issue.

**More precise description of the "mulmul" bug:**

  1: mul.[s,d] fd,fs,ft
  2: mul.[s,d] fd,fs,ft  or  [D]MULT[U] rs,rt

When the above sequence is executed by the CPU, if at least one of the source 
operands of the first mul instruction happens to be `sNaN`, `0` or `Infinity`, 
then the second mul instruction may produce an incorrect result.
This can happen both if the two mul instructions are next to each other of if 
the first one is in a delay slot and the second is the first instruction of the 
branch target.

**Description of the fix:**
This fix adds a backend pass to llvm which scans for mul instructions in each 
basic block and happens a nop whenever the following conditions are met:

- The current instruction is a single or double-precision floating-point mul 
instruction.
- The next instrution is either a mul instruction (any kind) or a branch 
instruction.

**Note:**
I chose `-mfix4300` as a name for the flag to follow the GCC nomenclature but I 
don't know if this is a good name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116238

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/lib/Target/Mips/CMakeLists.txt
  llvm/lib/Target/Mips/Mips.h
  llvm/lib/Target/Mips/MipsMulMulBugPass.cpp
  llvm/lib/Target/Mips/MipsTargetMachine.cpp
  llvm/test/CodeGen/Mips/vr4300mulmul/mulbranch.ll
  llvm/test/CodeGen/Mips/vr4300mulmul/mulmul.ll

Index: llvm/test/CodeGen/Mips/vr4300mulmul/mulmul.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/vr4300mulmul/mulmul.ll
@@ -0,0 +1,12 @@
+; RUN: llc -march=mips -mfix4300 -verify-machineinstrs < %s | FileCheck %s
+
+; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
+define dso_local i32 @fun(i32 signext %x, i32 signext %y) local_unnamed_addr #0 {
+; CHECK: mul
+; CHECK-NEXT: nop
+; CHECK-NEXT: mul
+  %mul = mul nsw i32 %x, %x
+  %mul1 = mul nsw i32 %y, %y
+  %add = add nuw nsw i32 %mul1, %mul
+  ret i32 %add
+}
Index: llvm/test/CodeGen/Mips/vr4300mulmul/mulbranch.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/vr4300mulmul/mulbranch.ll
@@ -0,0 +1,12 @@
+; RUN: llc -march=mips -mfix4300 -verify-machineinstrs < %s | FileCheck %s
+
+; Function Attrs: nounwind
+define dso_local i32 @my_func(i32 signext %a) local_unnamed_addr #0 {
+; CHECK: mul
+; CHECK-NEXT: nop
+  %mul = mul nsw i32 %a, %a
+  %call = tail call i32 @foo(i32 signext %mul) #2
+  ret i32 %call
+}
+
+declare dso_local i32 @foo(i32 signext) local_unnamed_addr #1
Index: llvm/lib/Target/Mips/MipsTargetMachine.cpp
===
--- llvm/lib/Target/Mips/MipsTargetMachine.cpp
+++ llvm/lib/Target/Mips/MipsTargetMachine.cpp
@@ -292,6 +292,10 @@
   // instructions which can be remapped to a 16 bit instruction.
   addPass(createMicroMipsSizeReducePass());
 
+  // This pass inserts a nop instruction between two back-to-back multiplication
+  // instructions when the "mfix4300" flag is passed.
+  addPass(createMipsMulMulBugPass());
+
   // The delay slot filler pass can potientially create forbidden slot hazards
   // for MIPSR6 and therefore it should go before MipsBranchExpansion pass.
   addPass(createMipsDelaySlotFillerPass());
Index: llvm/lib/Target/Mips/MipsMulMulBugPass.cpp
===
--- /dev/null
+++ llvm/lib/Target/Mips/MipsMulMulBugPass.cpp
@@ -0,0 +1,121 @@
+#include "Mips.h"
+#include "MipsInstrInfo.h"
+#include "MipsSubtarget.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Target/TargetMachine.h"
+
+#define DEBUG_TYPE "mips-r4300-mulmul-fix"
+
+using namespace llvm;
+
+static cl::opt
+EnableMulMulFix("mfix4300", cl::init(false),
+cl::desc("Enable the VR4300 mulmul bug fix."), cl::Hidden);
+
+class MipsMulMulBugFix : public MachineFunctionPass {
+public:
+  MipsMulMulBugFix() : MachineFunctionPass(ID) {}
+
+  StringRef getPassName() const override { return "Mips mulmul bugfix"; }
+
+  MachineFunctionProperties getRequiredProperties() const override {
+return MachineFunctionProperties().set(
+

[PATCH] D101037: [clang-tidy] Change shebang from python to python3

2021-12-23 Thread Dave Lee via Phabricator via cfe-commits
kastiglione added a comment.
Herald added a subscriber: carlosgalvezp.

+1 to committing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101037

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


[PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov requested review of this revision.
kstoimenov added a comment.

Added empty asan_static_rtl.cpp to work around the Windows build problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116182

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


[PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 396083.
kstoimenov added a comment.

Fixed a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116182

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/asan_rtl_static.cpp
  compiler-rt/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,6 +261,7 @@
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
+$
 $
 $
 $
@@ -286,6 +287,7 @@
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
+  $
   $
   $
   $
Index: compiler-rt/lib/asan/asan_rtl_static.cpp
===
--- /dev/null
+++ compiler-rt/lib/asan/asan_rtl_static.cpp
@@ -0,0 +1,15 @@
+//===-- asan_static_rtl.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// Main file of the ASan run-time library.
+//===--===//
+
+// This file is empty for now. Main reason to have it is workaround for Windows
+// build, which complains because no files are part of the asan_static lib.
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,7 +34,6 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
-asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -43,6 +42,16 @@
   asan_new_delete.cpp
   )
 
+set(ASAN_STATIC_SOURCES
+  asan_rtl_static.cpp
+  )
+
+if (NOT WIN32 AND NOT APPLE)
+  list(APPEND ASAN_STATIC_SOURCES
+asan_rtl_x86_64.S
+  )
+endif()
+
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -135,6 +144,12 @@
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTAsan_static
+ARCHS ${ASAN_SUPPORTED_ARCH}
+SOURCES ${ASAN_STATIC_SOURCES}
+ADDITIONAL_HEADERS ${ASAN_HEADERS}
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -176,6 +191,14 @@
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
+
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -207,6 +230,14 @@
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
+
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,11 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
+  // Always link the static runtime regardless of DSO or executable.
+  if (SanArgs.needsAsanRt()) {
+HelperStaticRuntimes.push_back("asan_static");
+  }
+
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.

[PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 396082.
kstoimenov added a comment.

s/set/append/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116182

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/asan_rtl_static.cpp
  compiler-rt/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,6 +261,7 @@
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
+$
 $
 $
 $
@@ -286,6 +287,7 @@
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
+  $
   $
   $
   $
Index: compiler-rt/lib/asan/asan_rtl_static.cpp
===
--- /dev/null
+++ compiler-rt/lib/asan/asan_rtl_static.cpp
@@ -0,0 +1,15 @@
+//===-- asan_rtl.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// Main file of the ASan run-time library.
+//===--===//
+
+// This file is empty for now. Main reason to have it is workaround for Windows
+// build, which complains because no files are part of the asan_static lib.
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,7 +34,6 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
-asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -43,6 +42,16 @@
   asan_new_delete.cpp
   )
 
+set(ASAN_STATIC_SOURCES
+  asan_rtl_static.cpp
+  )
+
+if (NOT WIN32 AND NOT APPLE)
+  list(APPEND ASAN_STATIC_SOURCES
+asan_rtl_x86_64.S
+  )
+endif()
+
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -135,6 +144,12 @@
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTAsan_static
+ARCHS ${ASAN_SUPPORTED_ARCH}
+SOURCES ${ASAN_STATIC_SOURCES}
+ADDITIONAL_HEADERS ${ASAN_HEADERS}
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -176,6 +191,14 @@
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
+
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -207,6 +230,14 @@
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
+
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,11 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
+  // Always link the static runtime regardless of DSO or executable.
+  if (SanArgs.needsAsanRt()) {
+HelperStaticRuntimes.push_back("asan_static");
+  }
+
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.

[PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 396081.
kstoimenov added a comment.

Added asan_rtl_static.cpp empty file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116182

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/asan_rtl_static.cpp
  compiler-rt/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,6 +261,7 @@
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
+$
 $
 $
 $
@@ -286,6 +287,7 @@
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
+  $
   $
   $
   $
Index: compiler-rt/lib/asan/asan_rtl_static.cpp
===
--- /dev/null
+++ compiler-rt/lib/asan/asan_rtl_static.cpp
@@ -0,0 +1,15 @@
+//===-- asan_rtl.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// Main file of the ASan run-time library.
+//===--===//
+
+// This file is empty for now. Main reason to have it is workaround for Windows
+// build, which complains because no files are part of the asan_static lib.
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,7 +34,6 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
-asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -43,6 +42,16 @@
   asan_new_delete.cpp
   )
 
+set(ASAN_STATIC_SOURCES
+  asan_rtl_static.cpp
+  )
+
+if (NOT WIN32 AND NOT APPLE)
+  set(ASAN_STATIC_SOURCES
+asan_rtl_x86_64.S
+  )
+endif()
+
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -135,6 +144,12 @@
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTAsan_static
+ARCHS ${ASAN_SUPPORTED_ARCH}
+SOURCES ${ASAN_STATIC_SOURCES}
+ADDITIONAL_HEADERS ${ASAN_HEADERS}
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -176,6 +191,14 @@
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
+
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -207,6 +230,14 @@
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
+
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,11 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
+  // Always link the static runtime regardless of DSO or executable.
+  if (SanArgs.needsAsanRt()) {
+HelperStaticRuntimes.push_back("asan_static");
+  }
+
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes 

[PATCH] D116233: [clang][ARM] re-use arm::isHardTPSupported for hardware TLS check

2021-12-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers planned changes to this revision.
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3219-3226
   // Check whether the target subarch supports the hardware TLS register
-  if (arm::getARMSubArchVersionNumber(EffectiveTriple) < 7 &&
-  llvm::ARM::parseArch(EffectiveTriple.getArchName()) !=
-  llvm::ARM::ArchKind::ARMV6T2) {
+  if (!arm::isHardTPSupported(EffectiveTriple)) {
 D.Diag(diag::err_target_unsupported_tp_hard)
 << EffectiveTriple.getArchName();
 return;
   }
   // Check whether the user asked for something other than -mtp=cp15

If I refactor `arm::getReadTPMode` a little, we might just be able to use that. 
Let me see if I can make that work like I'm imagining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116233

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


[PATCH] D116229: [clang-format] Add option to align pointers in C style casts differently

2021-12-23 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Why this option is useful? Why would someone want to have a different alignment 
in casts than in other places?
As such I'm opposed to introducing one more option. Is there any well 
established code style that has something like this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116229

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


[PATCH] D116188: [clang-format] Fix short enums getting wrapped even when denied

2021-12-23 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116188

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


[PATCH] D116229: [clang-format] Add option to align pointers in C style casts differently

2021-12-23 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3045
+// parenthesis of a cast we know we are in a cast.
+if (!Left.isOneOf(TT_PointerOrReference, tok::l_paren))
+  for (const FormatToken *Tok = 

What are `Left` and `Right` in your cases? I don't like the loop here and am 
not sure what exactly you want to check. Shouldn't `Left` be the 
`PointerOrReference` and `Right` is a `r_paren`?



Comment at: clang/unittests/Format/FormatTest.cpp:15346
 
+TEST_F(FormatTest, AlignPointersInCasts) {
+  FormatStyle Style = getLLVMStyle();

I think you should add some tests with simpler casts too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116229

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


[PATCH] D116233: [clang][ARM] re-use arm::isHardTPSupported for hardware TLS check

2021-12-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: nathanchance, ardb, peter.smith.
Herald added a subscriber: kristof.beyls.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This conditional check for -mstack-protector-guard=tls got out of sync
with the conditional check for -mtp=cp15 by me in D114116 
, because I
forgot about the similar check added in D113026 
.

Re-use the code in arm::isHardTPSupported so that these aren't out of
sync.

Interestingly, our CI reported this when testing
-mstack-protector-guard=tls; it was only reproducible with Debian's LLVM
and not upstream LLVM due to this out of tree patch:
https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/-/blob/snapshot/debian/patches/930008-arm.diff

Fixes: https://github.com/ClangBuiltLinux/linux/issues/1502


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116233

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3217,9 +3217,7 @@
 return;
   }
   // Check whether the target subarch supports the hardware TLS register
-  if (arm::getARMSubArchVersionNumber(EffectiveTriple) < 7 &&
-  llvm::ARM::parseArch(EffectiveTriple.getArchName()) !=
-  llvm::ARM::ArchKind::ARMV6T2) {
+  if (!arm::isHardTPSupported(EffectiveTriple)) {
 D.Diag(diag::err_target_unsupported_tp_hard)
 << EffectiveTriple.getArchName();
 return;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3217,9 +3217,7 @@
 return;
   }
   // Check whether the target subarch supports the hardware TLS register
-  if (arm::getARMSubArchVersionNumber(EffectiveTriple) < 7 &&
-  llvm::ARM::parseArch(EffectiveTriple.getArchName()) !=
-  llvm::ARM::ArchKind::ARMV6T2) {
+  if (!arm::isHardTPSupported(EffectiveTriple)) {
 D.Diag(diag::err_target_unsupported_tp_hard)
 << EffectiveTriple.getArchName();
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116188: [clang-format] Fix short enums getting wrapped even when denied

2021-12-23 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

In D116188#3208378 , @yodaldevoid 
wrote:

> Correct commit email

Since you only upload a diff, there is no name or email. ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116188

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


[PATCH] D116128: [clang][driver] Warn when '-mno-outline-atomics' is used with a non-AArch64 triple

2021-12-23 Thread Nathan Chancellor 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 rGbe8180af5854: [clang][driver] Warn when 
-mno-outline-atomics is used with a non-AArch64… (authored by 
nathanchance).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116128

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/unsupported-outline-atomics.c


Index: clang/test/Driver/unsupported-outline-atomics.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-outline-atomics.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target x86_64 -moutline-atomics -S %s -### 2>&1 | FileCheck %s 
-check-prefix=CHECK-OUTLINE-ATOMICS-X86
+// CHECK-OUTLINE-ATOMICS-X86: warning: 'x86_64' does not support 
'-moutline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-OUTLINE-ATOMICS-X86-NOT: "-target-feature" "+outline-atomics"
+
+// RUN: %clang -target x86_64 -mno-outline-atomics -S %s -### 2>&1 | FileCheck 
%s -check-prefix=CHECK-NO-OUTLINE-ATOMICS-X86
+// CHECK-NO-OUTLINE-ATOMICS-X86: warning: 'x86_64' does not support 
'-mno-outline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-NO-OUTLINE-ATOMICS-X86-NOT: "-target-feature" "-outline-atomics"
+
+// RUN: %clang -target riscv64 -moutline-atomics -S %s -### 2>&1 | FileCheck 
%s -check-prefix=CHECK-OUTLINE-ATOMICS-RISCV
+// CHECK-OUTLINE-ATOMICS-RISCV: warning: 'riscv64' does not support 
'-moutline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-OUTLINE-ATOMICS-RISCV-NOT: "-target-feature" "+outline-atomics"
+
+// RUN: %clang -target riscv64 -mno-outline-atomics -S %s -### 2>&1 | 
FileCheck %s -check-prefix=CHECK-NO-OUTLINE-ATOMICS-RISCV
+// CHECK-NO-OUTLINE-ATOMICS-RISCV: warning: 'riscv64' does not support 
'-mno-outline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-NO-OUTLINE-ATOMICS-RISCV-NOT: "-target-feature" "-outline-atomics"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7007,18 +7007,18 @@
 
   if (Arg *A = Args.getLastArg(options::OPT_moutline_atomics,
options::OPT_mno_outline_atomics)) {
-if (A->getOption().matches(options::OPT_moutline_atomics)) {
-  // Option -moutline-atomics supported for AArch64 target only.
-  if (!Triple.isAArch64()) {
-D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
-<< Triple.getArchName();
-  } else {
+// Option -moutline-atomics supported for AArch64 target only.
+if (!Triple.isAArch64()) {
+  D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
+  << Triple.getArchName() << A->getOption().getName();
+} else {
+  if (A->getOption().matches(options::OPT_moutline_atomics)) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back("+outline-atomics");
+  } else {
+CmdArgs.push_back("-target-feature");
+CmdArgs.push_back("-outline-atomics");
   }
-} else {
-  CmdArgs.push_back("-target-feature");
-  CmdArgs.push_back("-outline-atomics");
 }
   } else if (Triple.isAArch64() &&
  getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -568,7 +568,7 @@
   InGroup;
 
 def warn_drv_moutline_atomics_unsupported_opt : Warning<
-  "'%0' does not support '-moutline-atomics'; flag ignored">,
+  "'%0' does not support '-%1'; flag ignored">,
   InGroup;
 
 def warn_drv_darwin_sdk_invalid_settings : Warning<


Index: clang/test/Driver/unsupported-outline-atomics.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-outline-atomics.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target x86_64 -moutline-atomics -S %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OUTLINE-ATOMICS-X86
+// CHECK-OUTLINE-ATOMICS-X86: warning: 'x86_64' does not support '-moutline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-OUTLINE-ATOMICS-X86-NOT: "-target-feature" "+outline-atomics"
+
+// RUN: %clang -target x86_64 -mno-outline-atomics -S %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-NO-OUTLINE-ATOMICS-X86
+// CHECK-NO-OUTLINE-ATOMICS-X86: warning: 'x86_64' does not support '-mno-outline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-NO-OUTLINE-ATOMICS-X86-NOT: "-target-feature" "-outline-atomics"
+
+// RUN: %clang -target riscv64 -moutline-atomics -S %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OUTLINE-ATOMICS-RISCV
+// CHECK-OUTLINE-ATOMICS-RISCV: warning: 'riscv64' does not 

[clang] be8180a - [clang][driver] Warn when '-mno-outline-atomics' is used with a non-AArch64 triple

2021-12-23 Thread Nathan Chancellor via cfe-commits

Author: Nathan Chancellor
Date: 2021-12-23T12:36:42-07:00
New Revision: be8180af5854806a343c3dd334d97ba2c4bfadfa

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

LOG: [clang][driver] Warn when '-mno-outline-atomics' is used with a 
non-AArch64 triple

The Linux kernel has a make macro called cc-option that invokes the
compiler with an option in isolation to see if it is supported before
adding it to CFLAGS. The exit code of the compiler is used to determine
if the flag is supported and should be added to the compiler invocation.

A call to cc-option with '-mno-outline-atomics' was added to prevent
linking errors with newer GCC versions but this call succeeds with a
non-AArch64 target because there is no warning from clang with
'-mno-outline-atomics', just '-moutline-atomics'. Because the call
succeeds and adds '-mno-outline-atomics' to the compiler invocation,
there is a warning from LLVM because the 'outline-atomics target
feature is only supported by the AArch64 backend.

$ echo | clang -target x86_64 -moutline-atomics -Werror -x c -c -o /dev/null -
clang-14: error: The 'x86_64' architecture does not support -moutline-atomics; 
flag ignored [-Werror,-Woption-ignored]

$ echo $?
1

$ echo | clang -target x86_64 -mno-outline-atomics -Werror -x c -c -o /dev/null 
-
'-outline-atomics' is not a recognized feature for this target (ignoring 
feature)

$ echo $?
0

This does not match GCC's behavior, which errors when the flag is added
to a non-AArch64 target.

$ echo | gcc -moutline-atomics -x c -c -o /dev/null -
gcc: error: unrecognized command-line option ‘-moutline-atomics’; did you mean 
‘-finline-atomics’?

$ echo | gcc -mno-outline-atomics -x c -c -o /dev/null -
gcc: error: unrecognized command-line option ‘-mno-outline-atomics’; did you 
mean ‘-fno-inline-atomics’?

$ echo | aarch64-linux-gnu-gcc -moutline-atomics -x c -c -o /dev/null -

$ echo | aarch64-linux-gnu-gcc -mno-outline-atomics -x c -c -o /dev/null -

To get closer to  GCC's behavior, issue a warning when
'-mno-outline-atomics' is used without an AArch64 triple and do not add
'{-,+}outline-atomic" to the list of target features in these cases.

Link: https://github.com/ClangBuiltLinux/linux/issues/1552

Reviewed By: melver, nickdesaulniers

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

Added: 
clang/test/Driver/unsupported-outline-atomics.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3025e6fe3c02d..c623aeff11f05 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -568,7 +568,7 @@ def warn_drv_moutline_unsupported_opt : Warning<
   InGroup;
 
 def warn_drv_moutline_atomics_unsupported_opt : Warning<
-  "'%0' does not support '-moutline-atomics'; flag ignored">,
+  "'%0' does not support '-%1'; flag ignored">,
   InGroup;
 
 def warn_drv_darwin_sdk_invalid_settings : Warning<

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ca62229b8153e..65347a38490ee 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7007,18 +7007,18 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
 
   if (Arg *A = Args.getLastArg(options::OPT_moutline_atomics,
options::OPT_mno_outline_atomics)) {
-if (A->getOption().matches(options::OPT_moutline_atomics)) {
-  // Option -moutline-atomics supported for AArch64 target only.
-  if (!Triple.isAArch64()) {
-D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
-<< Triple.getArchName();
-  } else {
+// Option -moutline-atomics supported for AArch64 target only.
+if (!Triple.isAArch64()) {
+  D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
+  << Triple.getArchName() << A->getOption().getName();
+} else {
+  if (A->getOption().matches(options::OPT_moutline_atomics)) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back("+outline-atomics");
+  } else {
+CmdArgs.push_back("-target-feature");
+CmdArgs.push_back("-outline-atomics");
   }
-} else {
-  CmdArgs.push_back("-target-feature");
-  CmdArgs.push_back("-outline-atomics");
 }
   } else if (Triple.isAArch64() &&
  getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {

diff  --git a/clang/test/Driver/unsupported-outline-atomics.c 
b/clang/test/Driver/unsupported-outline-atomics.c
new file mode 100644
index 0..2e88528c2ec60
--- /dev/null
+++ 

[PATCH] D116189: [clang-format][NFC] Correct comment about checking merging of blocks

2021-12-23 Thread Gabriel Smith via Phabricator via cfe-commits
yodaldevoid updated this revision to Diff 396064.
yodaldevoid added a comment.

Correct commit email


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116189

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -391,7 +391,7 @@
   }
 }
 
-// Try to merge a block with left brace wrapped that wasn't yet covered
+// Try to merge a block with left brace unwrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
   bool ShouldMerge = false;
   if (TheLine->First->isOneOf(tok::kw_class, tok::kw_struct)) {


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -391,7 +391,7 @@
   }
 }
 
-// Try to merge a block with left brace wrapped that wasn't yet covered
+// Try to merge a block with left brace unwrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
   bool ShouldMerge = false;
   if (TheLine->First->isOneOf(tok::kw_class, tok::kw_struct)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116229: [clang-format] Add option to align pointers in C style casts differently

2021-12-23 Thread Gabriel Smith via Phabricator via cfe-commits
yodaldevoid updated this revision to Diff 396062.
yodaldevoid added a comment.

Correct commit email


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116229

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15343,6 +15343,30 @@
Style));
 }
 
+TEST_F(FormatTest, AlignPointersInCasts) {
+  FormatStyle Style = getLLVMStyle();
+  Style.PointerAlignment = FormatStyle::PAS_Right;
+  verifyFormat("(const int (*(*foo)(const void *))[3]) a", Style);
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("(const int (*(*foo)(const void*))[3]) a", Style);
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Right;
+  verifyFormat("(const int (*(*foo)(const void *))[3]) a", Style);
+  Style.PointerAlignment = FormatStyle::PAS_Right;
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Left;
+  verifyFormat("(const int (*(*foo)(const void*))[3]) a", Style);
+
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Pointer;
+  Style.ReferenceAlignment = FormatStyle::RAS_Pointer;
+  verifyFormat("(const int (*(*foo)(const void &))[3]) a", Style);
+  Style.ReferenceAlignment = FormatStyle::RAS_Left;
+  verifyFormat("(const int (*(*foo)(const void&))[3]) a", Style);
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Right;
+  verifyFormat("(const int (*(*foo)(const void &))[3]) a", Style);
+  Style.ReferenceAlignment = FormatStyle::RAS_Right;
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Left;
+  verifyFormat("(const int (*(*foo)(const void&))[3]) a", Style);
+}
+
 TEST_F(FormatTest, AlignConsecutiveAssignmentsAcrossEmptyLines) {
   FormatStyle Alignment = getLLVMStyle();
   Alignment.AlignConsecutiveMacros = FormatStyle::ACS_Consecutive;
@@ -18817,6 +18841,13 @@
   FormatStyle::PAS_Right);
   CHECK_PARSE("PointerAlignment: Middle", PointerAlignment,
   FormatStyle::PAS_Middle);
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Left;
+  CHECK_PARSE("PointerAlignmentInCast: Pointer", PointerAlignmentInCast,
+  FormatStyle::PACS_Pointer);
+  CHECK_PARSE("PointerAlignmentInCast: Left", PointerAlignmentInCast,
+  FormatStyle::PACS_Left);
+  CHECK_PARSE("PointerAlignmentInCast: Right", PointerAlignmentInCast,
+  FormatStyle::PACS_Right);
   Style.ReferenceAlignment = FormatStyle::RAS_Middle;
   CHECK_PARSE("ReferenceAlignment: Pointer", ReferenceAlignment,
   FormatStyle::RAS_Pointer);
Index: clang/lib/Format/TokenAnnotator.h
===
--- clang/lib/Format/TokenAnnotator.h
+++ clang/lib/Format/TokenAnnotator.h
@@ -199,6 +199,9 @@
   FormatStyle::PointerAlignmentStyle
   getTokenPointerOrReferenceAlignment(const FormatToken );
 
+  FormatStyle::PointerAlignmentStyle getTokenPointerOrReferenceAlignmentInCase(
+  const FormatToken );
+
   const FormatStyle 
 
   const AdditionalKeywords 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3037,6 +3037,19 @@
 Right.Next->Next->is(TT_RangeBasedForLoopColon))
   return getTokenPointerOrReferenceAlignment(Right) !=
  FormatStyle::PAS_Left;
+// To find if we are currently in a C style cast we just have to follow the
+// linked list until one of three conditions. If we have either reached the
+// end of the list or find the opening parenthesis of a cast we can assume
+// we are not currently in a cast. If we instead find the right-most
+// parenthesis of a cast we know we are in a cast.
+if (!Left.isOneOf(TT_PointerOrReference, tok::l_paren))
+  for (const FormatToken *Tok = 
+   Tok &&
+   (!Tok->MatchingParen || !Tok->MatchingParen->is(TT_CastRParen));
+   Tok = Tok->Next)
+if (Tok->Next && Tok->Next->is(TT_CastRParen))
+  return getTokenPointerOrReferenceAlignmentInCase(Right) !=
+ FormatStyle::PAS_Left;
 return (
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
  (getTokenPointerOrReferenceAlignment(Right) != FormatStyle::PAS_Left ||
@@ -,5 +4457,20 @@
   return Style.PointerAlignment;
 }
 
+FormatStyle::PointerAlignmentStyle
+TokenAnnotator::getTokenPointerOrReferenceAlignmentInCase(
+const FormatToken ) {
+  switch (Style.PointerAlignmentInCast) {
+  case FormatStyle::PACS_Pointer:
+return getTokenPointerOrReferenceAlignment(PointerOrReference);
+  case FormatStyle::PACS_Left:
+return FormatStyle::PAS_Left;

[PATCH] D116188: [clang-format] Fix short enums getting wrapped even when denied

2021-12-23 Thread Gabriel Smith via Phabricator via cfe-commits
yodaldevoid updated this revision to Diff 396060.
yodaldevoid added a comment.

Correct commit email


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116188

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2504,6 +2504,7 @@
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortEnumsOnASingleLine = true;
   verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  verifyFormat("typedef enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
   Style.AllowShortEnumsOnASingleLine = false;
   verifyFormat("enum {\n"
"  A,\n"
@@ -2511,6 +2512,20 @@
"  C\n"
"} ShortEnum1, ShortEnum2;",
Style);
+  verifyFormat("typedef enum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+  verifyFormat("typedef enum {\n"
+   "  A,\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -393,11 +393,18 @@
 
 // Try to merge a block with left brace wrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
+  const FormatToken *Tok = TheLine->First;
   bool ShouldMerge = false;
-  if (TheLine->First->isOneOf(tok::kw_class, tok::kw_struct)) {
+  if (Tok->is(tok::kw_typedef)) {
+Tok = Tok->getNextNonComment();
+assert(Tok);
+  }
+  if (Tok->isOneOf(tok::kw_class, tok::kw_struct)) {
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (I[1]->First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
+  } else if (Tok->is(tok::kw_enum)) {
+ShouldMerge = Style.AllowShortEnumsOnASingleLine;
   } else {
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||
   (I[1]->First->is(tok::r_brace) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2504,6 +2504,7 @@
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortEnumsOnASingleLine = true;
   verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  verifyFormat("typedef enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
   Style.AllowShortEnumsOnASingleLine = false;
   verifyFormat("enum {\n"
"  A,\n"
@@ -2511,6 +2512,20 @@
"  C\n"
"} ShortEnum1, ShortEnum2;",
Style);
+  verifyFormat("typedef enum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+  verifyFormat("typedef enum {\n"
+   "  A,\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -393,11 +393,18 @@
 
 // Try to merge a block with left brace wrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
+  const FormatToken *Tok = TheLine->First;
   bool ShouldMerge = false;
-  if (TheLine->First->isOneOf(tok::kw_class, tok::kw_struct)) {
+  if (Tok->is(tok::kw_typedef)) {
+Tok = Tok->getNextNonComment();
+assert(Tok);
+  }
+  if (Tok->isOneOf(tok::kw_class, tok::kw_struct)) {
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (I[1]->First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
+  } else if (Tok->is(tok::kw_enum)) {
+ShouldMerge = Style.AllowShortEnumsOnASingleLine;
   } else {
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||
   (I[1]->First->is(tok::r_brace) &&
___

[PATCH] D116189: [clang-format][NFC] Correct comment about checking merging of blocks

2021-12-23 Thread Gabriel Smith via Phabricator via cfe-commits
yodaldevoid added a comment.

In D116189#3207717 , @MyDeveloperDay 
wrote:

> We need your name and email address to be able to commit as you

Ah, right. `arcanist` should keep that information, but I wish Phabricator 
would give a way to provide it as well.

At any rate, please use Gabriel Smith 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116189

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


[PATCH] D112410: [SPIR-V] Add a toolchain for SPIR-V in clang

2021-12-23 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I slightly adjusted the test in eafc64ed6325eba962096d4a947d7e45e909bfde 
 :)

`-no-canonical-prefixes` can usually be omitted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112410

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


[clang] eafc64e - [Driver][test] Remove unneeded -no-canonical-prefixes and use preferred --target=

2021-12-23 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-12-23T11:25:13-08:00
New Revision: eafc64ed6325eba962096d4a947d7e45e909bfde

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

LOG: [Driver][test] Remove unneeded -no-canonical-prefixes and use preferred 
--target=

-no-canonical-prefixes is not needed if we omit "clang" from CHECK lines.
"-cc1" is sufficient to anchor the line we want to test.
--target= is preferred over Separate form -target.

Added: 


Modified: 
clang/test/Driver/spirv-toolchain.cl

Removed: 




diff  --git a/clang/test/Driver/spirv-toolchain.cl 
b/clang/test/Driver/spirv-toolchain.cl
index d2562c0b667d7..4be08f127290f 100644
--- a/clang/test/Driver/spirv-toolchain.cl
+++ b/clang/test/Driver/spirv-toolchain.cl
@@ -1,58 +1,58 @@
 // Check object emission.
-// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x cl -c %s 2>&1 | 
FileCheck --check-prefix=SPV64 %s
-// RUN: %clang -### -target spirv64 %s 2>&1 | FileCheck --check-prefix=SPV64 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x ir -c %s 2>&1 | 
FileCheck --check-prefix=SPV64 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x clcpp -c %s 2>&1 
| FileCheck --check-prefix=SPV64 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x c -c %s 2>&1 | 
FileCheck --check-prefix=SPV64 %s
+// RUN: %clang -### --target=spirv64 -x cl -c %s 2>&1 | FileCheck 
--check-prefix=SPV64 %s
+// RUN: %clang -### --target=spirv64 %s 2>&1 | FileCheck --check-prefix=SPV64 
%s
+// RUN: %clang -### --target=spirv64 -x ir -c %s 2>&1 | FileCheck 
--check-prefix=SPV64 %s
+// RUN: %clang -### --target=spirv64 -x clcpp -c %s 2>&1 | FileCheck 
--check-prefix=SPV64 %s
+// RUN: %clang -### --target=spirv64 -x c -c %s 2>&1 | FileCheck 
--check-prefix=SPV64 %s
 
-// SPV64: clang{{.*}} "-cc1" "-triple" "spirv64"
+// SPV64: "-cc1" "-triple" "spirv64"
 // SPV64-SAME: "-o" [[BC:".*bc"]]
 // SPV64: {{llvm-spirv.*"}} [[BC]] "-o" {{".*o"}}
 
-// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x cl -c %s 2>&1 | 
FileCheck --check-prefix=SPV32 %s
-// RUN: %clang -### -target spirv32 %s 2>&1 | FileCheck --check-prefix=SPV32 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x ir -c %s 2>&1 | 
FileCheck --check-prefix=SPV32 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x clcpp -c %s 2>&1 
| FileCheck --check-prefix=SPV32 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x c -c %s 2>&1 | 
FileCheck --check-prefix=SPV32 %s
+// RUN: %clang -### --target=spirv32 -x cl -c %s 2>&1 | FileCheck 
--check-prefix=SPV32 %s
+// RUN: %clang -### --target=spirv32 %s 2>&1 | FileCheck --check-prefix=SPV32 
%s
+// RUN: %clang -### --target=spirv32 -x ir -c %s 2>&1 | FileCheck 
--check-prefix=SPV32 %s
+// RUN: %clang -### --target=spirv32 -x clcpp -c %s 2>&1 | FileCheck 
--check-prefix=SPV32 %s
+// RUN: %clang -### --target=spirv32 -x c -c %s 2>&1 | FileCheck 
--check-prefix=SPV32 %s
 
-// SPV32: clang{{.*}} "-cc1" "-triple" "spirv32"
+// SPV32: "-cc1" "-triple" "spirv32"
 // SPV32-SAME: "-o" [[BC:".*bc"]]
 // SPV32: {{llvm-spirv.*"}} [[BC]] "-o" {{".*o"}}
 
 //-
 // Check Assembly emission.
-// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x cl -S %s 2>&1 | 
FileCheck --check-prefix=SPT64 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x ir -S %s 2>&1 | 
FileCheck --check-prefix=SPT64 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x clcpp -c %s 2>&1 
| FileCheck --check-prefix=SPV64 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x c -S %s 2>&1 | 
FileCheck --check-prefix=SPT64 %s
+// RUN: %clang -### --target=spirv64 -x cl -S %s 2>&1 | FileCheck 
--check-prefix=SPT64 %s
+// RUN: %clang -### --target=spirv64 -x ir -S %s 2>&1 | FileCheck 
--check-prefix=SPT64 %s
+// RUN: %clang -### --target=spirv64 -x clcpp -c %s 2>&1 | FileCheck 
--check-prefix=SPV64 %s
+// RUN: %clang -### --target=spirv64 -x c -S %s 2>&1 | FileCheck 
--check-prefix=SPT64 %s
 
-// SPT64: clang{{.*}} "-cc1" "-triple" "spirv64"
+// SPT64: "-cc1" "-triple" "spirv64"
 // SPT64-SAME: "-o" [[BC:".*bc"]]
 // SPT64: {{llvm-spirv.*"}} [[BC]] "--spirv-tools-dis" "-o" {{".*s"}}
 
-// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x cl -S %s 2>&1 | 
FileCheck --check-prefix=SPT32 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x ir -S %s 2>&1 | 
FileCheck --check-prefix=SPT32 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x clcpp -c %s 2>&1 
| FileCheck --check-prefix=SPV32 %s
-// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x c -S %s 2>&1 | 
FileCheck --check-prefix=SPT32 %s
+// RUN: %clang -### --target=spirv32 -x cl -S %s 2>&1 | 

[PATCH] D115604: [Support] Expand `<@>` as the base directory in response files.

2021-12-23 Thread Jack Andersen via Phabricator via cfe-commits
jackoalan updated this revision to Diff 396055.
jackoalan added a comment.

Make expansion token a parameter of `ExpandResponseFiles` and limit use to 
`readConfigFile`. Elaborate manual entry further and add entry to release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115604

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UsersManual.rst
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -1038,25 +1038,34 @@
   llvm::SmallVector Argv;
 
   TempDir TestDir("unittest", /*Unique*/ true);
+  TempDir TestSubDir(TestDir.path("subdir"), /*Unique*/ false);
 
-  llvm::SmallString<128> TestCfg;
-  llvm::sys::path::append(TestCfg, TestDir.path(), "foo");
-
+  llvm::SmallString<128> TestCfg = TestDir.path("foo");
   TempFile ConfigFile(TestCfg, "",
   "# Comment\n"
   "-option_1\n"
+  "-option_2=/dir1\n"
   "@subconfig\n"
-  "-option_3=abcd\n"
-  "-option_4=\\\n"
+  "-option_7=abcd\n"
+  "-option_8=\\\n"
   "cdef\n");
 
-  llvm::SmallString<128> TestCfg2;
-  llvm::sys::path::append(TestCfg2, TestDir.path(), "subconfig");
+  llvm::SmallString<128> TestCfg2 = TestDir.path("subconfig");
   TempFile ConfigFile2(TestCfg2, "",
-   "-option_2\n"
+   "-option_3\n"
+   "-option_4=/dir2\n"
+   "@subdir/subfoo\n"
"\n"
"   # comment\n");
 
+  llvm::SmallString<128> TestCfg3 = TestSubDir.path("subfoo");
+  TempFile ConfigFile3(TestCfg3, "",
+   "-option_5=/dir3\n"
+   "@/subfoo2\n");
+
+  llvm::SmallString<128> TestCfg4 = TestSubDir.path("subfoo2");
+  TempFile ConfigFile4(TestCfg4, "", "-option_6=qwerty\n");
+
   // Make sure the current directory is not the directory where config files
   // resides. In this case the code that expands response files will not find
   // 'subconfig' unless it resolves nested inclusions relative to the including
@@ -1071,11 +1080,18 @@
   bool Result = llvm::cl::readConfigFile(ConfigFile.path(), Saver, Argv);
 
   EXPECT_TRUE(Result);
-  EXPECT_EQ(Argv.size(), 4U);
+  EXPECT_EQ(Argv.size(), 8U);
   EXPECT_STREQ(Argv[0], "-option_1");
-  EXPECT_STREQ(Argv[1], "-option_2");
-  EXPECT_STREQ(Argv[2], "-option_3=abcd");
-  EXPECT_STREQ(Argv[3], "-option_4=cdef");
+  EXPECT_STREQ(Argv[1],
+   ("-option_2=" + TestDir.path() + "/dir1").str().c_str());
+  EXPECT_STREQ(Argv[2], "-option_3");
+  EXPECT_STREQ(Argv[3],
+   ("-option_4=" + TestDir.path() + "/dir2").str().c_str());
+  EXPECT_STREQ(Argv[4],
+   ("-option_5=" + TestSubDir.path() + "/dir3").str().c_str());
+  EXPECT_STREQ(Argv[5], "-option_6=qwerty");
+  EXPECT_STREQ(Argv[6], "-option_7=abcd");
+  EXPECT_STREQ(Argv[7], "-option_8=cdef");
 }
 
 TEST(CommandLineTest, PositionalEatArgsError) {
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -1078,11 +1078,44 @@
   return (S.size() >= 3 && S[0] == '\xef' && S[1] == '\xbb' && S[2] == '\xbf');
 }
 
+// Substitute token with the file's base path.
+static void ExpandBasePaths(StringRef BasePath, StringRef Token,
+StringSaver , const char *) {
+  assert(sys::path::is_absolute(BasePath));
+  const StringRef ArgString(Arg);
+
+  SmallString<128> ResponseFile;
+  StringRef::size_type StartPos = 0;
+  for (StringRef::size_type TokenPos = ArgString.find(Token);
+   TokenPos != StringRef::npos;
+   TokenPos = ArgString.find(Token, StartPos)) {
+// Token may appear more than once per arg (e.g. comma-separated linker
+// args). Support by using path-append on any subsequent appearances.
+const StringRef LHS = ArgString.substr(StartPos, TokenPos - StartPos);
+if (ResponseFile.empty())
+  ResponseFile = LHS;
+else
+  llvm::sys::path::append(ResponseFile, LHS);
+ResponseFile.append(BasePath);
+StartPos = TokenPos + Token.size();
+  }
+
+  if (!ResponseFile.empty()) {
+// Path-append the remaining arg substring if at least one token appeared.
+const StringRef Remaining = ArgString.substr(StartPos);
+if (!Remaining.empty())
+  llvm::sys::path::append(ResponseFile, Remaining);
+Arg = Saver.save(ResponseFile.str()).data();
+  }
+}
+
 // FName must be an absolute path.
-static llvm::Error ExpandResponseFile(
-StringRef FName, StringSaver 

[PATCH] D116229: [clang-format] Add option to align pointers in C style casts differently

2021-12-23 Thread Gabriel Smith via Phabricator via cfe-commits
yodaldevoid created this revision.
yodaldevoid added reviewers: HazardyKnusperkeks, MyDeveloperDay, curdeius, 
owenpan.
yodaldevoid requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I personally prefer that pointers are aligned to the right in most cases to 
avoid problems when multiple variables are declared at once. That said, I 
prefer left alignment in C style casts to avoid the extra space and because 
there is no chance of the sorts of problems you see in declarations. This 
setting supports people with preferences like mine.

Currently this affects the alignment of both pointers and references in C style 
casts. If someone wanted to affect references separately then a separate 
setting for that, similar to ReferenceAlignmet, could be added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116229

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15343,6 +15343,30 @@
Style));
 }
 
+TEST_F(FormatTest, AlignPointersInCasts) {
+  FormatStyle Style = getLLVMStyle();
+  Style.PointerAlignment = FormatStyle::PAS_Right;
+  verifyFormat("(const int (*(*foo)(const void *))[3]) a", Style);
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("(const int (*(*foo)(const void*))[3]) a", Style);
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Right;
+  verifyFormat("(const int (*(*foo)(const void *))[3]) a", Style);
+  Style.PointerAlignment = FormatStyle::PAS_Right;
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Left;
+  verifyFormat("(const int (*(*foo)(const void*))[3]) a", Style);
+
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Pointer;
+  Style.ReferenceAlignment = FormatStyle::RAS_Pointer;
+  verifyFormat("(const int (*(*foo)(const void &))[3]) a", Style);
+  Style.ReferenceAlignment = FormatStyle::RAS_Left;
+  verifyFormat("(const int (*(*foo)(const void&))[3]) a", Style);
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Right;
+  verifyFormat("(const int (*(*foo)(const void &))[3]) a", Style);
+  Style.ReferenceAlignment = FormatStyle::RAS_Right;
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Left;
+  verifyFormat("(const int (*(*foo)(const void&))[3]) a", Style);
+}
+
 TEST_F(FormatTest, AlignConsecutiveAssignmentsAcrossEmptyLines) {
   FormatStyle Alignment = getLLVMStyle();
   Alignment.AlignConsecutiveMacros = FormatStyle::ACS_Consecutive;
@@ -18817,6 +18841,13 @@
   FormatStyle::PAS_Right);
   CHECK_PARSE("PointerAlignment: Middle", PointerAlignment,
   FormatStyle::PAS_Middle);
+  Style.PointerAlignmentInCast = FormatStyle::PACS_Left;
+  CHECK_PARSE("PointerAlignmentInCast: Pointer", PointerAlignmentInCast,
+  FormatStyle::PACS_Pointer);
+  CHECK_PARSE("PointerAlignmentInCast: Left", PointerAlignmentInCast,
+  FormatStyle::PACS_Left);
+  CHECK_PARSE("PointerAlignmentInCast: Right", PointerAlignmentInCast,
+  FormatStyle::PACS_Right);
   Style.ReferenceAlignment = FormatStyle::RAS_Middle;
   CHECK_PARSE("ReferenceAlignment: Pointer", ReferenceAlignment,
   FormatStyle::RAS_Pointer);
Index: clang/lib/Format/TokenAnnotator.h
===
--- clang/lib/Format/TokenAnnotator.h
+++ clang/lib/Format/TokenAnnotator.h
@@ -199,6 +199,9 @@
   FormatStyle::PointerAlignmentStyle
   getTokenPointerOrReferenceAlignment(const FormatToken );
 
+  FormatStyle::PointerAlignmentStyle getTokenPointerOrReferenceAlignmentInCase(
+  const FormatToken );
+
   const FormatStyle 
 
   const AdditionalKeywords 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3037,6 +3037,19 @@
 Right.Next->Next->is(TT_RangeBasedForLoopColon))
   return getTokenPointerOrReferenceAlignment(Right) !=
  FormatStyle::PAS_Left;
+// To find if we are currently in a C style cast we just have to follow the
+// linked list until one of three conditions. If we have either reached the
+// end of the list or find the opening parenthesis of a cast we can assume
+// we are not currently in a cast. If we instead find the right-most
+// parenthesis of a cast we know we are in a cast.
+if (!Left.isOneOf(TT_PointerOrReference, tok::l_paren))
+  for (const FormatToken *Tok = 
+   Tok &&
+   (!Tok->MatchingParen || !Tok->MatchingParen->is(TT_CastRParen));
+   Tok = Tok->Next)
+if (Tok->Next && Tok->Next->is(TT_CastRParen))
+  return 

[PATCH] D116224: Revert "[amdgpu] Enable selection of `s_cselect_b64`."

2021-12-23 Thread Mark de Wever via Phabricator via cfe-commits
Mordante requested changes to this revision.
Mordante added a comment.
This revision now requires changes to proceed.

This revision reverts more than intended. Since it now touches libcxx directory 
it requires libc++ approval.
Please reduce the revert to the intended scope.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116224

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


[PATCH] D116224: Revert "[amdgpu] Enable selection of `s_cselect_b64`."

2021-12-23 Thread David Salinas via Phabricator via cfe-commits
david-salinas created this revision.
Herald added subscribers: luke957, abrachet, ormris, foad, dang, jdoerfert, 
phosek, kerbowa, usaxena95, pengfei, s.egerton, asbirlea, mstorsjo, lebedev.ri, 
kadircet, rupprecht, arphaman, steven_wu, mgrang, simoncook, fedor.sergeev, 
hiraditya, krytarowski, arichardson, t-tye, tpr, dstuttard, yaxunl, mgorny, 
nhaehnle, jvesely, kzhuravl, emaste, arsenm, dschuff.
Herald added a reviewer: lebedev.ri.
Herald added a reviewer: jhenderson.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
david-salinas requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, libcxx-commits, 
lldb-commits, Sanitizers, sstefan1, MaskRay, wdng.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, Sanitizers, LLDB, libc++, LLVM, clang-tools-extra.
Herald added a reviewer: libc++.

This reverts commit 640beb38e7710b939b3cfb3f4c54accc694b1d30 
.

Change-Id: I179ce9595d31af5847fc5c29d66ae8c845dff0a8


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116224

Files:
  clang-tools-extra/clangd/unittests/TestScheme.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/HIP.h
  clang/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml
  clang/test/CodeGen/catch-alignment-assumption-blacklist.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-blacklist.c
  clang/test/CodeGen/ubsan-blacklist.c
  clang/test/CodeGenCXX/cfi-blacklist.cpp
  clang/test/Driver/debug-var-experimental-switch.c
  clang/test/Sema/branch-protection-attr-err.c
  clang/test/SemaCXX/PR51712-large-array-constexpr-check-oom.cpp
  compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
  compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
  compiler-rt/lib/tsan/rtl/tsan_update_shadow_word.inc
  compiler-rt/test/fuzzer/EntropicScalePerExecTimeTest.cpp
  compiler-rt/test/fuzzer/entropic-scale-per-exec-time.test
  compiler-rt/test/memprof/TestCases/mem_info_cache_entries.cpp
  compiler-rt/test/memprof/TestCases/print_miss_rate.cpp
  compiler-rt/test/ubsan/TestCases/Pointer/alignment-assumption-ignorelist.cppp
  libcxx/cmake/caches/Generic-32bits.cmake
  libcxx/include/__memory/pointer_safety.h
  libcxx/test/libcxx/atomics/ext-int.verify.cpp
  libcxx/test/libcxx/atomics/libcpp-has-no-threads.compile.fail.cpp
  libcxx/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp
  libcxx/test/std/algorithms/robust_against_adl.pass.cpp
  
libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.compile.fail.cpp
  
libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
  
libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp
  
libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp
  libcxx/test/std/numerics/c.math/abs.fail.cpp
  libcxx/test/std/strings/string.view/string.view.cons/deduct.pass.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp
  
libcxx/test/std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp
  
libcxx/test/std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp
  
libcxx/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
  
libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.deprecated.fail.cpp
  libcxx/test/support/coroutine_types.h
  libcxx/test/support/tracked_value.h
  libcxx/utils/google-benchmark/.clang-format
  libcxx/utils/google-benchmark/.github/.libcxx-setup.sh
  libcxx/utils/google-benchmark/.github/ISSUE_TEMPLATE/bug_report.md
  libcxx/utils/google-benchmark/.github/ISSUE_TEMPLATE/feature_request.md
  libcxx/utils/google-benchmark/.github/workflows/bazel.yml
  
libcxx/utils/google-benchmark/.github/workflows/build-and-test-perfcounters.yml
  libcxx/utils/google-benchmark/.github/workflows/build-and-test.yml
  libcxx/utils/google-benchmark/.github/workflows/pylint.yml
  libcxx/utils/google-benchmark/.github/workflows/sanitizer.yml
  libcxx/utils/google-benchmark/.github/workflows/test_bindings.yml
  libcxx/utils/google-benchmark/.gitignore
  libcxx/utils/google-benchmark/.travis.yml
  libcxx/utils/google-benchmark/.ycm_extra_conf.py
  libcxx/utils/google-benchmark/AUTHORS
  libcxx/utils/google-benchmark/BUILD.bazel
  libcxx/utils/google-benchmark/CMakeLists.txt
  libcxx/utils/google-benchmark/CONTRIBUTING.md
  libcxx/utils/google-benchmark/CONTRIBUTORS
  libcxx/utils/google-benchmark/LICENSE
  libcxx/utils/google-benchmark/README.md
  libcxx/utils/google-benchmark/WORKSPACE
  libcxx/utils/google-benchmark/_config.yml
  libcxx/utils/google-benchmark/appveyor.yml
  libcxx/utils/google-benchmark/bindings/python/BUILD
  libcxx/utils/google-benchmark/bindings/python/build_defs.bzl
  

[PATCH] D115921: [RISCV] Refactor the RISCV ISA extension info and target features to support multiple extension version

2021-12-23 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/include/llvm/Support/RISCVISAInfo.h:33
+  bool operator!=(const RISCVExtensionVersion ) const {
+return !operator==(Version);
+  }

Use `!(*this == Version)`



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:154
 
-static Optional isExperimentalExtension(StringRef Ext) {
-  auto ExtIterator =
-  llvm::find_if(SupportedExperimentalExtensions, FindByName(Ext));
-  if (ExtIterator == std::end(SupportedExperimentalExtensions))
-return None;
+static std::vector isExperimentalExtension(StringRef 
Ext) {
+  std::vector Result;

This name was already bad and getting worse. It doesn't return a bool so 
shouldn't start with `is`. It should be called something like 
`getExperimentalExtensionVersions`. 



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:341
+  addVersionSuffix("experimental-", "zvlsseg", Major, Minor));
+} else if (isExperimentalExtension(ExtName).size()) {
+  Features.push_back(

Use `!isExperimentalExtension(ExtName).empty()`



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:404
+  auto ExperimentalExtension = isExperimentalExtension(Ext);
+  if (ExperimentalExtension.size()) {
 if (!EnableExperimentalExtension) {

!empty



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:481
+auto Info = isSupportedExtensionFeature(ExtName);
+if(!Info)
   continue;

Please fix this clang-format issue



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.cpp:56
+void RISCVSubtarget::initializeEnvironment() {
+  StdExtM = {0, 0};
+  StdExtA = {0, 0};

Add a reset  method?



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.cpp:91
 StringRef ABIName) {
+  initializeEnvironment();
   // Determine default and user-specified characteristics

Why do we need to initialize things now but didn't before?



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:38
   virtual void anchor();
-  bool HasStdExtM = false;
-  bool HasStdExtA = false;
-  bool HasStdExtF = false;
-  bool HasStdExtD = false;
-  bool HasStdExtC = false;
-  bool HasStdExtZba = false;
-  bool HasStdExtZbb = false;
-  bool HasStdExtZbc = false;
-  bool HasStdExtZbe = false;
-  bool HasStdExtZbf = false;
-  bool HasStdExtZbm = false;
-  bool HasStdExtZbp = false;
-  bool HasStdExtZbr = false;
-  bool HasStdExtZbs = false;
-  bool HasStdExtZbt = false;
-  bool HasStdExtV = false;
-  bool HasStdExtZvlsseg = false;
-  bool HasStdExtZfhmin = false;
-  bool HasStdExtZfh = false;
+  RISCVExtensionVersion StdExtM = {0, 0};
+  RISCVExtensionVersion StdExtA = {0, 0};

Can we have a default constructor for RISCVExtensionVersion?



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:106
   bool enableMachineScheduler() const override { return true; }
-  bool hasStdExtM() const { return HasStdExtM; }
-  bool hasStdExtA() const { return HasStdExtA; }
-  bool hasStdExtF() const { return HasStdExtF; }
-  bool hasStdExtD() const { return HasStdExtD; }
-  bool hasStdExtC() const { return HasStdExtC; }
-  bool hasStdExtZba() const { return HasStdExtZba; }
-  bool hasStdExtZbb() const { return HasStdExtZbb; }
-  bool hasStdExtZbc() const { return HasStdExtZbc; }
-  bool hasStdExtZbe() const { return HasStdExtZbe; }
-  bool hasStdExtZbf() const { return HasStdExtZbf; }
-  bool hasStdExtZbm() const { return HasStdExtZbm; }
-  bool hasStdExtZbp() const { return HasStdExtZbp; }
-  bool hasStdExtZbr() const { return HasStdExtZbr; }
-  bool hasStdExtZbs() const { return HasStdExtZbs; }
-  bool hasStdExtZbt() const { return HasStdExtZbt; }
-  bool hasStdExtV() const { return HasStdExtV; }
-  bool hasStdExtZvlsseg() const { return HasStdExtZvlsseg; }
-  bool hasStdExtZfhmin() const { return HasStdExtZfhmin; }
-  bool hasStdExtZfh() const { return HasStdExtZfh; }
+  bool hasStdExtM() const { return StdExtM != RISCVExtensionVersion{0, 0}; }
+  bool hasStdExtA() const { return StdExtA != RISCVExtensionVersion{0, 0}; }

Add a helper method to RISCVExtensionVersion to check for a null version?


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

https://reviews.llvm.org/D115921

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


[PATCH] D115790: [Coroutines] Set presplit attribute in Clang and mlir

2021-12-23 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 395963.
ChuanqiXu added a comment.

Clean codes.


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

https://reviews.llvm.org/D115790

Files:
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/test/CodeGenCoroutines/coro-always-inline.cpp
  clang/test/CodeGenCoroutines/coro-attributes.cpp
  llvm/docs/Coroutines.rst
  llvm/lib/Transforms/Coroutines/CoroEarly.cpp
  llvm/lib/Transforms/Coroutines/CoroInternal.h
  llvm/test/Transforms/Coroutines/coro-debug-O2.ll
  llvm/test/Transforms/Coroutines/coro-debug-coro-frame.ll
  llvm/test/Transforms/Coroutines/coro-debug-dbg.values-not_used_in_frame.ll
  llvm/test/Transforms/Coroutines/coro-debug-dbg.values.ll
  llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll
  llvm/test/Transforms/Coroutines/coro-noalias-param.ll
  llvm/test/Transforms/Coroutines/coro-split-01.ll
  llvm/test/Transforms/Coroutines/coro-split-recursive.ll
  llvm/test/Transforms/Coroutines/ex0.ll
  llvm/test/Transforms/Coroutines/ex1.ll
  llvm/test/Transforms/Coroutines/ex2.ll
  llvm/test/Transforms/Coroutines/ex3.ll
  llvm/test/Transforms/Coroutines/ex4.ll
  llvm/test/Transforms/Coroutines/ex5.ll
  llvm/test/Transforms/Coroutines/phi-coro-end.ll
  llvm/test/Transforms/Coroutines/restart-trigger.ll
  mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
  mlir/test/mlir-opt/async.mlir

Index: mlir/test/mlir-opt/async.mlir
===
--- /dev/null
+++ mlir/test/mlir-opt/async.mlir
@@ -0,0 +1,80 @@
+// Check if mlir marks the corresponding function with required coroutine attribute.
+//
+// RUN:   mlir-opt %s -async-to-async-runtime  \
+// RUN:   -async-runtime-ref-counting  \
+// RUN:   -async-runtime-ref-counting-opt  \
+// RUN:   -convert-async-to-llvm   \
+// RUN:   -convert-linalg-to-loops \
+// RUN:   -convert-scf-to-std  \
+// RUN:   -convert-linalg-to-llvm  \
+// RUN:   -convert-memref-to-llvm  \
+// RUN:   -convert-arith-to-llvm   \
+// RUN:   -convert-std-to-llvm \
+// RUN:   -reconcile-unrealized-casts  \
+// RUN: | FileCheck %s
+
+// CHECK: llvm.func @async_execute_fn{{.*}}attributes{{.*}}"coroutine.presplit", "0"
+// CHECK: llvm.func @async_execute_fn_0{{.*}}attributes{{.*}}"coroutine.presplit", "0"
+// CHECK: llvm.func @async_execute_fn_1{{.*}}attributes{{.*}}"coroutine.presplit", "0"
+
+func @main() {
+  %i0 = arith.constant 0 : index
+  %i1 = arith.constant 1 : index
+  %i2 = arith.constant 2 : index
+  %i3 = arith.constant 3 : index
+
+  %c0 = arith.constant 0.0 : f32
+  %c1 = arith.constant 1.0 : f32
+  %c2 = arith.constant 2.0 : f32
+  %c3 = arith.constant 3.0 : f32
+  %c4 = arith.constant 4.0 : f32
+
+  %A = memref.alloc() : memref<4xf32>
+  linalg.fill(%c0, %A) : f32, memref<4xf32>
+
+  %U = memref.cast %A :  memref<4xf32> to memref<*xf32>
+  call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+  memref.store %c1, %A[%i0]: memref<4xf32>
+  call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+  call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+  %outer = async.execute {
+memref.store %c2, %A[%i1]: memref<4xf32>
+call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+// No op async region to create a token for testing async dependency.
+%noop = async.execute {
+  call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+  async.yield
+}
+
+%inner = async.execute [%noop] {
+  memref.store %c3, %A[%i2]: memref<4xf32>
+  call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+  call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+  async.yield
+}
+async.await %inner : !async.token
+
+memref.store %c4, %A[%i3]: memref<4xf32>
+call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+async.yield
+  }
+  async.await %outer : !async.token
+
+  call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+  call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+  memref.dealloc %A : memref<4xf32>
+
+  return
+}
+
+func private @mlirAsyncRuntimePrintCurrentThreadId() -> ()
+
+func private @print_memref_f32(memref<*xf32>) attributes { llvm.emit_c_interface }
Index: mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
===
--- mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
+++ mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
@@ -190,6 +190,15 @@
 }
   }
 

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2021-12-23 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

And, I am seeing a lot of failures on nvptx machine (sm_70, cuda11.4) with this 
patch,

  libomptarget :: nvptx64-nvidia-cuda :: offloading/bug49021.cpp
  libomptarget :: nvptx64-nvidia-cuda :: offloading/bug49334.cpp
  libomptarget :: nvptx64-nvidia-cuda :: offloading/bug49779.cpp
  libomptarget :: nvptx64-nvidia-cuda :: offloading/bug51781.c
  libomptarget :: nvptx64-nvidia-cuda :: offloading/bug51982.c
  libomptarget :: nvptx64-nvidia-cuda :: 
unified_shared_memory/close_enter_exit.c
  libomptarget :: nvptx64-nvidia-cuda :: unified_shared_memory/close_modifier.c
  libomptarget :: nvptx64-nvidia-cuda :: unified_shared_memory/shared_update.c
  libomptarget :: nvptx64-nvidia-cuda-newRTL :: offloading/bug49021.cpp
  libomptarget :: nvptx64-nvidia-cuda-newRTL :: offloading/bug49334.cpp
  libomptarget :: nvptx64-nvidia-cuda-newRTL :: offloading/bug51781.c
  libomptarget :: nvptx64-nvidia-cuda-newRTL :: 
unified_shared_memory/close_enter_exit.c
  libomptarget :: nvptx64-nvidia-cuda-newRTL :: 
unified_shared_memory/close_modifier.c
  libomptarget :: nvptx64-nvidia-cuda-newRTL :: 
unified_shared_memory/shared_update.c

On amdgcn, these are the tests failing,

  libomptarget :: amdgcn-amd-amdhsa :: offloading/bug49021.cpp
  libomptarget :: amdgcn-amd-amdhsa :: offloading/bug51781.c
  libomptarget :: amdgcn-amd-amdhsa :: offloading/bug51982.c
  libomptarget :: amdgcn-amd-amdhsa-newRTL :: offloading/bug49021.cpp
  libomptarget :: amdgcn-amd-amdhsa-newRTL :: offloading/bug51781.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D115921: [RISCV] Refactor the RISCV ISA extension info and target features to support multiple extension version

2021-12-23 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.

In D115921#3206156 , @jrtc27 wrote:

> Do not bring back V draft 0.7. It is gone, it will never be supported again 
> by LLVM under that name. The standard extension namespace is reserved for 
> ratified extensions and development snapshots only, not old drafts vendors 
> decided to ship. For those, non-standard extension names are needed.

I understood only ratified extension is accepted. Even for ratified extension, 
the version is going to evolve in the future. So this patch is for that. v0p7 
is just used to go through the codepath to support multiple version and test as 
now there is no extension that is not the default version. I will change the 
test way.


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

https://reviews.llvm.org/D115921

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


Re: [PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov via cfe-commits
I got a couple of options myself:

adan_instrumentation
asan_fast_path
asan_mini

What do you think?


On Wed, Dec 22, 2021, 3:30 PM Evgenii Stepanov via Phabricator <
revi...@reviews.llvm.org> wrote:

> eugenis added a comment.
>
> I don't like the name "asan_dso". DSO means "dynamic shared object", and
> this is the very opposite of that. Maybe "asan_private" or "asan_helper"?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D116182/new/
>
> https://reviews.llvm.org/D116182
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: [PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2021-12-23 Thread Lieberman, Ron via cfe-commits
[AMD Official Use Only]

@Singh, Pushpinder is this resolved?
You were most recently working on it.

Thx

-Original Message-
From: Johannes Doerfert via Phabricator  
Sent: Wednesday, December 22, 2021 5:46 PM
To: georgakoud...@llnl.gov; jdoerf...@anl.gov; jhub...@vols.utk.edu; 
a.bat...@hotmail.com
Cc: matthew.v...@sony.com; andrew.savonic...@gmail.com; yanliang...@intel.com; 
xw111lu...@gmail.com; t...@google.com; shen...@google.com; sara.royu...@bsc.es; 
Islam, Saiyedul ; Song, Ruiling ; 
ravi.narayanasw...@intel.com; quic_soura...@quicinc.com; mlek...@skidmore.edu; 
li...@llnl.gov; li...@llnl.gov; jatin.bhat...@gmail.com; greg63...@gmail.com; 
florian_h...@apple.com; dougp...@gmail.com; deepak.eachemp...@hpe.com; 
david.gr...@arm.com; blitzrak...@gmail.com; Kumar N, Bhuvanendra 
; abidmus...@gmail.com; 
llvm-comm...@lists.llvm.org; a335p...@edu.uwaterloo.ca; Singh, Pushpinder 
; Palermo, Dan ; Lieberman, Ron 
; zhaos...@quicinc.com; jonathanchesterfi...@gmail.com; 
josemonsal...@gmail.com; chichun.c...@hpe.com; lebedev...@gmail.com; 
openmp-comm...@lists.llvm.org; reviews.llvm@jfbastien.com; 
i...@tianshilei.me; Liu, Yaxun (Sam) ; 
stefomeis...@gmail.com; zhang.guans...@gmail.com; cfe-commits@lists.llvm.org; 
balaji-sankar-naga-sai-sandeep.kos...@hpe.com; misono.tomoh...@fujitsu.com; 
sunil.shres...@hpe.com; jacob.weight...@hpe.com; Balasubrmanian, Vignesh 
; gandhi21...@gmail.com; michael.hl...@gmail.com
Subject: [PATCH] D102107: [OpenMP] Codegen aggregate for outlined function 
captures

[CAUTION: External Email]

jdoerfert accepted this revision.
jdoerfert added a comment.

Can we land this? AMD issues seems resolved.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD102107%2Fnew%2Fdata=04%7C01%7Cron.lieberman%40amd.com%7C586324e07cb7454e16da08d9c59ccb4a%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637758099586834909%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=H3ekOHEM0HLuanKZ%2FJN7enQIhkNzIROdSbWOLWRElpE%3Dreserved=0

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD102107data=04%7C01%7Cron.lieberman%40amd.com%7C586324e07cb7454e16da08d9c59ccb4a%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637758099586834909%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=wcnXCYfGWmr4XXBO%2B7kmmTxqdBCRzQETRxPtIKL7Z80%3Dreserved=0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2021-12-23 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.

Can we land this? AMD issues seems resolved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[clang] 1d1b5ef - [Hexagon] Driver/preprocessor options for Hexagon v69

2021-12-23 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2021-12-23T10:17:08-08:00
New Revision: 1d1b5efdef49fa814a7e4feadd175a3dfc6460a0

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

LOG: [Hexagon] Driver/preprocessor options for Hexagon v69

Added: 
clang/test/Driver/hexagon-hvx-ieee-fp.c
clang/test/Driver/hexagon-hvx-qfloat.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/Hexagon.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/lib/Headers/hexagon_types.h
clang/test/Driver/hexagon-hvx.c
clang/test/Driver/hexagon-toolchain-elf.c
clang/test/Misc/target-invalid-cpu-note.c
clang/test/Preprocessor/hexagon-predefines.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 9776cd7b7b250..3025e6fe3c02d 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -449,6 +449,11 @@ def warn_drv_vectorize_needs_hvx : Warning<
   "auto-vectorization requires HVX, use -mhvx to enable it">,
   InGroup;
 
+def err_drv_invalid_hvx_qfloat : Error<
+  "-mhvx-qfloat is not supported without a -mhvx/-mhvx= flag.">;
+def err_drv_invalid_arch_hvx_qfloat : Error<
+  "-mhvx-qfloat is not supported on HVX %0.">;
+
 def err_drv_module_header_wrong_kind : Error<
   "header file '%0' input type '%1' does not match type of prior input "
   "in module compilation; use '-x %2' to override">;

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 08e9e1a3432ae..dc8bd831f2a26 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4160,6 +4160,8 @@ def mv67t : Flag<["-"], "mv67t">, 
Group,
   Alias, AliasArgs<["hexagonv67t"]>;
 def mv68 : Flag<["-"], "mv68">, Group,
   Alias, AliasArgs<["hexagonv68"]>;
+def mv69 : Flag<["-"], "mv69">, Group,
+  Alias, AliasArgs<["hexagonv69"]>;
 def mhexagon_hvx : Flag<["-"], "mhvx">, Group,
   HelpText<"Enable Hexagon Vector eXtensions">;
 def mhexagon_hvx_EQ : Joined<["-"], "mhvx=">,
@@ -4171,6 +4173,18 @@ def mno_hexagon_hvx : Flag<["-"], "mno-hvx">,
 def mhexagon_hvx_length_EQ : Joined<["-"], "mhvx-length=">,
   Group, HelpText<"Set Hexagon Vector Length">,
   Values<"64B,128B">;
+def mhexagon_hvx_qfloat : Flag<["-"], "mhvx-qfloat">,
+  Group,
+  HelpText<"Enable Hexagon HVX QFloat instructions">;
+def mno_hexagon_hvx_qfloat : Flag<["-"], "mno-hvx-qfloat">,
+  Group,
+  HelpText<"Disable Hexagon HVX QFloat instructions">;
+def mhexagon_hvx_ieee_fp : Flag<["-"], "mhvx-ieee-fp">,
+  Group,
+  HelpText<"Enable Hexagon HVX IEEE floating-point">;
+def mno_hexagon_hvx_ieee_fp : Flag<["-"], "mno-hvx-ieee-fp">,
+  Group,
+  HelpText<"Disable Hexagon HVX IEEE floating-point">;
 def ffixed_r19: Flag<["-"], "ffixed-r19">,
   HelpText<"Reserve register r19 (Hexagon only)">;
 def mmemops : Flag<["-"], "mmemops">, Group,

diff  --git a/clang/lib/Basic/Targets/Hexagon.cpp 
b/clang/lib/Basic/Targets/Hexagon.cpp
index 9c37dee7e89a4..161369242926e 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -68,6 +68,9 @@ void HexagonTargetInfo::getTargetDefines(const LangOptions 
,
   } else if (CPU == "hexagonv68") {
 Builder.defineMacro("__HEXAGON_V68__");
 Builder.defineMacro("__HEXAGON_ARCH__", "68");
+  } else if (CPU == "hexagonv69") {
+Builder.defineMacro("__HEXAGON_V69__");
+Builder.defineMacro("__HEXAGON_ARCH__", "69");
   }
 
   if (hasFeature("hvx-length64b")) {
@@ -128,6 +131,10 @@ bool 
HexagonTargetInfo::handleTargetFeatures(std::vector ,
 else if (F == "+audio")
   HasAudio = true;
   }
+  if (CPU.compare("hexagonv68") >= 0) {
+HasLegalHalfType = true;
+HasFloat16 = true;
+  }
   return true;
 }
 
@@ -214,7 +221,7 @@ static constexpr CPUSuffix Suffixes[] = {
 {{"hexagonv60"}, {"60"}}, {{"hexagonv62"},  {"62"}},
 {{"hexagonv65"}, {"65"}}, {{"hexagonv66"},  {"66"}},
 {{"hexagonv67"}, {"67"}}, {{"hexagonv67t"}, {"67t"}},
-{{"hexagonv68"}, {"68"}},
+{{"hexagonv68"}, {"68"}}, {{"hexagonv69"},  {"69"}},
 };
 
 const char *HexagonTargetInfo::getHexagonCPUSuffix(StringRef Name) {

diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 2ce7904ecc40d..f9785e42025cc 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -88,6 +88,27 @@ static void handleHVXTargetFeatures(const Driver , const 
ArgList ,
 Args.MakeArgString(llvm::Twine("+hvx-length") + HVXLength.lower());
 Features.push_back(HVXFeature);
   }
+
+  // Handle -mhvx-qfloat.
+  // QFloat is valid only on 

[PATCH] D116226: [clang] adds `__remove_const` as a compiler built-in

2021-12-23 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
Herald added a subscriber: dexonsmith.
cjdb 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/D116226

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/remove_cvref.cpp

Index: clang/test/SemaCXX/remove_cvref.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/remove_cvref.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 %s
+
+template 
+constexpr bool check_remove_qualifiers() {
+  static_assert(__is_same(__remove_const(const T), T), "");
+  return true;
+}
+
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+
+struct S {};
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
+static_assert(check_remove_qualifiers(), "");
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/TypeLoc.h"
 #include "clang/AST/TypeLocVisitor.h"
 #include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
@@ -1266,6 +1267,8 @@
 return UnaryTransformType::AddCV;
   case TST_add_volatile:
 return UnaryTransformType::AddVolatile;
+  case TST_remove_const:
+return UnaryTransformType::RemoveConst;
   case TST_underlyingType:
 return UnaryTransformType::EnumUnderlyingType;
   default:
@@ -1659,6 +1662,7 @@
   case DeclSpec::TST_add_const:
   case DeclSpec::TST_add_cv:
   case DeclSpec::TST_add_volatile:
+  case DeclSpec::TST_remove_const:
 Result = S.GetTypeFromParser(DS.getRepAsType());
 assert(!Result.isNull() && "Didn't get a type for the transformation?");
 Result = S.BuildUnaryTransformType(
@@ -5996,7 +6000,7 @@
 void VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
   // Make sure it is a unary transform type
   assert(DS.getTypeSpecType() >= DeclSpec::TST_underlyingType &&
- DS.getTypeSpecType() <= DeclSpec::TST_add_volatile);
+ DS.getTypeSpecType() <= DeclSpec::TST_remove_const);
   TL.setKWLoc(DS.getTypeSpecTypeLoc());
   TL.setParensRange(DS.getTypeofParensRange());
   assert(DS.getRepAsType());
@@ -9088,7 +9092,8 @@
 }
   case UnaryTransformType::AddConst:
   case UnaryTransformType::AddCV:
-  case UnaryTransformType::AddVolatile: {
+  case UnaryTransformType::AddVolatile:
+  case UnaryTransformType::RemoveConst: {
 SplitQualType Split = BaseType.getSplitUnqualifiedType();
 Qualifiers Quals = BaseType.getQualifiers();
 if (BaseType->isReferenceType() || BaseType->isFunctionType())
@@ -9102,6 +9107,10 @@
   [[fallthrough]];
 case UnaryTransformType::AddVolatile:
   Quals.addVolatile();
+  break;
+case UnaryTransformType::RemoveConst:
+  Quals.removeConst();
+  break;
 }
 QualType Underlying(Split.Ty, Quals.getAsOpaqueValue());
 return Context.getUnaryTransformType(BaseType, Underlying, UKind);
Index: 

[PATCH] D116221: [AArch64][ARM][Clang] Unaligned Access Warning Added

2021-12-23 Thread Pablo Barrio via Phabricator via cfe-commits
pbarrio requested changes to this revision.
pbarrio added a comment.
This revision now requires changes to proceed.

Suggest clarifying the commit message to something like:

"Added warning for potential cases of unaligned access when option 
-mno-unaligned-access has been specified".

Nice testing :)




Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:463-464
options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_mno_unaligned_access))
+{
   Features.push_back("+strict-align");

Nit: preserve coding style of the file. Move the bracket to the previous line, 
preceded by a space. I.e.

if (A->getOption().matches(options::OPT_mno_unaligned_access)) {


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116221

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


[PATCH] D116188: [clang-format] Fix short enums getting wrapped even when denied

2021-12-23 Thread Gabriel Smith via Phabricator via cfe-commits
yodaldevoid updated this revision to Diff 396041.
yodaldevoid added a comment.

Addressed reviewer comments

- Removed unnecessary null checks
- Added tests for typedefs preceding short enums


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116188

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2504,6 +2504,7 @@
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortEnumsOnASingleLine = true;
   verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  verifyFormat("typedef enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
   Style.AllowShortEnumsOnASingleLine = false;
   verifyFormat("enum {\n"
"  A,\n"
@@ -2511,6 +2512,20 @@
"  C\n"
"} ShortEnum1, ShortEnum2;",
Style);
+  verifyFormat("typedef enum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+  verifyFormat("typedef enum {\n"
+   "  A,\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -393,11 +393,18 @@
 
 // Try to merge a block with left brace wrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
+  const FormatToken *Tok = TheLine->First;
   bool ShouldMerge = false;
-  if (TheLine->First->isOneOf(tok::kw_class, tok::kw_struct)) {
+  if (Tok->is(tok::kw_typedef)) {
+Tok = Tok->getNextNonComment();
+assert(Tok);
+  }
+  if (Tok->isOneOf(tok::kw_class, tok::kw_struct)) {
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (I[1]->First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
+  } else if (Tok->is(tok::kw_enum)) {
+ShouldMerge = Style.AllowShortEnumsOnASingleLine;
   } else {
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||
   (I[1]->First->is(tok::r_brace) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2504,6 +2504,7 @@
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortEnumsOnASingleLine = true;
   verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  verifyFormat("typedef enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
   Style.AllowShortEnumsOnASingleLine = false;
   verifyFormat("enum {\n"
"  A,\n"
@@ -2511,6 +2512,20 @@
"  C\n"
"} ShortEnum1, ShortEnum2;",
Style);
+  verifyFormat("typedef enum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+  verifyFormat("typedef enum {\n"
+   "  A,\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -393,11 +393,18 @@
 
 // Try to merge a block with left brace wrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
+  const FormatToken *Tok = TheLine->First;
   bool ShouldMerge = false;
-  if (TheLine->First->isOneOf(tok::kw_class, tok::kw_struct)) {
+  if (Tok->is(tok::kw_typedef)) {
+Tok = Tok->getNextNonComment();
+assert(Tok);
+  }
+  if (Tok->isOneOf(tok::kw_class, tok::kw_struct)) {
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (I[1]->First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
+  } else if (Tok->is(tok::kw_enum)) {
+ShouldMerge = Style.AllowShortEnumsOnASingleLine;
   } else {
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||
 

[PATCH] D115604: [Support] Expand `<@>` as the base directory in response files.

2021-12-23 Thread Jack Andersen via Phabricator via cfe-commits
jackoalan added a comment.

> 1. It it possible to limit the new syntax to config files only? It would 
> avoid concerns of gcc compatibility.

Yes, ultimately this use case only calls for extending config files.

> Is it possible to use more understandable designation, like `` or 
> something similar?

I agree, keyword directives like this would be more flexible in the long term 
and the use of shell redirection characters would theoretically protect any 
general purpose word. For now, I think it is acceptable to consume `` 
as a singular token, but in the future, generic `<(.*)>` tokenization may be 
worth adding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115604

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


[clang] 4bf3165 - Revert "[ASan] Moved optimized callbacks into a separate library."

2021-12-23 Thread Kirill Stoimenov via cfe-commits

Author: Kirill Stoimenov
Date: 2021-12-23T17:13:18Z
New Revision: 4bf31659fac73ed6ebeb4b4d95dc41aac5dcd666

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

LOG: Revert "[ASan] Moved optimized callbacks into a separate library."

This reverts commit ab3640aa0e8361921a5d0cdc393a5b75e78ec22b.

Reviewed By: kstoimenov

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/sanitizer-ld.c
compiler-rt/lib/asan/CMakeLists.txt
compiler-rt/lib/asan/tests/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 267625c70b251..407f81a2ae09a 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,11 +826,6 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
-  // Always link the static runtime regardless of DSO or executable.
-  if (SanArgs.needsAsanRt()) {
-HelperStaticRuntimes.push_back("asan_static");
-  }
-
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index ea8c49f2384ad..d62e19fd4021b 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address 
-shared-libsan \

diff  --git a/compiler-rt/lib/asan/CMakeLists.txt 
b/compiler-rt/lib/asan/CMakeLists.txt
index 2ca59c94cc757..2e63c8d051688 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -34,6 +34,7 @@ set(ASAN_SOURCES
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
+asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -42,12 +43,6 @@ set(ASAN_CXX_SOURCES
   asan_new_delete.cpp
   )
 
-if (NOT WIN32 AND NOT APPLE)
-  set(ASAN_STATIC_SOURCES
-asan_rtl_x86_64.S
-  )
-endif()
-
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -140,12 +135,6 @@ if(NOT APPLE)
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
-  add_compiler_rt_object_libraries(RTAsan_static
-ARCHS ${ASAN_SUPPORTED_ARCH}
-SOURCES ${ASAN_STATIC_SOURCES}
-ADDITIONAL_HEADERS ${ASAN_HEADERS}
-CFLAGS ${ASAN_CFLAGS}
-DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -187,14 +176,6 @@ if(APPLE)
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
-
-  add_compiler_rt_runtime(clang_rt.asan_static
-STATIC
-ARCHS ${ASAN_SUPPORTED_ARCH}
-OBJECT_LIBS RTAsan_static
-CFLAGS ${ASAN_CFLAGS}
-DEFS ${ASAN_COMMON_DEFINITIONS}
-PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -226,14 +207,6 @@ else()
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
-  add_compiler_rt_runtime(clang_rt.asan_static
-STATIC
-ARCHS ${ASAN_SUPPORTED_ARCH}
-OBJECT_LIBS RTAsan_static
-CFLAGS ${ASAN_CFLAGS}
-DEFS ${ASAN_COMMON_DEFINITIONS}
-PARENT_TARGET asan)
-
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}

diff  --git a/compiler-rt/lib/asan/tests/CMakeLists.txt 
b/compiler-rt/lib/asan/tests/CMakeLists.txt
index 95a324766ae7c..cc375acf2dfbc 100644
--- a/compiler-rt/lib/asan/tests/CMakeLists.txt
+++ b/compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,7 +261,6 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT ANDROID)
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
-$
 $
 $
 $
@@ -287,7 +286,6 @@ if(ANDROID)
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
-  $
   $
   $
   $



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


[PATCH] D116223: Revert "[ASan] Moved optimized callbacks into a separate library."

2021-12-23 Thread Kirill Stoimenov 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 rG4bf31659fac7: Revert [ASan] Moved optimized callbacks 
into a separate library. (authored by kstoimenov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116223

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,7 +261,6 @@
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
-$
 $
 $
 $
@@ -287,7 +286,6 @@
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
-  $
   $
   $
   $
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,6 +34,7 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
+asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -42,12 +43,6 @@
   asan_new_delete.cpp
   )
 
-if (NOT WIN32 AND NOT APPLE)
-  set(ASAN_STATIC_SOURCES
-asan_rtl_x86_64.S
-  )
-endif()
-
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -140,12 +135,6 @@
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
-  add_compiler_rt_object_libraries(RTAsan_static
-ARCHS ${ASAN_SUPPORTED_ARCH}
-SOURCES ${ASAN_STATIC_SOURCES}
-ADDITIONAL_HEADERS ${ASAN_HEADERS}
-CFLAGS ${ASAN_CFLAGS}
-DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -187,14 +176,6 @@
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
-
-  add_compiler_rt_runtime(clang_rt.asan_static
-STATIC
-ARCHS ${ASAN_SUPPORTED_ARCH}
-OBJECT_LIBS RTAsan_static
-CFLAGS ${ASAN_CFLAGS}
-DEFS ${ASAN_COMMON_DEFINITIONS}
-PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -226,14 +207,6 @@
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
-  add_compiler_rt_runtime(clang_rt.asan_static
-STATIC
-ARCHS ${ASAN_SUPPORTED_ARCH}
-OBJECT_LIBS RTAsan_static
-CFLAGS ${ASAN_CFLAGS}
-DEFS ${ASAN_COMMON_DEFINITIONS}
-PARENT_TARGET asan)
-
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,11 +826,6 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
-  // Always link the static runtime regardless of DSO or executable.
-  if (SanArgs.needsAsanRt()) {
-HelperStaticRuntimes.push_back("asan_static");
-  }
-
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116223: Revert "[ASan] Moved optimized callbacks into a separate library."

2021-12-23 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov created this revision.
Herald added a subscriber: mgorny.
kstoimenov requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

This reverts commit ab3640aa0e8361921a5d0cdc393a5b75e78ec22b 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116223

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,7 +261,6 @@
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
-$
 $
 $
 $
@@ -287,7 +286,6 @@
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
-  $
   $
   $
   $
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,6 +34,7 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
+asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -42,12 +43,6 @@
   asan_new_delete.cpp
   )
 
-if (NOT WIN32 AND NOT APPLE)
-  set(ASAN_STATIC_SOURCES
-asan_rtl_x86_64.S
-  )
-endif()
-
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -140,12 +135,6 @@
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
-  add_compiler_rt_object_libraries(RTAsan_static
-ARCHS ${ASAN_SUPPORTED_ARCH}
-SOURCES ${ASAN_STATIC_SOURCES}
-ADDITIONAL_HEADERS ${ASAN_HEADERS}
-CFLAGS ${ASAN_CFLAGS}
-DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -187,14 +176,6 @@
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
-
-  add_compiler_rt_runtime(clang_rt.asan_static
-STATIC
-ARCHS ${ASAN_SUPPORTED_ARCH}
-OBJECT_LIBS RTAsan_static
-CFLAGS ${ASAN_CFLAGS}
-DEFS ${ASAN_COMMON_DEFINITIONS}
-PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -226,14 +207,6 @@
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
-  add_compiler_rt_runtime(clang_rt.asan_static
-STATIC
-ARCHS ${ASAN_SUPPORTED_ARCH}
-OBJECT_LIBS RTAsan_static
-CFLAGS ${ASAN_CFLAGS}
-DEFS ${ASAN_COMMON_DEFINITIONS}
-PARENT_TARGET asan)
-
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,11 +826,6 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
-  // Always link the static runtime regardless of DSO or executable.
-  if (SanArgs.needsAsanRt()) {
-HelperStaticRuntimes.push_back("asan_static");
-  }
-
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4c8becb - [Hexagon] Add Hexagon v69 builtins to clang

2021-12-23 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2021-12-23T09:00:15-08:00
New Revision: 4c8becbeee18a4ef83a6d8005b0e0fe19a5077ed

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

LOG: [Hexagon] Add Hexagon v69 builtins to clang

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsHexagon.def
clang/include/clang/Basic/BuiltinsHexagonDep.def
clang/lib/Headers/hexagon_protos.h
clang/lib/Headers/hvx_hexagon_protos.h

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsHexagon.def 
b/clang/include/clang/Basic/BuiltinsHexagon.def
index 0001bd5561174..0f62c235bb626 100644
--- a/clang/include/clang/Basic/BuiltinsHexagon.def
+++ b/clang/include/clang/Basic/BuiltinsHexagon.def
@@ -17,8 +17,10 @@
 #   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
+#pragma push_macro("V69")
+#define V69 "v69"
 #pragma push_macro("V68")
-#define V68 "v68"
+#define V68 "v68|" V69
 #pragma push_macro("V67")
 #define V67 "v67|" V68
 #pragma push_macro("V66")
@@ -34,8 +36,10 @@
 #pragma push_macro("V5")
 #define V5 "v5|" V55
 
+#pragma push_macro("HVXV69")
+#define HVXV69 "hvxv69"
 #pragma push_macro("HVXV68")
-#define HVXV68 "hvxv68"
+#define HVXV68 "hvxv68|" HVXV69
 #pragma push_macro("HVXV67")
 #define HVXV67 "hvxv67|" HVXV68
 #pragma push_macro("HVXV66")
@@ -128,6 +132,7 @@ 
TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", "
 #pragma pop_macro("HVXV66")
 #pragma pop_macro("HVXV67")
 #pragma pop_macro("HVXV68")
+#pragma pop_macro("HVXV69")
 
 #pragma pop_macro("V5")
 #pragma pop_macro("V55")
@@ -137,6 +142,7 @@ 
TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", "
 #pragma pop_macro("V66")
 #pragma pop_macro("V67")
 #pragma pop_macro("V68")
+#pragma pop_macro("V69")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/include/clang/Basic/BuiltinsHexagonDep.def 
b/clang/include/clang/Basic/BuiltinsHexagonDep.def
index 152c9c4dd8adb..2eb4ca69c7bde 100644
--- a/clang/include/clang/Basic/BuiltinsHexagonDep.def
+++ b/clang/include/clang/Basic/BuiltinsHexagonDep.def
@@ -1739,3 +1739,150 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10, 
"V32iV32iV32iUIi", "", HVXV68)
 TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_128B, "V64iV64iV64iUIi", "", 
HVXV68)
 TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_vxx, "V32iV32iV32iV32iUIi", 
"", HVXV68)
 TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_vxx_128B, 
"V64iV64iV64iV64iUIi", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_hf, "V16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_hf_128B, "V32iV32i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_sf, "V16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_sf_128B, "V32iV32i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf, "V16iV16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_128B, "V32iV32iV32i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_hf, "V16iV16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_hf_128B, "V32iV32iV32i", "", 
HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16, "V16iV16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16_128B, "V32iV32iV32i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16_mix, "V16iV16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16_mix_128B, "V32iV32iV32i", "", 
HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32, "V16iV16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32_128B, "V32iV32iV32i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32_mix, "V16iV16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32_mix_128B, "V32iV32iV32i", "", 
HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf, "V16iV16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_128B, "V32iV32iV32i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_hf, "V32iV16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_hf_128B, "V64iV32iV32i", "", 
HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_sf, "V16iV16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_sf_128B, "V32iV32iV32i", "", 
HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign_fp, "V16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign_fp_128B, "V32iV32i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf16, "V16iV16i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf16_128B, "V32iV32i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf32, "V16iV32i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf32_128B, "V32iV64i", "", HVXV68)
+TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_sf_qf32, "V16iV16i", "", HVXV68)

[PATCH] D116221: [AArch64][ARM][Clang] Unaligned Access Warning Added

2021-12-23 Thread Mubashar Ahmad via Phabricator via cfe-commits
mubashar_ created this revision.
mubashar_ added a reviewer: lenary.
Herald added a subscriber: kristof.beyls.
mubashar_ requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A warning for when potential cases of
unaligned access with option -mno-unaligned-access 
enabled has been added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116221

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.h
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Sema/test-wunaligned-access.cpp

Index: clang/test/Sema/test-wunaligned-access.cpp
===
--- /dev/null
+++ clang/test/Sema/test-wunaligned-access.cpp
@@ -0,0 +1,298 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wunaligned-access
+
+// Packed-Unpacked Tests (No Pragma)
+
+struct T1
+{
+char a;
+int b;
+};
+
+struct __attribute__((packed)) U1 // Causes warning
+{
+char a;
+T1 b; // expected-warning {{field b within its parent 'U1' has an alignment greater than its parent this may be caused by 'U1' being packed and can lead to unaligned accesses}}
+int c;
+};
+
+struct __attribute__((packed)) U2 // No warning
+{
+char a;
+T1 b __attribute__((aligned(4)));
+int c;
+};
+
+struct __attribute__((packed)) U3 // No warning
+{
+char a;
+char b;
+short c;
+T1 d;
+};
+
+struct __attribute__((packed)) U4 // No warning
+{
+T1 a;
+int b;
+};
+
+struct __attribute__((aligned(4), packed)) U5 // Causes warning
+{
+char a;
+T1 b; // expected-warning {{field b within its parent 'U5' has an alignment greater than its parent this may be caused by 'U5' being packed and can lead to unaligned accesses}}
+int c;
+};
+
+struct __attribute__((aligned(4), packed)) U6 // No warning
+{
+char a;
+char b;
+short c;
+T1 d;
+};
+
+// Packed-Unpacked Tests with Pragma
+
+#pragma pack(push, 1)
+
+struct __attribute__((packed)) U7 // Causes warning
+{
+char a;
+T1 b; // expected-warning {{field b within its parent 'U7' has an alignment greater than its parent this may be caused by 'U7' being packed and can lead to unaligned accesses}}
+int c;
+};
+
+struct __attribute__((packed)) U8
+{
+char a;
+T1 b __attribute__((aligned(4))); // expected-warning {{field b within its parent 'U8' has an alignment greater than its parent this may be caused by 'U8' being packed and can lead to unaligned accesses}}
+int c;
+};
+
+struct __attribute__((aligned(4))) U9
+{
+char a;
+T1 b; // expected-warning {{field b within its parent 'U9' has an alignment greater than its parent this may be caused by 'U9' being packed and can lead to unaligned accesses}}
+int c;
+};
+
+struct U10
+{
+char a;
+T1 b; // expected-warning {{field b within its parent 'U10' has an alignment greater than its parent this may be caused by 'U10' being packed and can lead to unaligned accesses}}
+int c;
+};
+
+#pragma pack(pop)
+
+// Packed-Packed Tests
+
+struct __attribute__((packed)) T2
+{
+char a;
+int b;
+};
+
+struct __attribute__((packed)) U11
+{
+char a;
+T2 b;
+int c;
+};
+
+#pragma pack(push, 1)
+struct U12 // No warning
+{
+char a;
+T2 b;
+int c;
+};
+#pragma pack(pop)
+
+// Unpacked-Packed Tests
+
+struct U13 // No warning
+{
+char a;
+T2 b;
+int c;
+};
+
+struct U14 // No warning
+{
+char a;
+T2 b __attribute__((aligned(4)));
+int c;
+};
+
+// Unpacked-Unpacked Test
+
+struct T3
+{
+char a;
+int b;
+};
+
+struct U15 // No warning
+{
+char a;
+T3 b;
+int c;
+};
+
+// Packed-Packed-Unpacked Test (No pragma)
+
+struct __attribute__((packed)) A1
+{
+char a;
+T1 b; // expected-warning {{field b within its parent 'A1' has an alignment greater than its parent this may be caused by 'A1' being packed and can lead to unaligned accesses}}
+};
+
+struct __attribute__((packed)) U16 // No warning
+{
+char a;
+A1 b;
+int c;
+};
+
+struct __attribute__((packed)) A2 // No warning
+{
+char a;
+T1 b __attribute__((aligned(4)));
+};
+
+struct __attribute__((packed)) U17 // Caused warning
+{
+char a;
+A2 b; // expected-warning {{field b within its parent 'U17' has an alignment greater than its parent this may be caused by 'U17' being packed and can lead to unaligned accesses}}
+int c;
+};
+
+// Packed-Unpacked-Packed tests
+
+struct A3
+{
+char a;
+T2 b;
+};
+
+struct __attribute__((packed)) U18
+{
+char a;
+A3 b;
+int c;
+};
+
+struct A4
+{
+char a;
+T2 b;
+int c;
+};
+
+#pragma pack(push, 1)
+struct U19 // Caused warning
+{
+char a;
+A4 b; // expected-warning {{field b within its parent 'U19' has an alignment 

[PATCH] D116216: Prevent adding module flag - amdgpu_hostcall multiple times.

2021-12-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D116216#3208096 , @pvellien wrote:

> The testcases related to this patch are already added via this patch 
> https://reviews.llvm.org/D112820.

If this patch does not result in test changes, then there is no test coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116216

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


[PATCH] D116204: [C++20] [Coroutines] Allow promise_type to not define return_void or return_value

2021-12-23 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/test/SemaCXX/coroutines.cpp:987
+//
+// So it isn't ill-formed if the promise doesn't define return_value and 
return_void. It is just a UB.
+coro no_return_value_or_return_void() {

It's not UB; it's //potential// UB.
My understanding is that such a coroutine could still be used:
- if it exits by throwing an exception instead of `co_return`'ing
- if it suspends and then its caller `destroy`s it instead of `resume`ing it

I believe it would be useful to have some actual tests for these scenarios, 
that would actually run and check that the runtime behavior is correct, or at 
least check the IR that was generated. Is that possible?


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

https://reviews.llvm.org/D116204

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


[PATCH] D116216: Prevent adding module flag - amdgpu_hostcall multiple times.

2021-12-23 Thread praveen velliengiri via Phabricator via cfe-commits
pvellien added a comment.

The testcases related to this patch are already added via this patch 
https://reviews.llvm.org/D112820.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116216

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


[PATCH] D115604: [Support] Expand `<@>` as the base directory in response files.

2021-12-23 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Thank you for the detailed explanation. Now I see how you are going to use this 
facility and think it worth implementation. A couple of questions.

1. It it possible to limit the new syntax to config files only? It would avoid 
concerns of gcc compatibility.

2. The new token is  a weird combination of special symbols, it cannot be 
understood without reading documentation. Is it possible to use more 
understandable designation, like `` or something similar? It would make 
config files more readable and allow future extensions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115604

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


[PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov 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 rGab3640aa0e83: [ASan] Moved optimized callbacks into a 
separate library. (authored by kstoimenov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116182

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,6 +261,7 @@
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
+$
 $
 $
 $
@@ -286,6 +287,7 @@
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
+  $
   $
   $
   $
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,7 +34,6 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
-asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -43,6 +42,12 @@
   asan_new_delete.cpp
   )
 
+if (NOT WIN32 AND NOT APPLE)
+  set(ASAN_STATIC_SOURCES
+asan_rtl_x86_64.S
+  )
+endif()
+
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -135,6 +140,12 @@
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTAsan_static
+ARCHS ${ASAN_SUPPORTED_ARCH}
+SOURCES ${ASAN_STATIC_SOURCES}
+ADDITIONAL_HEADERS ${ASAN_HEADERS}
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -176,6 +187,14 @@
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
+
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -207,6 +226,14 @@
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
+
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,11 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
+  // Always link the static runtime regardless of DSO or executable.
+  if (SanArgs.needsAsanRt()) {
+HelperStaticRuntimes.push_back("asan_static");
+  }
+
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ab3640a - [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov via cfe-commits

Author: Kirill Stoimenov
Date: 2021-12-23T16:40:36Z
New Revision: ab3640aa0e8361921a5d0cdc393a5b75e78ec22b

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

LOG: [ASan] Moved optimized callbacks into a separate library.

This will allow linking in the callbacks directly instead of using PLT.

Reviewed By: vitalybuka

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/sanitizer-ld.c
compiler-rt/lib/asan/CMakeLists.txt
compiler-rt/lib/asan/tests/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 407f81a2ae09a..267625c70b251 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,11 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
+  // Always link the static runtime regardless of DSO or executable.
+  if (SanArgs.needsAsanRt()) {
+HelperStaticRuntimes.push_back("asan_static");
+  }
+
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index d62e19fd4021b..ea8c49f2384ad 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address 
-shared-libsan \

diff  --git a/compiler-rt/lib/asan/CMakeLists.txt 
b/compiler-rt/lib/asan/CMakeLists.txt
index 2e63c8d051688..2ca59c94cc757 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -34,7 +34,6 @@ set(ASAN_SOURCES
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
-asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -43,6 +42,12 @@ set(ASAN_CXX_SOURCES
   asan_new_delete.cpp
   )
 
+if (NOT WIN32 AND NOT APPLE)
+  set(ASAN_STATIC_SOURCES
+asan_rtl_x86_64.S
+  )
+endif()
+
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -135,6 +140,12 @@ if(NOT APPLE)
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTAsan_static
+ARCHS ${ASAN_SUPPORTED_ARCH}
+SOURCES ${ASAN_STATIC_SOURCES}
+ADDITIONAL_HEADERS ${ASAN_HEADERS}
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -176,6 +187,14 @@ if(APPLE)
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
+
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -207,6 +226,14 @@ else()
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
+
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}

diff  --git a/compiler-rt/lib/asan/tests/CMakeLists.txt 
b/compiler-rt/lib/asan/tests/CMakeLists.txt
index cc375acf2dfbc..95a324766ae7c 100644
--- a/compiler-rt/lib/asan/tests/CMakeLists.txt
+++ b/compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,6 +261,7 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT ANDROID)
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
+$
 $
 $
 $
@@ -286,6 +287,7 @@ if(ANDROID)
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
+  $
   $
   $
   $



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


[PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov added a comment.

Renamed it 'dso' to 'static'. I know it could be a little bit confusing. I was 
considering 'static_link' or 'always_static', but it seems too long.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116182

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


[PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-23 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 396031.
kstoimenov marked an inline comment as done.
kstoimenov added a comment.

Remaned dso to static.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116182

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,6 +261,7 @@
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
+$
 $
 $
 $
@@ -286,6 +287,7 @@
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
+  $
   $
   $
   $
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,7 +34,6 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
-asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -43,6 +42,12 @@
   asan_new_delete.cpp
   )
 
+if (NOT WIN32 AND NOT APPLE)
+  set(ASAN_STATIC_SOURCES
+asan_rtl_x86_64.S
+  )
+endif()
+
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -135,6 +140,12 @@
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTAsan_static
+ARCHS ${ASAN_SUPPORTED_ARCH}
+SOURCES ${ASAN_STATIC_SOURCES}
+ADDITIONAL_HEADERS ${ASAN_HEADERS}
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -176,6 +187,14 @@
 LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
 DEFS ${ASAN_DYNAMIC_DEFINITIONS}
 PARENT_TARGET asan)
+
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
 else()
   # Build separate libraries for each target.
 
@@ -207,6 +226,14 @@
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
+  add_compiler_rt_runtime(clang_rt.asan_static
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_static
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
+
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,11 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
+  // Always link the static runtime regardless of DSO or executable.
+  if (SanArgs.needsAsanRt()) {
+HelperStaticRuntimes.push_back("asan_static");
+  }
+
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116204: [C++20] [Coroutines] Allow promise_type to not define return_void or return_value

2021-12-23 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan accepted this revision.
urnathan added a comment.
This revision is now accepted and ready to land.

looks good!  Yay, Halting Problem :)


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

https://reviews.llvm.org/D116204

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


[PATCH] D112410: [SPIR-V] Add a toolchain for SPIR-V in clang

2021-12-23 Thread Anastasia Stulova 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 rG0045d01af96f: [SPIR-V] Add a toolchain for SPIR-V in clang 
(authored by Anastasia).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112410

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Tool.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/SPIRV.cpp
  clang/lib/Driver/ToolChains/SPIRV.h
  clang/test/Driver/spirv-toolchain.cl

Index: clang/test/Driver/spirv-toolchain.cl
===
--- /dev/null
+++ clang/test/Driver/spirv-toolchain.cl
@@ -0,0 +1,65 @@
+// Check object emission.
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x cl -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+// RUN: %clang -### -target spirv64 %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x ir -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x clcpp -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x c -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+
+// SPV64: clang{{.*}} "-cc1" "-triple" "spirv64"
+// SPV64-SAME: "-o" [[BC:".*bc"]]
+// SPV64: {{llvm-spirv.*"}} [[BC]] "-o" {{".*o"}}
+
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x cl -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+// RUN: %clang -### -target spirv32 %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x ir -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x clcpp -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x c -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+
+// SPV32: clang{{.*}} "-cc1" "-triple" "spirv32"
+// SPV32-SAME: "-o" [[BC:".*bc"]]
+// SPV32: {{llvm-spirv.*"}} [[BC]] "-o" {{".*o"}}
+
+//-
+// Check Assembly emission.
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x cl -S %s 2>&1 | FileCheck --check-prefix=SPT64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x ir -S %s 2>&1 | FileCheck --check-prefix=SPT64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x clcpp -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x c -S %s 2>&1 | FileCheck --check-prefix=SPT64 %s
+
+// SPT64: clang{{.*}} "-cc1" "-triple" "spirv64"
+// SPT64-SAME: "-o" [[BC:".*bc"]]
+// SPT64: {{llvm-spirv.*"}} [[BC]] "--spirv-tools-dis" "-o" {{".*s"}}
+
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x cl -S %s 2>&1 | FileCheck --check-prefix=SPT32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x ir -S %s 2>&1 | FileCheck --check-prefix=SPT32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x clcpp -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x c -S %s 2>&1 | FileCheck --check-prefix=SPT32 %s
+
+// SPT32: clang{{.*}} "-cc1" "-triple" "spirv32"
+// SPT32-SAME: "-o" [[BC:".*bc"]]
+// SPT32: {{llvm-spirv.*"}} [[BC]] "--spirv-tools-dis" "-o" {{".*s"}}
+
+//-
+// Check assembly input -> object output
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x assembler -c %s 2>&1 | FileCheck --check-prefix=ASM %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x assembler -c %s 2>&1 | FileCheck --check-prefix=ASM %s
+// ASM: {{llvm-spirv.*"}} {{".*"}} "-to-binary" "-o" {{".*o"}}
+
+//-
+// Check --save-temps.
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x cl -c %s --save-temps 2>&1 | FileCheck --check-prefix=TMP %s
+
+// TMP: clang{{.*}} "-cc1" "-triple" "spirv64"
+// TMP-SAME: "-E"
+// TMP-SAME: "-o" [[I:".*i"]]
+// TMP: clang{{.*}} "-cc1" "-triple" "spirv64"
+// TMP-SAME: "-o" [[BC:".*bc"]]
+// TMP-SAME: [[I]]
+// TMP: {{llvm-spirv.*"}} [[BC]] "--spirv-tools-dis" "-o" [[S:".*s"]]
+// TMP: {{llvm-spirv.*"}} [[S]] "-to-binary" "-o" {{".*o"}}
+
+//-
+// Check that warning occurs if multiple input files are passed.
+// RUN: %clang -### -target spirv64 %s %s 2>&1 | FileCheck --check-prefix=WARN %s
+
+// WARN: warning: Linking multiple input files is not supported for SPIR-V 

[clang] 0045d01 - [SPIR-V] Add a toolchain for SPIR-V in clang

2021-12-23 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-12-23T15:10:09Z
New Revision: 0045d01af96ff56c5b62d133be076020a33867ff

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

LOG: [SPIR-V] Add a toolchain for SPIR-V in clang

This patch adds a toolchain (TC) for SPIR-V along with the
following changes in Driver and base ToolChain and Tool.
This is required to provide a mechanism in clang to bypass
SPIR-V backend in LLVM for SPIR-V until it lands in LLVM and
matures.

The SPIR-V code is generated by the SPIRV-LLVM translator tool
named 'llvm-spirv' that is sought in 'PATH'.

The compilation phases/actions should be bound for SPIR-V in
the meantime as following:

compile -> tools::Clang
backend -> tools::SPIRV::Translator
assemble -> tools::SPIRV::Translator

However, Driver’s ToolSelector collapses compile-backend-assemble
and compile-backend sequences to tools::Clang. To prevent this,
added new {use,has}IntegratedBackend properties in ToolChain and
Tool to which the ToolSelector reacts on, and which SPIR-V TC
overrides.

Linking of multiple input files is currently not supported but
can be added separately.

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

Co-authored-by: Henry Linjamäki 

Added: 
clang/test/Driver/spirv-toolchain.cl

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Tool.h
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Clang.h
clang/lib/Driver/ToolChains/SPIRV.cpp
clang/lib/Driver/ToolChains/SPIRV.h

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index ce66ef58fca62..3f9947afc29be 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3093,6 +3093,15 @@ There is a set of concrete HW architectures that OpenCL 
can be compiled for.
 Generic Targets
 ^^^
 
+- A SPIR-V binary can be produced for 32 or 64 bit targets.
+
+   .. code-block:: console
+
+$ clang -target spirv32 test.cl
+$ clang -target spirv64 test.cl
+
+  More details can be found in :ref:`the SPIR-V support section `.
+
 - SPIR is available as a generic target to allow portable bitcode to be 
produced
   that can be used across GPU toolchains. The implementation follows `the SPIR
   specification `_. There are two flavors
@@ -3510,6 +3519,51 @@ Clang expects the GCC executable "gcc.exe" compiled for
 `Some tests might fail `_ on
 ``x86_64-w64-mingw32``.
 
+.. _spir-v:
+
+SPIR-V support
+--
+
+Clang supports generation of SPIR-V conformant to `the OpenCL Environment
+Specification
+`_.
+
+To generate SPIR-V binaries, Clang uses the external ``llvm-spirv`` tool from 
the
+`SPIRV-LLVM-Translator repo
+`_.
+
+Prior to the generation of SPIR-V binary with Clang, ``llvm-spirv``
+should be built or installed. Please refer to `the following instructions
+`_
+for more details. Clang will expects the ``llvm-spirv`` executable to
+be present in the ``PATH`` environment variable. Clang uses ``llvm-spirv``
+with `the conformant assembly syntax package
+`_.
+
+`The versioning
+`_ of
+``llvm-spirv`` is aligned with Clang major releases. The same applies to the
+main development branch. It is therefore important to ensure the ``llvm-spirv``
+version is in alignment with the Clang version. For troubleshooting purposes
+``llvm-spirv`` can be `tested in isolation
+`_.
+
+Example usage for OpenCL kernel compilation:
+
+   .. code-block:: console
+
+ $ clang -target spirv32 test.cl
+ $ clang -target spirv64 test.cl
+
+Both invocations of Clang will result in the generation of a SPIR-V binary file
+`test.o` for 32 bit and 64 bit respectively. This file can be imported
+by an OpenCL driver that support SPIR-V consumption or it can be compiled
+further by offline SPIR-V consumer tools.
+
+Converting to SPIR-V produced with the optimization levels other than `-O0` is
+currently available as an experimental feature and it is not guaranteed to work
+in all cases.
+
 .. _clang-cl:
 
 clang-cl

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 

[PATCH] D116216: Prevent adding module flag - amdgpu_hostcall multiple times.

2021-12-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri requested changes to this revision.
lebedev.ri added a comment.
This revision now requires changes to proceed.

test coverage?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116216

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


[PATCH] D116216: Prevent adding module flag - amdgpu_hostcall multiple times.

2021-12-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116216

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


[PATCH] D113779: [Clang] Add mfp16, mfp16fml and mdotprod flags for ARM target features.

2021-12-23 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

> If anybody has contacts to GCC that would be very helpful. Unfortunately I 
> don't think I will be able to drive this.

Ok, I will bring this up internally first with some folks that work on GCC and 
see what happens. To be continued...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113779

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


[clang] 7977fd7 - [OpenMP] Remove no-op cast (NFC)

2021-12-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-12-23T15:15:26+01:00
New Revision: 7977fd7cfc5b60742af062ae4aef46fe400cca9d

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

LOG: [OpenMP] Remove no-op cast (NFC)

This was casting the address to its own element type, which is
a no-op.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index fe4cca16eb53..03aa84aecef4 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -688,8 +688,6 @@ static void EmitOMPAggregateInit(CodeGenFunction , 
Address DestAddr,
   // Drill down to the base element type on both arrays.
   const ArrayType *ArrayTy = Type->getAsArrayTypeUnsafe();
   llvm::Value *NumElements = CGF.emitArrayLength(ArrayTy, ElementTy, DestAddr);
-  DestAddr =
-  CGF.Builder.CreateElementBitCast(DestAddr, DestAddr.getElementType());
   if (DRD)
 SrcAddr =
 CGF.Builder.CreateElementBitCast(SrcAddr, DestAddr.getElementType());



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


[PATCH] D116218: [clangd] Fix selection on multi-dimensional array.

2021-12-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116218

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -318,6 +318,13 @@
   {"[[st^ruct {int x;}]] y;", "CXXRecordDecl"},
   {"[[struct {int x;} ^y]];", "VarDecl"},
   {"struct {[[int ^x]];} y;", "FieldDecl"},
+
+  // Tricky case: nested ConstantArrayTypeLocs have the same token range.
+  {"const int x = 1, y = 2; int array[^[[x]]][10][y];", "DeclRefExpr"},
+  {"const int x = 1, y = 2; int array[x][10][^[[y]]];", "DeclRefExpr"},
+  {"const int x = 1, y = 2; int array[x][^[[10]]][y];", "IntegerLiteral"},
+  {"const int x = 1, y = 2; [[i^nt]] array[x][10][y];", "BuiltinTypeLoc"},
+
   // FIXME: the AST has no location info for qualifiers.
   {"const [[a^uto]] x = 42;", "AutoTypeLoc"},
   {"[[co^nst auto x = 42]];", "VarDecl"},
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -511,6 +511,24 @@
   bool TraverseTypeLoc(TypeLoc X) {
 return traverseNode(, [&] { return Base::TraverseTypeLoc(X); });
   }
+
+  // Multi-dimensional arrays are tricky:
+  //
+  // int array[Size][10];
+  // ~~~  ~~  ConstantArrayTypeLoc int[Size][10]
+  // ~~~  |-ConstantArrayTypeLoc int[10]
+  //
+  // We have two nested ConstantArrayTypeLocs, both claim the same token range.
+  // We want to the SizeExpr in the first ConstantArrayTypeLoc to own the 
"Size"
+  // token rather than the second ConstantArrayTypeLoc.
+  // We override the default ConstantArrayTypeLoc traversal behavior by swaping
+  // the traversal order of SizeExpr and ElementTypeLoc, which gives a chance
+  // for the SizeExpr to claim its tokens.
+  bool TraverseConstantArrayTypeLoc(ConstantArrayTypeLoc X) {
+if (!Base::TraverseStmt(X.getSizeExpr()))
+  return false;
+return TraverseTypeLoc(X.getElementLoc());
+  }
   bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc ) {
 return traverseNode(,
 [&] { return Base::TraverseTemplateArgumentLoc(X); });


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -318,6 +318,13 @@
   {"[[st^ruct {int x;}]] y;", "CXXRecordDecl"},
   {"[[struct {int x;} ^y]];", "VarDecl"},
   {"struct {[[int ^x]];} y;", "FieldDecl"},
+
+  // Tricky case: nested ConstantArrayTypeLocs have the same token range.
+  {"const int x = 1, y = 2; int array[^[[x]]][10][y];", "DeclRefExpr"},
+  {"const int x = 1, y = 2; int array[x][10][^[[y]]];", "DeclRefExpr"},
+  {"const int x = 1, y = 2; int array[x][^[[10]]][y];", "IntegerLiteral"},
+  {"const int x = 1, y = 2; [[i^nt]] array[x][10][y];", "BuiltinTypeLoc"},
+
   // FIXME: the AST has no location info for qualifiers.
   {"const [[a^uto]] x = 42;", "AutoTypeLoc"},
   {"[[co^nst auto x = 42]];", "VarDecl"},
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -511,6 +511,24 @@
   bool TraverseTypeLoc(TypeLoc X) {
 return traverseNode(, [&] { return Base::TraverseTypeLoc(X); });
   }
+
+  // Multi-dimensional arrays are tricky:
+  //
+  // int array[Size][10];
+  // ~~~  ~~  ConstantArrayTypeLoc int[Size][10]
+  // ~~~  |-ConstantArrayTypeLoc int[10]
+  //
+  // We have two nested ConstantArrayTypeLocs, both claim the same token range.
+  // We want to the SizeExpr in the first ConstantArrayTypeLoc to own the "Size"
+  // token rather than the second ConstantArrayTypeLoc.
+  // We override the default ConstantArrayTypeLoc traversal behavior by swaping
+  // the traversal order of SizeExpr and ElementTypeLoc, which gives a chance
+  // for the SizeExpr to claim its tokens.
+  bool TraverseConstantArrayTypeLoc(ConstantArrayTypeLoc X) {
+if (!Base::TraverseStmt(X.getSizeExpr()))
+  return false;
+return TraverseTypeLoc(X.getElementLoc());
+  }
   bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc ) {
 return traverseNode(,
 [&] { return 

[clang] bf2b555 - [CodeGen] Use CreateConstInBoundsGEP() in one more place

2021-12-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-12-23T14:58:47+01:00
New Revision: bf2b5551f9192106b1997f7c9c3bdc36be2dc381

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

LOG: [CodeGen] Use CreateConstInBoundsGEP() in one more place

This does exactly what this code manually implemented.

Added: 


Modified: 
clang/lib/CodeGen/CGExprCXX.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index ca4450a8cf1c..0571c498c377 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -1052,13 +1052,8 @@ void CodeGenFunction::EmitNewArrayInitializer(
   InitListElements =
   cast(ILE->getType()->getAsArrayTypeUnsafe())
   ->getSize().getZExtValue();
-  CurPtr =
-  Address(Builder.CreateInBoundsGEP(CurPtr.getElementType(),
-CurPtr.getPointer(),
-Builder.getSize(InitListElements),
-"string.init.end"),
-  CurPtr.getAlignment().alignmentAtOffset(InitListElements *
-  ElementSize));
+  CurPtr = Builder.CreateConstInBoundsGEP(
+  CurPtr, InitListElements, "string.init.end");
 
   // Zero out the rest, if any remain.
   llvm::ConstantInt *ConstNum = dyn_cast(NumElements);



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


[clang] 2c7dc13 - [CGBuilder] Add CreateGEP() overload that accepts an Address

2021-12-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-12-23T14:53:42+01:00
New Revision: 2c7dc13146ba0c2991e4950ce159276ad5d9aece

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

LOG: [CGBuilder] Add CreateGEP() overload that accepts an Address

Add an overload for an Address and a single non-constant offset.
This makes it easier to preserve the element type and adjust the
alignment appropriately.

Added: 


Modified: 
clang/lib/CodeGen/CGBuilder.h
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index 5639abf569827..7c9f41e84eaf5 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -258,6 +258,21 @@ class CGBuilderTy : public CGBuilderBaseTy {
Addr.getAlignment().alignmentAtOffset(Index * EltSize));
   }
 
+  /// Create GEP with single dynamic index. The address alignment is reduced
+  /// according to the element size.
+  using CGBuilderBaseTy::CreateGEP;
+  Address CreateGEP(Address Addr, llvm::Value *Index,
+const llvm::Twine  = "") {
+const llvm::DataLayout  = BB->getParent()->getParent()->getDataLayout();
+CharUnits EltSize =
+CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType()));
+
+return Address(CreateGEP(Addr.getElementType(), Addr.getPointer(), Index,
+ Name),
+   Addr.getElementType(),
+   Addr.getAlignment().alignmentOfArrayElement(EltSize));
+  }
+
   /// Given a pointer to i8, adjust it by a given constant offset.
   Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset,
  const llvm::Twine  = "") {

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 8a75f06882bc6..fe4cca16eb533 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4501,10 +4501,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction , 
SourceLocation Loc,
 std::tie(Addr, Size) = getPointerAndSize(CGF, E);
 llvm::Value *Idx = CGF.EmitLoadOfScalar(PosLVal, E->getExprLoc());
 LValue Base = CGF.MakeAddrLValue(
-Address(CGF.Builder.CreateGEP(AffinitiesArray.getElementType(),
-  AffinitiesArray.getPointer(), Idx),
-AffinitiesArray.getAlignment()),
-KmpTaskAffinityInfoTy);
+CGF.Builder.CreateGEP(AffinitiesArray, Idx), 
KmpTaskAffinityInfoTy);
 // affs[i].base_addr = &;
 LValue BaseAddrLVal = CGF.EmitLValueForField(
 Base, *std::next(KmpAffinityInfoRD->field_begin(), BaseAddr));
@@ -4668,12 +4665,10 @@ CGOpenMPRuntime::getDepobjElements(CodeGenFunction 
, LValue DepobjLVal,
   Base.getAddress(CGF), CGF.ConvertTypeForMem(KmpDependInfoPtrTy));
   Base = CGF.MakeAddrLValue(Addr, KmpDependInfoTy, Base.getBaseInfo(),
 Base.getTBAAInfo());
-  llvm::Value *DepObjAddr = CGF.Builder.CreateGEP(
-  Addr.getElementType(), Addr.getPointer(),
-  llvm::ConstantInt::get(CGF.IntPtrTy, -1, /*isSigned=*/true));
+  Address DepObjAddr = CGF.Builder.CreateGEP(
+  Addr, llvm::ConstantInt::get(CGF.IntPtrTy, -1, /*isSigned=*/true));
   LValue NumDepsBase = CGF.MakeAddrLValue(
-  Address(DepObjAddr, Addr.getAlignment()), KmpDependInfoTy,
-  Base.getBaseInfo(), Base.getTBAAInfo());
+  DepObjAddr, KmpDependInfoTy, Base.getBaseInfo(), Base.getTBAAInfo());
   // NumDeps = deps[i].base_addr;
   LValue BaseAddrLVal = CGF.EmitLValueForField(
   NumDepsBase, *std::next(KmpDependInfoRD->field_begin(), BaseAddr));
@@ -4709,10 +4704,7 @@ static void emitDependData(CodeGenFunction , 
QualType ,
   LValue  = *Pos.get();
   llvm::Value *Idx = CGF.EmitLoadOfScalar(PosLVal, E->getExprLoc());
   Base = CGF.MakeAddrLValue(
-  Address(CGF.Builder.CreateGEP(DependenciesArray.getElementType(),
-DependenciesArray.getPointer(), Idx),
-  DependenciesArray.getAlignment()),
-  KmpDependInfoTy);
+  CGF.Builder.CreateGEP(DependenciesArray, Idx), KmpDependInfoTy);
 }
 // deps[i].base_addr = &;
 LValue BaseAddrLVal = CGF.EmitLValueForField(
@@ -4769,12 +4761,10 @@ emitDepobjElementsSizes(CodeGenFunction , QualType 
,
   Base.getAddress(CGF), KmpDependInfoPtrT);
   Base = CGF.MakeAddrLValue(Addr, KmpDependInfoTy, Base.getBaseInfo(),
 Base.getTBAAInfo());
-  llvm::Value *DepObjAddr = CGF.Builder.CreateGEP(
-  Addr.getElementType(), Addr.getPointer(),
-  

[clang] 86b001a - [C++20] [Modules] Mark imported module as imported if not exported

2021-12-23 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2021-12-23T21:14:13+08:00
New Revision: 86b001a94172ac625f17f381c971dad3b9367278

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

LOG: [C++20] [Modules] Mark imported module as imported if not exported

In C++20 Modules, imported module which doesn't get exported wouldn't be
recorded. This patch would record such modules to avoid possible
incorrect visibility problems.

Reviewed By: urnathan

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

Added: 


Modified: 
clang/lib/Sema/SemaModule.cpp
clang/test/Modules/module-transtive-instantiation.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index f497199badc10..a4b9f3c242c1c 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -383,11 +383,18 @@ DeclResult Sema::ActOnModuleImport(SourceLocation 
StartLoc,
   if (!ModuleScopes.empty())
 Context.addModuleInitializer(ModuleScopes.back().Module, Import);
 
-  // Re-export the module if needed.
   if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {
+// Re-export the module if the imported module is exported.
+// Note that we don't need to add re-exported module to Imports field
+// since `Exports` implies the module is imported already.
 if (ExportLoc.isValid() || getEnclosingExportDecl(Import))
   getCurrentModule()->Exports.emplace_back(Mod, false);
+else
+  getCurrentModule()->Imports.insert(Mod);
   } else if (ExportLoc.isValid()) {
+// [module.interface]p1:
+// An export-declaration shall inhabit a namespace scope and appear in the
+// purview of a module interface unit.
 Diag(ExportLoc, diag::err_export_not_in_module_interface);
   }
 

diff  --git a/clang/test/Modules/module-transtive-instantiation.cpp 
b/clang/test/Modules/module-transtive-instantiation.cpp
index 2c5c7ead8ad53..b44f0bbfdf399 100644
--- a/clang/test/Modules/module-transtive-instantiation.cpp
+++ b/clang/test/Modules/module-transtive-instantiation.cpp
@@ -3,11 +3,9 @@
 // RUN: %clang_cc1 -std=c++20 
%S/Inputs/module-transtive-instantiation/Templ.cppm -emit-module-interface -o 
%t/Templ.pcm
 // RUN: %clang_cc1 -std=c++20 
%S/Inputs/module-transtive-instantiation/bar.cppm  -emit-module-interface 
-fprebuilt-module-path=%t -o %t/bar.pcm
 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only 
-verify
+// expected-no-diagnostics
 
 import bar;
 int foo() {
-// FIXME: It shouldn't be an error. Since the `G` is already imported in 
bar.
-return bar(); // 
expected-error@Inputs/module-transtive-instantiation/bar.cppm:5 {{definition of 
'G' must be imported from module 'Templ' before it is required}}
-   // expected-note@-1 {{in instantiation of function 
template specialization 'bar' requested here}}
-   // 
expected-note@Inputs/module-transtive-instantiation/Templ.cppm:3 {{definition 
here is not reachable}}
+  return bar();
 }



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


[clang] 1e2c31c - Revert "[C++20] [Coroutines] Mark imported module as imported if not exported"

2021-12-23 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2021-12-23T21:10:07+08:00
New Revision: 1e2c31c66be79b6ca6aeb42fc2835017935b8b27

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

LOG: Revert "[C++20] [Coroutines] Mark imported module as imported if not 
exported"

This reverts commit 368318bcce66d9fef420fc34cca361b79d80cee5.

The title is not right. It should be a patch about modules instead of
coroutines.

Added: 


Modified: 
clang/lib/Sema/SemaModule.cpp
clang/test/Modules/module-transtive-instantiation.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index a4b9f3c242c1c..f497199badc10 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -383,18 +383,11 @@ DeclResult Sema::ActOnModuleImport(SourceLocation 
StartLoc,
   if (!ModuleScopes.empty())
 Context.addModuleInitializer(ModuleScopes.back().Module, Import);
 
+  // Re-export the module if needed.
   if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {
-// Re-export the module if the imported module is exported.
-// Note that we don't need to add re-exported module to Imports field
-// since `Exports` implies the module is imported already.
 if (ExportLoc.isValid() || getEnclosingExportDecl(Import))
   getCurrentModule()->Exports.emplace_back(Mod, false);
-else
-  getCurrentModule()->Imports.insert(Mod);
   } else if (ExportLoc.isValid()) {
-// [module.interface]p1:
-// An export-declaration shall inhabit a namespace scope and appear in the
-// purview of a module interface unit.
 Diag(ExportLoc, diag::err_export_not_in_module_interface);
   }
 

diff  --git a/clang/test/Modules/module-transtive-instantiation.cpp 
b/clang/test/Modules/module-transtive-instantiation.cpp
index b44f0bbfdf399..2c5c7ead8ad53 100644
--- a/clang/test/Modules/module-transtive-instantiation.cpp
+++ b/clang/test/Modules/module-transtive-instantiation.cpp
@@ -3,9 +3,11 @@
 // RUN: %clang_cc1 -std=c++20 
%S/Inputs/module-transtive-instantiation/Templ.cppm -emit-module-interface -o 
%t/Templ.pcm
 // RUN: %clang_cc1 -std=c++20 
%S/Inputs/module-transtive-instantiation/bar.cppm  -emit-module-interface 
-fprebuilt-module-path=%t -o %t/bar.pcm
 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only 
-verify
-// expected-no-diagnostics
 
 import bar;
 int foo() {
-  return bar();
+// FIXME: It shouldn't be an error. Since the `G` is already imported in 
bar.
+return bar(); // 
expected-error@Inputs/module-transtive-instantiation/bar.cppm:5 {{definition of 
'G' must be imported from module 'Templ' before it is required}}
+   // expected-note@-1 {{in instantiation of function 
template specialization 'bar' requested here}}
+   // 
expected-note@Inputs/module-transtive-instantiation/Templ.cppm:3 {{definition 
here is not reachable}}
 }



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


[PATCH] D116098: [C++20] [Modules] Mark imported module as imported if not exported

2021-12-23 Thread Chuanqi Xu 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 rG368318bcce66: [C++20] [Coroutines] Mark imported module as 
imported if not exported (authored by ChuanqiXu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116098

Files:
  clang/lib/Sema/SemaModule.cpp
  clang/test/Modules/module-transtive-instantiation.cpp


Index: clang/test/Modules/module-transtive-instantiation.cpp
===
--- clang/test/Modules/module-transtive-instantiation.cpp
+++ clang/test/Modules/module-transtive-instantiation.cpp
@@ -3,11 +3,9 @@
 // RUN: %clang_cc1 -std=c++20 
%S/Inputs/module-transtive-instantiation/Templ.cppm -emit-module-interface -o 
%t/Templ.pcm
 // RUN: %clang_cc1 -std=c++20 
%S/Inputs/module-transtive-instantiation/bar.cppm  -emit-module-interface 
-fprebuilt-module-path=%t -o %t/bar.pcm
 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only 
-verify
+// expected-no-diagnostics
 
 import bar;
 int foo() {
-// FIXME: It shouldn't be an error. Since the `G` is already imported in 
bar.
-return bar(); // 
expected-error@Inputs/module-transtive-instantiation/bar.cppm:5 {{definition of 
'G' must be imported from module 'Templ' before it is required}}
-   // expected-note@-1 {{in instantiation of function 
template specialization 'bar' requested here}}
-   // 
expected-note@Inputs/module-transtive-instantiation/Templ.cppm:3 {{definition 
here is not reachable}}
+  return bar();
 }
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -383,11 +383,18 @@
   if (!ModuleScopes.empty())
 Context.addModuleInitializer(ModuleScopes.back().Module, Import);
 
-  // Re-export the module if needed.
   if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {
+// Re-export the module if the imported module is exported.
+// Note that we don't need to add re-exported module to Imports field
+// since `Exports` implies the module is imported already.
 if (ExportLoc.isValid() || getEnclosingExportDecl(Import))
   getCurrentModule()->Exports.emplace_back(Mod, false);
+else
+  getCurrentModule()->Imports.insert(Mod);
   } else if (ExportLoc.isValid()) {
+// [module.interface]p1:
+// An export-declaration shall inhabit a namespace scope and appear in the
+// purview of a module interface unit.
 Diag(ExportLoc, diag::err_export_not_in_module_interface);
   }
 


Index: clang/test/Modules/module-transtive-instantiation.cpp
===
--- clang/test/Modules/module-transtive-instantiation.cpp
+++ clang/test/Modules/module-transtive-instantiation.cpp
@@ -3,11 +3,9 @@
 // RUN: %clang_cc1 -std=c++20 %S/Inputs/module-transtive-instantiation/Templ.cppm -emit-module-interface -o %t/Templ.pcm
 // RUN: %clang_cc1 -std=c++20 %S/Inputs/module-transtive-instantiation/bar.cppm  -emit-module-interface -fprebuilt-module-path=%t -o %t/bar.pcm
 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only -verify
+// expected-no-diagnostics
 
 import bar;
 int foo() {
-// FIXME: It shouldn't be an error. Since the `G` is already imported in bar.
-return bar(); // expected-error@Inputs/module-transtive-instantiation/bar.cppm:5 {{definition of 'G' must be imported from module 'Templ' before it is required}}
-   // expected-note@-1 {{in instantiation of function template specialization 'bar' requested here}}
-   // expected-note@Inputs/module-transtive-instantiation/Templ.cppm:3 {{definition here is not reachable}}
+  return bar();
 }
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -383,11 +383,18 @@
   if (!ModuleScopes.empty())
 Context.addModuleInitializer(ModuleScopes.back().Module, Import);
 
-  // Re-export the module if needed.
   if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {
+// Re-export the module if the imported module is exported.
+// Note that we don't need to add re-exported module to Imports field
+// since `Exports` implies the module is imported already.
 if (ExportLoc.isValid() || getEnclosingExportDecl(Import))
   getCurrentModule()->Exports.emplace_back(Mod, false);
+else
+  getCurrentModule()->Imports.insert(Mod);
   } else if (ExportLoc.isValid()) {
+// [module.interface]p1:
+// An export-declaration shall inhabit a namespace scope and appear in the
+// purview of a module interface unit.
 Diag(ExportLoc, diag::err_export_not_in_module_interface);
   }
 

[clang] 368318b - [C++20] [Coroutines] Mark imported module as imported if not exported

2021-12-23 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2021-12-23T20:51:05+08:00
New Revision: 368318bcce66d9fef420fc34cca361b79d80cee5

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

LOG: [C++20] [Coroutines] Mark imported module as imported if not exported

In C++20 Modules, imported module which doesn't get exported wouldn't be
recorded. This patch would record such modules to avoid possible
incorrect visibility problems.

Reviewed By: urnathan

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

Added: 


Modified: 
clang/lib/Sema/SemaModule.cpp
clang/test/Modules/module-transtive-instantiation.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index f497199badc10..a4b9f3c242c1c 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -383,11 +383,18 @@ DeclResult Sema::ActOnModuleImport(SourceLocation 
StartLoc,
   if (!ModuleScopes.empty())
 Context.addModuleInitializer(ModuleScopes.back().Module, Import);
 
-  // Re-export the module if needed.
   if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {
+// Re-export the module if the imported module is exported.
+// Note that we don't need to add re-exported module to Imports field
+// since `Exports` implies the module is imported already.
 if (ExportLoc.isValid() || getEnclosingExportDecl(Import))
   getCurrentModule()->Exports.emplace_back(Mod, false);
+else
+  getCurrentModule()->Imports.insert(Mod);
   } else if (ExportLoc.isValid()) {
+// [module.interface]p1:
+// An export-declaration shall inhabit a namespace scope and appear in the
+// purview of a module interface unit.
 Diag(ExportLoc, diag::err_export_not_in_module_interface);
   }
 

diff  --git a/clang/test/Modules/module-transtive-instantiation.cpp 
b/clang/test/Modules/module-transtive-instantiation.cpp
index 2c5c7ead8ad53..b44f0bbfdf399 100644
--- a/clang/test/Modules/module-transtive-instantiation.cpp
+++ b/clang/test/Modules/module-transtive-instantiation.cpp
@@ -3,11 +3,9 @@
 // RUN: %clang_cc1 -std=c++20 
%S/Inputs/module-transtive-instantiation/Templ.cppm -emit-module-interface -o 
%t/Templ.pcm
 // RUN: %clang_cc1 -std=c++20 
%S/Inputs/module-transtive-instantiation/bar.cppm  -emit-module-interface 
-fprebuilt-module-path=%t -o %t/bar.pcm
 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only 
-verify
+// expected-no-diagnostics
 
 import bar;
 int foo() {
-// FIXME: It shouldn't be an error. Since the `G` is already imported in 
bar.
-return bar(); // 
expected-error@Inputs/module-transtive-instantiation/bar.cppm:5 {{definition of 
'G' must be imported from module 'Templ' before it is required}}
-   // expected-note@-1 {{in instantiation of function 
template specialization 'bar' requested here}}
-   // 
expected-note@Inputs/module-transtive-instantiation/Templ.cppm:3 {{definition 
here is not reachable}}
+  return bar();
 }



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


[PATCH] D115561: [Clang][OpenMP] Add the support for atomic compare in parser

2021-12-23 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/OpenMPClause.h:2234
+/// In this example directive '#pragma omp atomic' has 'compare' clause.
+class OMPCompareClause : public OMPClause {
+public:

`final`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11398-11400
+// TODO: For now we emit an error here and in emitOMPAtomicExpr we ignore
+// code gen.
+Diag(Body->getBeginLoc(), diag::err_omp_atomic_compare);

Maybe emit error in codegen instead? Without adding `err_omp_atomic_compare` 
message in include/clang/Basic/DiagnosticSemaKinds.td, just emit emit directly 
there:
```
  unsigned DiagID = CGM.getDiags().getCustomDiagID(
  DiagnosticsEngine::Error, "atomic compare is not supported for now");
  CGM.getDiags().Report(SLoc, DiagID);

```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115561

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


[PATCH] D115103: Leak Sanitizer port to Windows

2021-12-23 Thread Clemens Wasser via Phabricator via cfe-commits
clemenswasser added a comment.

@vitalybuka I have now removed all `LSAN_BASE` occurrences.
However the invocations of the compiled test executables don't seem to work 
either.
This doesn't work:
`// RUN: %env_lsan_opts=use_stacks=0:use_registers=0 not %run %t foo 2>&1 | 
FileCheck %s --check-prefix=CHECK-do`
It generates this error:

  [build] $ ":" "RUN: at line 3"
  [build] $ "env" "LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0" 
"not" 
"E:\git\llvm-project\llvm\build\ninja_debug\projects\compiler-rt\test\lsan\X86_64LsanConfig\TestCases\Output\leak_check_at_exit.cpp.tmp.exe"
 "foo"
  [build] note: command had no output on stdout or stderr
  [build] error: command failed with exit status: True

One of the problems seems to be that `%t` doesn't have a `.exe` ending on 
Windows.
I also tried changing `%t` to `%t.exe`, but that doesn't fix the problem and 
produces the same error.
I think the `not` command(?) is the part that fails?

When I run it on my own, it does work:

  PS E:\git\llvm-project> & 
'E:\git\llvm-project\llvm\build\ninja_debug\projects\compiler-rt\test\lsan\X86_64LsanConfig\TestCases\Output\leak_check_at_exit.cpp.tmp.exe'
  Test alloc: 61A0.
  
  =
  ==25768==ERROR: LeakSanitizer: detected memory leaks
  
  Direct leak of 1337 byte(s) in 1 object(s) allocated from:
  #0 0x7ff6e2f745be in __asan_wrap_malloc 
E:\git\llvm-project\compiler-rt\lib\lsan\lsan_interceptors.cpp:75
  #1 0x7ff6e2f2aade in main 
E:\git\llvm-project\compiler-rt\test\lsan\TestCases\leak_check_at_exit.cpp:13:40
  #2 0x7ff6e2f79b5b in __scrt_common_main_seh 
d:\a01\_work\6\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  #3 0x7fffde187033  (C:\WINDOWS\System32\KERNEL32.DLL+0x180017033)
  #4 0x7fffde8a2650  (C:\WINDOWS\SYSTEM32\ntdll.dll+0x180052650)
  
  SUMMARY: LeakSanitizer: 1337 byte(s) leaked in 1 allocation(s).


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

https://reviews.llvm.org/D115103

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


[PATCH] D116204: [C++20] [Coroutines] Allow promise_type to not define return_void or return_value

2021-12-23 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 396009.
ChuanqiXu marked 2 inline comments as done.
ChuanqiXu added a comment.

Address comments.


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

https://reviews.llvm.org/D116204

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/SemaCXX/coroutines-exp-namespace.cpp
  clang/test/SemaCXX/coroutines.cpp

Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -970,19 +970,34 @@
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
 
-struct bad_promise_no_return_func { // expected-note {{'bad_promise_no_return_func' defined here}}
-  coro get_return_object();
+struct promise_no_return_func {
+  coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend() noexcept;
   void unhandled_exception();
 };
-// FIXME: The PDTS currently specifies this as UB, technically forbidding a
-// diagnostic.
-coro no_return_value_or_return_void() {
-  // expected-error@-1 {{'bad_promise_no_return_func' must declare either 'return_value' or 'return_void'}}
+// [dcl.fct.def.coroutine]/p6
+// If searches for the names return_­void and return_­value in the scope of
+// the promise type each find any declarations, the program is ill-formed.
+// [Note 1: If return_­void is found, flowing off the end of a coroutine is
+// equivalent to a co_­return with no operand. Otherwise, flowing off the end
+// of a coroutine results in undefined behavior ([stmt.return.coroutine]). —
+// end note]
+//
+// So it isn't ill-formed if the promise doesn't define return_value and return_void. It is just a UB.
+coro no_return_value_or_return_void() {
   co_await a;
 }
 
+// The following two tests that it would emit correct warning if we co_return in `promise_no_return_func`.
+coro no_return_value_or_return_void_2() {
+  co_return; // expected-error {{no member named 'return_void'}}
+}
+
+coro no_return_value_or_return_void_3() {
+  co_return 43; // expected-error {{no member named 'return_value'}}
+}
+
 struct bad_await_suspend_return {
   bool await_ready();
   // expected-error@+1 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'char')}}
Index: clang/test/SemaCXX/coroutines-exp-namespace.cpp
===
--- clang/test/SemaCXX/coroutines-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutines-exp-namespace.cpp
@@ -978,19 +978,6 @@
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
 
-struct bad_promise_no_return_func { // expected-note {{'bad_promise_no_return_func' defined here}}
-  coro get_return_object();
-  suspend_always initial_suspend();
-  suspend_always final_suspend() noexcept;
-  void unhandled_exception();
-};
-// FIXME: The PDTS currently specifies this as UB, technically forbidding a
-// diagnostic.
-coro no_return_value_or_return_void() {
-  // expected-error@-1 {{'bad_promise_no_return_func' must declare either 'return_value' or 'return_void'}}
-  co_await a;
-}
-
 struct bad_await_suspend_return {
   bool await_ready();
   // expected-error@+1 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'char')}}
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -1391,9 +1391,13 @@
   assert(!IsPromiseDependentType &&
  "cannot make statement while the promise type is dependent");
 
-  // [dcl.fct.def.coroutine]/4
-  // The unqualified-ids 'return_void' and 'return_value' are looked up in
-  // the scope of class P. If both are found, the program is ill-formed.
+  // [dcl.fct.def.coroutine]/p6
+  // If searches for the names return_­void and return_­value in the scope of
+  // the promise type each find any declarations, the program is ill-formed.
+  // [Note 1: If return_­void is found, flowing off the end of a coroutine is
+  // equivalent to a co_­return with no operand. Otherwise, flowing off the end
+  // of a coroutine results in undefined behavior ([stmt.return.coroutine]). —
+  // end note]
   bool HasRVoid, HasRValue;
   LookupResult LRVoid =
   lookupMember(S, "return_void", PromiseRecordDecl, Loc, HasRVoid);
@@ -1414,18 +1418,20 @@
 << LRValue.getLookupName();
 return false;
   } else if (!HasRVoid && !HasRValue) {
-// FIXME: The PDTS currently specifies this case as UB, not ill-formed.
-// However we still diagnose this as an error since until the PDTS is fixed.
-S.Diag(FD.getLocation(),
-   diag::err_coroutine_promise_requires_return_function)
-<< PromiseRecordDecl;
-S.Diag(PromiseRecordDecl->getLocation(), diag::note_defined_here)
-<< PromiseRecordDecl;
-return 

[PATCH] D116098: [C++20] [Modules] Mark imported module as imported if not exported

2021-12-23 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan accepted this revision.
urnathan added a comment.
This revision is now accepted and ready to land.

lgtm!


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

https://reviews.llvm.org/D116098

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


[PATCH] D116098: [C++20] [Modules] Mark imported module as imported if not exported

2021-12-23 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 396007.
ChuanqiXu added a comment.

Address comments.


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

https://reviews.llvm.org/D116098

Files:
  clang/lib/Sema/SemaModule.cpp
  clang/test/Modules/module-transtive-instantiation.cpp


Index: clang/test/Modules/module-transtive-instantiation.cpp
===
--- clang/test/Modules/module-transtive-instantiation.cpp
+++ clang/test/Modules/module-transtive-instantiation.cpp
@@ -3,11 +3,9 @@
 // RUN: %clang_cc1 -std=c++20 
%S/Inputs/module-transtive-instantiation/Templ.cppm -emit-module-interface -o 
%t/Templ.pcm
 // RUN: %clang_cc1 -std=c++20 
%S/Inputs/module-transtive-instantiation/bar.cppm  -emit-module-interface 
-fprebuilt-module-path=%t -o %t/bar.pcm
 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only 
-verify
+// expected-no-diagnostics
 
 import bar;
 int foo() {
-// FIXME: It shouldn't be an error. Since the `G` is already imported in 
bar.
-return bar(); // 
expected-error@Inputs/module-transtive-instantiation/bar.cppm:5 {{definition of 
'G' must be imported from module 'Templ' before it is required}}
-   // expected-note@-1 {{in instantiation of function 
template specialization 'bar' requested here}}
-   // 
expected-note@Inputs/module-transtive-instantiation/Templ.cppm:3 {{definition 
here is not reachable}}
+  return bar();
 }
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -383,11 +383,18 @@
   if (!ModuleScopes.empty())
 Context.addModuleInitializer(ModuleScopes.back().Module, Import);
 
-  // Re-export the module if needed.
   if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {
+// Re-export the module if the imported module is exported.
+// Note that we don't need to add re-exported module to Imports field
+// since `Exports` implies the module is imported already.
 if (ExportLoc.isValid() || getEnclosingExportDecl(Import))
   getCurrentModule()->Exports.emplace_back(Mod, false);
+else
+  getCurrentModule()->Imports.insert(Mod);
   } else if (ExportLoc.isValid()) {
+// [module.interface]p1:
+// An export-declaration shall inhabit a namespace scope and appear in the
+// purview of a module interface unit.
 Diag(ExportLoc, diag::err_export_not_in_module_interface);
   }
 


Index: clang/test/Modules/module-transtive-instantiation.cpp
===
--- clang/test/Modules/module-transtive-instantiation.cpp
+++ clang/test/Modules/module-transtive-instantiation.cpp
@@ -3,11 +3,9 @@
 // RUN: %clang_cc1 -std=c++20 %S/Inputs/module-transtive-instantiation/Templ.cppm -emit-module-interface -o %t/Templ.pcm
 // RUN: %clang_cc1 -std=c++20 %S/Inputs/module-transtive-instantiation/bar.cppm  -emit-module-interface -fprebuilt-module-path=%t -o %t/bar.pcm
 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only -verify
+// expected-no-diagnostics
 
 import bar;
 int foo() {
-// FIXME: It shouldn't be an error. Since the `G` is already imported in bar.
-return bar(); // expected-error@Inputs/module-transtive-instantiation/bar.cppm:5 {{definition of 'G' must be imported from module 'Templ' before it is required}}
-   // expected-note@-1 {{in instantiation of function template specialization 'bar' requested here}}
-   // expected-note@Inputs/module-transtive-instantiation/Templ.cppm:3 {{definition here is not reachable}}
+  return bar();
 }
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -383,11 +383,18 @@
   if (!ModuleScopes.empty())
 Context.addModuleInitializer(ModuleScopes.back().Module, Import);
 
-  // Re-export the module if needed.
   if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {
+// Re-export the module if the imported module is exported.
+// Note that we don't need to add re-exported module to Imports field
+// since `Exports` implies the module is imported already.
 if (ExportLoc.isValid() || getEnclosingExportDecl(Import))
   getCurrentModule()->Exports.emplace_back(Mod, false);
+else
+  getCurrentModule()->Imports.insert(Mod);
   } else if (ExportLoc.isValid()) {
+// [module.interface]p1:
+// An export-declaration shall inhabit a namespace scope and appear in the
+// purview of a module interface unit.
 Diag(ExportLoc, diag::err_export_not_in_module_interface);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116204: [C++20] [Coroutines] Allow promise_type to not define return_void or return_value

2021-12-23 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked 2 inline comments as done.
ChuanqiXu added inline comments.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:1431-1432
+//
+// Then AnalysisBasedWarning would emit a warning about `foo()` lacks a
+// co_return statements.
+Fallthrough = S.ActOnNullStmt(PromiseRecordDecl->getLocation());

urnathan wrote:
> Your testcase doesnt show such a warning.  This seems unhelpful.  
Oh, I need emphasize in the comment that the warning is not correct. I want to 
say that if we don't set `FallThrough`, the compiler would emit incorrect 
warning. And in this revision, we set `FallThrough` so that we could avoid the 
warning. The edited test case could  address this.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:1437-1440
 // If the unqualified-id return_void is found, flowing off the end of a
 // coroutine is equivalent to a co_return with no operand. Otherwise,
 // flowing off the end of a coroutine results in undefined behavior.
 Fallthrough = S.BuildCoreturnStmt(FD.getLocation(), nullptr,

urnathan wrote:
> there's some repetition in the comments.  Perhaps a bloc comment before the 
> if-else sequence?
Yeah, would do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116204

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


[PATCH] D116204: [C++20] [Coroutines] Allow promise_type to not define return_void or return_value

2021-12-23 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added inline comments.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:1431-1432
+//
+// Then AnalysisBasedWarning would emit a warning about `foo()` lacks a
+// co_return statements.
+Fallthrough = S.ActOnNullStmt(PromiseRecordDecl->getLocation());

Your testcase doesnt show such a warning.  This seems unhelpful.  



Comment at: clang/lib/Sema/SemaCoroutine.cpp:1437-1440
 // If the unqualified-id return_void is found, flowing off the end of a
 // coroutine is equivalent to a co_return with no operand. Otherwise,
 // flowing off the end of a coroutine results in undefined behavior.
 Fallthrough = S.BuildCoreturnStmt(FD.getLocation(), nullptr,

there's some repetition in the comments.  Perhaps a bloc comment before the 
if-else sequence?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116204

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


[PATCH] D116098: [C++20] [Modules] Mark imported module as imported if not exported

2021-12-23 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D116098#3207812 , @urnathan wrote:

> as all exports are also imports, is there a reason we don;t also add the 
> exports into the import table?

I am not sure if it has an intentional reason or it is just an oversight. From 
my practice, the `Imports` field in C++20 modules is empty all the time.

> is Exports really 'ExportedImports' and 'Imports'  really 
> 'NotExportedImports'?  If that's the case, this patch is fine.

Yes. From the codes, only `export import X` would add `X` to the `exported` 
list. And if we write `import X`, the `Imports` field is empty too.


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

https://reviews.llvm.org/D116098

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


[clang] 53f0538 - [CodeGen] Use correct element type for store to sret

2021-12-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-12-23T13:02:49+01:00
New Revision: 53f0538181fd62f2a5efa9c73589f75e80454a8e

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

LOG: [CodeGen] Use correct element type for store to sret

sret is special in that it does not use the memory type
representation. Manually construct the LValue using ConvertType
instead of ConvertTypeForMem here.

This fixes matrix-lowering-opt-levels.c on s390x.

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index b202326cf757..d70f78fea6b4 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3469,12 +3469,19 @@ void CodeGenFunction::EmitFunctionEpilog(const 
CGFunctionInfo ,
 case TEK_Aggregate:
   // Do nothing; aggregrates get evaluated directly into the destination.
   break;
-case TEK_Scalar:
-  EmitStoreOfScalar(Builder.CreateLoad(ReturnValue),
-MakeNaturalAlignAddrLValue(&*AI, RetTy),
-/*isInit*/ true);
+case TEK_Scalar: {
+  LValueBaseInfo BaseInfo;
+  TBAAAccessInfo TBAAInfo;
+  CharUnits Alignment =
+  CGM.getNaturalTypeAlignment(RetTy, , );
+  Address ArgAddr(&*AI, ConvertType(RetTy), Alignment);
+  LValue ArgVal =
+  LValue::MakeAddr(ArgAddr, RetTy, getContext(), BaseInfo, TBAAInfo);
+  EmitStoreOfScalar(
+  Builder.CreateLoad(ReturnValue), ArgVal, /*isInit*/ true);
   break;
 }
+}
 break;
   }
 



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


[PATCH] D116098: [C++20] [Modules] Mark imported module as imported if not exported

2021-12-23 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added a comment.

as all exports are also imports, is there a reason we don;t also add the 
exports into the import table?  is Exports really 'ExportedImports' and 
'Imports'  really 'NotExportedImports'?  If that's the case, this patch is fine.




Comment at: clang/lib/Sema/SemaModule.cpp:386
 
   // Re-export the module if needed.
   if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {

This comment will need adjusting.


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

https://reviews.llvm.org/D116098

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


[PATCH] D116216: Prevent adding module flag - amdgpu_hostcall multiple times.

2021-12-23 Thread praveen velliengiri via Phabricator via cfe-commits
pvellien created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, kzhuravl.
pvellien requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

HIP program with printf call fails to compile with -fsanitize=address option, 
because of appending module flag - amdgpu_hostcall twice, one for printf and 
one for sanitize option. This patch fixes that issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116216

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -565,7 +565,9 @@
 "__amdgpu_device_library_preserve_asan_functions_ptr", nullptr,
 llvm::GlobalVariable::NotThreadLocal);
 addCompilerUsedGlobal(Var);
-getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+if (!getModule().getModuleFlag("amdgpu_hostcall")) {
+  getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+}
   }
 
   emitLLVMUsed();


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -565,7 +565,9 @@
 "__amdgpu_device_library_preserve_asan_functions_ptr", nullptr,
 llvm::GlobalVariable::NotThreadLocal);
 addCompilerUsedGlobal(Var);
-getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+if (!getModule().getModuleFlag("amdgpu_hostcall")) {
+  getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+}
   }
 
   emitLLVMUsed();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 09669e6 - [CodeGen] Avoid pointer element type access when creating LValue

2021-12-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-12-23T10:53:15+01:00
New Revision: 09669e6c5fa1e8db9c1091cc264640fb0377d6b6

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

LOG: [CodeGen] Avoid pointer element type access when creating LValue

This required fixing two places that were passing the pointer type
rather than the expected pointee type to the method.

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CodeGenFunction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 577252fdfeac5..34b4951a7f721 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1309,7 +1309,8 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
 const ConstantExpr *CE = cast(E);
 if (llvm::Value *Result = ConstantEmitter(*this).tryEmitConstantExpr(CE)) {
   QualType RetType = cast(CE->getSubExpr()->IgnoreImplicit())
- ->getCallReturnType(getContext());
+ ->getCallReturnType(getContext())
+ ->getPointeeType();
   return MakeNaturalAlignAddrLValue(Result, RetType);
 }
 return EmitLValue(cast(E)->getSubExpr());

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 7bd7d97da43a9..8a75f06882bc6 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -5945,7 +5945,7 @@ static llvm::Value *emitReduceInitFunction(CodeGenModule 
,
   } else {
 OrigLVal = CGF.MakeNaturalAlignAddrLValue(
 llvm::ConstantPointerNull::get(CGM.VoidPtrTy),
-CGM.getContext().VoidPtrTy);
+CGM.getContext().VoidTy);
   }
   // Emit the initializer:
   // %0 = bitcast void* %arg to *

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index b437ba01c676a..e6adec6948aff 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -188,8 +188,8 @@ LValue 
CodeGenFunction::MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T) {
   LValueBaseInfo BaseInfo;
   TBAAAccessInfo TBAAInfo;
   CharUnits Alignment = CGM.getNaturalTypeAlignment(T, , );
-  return LValue::MakeAddr(Address(V, Alignment), T, getContext(), BaseInfo,
-  TBAAInfo);
+  Address Addr(V, ConvertTypeForMem(T), Alignment);
+  return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
 }
 
 /// Given a value of type T* that may not be to a complete object,



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


[PATCH] D116189: [clang-format][NFC] Correct comment about checking merging of blocks

2021-12-23 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

We need your name and email address to be able to commit as you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116189

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


[PATCH] D116171: [OpenMP] Fix incorrect type when casting from uintptr

2021-12-23 Thread Nikita Popov 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 rG1201a0f3955b: [OpenMP] Fix incorrect type when casting from 
uintptr (authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116171

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_num_teams_codegen.cpp
  clang/test/OpenMP/target_teams_thread_limit_codegen.cpp
  clang/test/OpenMP/teams_codegen.cpp
  clang/test/OpenMP/teams_distribute_codegen.cpp
  clang/test/OpenMP/teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp