[clang] 66d9d10 - [clang][AST] Add support for ShuffleVectorExpr to ASTImporter

2021-09-27 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2021-09-27T10:17:12+02:00
New Revision: 66d9d1012b031e7f7559e8f0e03b9e7bfb6c20a1

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

LOG: [clang][AST] Add support for ShuffleVectorExpr to ASTImporter

Addresses https://bugs.llvm.org/show_bug.cgi?id=51902

Reviewed By: shafik, martong

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 4e4ca7a207f5..6c624b2bf7e7 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -583,6 +583,7 @@ namespace clang {
 ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
 ExpectedStmt VisitChooseExpr(ChooseExpr *E);
+ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
@@ -6730,6 +6731,24 @@ ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr 
*E) {
  ToRParenLoc, CondIsTrue);
 }
 
+ExpectedStmt ASTNodeImporter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
+  Error Err = Error::success();
+  auto ToRParenLoc = importChecked(Err, E->getRParenLoc());
+  auto ToBeginLoc = importChecked(Err, E->getBeginLoc());
+  auto ToType = importChecked(Err, E->getType());
+  const unsigned NumSubExprs = E->getNumSubExprs();
+
+  llvm::SmallVector ToSubExprs;
+  llvm::ArrayRef FromSubExprs(E->getSubExprs(), NumSubExprs);
+  ToSubExprs.resize(NumSubExprs);
+
+  if ((Err = ImportContainerChecked(FromSubExprs, ToSubExprs)))
+return std::move(Err);
+
+  return new (Importer.getToContext()) ShuffleVectorExpr(
+  Importer.getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
+}
+
 ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   ExpectedType TypeOrErr = import(E->getType());
   if (!TypeOrErr)

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index f14232257bbb..66ec873ffb89 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -290,6 +290,25 @@ TEST_P(ImportExpr, ImportChooseExpr) {
  functionDecl(hasDescendant(chooseExpr(;
 }
 
+const internal::VariadicDynCastAllOfMatcher
+shuffleVectorExpr;
+
+TEST_P(ImportExpr, ImportShuffleVectorExpr) {
+  MatchVerifier Verifier;
+  constexpr auto Code = R"code(
+typedef double vector4double __attribute__((__vector_size__(32)));
+vector4double declToImport(vector4double a, vector4double b) {
+  return __builtin_shufflevector(a, b, 0, 1, 2, 3);
+}
+  )code";
+  const auto Pattern = functionDecl(hasDescendant(shuffleVectorExpr(
+  allOf(has(declRefExpr(to(parmVarDecl(hasName("a"),
+has(declRefExpr(to(parmVarDecl(hasName("b"),
+has(integerLiteral(equals(0))), has(integerLiteral(equals(1))),
+has(integerLiteral(equals(2))), has(integerLiteral(equals(3)));
+  testImport(Code, Lang_C99, "", Lang_C99, Verifier, Pattern);
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport("void declToImport() { (void)__null; }", Lang_CXX03, "",



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


[PATCH] D110052: [clang][AST] Add support for ShuffleVectorExpr to ASTImporter

2021-09-27 Thread Balázs Benics 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 rG66d9d1012b03: [clang][AST] Add support for ShuffleVectorExpr 
to ASTImporter (authored by steakhal).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110052

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -290,6 +290,25 @@
  functionDecl(hasDescendant(chooseExpr(;
 }
 
+const internal::VariadicDynCastAllOfMatcher
+shuffleVectorExpr;
+
+TEST_P(ImportExpr, ImportShuffleVectorExpr) {
+  MatchVerifier Verifier;
+  constexpr auto Code = R"code(
+typedef double vector4double __attribute__((__vector_size__(32)));
+vector4double declToImport(vector4double a, vector4double b) {
+  return __builtin_shufflevector(a, b, 0, 1, 2, 3);
+}
+  )code";
+  const auto Pattern = functionDecl(hasDescendant(shuffleVectorExpr(
+  allOf(has(declRefExpr(to(parmVarDecl(hasName("a"),
+has(declRefExpr(to(parmVarDecl(hasName("b"),
+has(integerLiteral(equals(0))), has(integerLiteral(equals(1))),
+has(integerLiteral(equals(2))), has(integerLiteral(equals(3)));
+  testImport(Code, Lang_C99, "", Lang_C99, Verifier, Pattern);
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport("void declToImport() { (void)__null; }", Lang_CXX03, "",
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -583,6 +583,7 @@
 ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
 ExpectedStmt VisitChooseExpr(ChooseExpr *E);
+ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
@@ -6730,6 +6731,24 @@
  ToRParenLoc, CondIsTrue);
 }
 
+ExpectedStmt ASTNodeImporter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
+  Error Err = Error::success();
+  auto ToRParenLoc = importChecked(Err, E->getRParenLoc());
+  auto ToBeginLoc = importChecked(Err, E->getBeginLoc());
+  auto ToType = importChecked(Err, E->getType());
+  const unsigned NumSubExprs = E->getNumSubExprs();
+
+  llvm::SmallVector ToSubExprs;
+  llvm::ArrayRef FromSubExprs(E->getSubExprs(), NumSubExprs);
+  ToSubExprs.resize(NumSubExprs);
+
+  if ((Err = ImportContainerChecked(FromSubExprs, ToSubExprs)))
+return std::move(Err);
+
+  return new (Importer.getToContext()) ShuffleVectorExpr(
+  Importer.getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
+}
+
 ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   ExpectedType TypeOrErr = import(E->getType());
   if (!TypeOrErr)


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -290,6 +290,25 @@
  functionDecl(hasDescendant(chooseExpr(;
 }
 
+const internal::VariadicDynCastAllOfMatcher
+shuffleVectorExpr;
+
+TEST_P(ImportExpr, ImportShuffleVectorExpr) {
+  MatchVerifier Verifier;
+  constexpr auto Code = R"code(
+typedef double vector4double __attribute__((__vector_size__(32)));
+vector4double declToImport(vector4double a, vector4double b) {
+  return __builtin_shufflevector(a, b, 0, 1, 2, 3);
+}
+  )code";
+  const auto Pattern = functionDecl(hasDescendant(shuffleVectorExpr(
+  allOf(has(declRefExpr(to(parmVarDecl(hasName("a"),
+has(declRefExpr(to(parmVarDecl(hasName("b"),
+has(integerLiteral(equals(0))), has(integerLiteral(equals(1))),
+has(integerLiteral(equals(2))), has(integerLiteral(equals(3)));
+  testImport(Code, Lang_C99, "", Lang_C99, Verifier, Pattern);
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport("void declToImport() { (void)__null; }", Lang_CXX03, "",
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -583,6 +583,7 @@
 ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
 ExpectedStmt VisitChooseExpr(ChooseExpr *E);
+ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);

[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-09-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Great work!




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1591-1595
   template 
   LLVM_NODISCARD static ProgramStateRef
-  assign(ProgramStateRef State, SValBuilder &Builder, RangeSet::Factory &F,
- ClassOrSymbol CoS, RangeSet NewConstraint) {
+  assign(ProgramStateRef State, RangeConstraintManager *RCM,
+ SValBuilder &Builder, RangeSet::Factory &F, ClassOrSymbol CoS,
+ RangeSet NewConstraint) {

Hm, why don't we acquire `RCM`, `Builder`, `F` in the constructor? I'm 
expecting all of them to remain the same for all the `assign()` calls.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1603-1604
 
+  template 
+  bool handleRem(const SymT *Sym, RangeSet Constraint) {
+// a % b != 0 implies that a != 0.

Why is this not a `const` member function?



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1605
+  bool handleRem(const SymT *Sym, RangeSet Constraint) {
+// a % b != 0 implies that a != 0.
+if (Sym->getOpcode() != BO_Rem)

I think you should also implement `a % b == 0 implies that a == 0`.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1628
 private:
-  ConstraintAssignor(ProgramStateRef State, SValBuilder &Builder,
- RangeSet::Factory &F)
-  : State(State), Builder(Builder), RangeFactory(F) {}
+  ConstraintAssignor(ProgramStateRef State, RangeConstraintManager *RCM,
+ SValBuilder &Builder, RangeSet::Factory &F)

IMO we should pass a reference here, just like the rest of the parameters.



Comment at: clang/test/Analysis/constraint-assignor.c:18
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}

It's still mindboggling that we need to do this. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110357

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


[PATCH] D110387: [Analyzer][NFC] Move RangeConstraintManager's def before ConstraintAssignor's def

2021-09-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

It seems clean to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110387

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


[PATCH] D110258: [AArch64] Always add -tune-cpu argument to -cc1 driver

2021-09-27 Thread David Sherwood via Phabricator via cfe-commits
david-arm updated this revision to Diff 375169.
david-arm retitled this revision from "[AArch64][Clang] Always add -tune-cpu 
argument to -cc1 driver" to "[AArch64] Always add -tune-cpu argument to -cc1 
driver".
david-arm edited the summary of this revision.
david-arm added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

- Updated the patch to use mtune properly and set the scheduling model 
accordingly


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

https://reviews.llvm.org/D110258

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aarch64-mtune.c
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/unittests/Target/AArch64/InstSizes.cpp
  llvm/unittests/Target/AArch64/MatrixRegisterAliasing.cpp

Index: llvm/unittests/Target/AArch64/MatrixRegisterAliasing.cpp
===
--- llvm/unittests/Target/AArch64/MatrixRegisterAliasing.cpp
+++ llvm/unittests/Target/AArch64/MatrixRegisterAliasing.cpp
@@ -26,6 +26,7 @@
 
 std::unique_ptr createInstrInfo(TargetMachine *TM) {
   AArch64Subtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()),
+  std::string(TM->getTargetCPU()),
   std::string(TM->getTargetFeatureString()), *TM,
   /* isLittle */ false);
   return std::make_unique(ST);
Index: llvm/unittests/Target/AArch64/InstSizes.cpp
===
--- llvm/unittests/Target/AArch64/InstSizes.cpp
+++ llvm/unittests/Target/AArch64/InstSizes.cpp
@@ -29,6 +29,7 @@
 
 std::unique_ptr createInstrInfo(TargetMachine *TM) {
   AArch64Subtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()),
+  std::string(TM->getTargetCPU()),
   std::string(TM->getTargetFeatureString()), *TM,
   /* isLittle */ false);
   return std::make_unique(ST);
Index: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
===
--- llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -354,10 +354,13 @@
 const AArch64Subtarget *
 AArch64TargetMachine::getSubtargetImpl(const Function &F) const {
   Attribute CPUAttr = F.getFnAttribute("target-cpu");
+  Attribute TuneAttr = F.getFnAttribute("tune-cpu");
   Attribute FSAttr = F.getFnAttribute("target-features");
 
   std::string CPU =
   CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU;
+  std::string TuneCPU =
+  TuneAttr.isValid() ? TuneAttr.getValueAsString().str() : CPU;
   std::string FS =
   FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS;
 
@@ -398,6 +401,7 @@
   Key += "SVEMax";
   Key += std::to_string(MaxSVEVectorSize);
   Key += CPU;
+  Key += TuneCPU;
   Key += FS;
 
   auto &I = SubtargetMap[Key];
@@ -406,7 +410,7 @@
 // creation will depend on the TM and the code generation flags on the
 // function that reside in TargetOptions.
 resetTargetOptions(F);
-I = std::make_unique(TargetTriple, CPU, FS, *this,
+I = std::make_unique(TargetTriple, CPU, TuneCPU, FS, *this,
isLittle, MinSVEVectorSize,
MaxSVEVectorSize);
   }
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -293,7 +293,8 @@
   /// passed in feature string so that we can use initializer lists for
   /// subtarget initialization.
   AArch64Subtarget &initializeSubtargetDependencies(StringRef FS,
-StringRef CPUString);
+StringRef CPUString,
+StringRef TuneCPUString);
 
   /// Initialize properties based on the selected processor family.
   void initializeProperties();
@@ -301,7 +302,7 @@
 public:
   /// This constructor initializes the data members to match that
   /// of the specified triple.
-  AArch64Subtarget(const Triple &TT, const std::string &CPU,
+  AArch64Subtarget(const Triple &TT, const std::string &CPU, const std::string &TuneCPU,
const std::string &FS, const TargetMachine &TM,
bool LittleEndian,
unsigned MinSVEVectorSizeInBitsOverride = 0,
Index: llvm/lib/Target/AArch64/AArch64Subtarget.cpp
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -52,13 +52,17 @@
 
 AArch64Subtarget &
 AArch64Subtarget::initializeSubtargetDependencies(StringRef FS,
-   

[PATCH] D110525: [docs] fix docs for bugprone-virtual-near-miss & performance-type-promotion-in-math-fn

2021-09-27 Thread M B via Phabricator via cfe-commits
bakinovsky-m created this revision.
bakinovsky-m added a reviewer: aaron.ballman.
bakinovsky-m created this object with edit policy "Administrators".
bakinovsky-m added a project: clang-tools-extra.
bakinovsky-m requested review of this revision.
Herald added a subscriber: cfe-commits.

bugprone-virtual-near-miss & performance-type-promotion-in-math-fn


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110525

Files:
  clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst


Index: 
clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
@@ -6,7 +6,7 @@
 Finds calls to C math library functions (from ``math.h`` or, in C++, ``cmath``)
 with implicit ``float`` to ``double`` promotions.
 
-For example, warns on ``::sin(0.f)``, because this funciton's parameter is a
+For example, warns on ``::sin(0.f)``, because this function's parameter is a
 double. You probably meant to call ``std::sin(0.f)`` (in C++), or ``sinf(0.f)``
 (in C).
 
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
@@ -15,6 +15,6 @@
   };
 
   struct Derived : Base {
-virtual funk();
+virtual void funk();
 // warning: 'Derived::funk' has a similar name and the same signature as 
virtual method 'Base::func'; did you mean to override it?
   };


Index: clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
+++ clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
@@ -6,7 +6,7 @@
 Finds calls to C math library functions (from ``math.h`` or, in C++, ``cmath``)
 with implicit ``float`` to ``double`` promotions.
 
-For example, warns on ``::sin(0.f)``, because this funciton's parameter is a
+For example, warns on ``::sin(0.f)``, because this function's parameter is a
 double. You probably meant to call ``std::sin(0.f)`` (in C++), or ``sinf(0.f)``
 (in C).
 
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
@@ -15,6 +15,6 @@
   };
 
   struct Derived : Base {
-virtual funk();
+virtual void funk();
 // warning: 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it?
   };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110258: [AArch64] Always add -tune-cpu argument to -cc1 driver

2021-09-27 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Sounds great.  Glad to see us taking this route.

Unfortunately I think we do need to split the subtargetfeatures up into arch 
flags and tune flags. Same for the details in 
AArch64Subtarget::initializeProperties. It is hopefully a fairly mechanical 
process, but they are an important part of tuning and without them -mtune is 
only a half-working option.

Are you happy to give that a go too?




Comment at: llvm/lib/Target/AArch64/AArch64Subtarget.h:305
   /// of the specified triple.
-  AArch64Subtarget(const Triple &TT, const std::string &CPU,
+  AArch64Subtarget(const Triple &TT, const std::string &CPU, const std::string 
&TuneCPU,
const std::string &FS, const TargetMachine &TM,

Needs reformatting.


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

https://reviews.llvm.org/D110258

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


[PATCH] D110142: [clang][Driver] Correct runtime path for Arm hard float targets

2021-09-27 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

> I'd hope that it works this way (armv8l-*) :)

Cool I'm going to work with that goal in mind then.

I've turned it off by default for 32 bit Arm linux until it's made compatible: 
https://reviews.llvm.org/rG3c65d54ec3d2


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110142

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


[PATCH] D110258: [AArch64] Always add -tune-cpu argument to -cc1 driver

2021-09-27 Thread David Sherwood via Phabricator via cfe-commits
david-arm added a comment.

In D110258#3023818 , @dmgreen wrote:

> Sounds great.  Glad to see us taking this route.
>
> Unfortunately I think we do need to split the subtargetfeatures up into arch 
> flags and tune flags. Same for the details in 
> AArch64Subtarget::initializeProperties. It is hopefully a fairly mechanical 
> process, but they are an important part of tuning and without them -mtune is 
> only a half-working option.
>
> Are you happy to give that a go too?

Hi @dmgreen, sure I can try. The only problem is that I don't really understand 
what to do here. I used the X86Subtarget as a guidance and the TuneCPU flag 
only seems to be used for scheduling and nothing else. It's not obvious to me 
how the TuneCPU flag decides the features as I thought it was purely for 
scheduling?


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

https://reviews.llvm.org/D110258

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


[PATCH] D110432: [clang-format][docs] mark new clang-format configuration options based on which version they would GA

2021-09-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 375177.
MyDeveloperDay marked 2 inline comments as done.
MyDeveloperDay added a comment.

Mark all options with their version, 
Move the \version into the comment
Warning if we add new options without a version

I think this is a fairly good representation (there could be a couple that are 
incorrectly labelled as a later version (if they have been modified), I had to 
kind of pull the "commit" from git blame then use the sha to determine the 
first branch. (with git name-rev ), Its more likely to have said it was 
added in a later release, (especially if the type of the option had changed), 
but perhaps lets start here and if we see a few that are incorrectly labelled 
we can work out way back on those, but it was hard to do this for the 130+ 
options


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

https://reviews.llvm.org/D110432

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/include/clang/Tooling/Inclusions/IncludeStyle.h

Index: clang/include/clang/Tooling/Inclusions/IncludeStyle.h
===
--- clang/include/clang/Tooling/Inclusions/IncludeStyle.h
+++ clang/include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -50,6 +50,7 @@
 
   /// Dependent on the value, multiple ``#include`` blocks can be sorted
   /// as one and divided based on category.
+  /// \version 7
   IncludeBlocksStyle IncludeBlocks;
 
   /// See documentation of ``IncludeCategories``.
@@ -113,6 +114,7 @@
   ///   Priority:1
   ///   SortPriority:0
   /// \endcode
+  /// \version 7
   std::vector IncludeCategories;
 
   /// Specify a regular expression of suffixes that are allowed in the
@@ -126,6 +128,7 @@
   ///
   /// For example, if configured to "(_test)?$", then a header a.h would be seen
   /// as the "main" include in both a.cc and a_test.cc.
+  /// \version 7
   std::string IncludeIsMainRegex;
 
   /// Specify a regular expression for files being formatted
@@ -146,6 +149,7 @@
   /// also being respected in later phase). Without this option set,
   /// ``ClassImpl.hpp`` would not have the main include file put on top
   /// before any other include.
+  /// \version 7
   std::string IncludeIsMainSourceRegex;
 };
 
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -63,6 +63,7 @@
   bool InheritsParentConfig;
 
   /// The extra indent or outdent of access modifiers, e.g. ``public:``.
+  /// \version 3.3
   int AccessModifierOffset;
 
   /// Different styles for aligning after open brackets.
@@ -92,6 +93,7 @@
   ///
   /// This applies to round brackets (parentheses), angle brackets and square
   /// brackets.
+  /// \version 3.8
   BracketAlignmentStyle AlignAfterOpenBracket;
 
   /// Different style for aligning array initializers.
@@ -121,6 +123,7 @@
   };
   /// if not ``None``, when using initialization for an array of structs
   /// aligns the fields into columns.
+  /// \version 13
   ArrayInitializerAlignmentStyle AlignArrayOfStructures;
 
   /// Styles for alignment of consecutive tokens. Tokens can be assignment signs
@@ -205,6 +208,7 @@
   ///  /* some comment */
   ///  #define bar(y, z)(y + z)
   ///\endcode
+  /// \version 13
   AlignConsecutiveStyle AlignConsecutiveMacros;
 
   /// Style of aligning consecutive assignments.
@@ -273,6 +277,7 @@
   ///  /* A comment. */
   ///  double e = 4;
   ///\endcode
+  /// \version 13
   AlignConsecutiveStyle AlignConsecutiveAssignments;
 
   /// Style of aligning consecutive bit field.
@@ -342,6 +347,7 @@
   ///  /* A comment. */
   ///  int ee   : 3;
   ///\endcode
+  /// \version 13
   AlignConsecutiveStyle AlignConsecutiveBitFields;
 
   /// Style of aligning consecutive declarations.
@@ -411,6 +417,7 @@
   ///  /* A comment. */
   ///  boolc = false;
   ///\endcode
+  /// \version 13
   AlignConsecutiveStyle AlignConsecutiveDeclarations;
 
   /// Different styles for aligning escaped newlines.
@@ -445,6 +452,7 @@
   };
 
   /// Options for aligning backslashes in escaped newlines.
+  /// \version 5
   EscapedNewlineAlignmentStyle AlignEscapedNewlines;
 
   /// Different styles for aligning operands.
@@ -483,6 +491,7 @@
 
   /// If ``true``, horizontally align operands of binary and ternary
   /// expressions.
+  /// \version 12
   OperandAlignmentStyle AlignOperands;
 
   /// If ``true``, aligns trailing comments.
@@ -491,6 +500,7 @@
   ///   int a; // My comment a  vs. int a; // My comment a
   ///   int b = 2; // comment  bint b = 2; // comment about b
   /// \endcode
+  /// \version 3.7
   bool AlignTrailingComments;
 
   /// \brief If a function call or braced initializer list doesn't fit on a
@@ -507,10 +51

[PATCH] D110258: [AArch64] Always add -tune-cpu argument to -cc1 driver

2021-09-27 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

I think ProcessorModel is

  class ProcessorModel f,
   list tunef = []>

So we are always currently passing tunef  = [] from AArch64 and passing all 
features through f. They need to be split out and then hopefully the call to 
ParseSubtargetFeatures will use CPU and TuneCPU appropriately.


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

https://reviews.llvm.org/D110258

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


[PATCH] D110432: [clang-format][docs] mark new clang-format configuration options based on which version they would GA

2021-09-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/tools/dump_format_style.py:237
+field_type, field_name, trailcomment, version = 
re.match(r'([<>:\w(,\s)]+)\s+(\w+)\s*(\/\*version=([0-9.]*)\*\/)*;',
   line).groups()
+option = Option(str(field_name), str(field_type), comment, version)

HazardyKnusperkeks wrote:
> I think this was aligned to the opening parenthesis of match(.
> 
> If we only had an automatic formatting tool. 😃 
I'm going to run this tool through pylint after this commit, as its currently 
very bad! but I don't want to do this in one go

```
* Module dump_format_style
dump_format_style.py:20:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:21:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:24:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:25:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:26:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:29:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:30:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:31:0: W0311: Bad indentation. Found 6 spaces, expected 12 
(bad-indentation)
dump_format_style.py:34:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:36:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:37:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:38:0: W0311: Bad indentation. Found 6 spaces, expected 12 
(bad-indentation)
dump_format_style.py:39:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:40:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:41:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:42:0: W0311: Bad indentation. Found 6 spaces, expected 12 
(bad-indentation)
dump_format_style.py:43:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:44:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:47:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:48:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:49:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:50:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:51:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:52:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:53:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:54:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:55:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:56:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:57:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:61:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:62:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:63:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:64:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:65:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:66:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:67:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:68:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:70:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:71:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:72:0: W0311: Bad indentation. Found 4 spaces, expected 8 
(bad-indentation)
dump_format_style.py:74:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:77:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:78:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:79:0: W0311: Bad indentation. Found 2 spaces, expected 4 
(bad-indentation)
dump_format_style.py:80

[libunwind] 77aa9ca - [libunwind] Support cfi_undefined and cfi_register for float registers.

2021-09-27 Thread Daniel Kiss via cfe-commits

Author: Daniel Kiss
Date: 2021-09-27T12:04:02+02:00
New Revision: 77aa9ca92ae4732f5f92e580e14bb4d757f6b364

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

LOG:  [libunwind] Support cfi_undefined and cfi_register for float registers.

During a backtrace the `.cfi_undefined` for a float register causes an assert 
in libunwind.

Reviewed By: MaskRay

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

Added: 
libunwind/test/floatregister.pass.cpp

Modified: 
libunwind/src/DwarfInstructions.hpp

Removed: 




diff  --git a/libunwind/src/DwarfInstructions.hpp 
b/libunwind/src/DwarfInstructions.hpp
index 60b242e0c143..53baf6a148f3 100644
--- a/libunwind/src/DwarfInstructions.hpp
+++ b/libunwind/src/DwarfInstructions.hpp
@@ -115,12 +115,13 @@ double DwarfInstructions::getSavedFloatRegister(
 return addressSpace.getDouble(
 evaluateExpression((pint_t)savedReg.value, addressSpace,
 registers, cfa));
-
+  case CFI_Parser::kRegisterInRegister:
+return registers.getFloatRegister((int)savedReg.value);
+  case CFI_Parser::kRegisterUndefined:
+return 0.0;
   case CFI_Parser::kRegisterIsExpression:
   case CFI_Parser::kRegisterUnused:
-  case CFI_Parser::kRegisterUndefined:
   case CFI_Parser::kRegisterOffsetFromCFA:
-  case CFI_Parser::kRegisterInRegister:
 // FIX ME
 break;
   }

diff  --git a/libunwind/test/floatregister.pass.cpp 
b/libunwind/test/floatregister.pass.cpp
new file mode 100644
index ..64107e6d490b
--- /dev/null
+++ b/libunwind/test/floatregister.pass.cpp
@@ -0,0 +1,51 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// REQUIRES: linux && target={{aarch64-.+}}
+
+// Basic test for float registers number are accepted.
+
+#include 
+#include 
+#include 
+#include 
+
+_Unwind_Reason_Code frame_handler(struct _Unwind_Context *ctx, void *arg) {
+  (void)arg;
+  Dl_info info = {0, 0, 0, 0};
+
+  // Unwind util the main is reached, above frames depend on the platform and
+  // architecture.
+  if (dladdr(reinterpret_cast(_Unwind_GetIP(ctx)), &info) &&
+  info.dli_sname && !strcmp("main", info.dli_sname))
+_Exit(0);
+
+  return _URC_NO_REASON;
+}
+
+__attribute__((noinline)) void foo() {
+  // Provide some CFI directives that instructs the unwinder where given
+  // float register is.
+#if defined(__aarch64__)
+  // DWARF register number for V0-V31 registers are 64-95.
+  // Previous value of V0 is saved at offset 0 from CFA.
+  asm volatile(".cfi_offset 64, 0");
+  // From now on the previous value of register can't be restored anymore.
+  asm volatile(".cfi_undefined 65");
+  asm volatile(".cfi_undefined 95");
+  // Previous value of V2 is in V30.
+  asm volatile(".cfi_register  66, 94");
+#endif
+  _Unwind_Backtrace(frame_handler, NULL);
+}
+
+int main() {
+  foo();
+  return -2;
+}



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


[PATCH] D110432: [clang-format][docs] mark new clang-format configuration options based on which version they would GA

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



Comment at: clang/docs/tools/dump_format_style.py:218
+  if line.startswith(r'/// \version'):
+match = re.match(r'/// \\version\s*(?P[0-9.]+)*',line)
+if match:

This needs to be escaped, doesn't it?



Comment at: clang/docs/tools/dump_format_style.py:218
+  if line.startswith(r'/// \version'):
+match = re.match(r'/// \\version\s*(?P[0-9.]+)*',line)
+if match:

HazardyKnusperkeks wrote:
> This needs to be escaped, doesn't it?
This shouldn't be needed, or?



Comment at: clang/include/clang/Format/Format.h:766
   /// If ``true``, ``while (true) continue;`` can be put on a single
-  /// line.
+  /// line
+  /// \version 3.7

The dot should be kept. Also somehow the output has the dot, but also an A 
afterwards.



Comment at: clang/include/clang/Format/Format.h:2608
   // clang-format off
-  /// Whether to wrap JavaScript import/export statements.
-  /// \code{.js}
-  ///true:
-  ///import {
-  ///VeryLongImportsAreAnnoying,
-  ///VeryLongImportsAreAnnoying,
-  ///VeryLongImportsAreAnnoying,
-  ///} from 'some/module.js'
-  ///
-  ///false:
-  ///import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, 
VeryLongImportsAreAnnoying,} from "some/module.js"
-  /// \endcode
-  bool JavaScriptWrapImports;
+ /// Whether to wrap JavaScript import/export statements.
+ /// \code{.js}

A Space is missing in that block.



Comment at: clang/include/clang/Format/Format.h:3043
+  /// \endcode
+  /// \version 14
   bool ReflowComments;

Some whitespace changes here.

And Version 14 is definitely wrong. It was already in 4 and not in 3.8, don't 
know how many version were in between.



Comment at: clang/include/clang/Format/Format.h:3106
   /// sensitive fashion.
+  /// \version 14
   SortIncludesOptions SortIncludes;

Was also already in 4, but just as bool.


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

https://reviews.llvm.org/D110432

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


[PATCH] D110528: [clang][ASTImporter] Add import of thread safety attributes.

2021-09-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, whisperity, martong, teemperor, gamesh411, 
Szelethus, dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Attributes of "C/C++ Thread safety attributes" section in Attr.td
are added to ASTImporter. The not added attributes from this section
do not need special import handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110528

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6545,6 +6545,31 @@
   EXPECT_EQ(FromAttr->getType()->getName(), ToAttr->getType()->getName());
 }
 
+TEST_P(ImportAttributes, ImportGuardedVar) {
+  GuardedVarAttr *FromAttr, *ToAttr;
+  importAttr("int test __attribute__((guarded_var));", FromAttr,
+  ToAttr);
+}
+
+TEST_P(ImportAttributes, ImportPtGuardedVar) {
+  PtGuardedVarAttr *FromAttr, *ToAttr;
+  importAttr("int *test __attribute__((pt_guarded_var));", FromAttr,
+  ToAttr);
+}
+
+TEST_P(ImportAttributes, ImportScopedLockable) {
+  ScopedLockableAttr *FromAttr, *ToAttr;
+  importAttr("struct __attribute__((scoped_lockable)) test {};",
+FromAttr, ToAttr);
+}
+
+TEST_P(ImportAttributes, ImportCapability) {
+  CapabilityAttr *FromAttr, *ToAttr;
+  importAttr(
+  "struct __attribute__((capability(\"cap\"))) test {};", FromAttr, ToAttr);
+  EXPECT_EQ(FromAttr->getName(), ToAttr->getName());
+}
+
 TEST_P(ImportAttributes, ImportAssertCapability) {
   AssertCapabilityAttr *FromAttr, *ToAttr;
   importAttr(
@@ -6553,6 +6578,147 @@
   checkImportVariadicArg(FromAttr->args(), ToAttr->args());
 }
 
+TEST_P(ImportAttributes, ImportAcquireCapability) {
+  AcquireCapabilityAttr *FromAttr, *ToAttr;
+  importAttr(
+  "void test(int A1, int A2) __attribute__((acquire_capability(A1, A2)));",
+  FromAttr, ToAttr);
+  checkImportVariadicArg(FromAttr->args(), ToAttr->args());
+}
+
+TEST_P(ImportAttributes, ImportTryAcquireCapability) {
+  TryAcquireCapabilityAttr *FromAttr, *ToAttr;
+  importAttr(
+  "void test(int A1, int A2) __attribute__((try_acquire_capability(1, A1, "
+  "A2)));",
+  FromAttr, ToAttr);
+  checkImported(FromAttr->getSuccessValue(), ToAttr->getSuccessValue());
+  checkImportVariadicArg(FromAttr->args(), ToAttr->args());
+}
+
+TEST_P(ImportAttributes, ImportReleaseCapability) {
+  ReleaseCapabilityAttr *FromAttr, *ToAttr;
+  importAttr(
+  "void test(int A1, int A2) __attribute__((release_capability(A1, A2)));",
+  FromAttr, ToAttr);
+  checkImportVariadicArg(FromAttr->args(), ToAttr->args());
+}
+
+TEST_P(ImportAttributes, ImportRequiresCapability) {
+  RequiresCapabilityAttr *FromAttr, *ToAttr;
+  importAttr(
+  "void test(int A1, int A2) __attribute__((requires_capability(A1, A2)));",
+  FromAttr, ToAttr);
+  checkImportVariadicArg(FromAttr->args(), ToAttr->args());
+}
+
+TEST_P(ImportAttributes, ImportNoThreadSafetyAnalysis) {
+  NoThreadSafetyAnalysisAttr *FromAttr, *ToAttr;
+  importAttr(
+  "void test() __attribute__((no_thread_safety_analysis));", FromAttr,
+  ToAttr);
+}
+
+TEST_P(ImportAttributes, ImportGuardedBy) {
+  GuardedByAttr *FromAttr, *ToAttr;
+  importAttr(
+  R"(
+  int G;
+  int test __attribute__((guarded_by(G)));
+  )",
+  FromAttr, ToAttr);
+  checkImported(FromAttr->getArg(), ToAttr->getArg());
+}
+
+TEST_P(ImportAttributes, ImportPtGuardedBy) {
+  PtGuardedByAttr *FromAttr, *ToAttr;
+  importAttr(
+  R"(
+  int G;
+  int *test __attribute__((pt_guarded_by(G)));
+  )",
+  FromAttr, ToAttr);
+  checkImported(FromAttr->getArg(), ToAttr->getArg());
+}
+
+TEST_P(ImportAttributes, ImportAcquiredAfter) {
+  AcquiredAfterAttr *FromAttr, *ToAttr;
+  importAttr(
+  R"(
+  struct __attribute__((lockable)) L {};
+  L A1;
+  L A2;
+  L test __attribute__((acquired_after(A1, A2)));
+  )",
+  FromAttr, ToAttr);
+  checkImportVariadicArg(FromAttr->args(), ToAttr->args());
+}
+
+TEST_P(ImportAttributes, ImportAcquiredBefore) {
+  AcquiredBeforeAttr *FromAttr, *ToAttr;
+  importAttr(
+  R"(
+  struct __attribute__((lockable)) L {};
+  L A1;
+  L A2;
+  L test __attribute__((acquired_before(A1, A2)));
+  )",
+  FromAttr, ToAttr);
+  checkImportVariadicArg(FromAttr->args(), ToAttr->args());
+}
+
+TEST_P(ImportAttributes, ImportAssertExclusiveLock) {
+  AssertExclusiveLockAttr *FromAttr, *ToAttr;
+  importAttr("void test(int A1, int A2) "
+   "__attribute__((assert_exclusive_lock(A1, A2)));",
+   FromAttr, ToAttr);
+  checkImportVariadicArg(FromAttr->arg

[PATCH] D106876: Remove non-affecting module maps from PCM files.

2021-09-27 Thread Ilya Kuteev via Phabricator via cfe-commits
ilyakuteev updated this revision to Diff 375187.

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

https://reviews.llvm.org/D106876

Files:
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
  clang/test/Modules/add-remove-irrelevant-mobile-map.m
  clang/test/SemaCXX/Inputs/compare.modulemap
  clang/test/SemaCXX/compare-modules-cxx2a.cpp

Index: clang/test/SemaCXX/compare-modules-cxx2a.cpp
===
--- clang/test/SemaCXX/compare-modules-cxx2a.cpp
+++ clang/test/SemaCXX/compare-modules-cxx2a.cpp
@@ -1,15 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -I%S/Inputs %s -fno-modules-error-recovery
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
 
-#pragma clang module build compare
-module compare {
-  explicit module cmp {}
-  explicit module other {}
-}
-#pragma clang module contents
-#pragma clang module begin compare.cmp
-#include "std-compare.h"
-#pragma clang module end
-#pragma clang module endbuild
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -fmodules-cache-path=%t.mcp -I%S/Inputs %s -fno-modules-error-recovery -fmodule-map-file=%S/Inputs/compare.modulemap
 
 struct CC { CC(...); };
 
@@ -24,10 +16,10 @@
 
 // expected-note@std-compare.h:* 2+{{not reachable}}
 
-void b() { void(0 <=> 0); } // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+void b() { void(0 <=> 0); } // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 
 struct B {
-  CC operator<=>(const B&) const = default; // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+  CC operator<=>(const B&) const = default; // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 };
 auto vb = B() <=> B(); // expected-note {{required here}}
 
Index: clang/test/SemaCXX/Inputs/compare.modulemap
===
--- /dev/null
+++ clang/test/SemaCXX/Inputs/compare.modulemap
@@ -0,0 +1,6 @@
+module compare {
+  explicit module cmp {
+header "std-compare.h"
+  }
+  explicit module other {}
+}
Index: clang/test/Modules/add-remove-irrelevant-mobile-map.m
===
--- /dev/null
+++ clang/test/Modules/add-remove-irrelevant-mobile-map.m
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
+
+// Build without b.modulemap
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap %s -verify
+// RUN: cp %t.mcp/a.pcm %t/a.pcm
+
+// Build with b.modulemap
+// RUN: rm -rf %t.mcp
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap %s -verify
+// RUN: not diff %t.mcp/a.pcm %t/a.pcm
+
+// expected-no-diagnostics
+
+@import a;
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
@@ -0,0 +1 @@
+module b { }
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
@@ -0,0 +1 @@
+module a { }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -149,6 +149,59 @@
 
 namespace {
 
+std::set GetAllModuleMaps(const HeaderSearch &HS,
+ Module *RootModule) {
+  std::set ModuleMaps{};
+  std::set ProcessedModules;
+  SmallVector ModulesToProcess{RootModule};
+
+  SmallVector FilesByUID;
+  HS.getFileMgr().GetUniqueIDMapping(FilesByUID);
+
+  if (FilesByUID.size() > HS.header_file_size())
+FilesByUID.resize(HS.header_file_size());
+
+  for (unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
+const FileEntry *File = FilesByUID[UID];
+if (!File)
+  continue;
+
+const HeaderFileInfo *HFI =
+HS.getExistingFileInfo(File, /*WantExternal*/ false);
+if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
+  continue;
+
+for (const auto &KH : HS.findAllModulesForHeader(File)) {
+  if (!KH.getModule())

[PATCH] D110216: [clang] retain type sugar in auto / template argument deduction

2021-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov marked an inline comment as done.
mizvekov added inline comments.



Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:470
+  ExpectedHint{": S1", "x"},
+  ExpectedHint{": S2::Inner", "y"});
 }

nridge wrote:
> This test expectation change is suspicious. The type is being printed with 
> `PrintingPolicy::SuppressScope=true`, shouldn't that still be respected?
Thanks for pointing that out, I will take a look, but I suspect this to be some 
TypePrinter issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110216

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


[PATCH] D110258: [AArch64] Always add -tune-cpu argument to -cc1 driver

2021-09-27 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

I think these are the features I would class as tuning:

  FeatureExperimentalZeroingPseudos
  FeatureZCRegMove
  FeatureZCZeroingGP
  FeatureNoZCZeroingFP
  FeatureZCZeroing
  FeatureZCZeroingFPWorkaround
  FeatureStrictAlign
  FeatureBalanceFPOps
  FeaturePredictableSelectIsExpensive
  FeatureCustomCheapAsMoveHandling
  FeatureExynosCheapAsMoveHandling
  FeaturePostRAScheduler
  FeatureSlowMisaligned128Store
  FeatureSlowPaired128
  FeatureSlowSTRQro
  FeatureAlternateSExtLoadCVTF32Pattern
  FeatureArithmeticBccFusion
  FeatureArithmeticCbzFusion
  FeatureCmpBccFusion
  FeatureFuseAddress
  FeatureFuseAES
  FeatureFuseArithmeticLogic
  FeatureFuseCCSelect
  FeatureFuseCryptoEOR
  FeatureFuseLiterals
  FeatureDisableLatencySchedHeuristic
  FeatureForce32BitJumpTables
  FeatureUseRSqrt
  FeatureLSLFast
  FeatureAggressiveFMA

The `ProcA55` type features set `ARMProcFamily`, which seems to be used for 
tuning everywhere they are used, so would probably class as tuning features too.


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

https://reviews.llvm.org/D110258

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


[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Headers.cpp:174
+  IncludeStructure::HeaderID Result = R.first->getValue();
+  auto RealPathName = Entry->tryGetRealPathName();
+  if (!RealPathName.empty() &&

no auto here. I really hope this isn't std::string :-)

Actually I think you can avoid extracting this variable at all, because the 
!RealPathName.empty() check is redundant. The case where both sides are empty 
is rare enough that it's fine to assign as long as the *stored* name is empty.



Comment at: clang-tools-extra/clangd/Headers.cpp:176
+  if (!RealPathName.empty() &&
+  RealPathNames[static_cast(Result)].empty())
+RealPathNames[static_cast(Result)] = RealPathName.str();

extract `std::string &RealPathName = RealPathNames[...]`?



Comment at: clang-tools-extra/clangd/Headers.cpp:185
+  llvm::DenseMap Result;
+  if (static_cast(Root) >= RealPathNames.size()) {
+elog("Requested includeDepth for {0} which doesn't exist IncludeStructure",

This is a "can't happen" condition - remove or replace with an assert?



Comment at: clang-tools-extra/clangd/Headers.cpp:205
   CurrentLevel.push_back(Child);
-  const auto &Name = RealPathNames[Child];
   // Can't include files if we don't have their real path.
+  if (!RealPathNames[static_cast(Child)].empty())

This is no longer true, we don't need the check.



Comment at: clang-tools-extra/clangd/Headers.h:116
 public:
-  std::vector MainFileIncludes;
+  // Identifying files in a way that persists from preamble build to subsequent
+  // builds is surprisingly hard. FileID is unavailable in 
InclusionDirective(),

sammccall wrote:
> As mentioned offline, this is an implementation comment, but it doesn't say 
> *what the HeaderID is*.
> 
> Suggest something like:
> ```
> HeaderID identifies file in the include graph.
> It corresponds to a FileEntry rather than a FileID, but stays stable across 
> preamble & main file builds.
> ```
> 
> I'd move this impl comment back down to the private StringMap, but it could 
> also follow the description.
This doesn't seem to be done.
You've added a line to the *bottom* of the implementation comment defining 
`HeaderID` in terms of the implementation.

A reader rather needs complete self-contained description of the concept at the 
*top*, optionally followed by an explanation about the implementation 
(separated by a blank line).



Comment at: clang-tools-extra/clangd/unittests/HeadersTests.cpp:70
+  IncludeStructure::HeaderID getID(StringRef Filename) {
+auto Includes = collectIncludes();
+auto Entry = Clang->getSourceManager().getFileManager().getFile(Filename);

reparsing the code several times to obtain header IDs doesn't seem reasonable. 
It's surprising behavior from a test helper, and it requires that header IDs 
are stable across parses!

Can we just pass in the IncludeStructure instead?



Comment at: clang-tools-extra/clangd/unittests/HeadersTests.cpp:234
+  auto Includes = collectIncludes();
+  EXPECT_THAT(Includes.IncludeChildren[getID(MainFile)],
+  UnorderedElementsAreArray({getID(FooHeader), getID(BarHeader)}));

Why are we asserting on every element of the map one at a time, instead of the 
whole map at once? Seems like it would be more regular and easier to read.

I'd probably just write:
```
DenseMap> Expected = { ... };
EXPECT_EQ(Expected, Includes.IncludeChildren);
```



Comment at: clang-tools-extra/clangd/unittests/HeadersTests.cpp:236
+  UnorderedElementsAreArray({getID(FooHeader), getID(BarHeader)}));
+  EXPECT_TRUE(Includes.IncludeChildren[getID(BarHeader)].empty());
+  EXPECT_THAT(Includes.IncludeChildren[getID(FooHeader)],

EXPECT_THAT(foo.empty()) -> EXPECT_THAT(foo, IsEmpty()).
(Much better error messages)



Comment at: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp:511
   EqInc(), 
ExpectedAST.getIncludeStructure().MainFileIncludes));
-  auto StringMapToVector = [](const llvm::StringMap SM) {
+  auto Flatten = [](const llvm::DenseMap
+&IncludeDepth,

The ratio of setup to punchline of the rest of this test seems like it's gotten 
out of hand (it wasn't great before, but it's doubled).

What about just
```
auto &FM = PatchedAST->getSourceManager().getFileManager();
auto &Includes = PatchedAST->getIncludeStructure();
auto MainID = Includes.getID(FM.getFile(testPath("foo.cpp")));
auto AuxID = Includes.getID(FM.getFile(testPath("sub/aux.h")));
EXPECT_THAT(Includes.IncludeChildren.at(MainID), Contains(AuxID));
```

It tests a bit less I guess, but seems like enough




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

2021-09-27 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@phosek
It was probably my fault (mix of different in-tree / out of tree builds)
Quick question, why the path to `__config_site` contains this triple
`x86_64-pc-linux-gnu`
(in `/usr/lib/llvm-14/include/x86_64-pc-linux-gnu/c++/v1/__config_site`)
when it is usually:
`x86_64-linux-gnu`
(does not contain `-pc`)
thanks?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89013

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-27 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 375079.
gandhi21299 added a comment.

- Declare an unhandled call lowering in SelectionDAG when a callee is 
encountered which cannot be casted into a Function
- I am still investigating the effects on GlobalISel side of things, there 
seems to be a problem when lowering a call to `@func` in `@kernel` as well.
- inline-calls.ll is expected to fail with this patch, we could turn it into a 
negative test depending on how the work goes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
  llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/test/CodeGen/AMDGPU/inline-calls.ll


Index: llvm/test/CodeGen/AMDGPU/inline-calls.ll
===
--- llvm/test/CodeGen/AMDGPU/inline-calls.ll
+++ llvm/test/CodeGen/AMDGPU/inline-calls.ll
@@ -1,6 +1,4 @@
 ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck  
%s
-; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck  %s
-; RUN: llc -march=r600 -mcpu=redwood -verify-machineinstrs < %s | FileCheck %s
 
 ; ALL-NOT: {{^}}func:
 define internal i32 @func(i32 %a) {
@@ -18,8 +16,8 @@
   ret void
 }
 
-; CHECK-NOT: func_alias
-; ALL-NOT: func_alias
+; CHECK: func_alias
+; ALL: func_alias
 @func_alias = alias i32 (i32), i32 (i32)* @func
 
 ; ALL: {{^}}kernel3:
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -3007,6 +3007,13 @@
   bool IsSibCall = false;
   bool IsThisReturn = false;
   MachineFunction &MF = DAG.getMachineFunction();
+  GlobalAddressSDNode *GSD = dyn_cast(Callee);
+
+  if (GSD) {
+const GlobalValue *GV = GSD->getGlobal();
+if (!isa(GV))
+  return lowerUnhandledCall(CLI, InVals, "callee is not a function ");
+  }
 
   if (Callee.isUndef() || isNullConstant(Callee)) {
 if (!CLI.IsTailCall) {
@@ -3264,7 +3271,7 @@
   Ops.push_back(Callee);
   // Add a redundant copy of the callee global which will not be legalized, as
   // we need direct access to the callee later.
-  if (GlobalAddressSDNode *GSD = dyn_cast(Callee)) {
+  if (GSD) {
 const GlobalValue *GV = GSD->getGlobal();
 Ops.push_back(DAG.getTargetGlobalAddress(GV, DL, MVT::i64));
   } else {
Index: llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
@@ -93,6 +93,8 @@
 
   for (GlobalAlias &A : M.aliases()) {
 if (Function* F = dyn_cast(A.getAliasee())) {
+  if (A.getLinkage() != GlobalValue::InternalLinkage)
+continue;
   A.replaceAllUsesWith(F);
   AliasesToRemove.push_back(&A);
 }
Index: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
@@ -0,0 +1,15 @@
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -x hip -emit-llvm -S 
-o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm 
-amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), 
void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5084,9 +5084,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we


Index: llvm/test/CodeGen/AMDGPU/inline-calls.ll
===
--- llvm/test/CodeGen/AMDGPU/inline-calls.ll
+++ llvm/test/CodeGen/AMDGPU/inline-calls.ll
@@ -1,6 +1,4 @@
 ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck  %s
-; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck  %s
-; RUN: llc -march=r600 -mcpu=redwood -verify-machineinstrs < %s | FileCheck %s
 
 ; ALL-N

[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-27 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

It does not look like function calls are supported yet in AMDGPUCallLowering, 
is that correct?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D110432: [clang-format][docs] mark new clang-format configuration options based on which version they would GA

2021-09-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 375206.
MyDeveloperDay marked 6 inline comments as done.
MyDeveloperDay added a comment.

- Minor available version corrections
- Addressing review comments


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

https://reviews.llvm.org/D110432

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/include/clang/Tooling/Inclusions/IncludeStyle.h

Index: clang/include/clang/Tooling/Inclusions/IncludeStyle.h
===
--- clang/include/clang/Tooling/Inclusions/IncludeStyle.h
+++ clang/include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -50,6 +50,7 @@
 
   /// Dependent on the value, multiple ``#include`` blocks can be sorted
   /// as one and divided based on category.
+  /// \version 7
   IncludeBlocksStyle IncludeBlocks;
 
   /// See documentation of ``IncludeCategories``.
@@ -113,6 +114,7 @@
   ///   Priority:1
   ///   SortPriority:0
   /// \endcode
+  /// \version 7
   std::vector IncludeCategories;
 
   /// Specify a regular expression of suffixes that are allowed in the
@@ -126,6 +128,7 @@
   ///
   /// For example, if configured to "(_test)?$", then a header a.h would be seen
   /// as the "main" include in both a.cc and a_test.cc.
+  /// \version 7
   std::string IncludeIsMainRegex;
 
   /// Specify a regular expression for files being formatted
@@ -146,6 +149,7 @@
   /// also being respected in later phase). Without this option set,
   /// ``ClassImpl.hpp`` would not have the main include file put on top
   /// before any other include.
+  /// \version 7
   std::string IncludeIsMainSourceRegex;
 };
 
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -63,6 +63,7 @@
   bool InheritsParentConfig;
 
   /// The extra indent or outdent of access modifiers, e.g. ``public:``.
+  /// \version 3.3
   int AccessModifierOffset;
 
   /// Different styles for aligning after open brackets.
@@ -92,6 +93,7 @@
   ///
   /// This applies to round brackets (parentheses), angle brackets and square
   /// brackets.
+  /// \version 3.8
   BracketAlignmentStyle AlignAfterOpenBracket;
 
   /// Different style for aligning array initializers.
@@ -121,6 +123,7 @@
   };
   /// if not ``None``, when using initialization for an array of structs
   /// aligns the fields into columns.
+  /// \version 13
   ArrayInitializerAlignmentStyle AlignArrayOfStructures;
 
   /// Styles for alignment of consecutive tokens. Tokens can be assignment signs
@@ -205,6 +208,7 @@
   ///  /* some comment */
   ///  #define bar(y, z)(y + z)
   ///\endcode
+  /// \version 13
   AlignConsecutiveStyle AlignConsecutiveMacros;
 
   /// Style of aligning consecutive assignments.
@@ -273,6 +277,7 @@
   ///  /* A comment. */
   ///  double e = 4;
   ///\endcode
+  /// \version 13
   AlignConsecutiveStyle AlignConsecutiveAssignments;
 
   /// Style of aligning consecutive bit field.
@@ -342,6 +347,7 @@
   ///  /* A comment. */
   ///  int ee   : 3;
   ///\endcode
+  /// \version 13
   AlignConsecutiveStyle AlignConsecutiveBitFields;
 
   /// Style of aligning consecutive declarations.
@@ -411,6 +417,7 @@
   ///  /* A comment. */
   ///  boolc = false;
   ///\endcode
+  /// \version 13
   AlignConsecutiveStyle AlignConsecutiveDeclarations;
 
   /// Different styles for aligning escaped newlines.
@@ -445,6 +452,7 @@
   };
 
   /// Options for aligning backslashes in escaped newlines.
+  /// \version 5
   EscapedNewlineAlignmentStyle AlignEscapedNewlines;
 
   /// Different styles for aligning operands.
@@ -483,6 +491,7 @@
 
   /// If ``true``, horizontally align operands of binary and ternary
   /// expressions.
+  /// \version 12
   OperandAlignmentStyle AlignOperands;
 
   /// If ``true``, aligns trailing comments.
@@ -491,6 +500,7 @@
   ///   int a; // My comment a  vs. int a; // My comment a
   ///   int b = 2; // comment  bint b = 2; // comment about b
   /// \endcode
+  /// \version 3.7
   bool AlignTrailingComments;
 
   /// \brief If a function call or braced initializer list doesn't fit on a
@@ -507,10 +517,12 @@
   ///c,
   ///d);
   /// \endcode
+  /// \version 9
   bool AllowAllArgumentsOnNextLine;
 
   /// This option is **deprecated**. See ``NextLine`` of
   /// ``PackConstructorInitializers``.
+  /// \version 9
   bool AllowAllConstructorInitializersOnNextLine;
 
   /// If the function declaration doesn't fit on a line,
@@ -528,6 +540,7 @@
   ///   int d,
   ///   int e);
   /// \endcode
+  /// \version 3.3
   bool AllowAllParametersOfDeclarationOnNextLine;
 
   /// Allow short enums on a single line.
@@ -541,6 +554,7 @@
   ///

[PATCH] D110432: [clang-format][docs] mark new clang-format configuration options based on which version they would GA

2021-09-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/tools/dump_format_style.py:218
+  if line.startswith(r'/// \version'):
+match = re.match(r'/// \\version\s*(?P[0-9.]+)*',line)
+if match:

HazardyKnusperkeks wrote:
> HazardyKnusperkeks wrote:
> > This needs to be escaped, doesn't it?
> This shouldn't be needed, or?
I don't think it means any character in a `[...]` but I'm not a regex expert

https://regex101.com/r/0e08JP/1

It is needed because prior to 4.0 we had 3.3->3.9





Comment at: clang/include/clang/Format/Format.h:3043
+  /// \endcode
+  /// \version 14
   bool ReflowComments;

HazardyKnusperkeks wrote:
> Some whitespace changes here.
> 
> And Version 14 is definitely wrong. It was already in 4 and not in 3.8, don't 
> know how many version were in between.
{F19274652}


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

https://reviews.llvm.org/D110432

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


[PATCH] D110493: [clang-tidy] Fix bug 51790 in readability-uppercase-literal-suffix

2021-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for the fix!




Comment at: 
clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp:137-138
 
+  // Make sure the first character is actually a digit
+  // https://bugs.llvm.org/show_bug.cgi?id=51790
+  if (!std::isdigit(static_cast(LiteralSourceText.front(





Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-uppercase-literal-suffix-integer.cpp:286
+  int x = Vector<10>::kCapacity;
+}

Can you add a `// CHECK-MESSAGES-NOT:` line to the places where we used to 
diagnose but no longer do? That helps make the test more explicit.

Another test to add is a nontype template parameter whose identifier ends in a 
digit just before the `i`. e.g., `foo1i`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110493

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


[PATCH] D109144: [SPIR-V] Add SPIR-V triple architecture and clang target info

2021-09-27 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 375216.
linjamaki added a comment.

Rename SPIRABIInfo -> CommonSPIRABIInfo and SPIRTargetCodeGenInfo -> 
CommonSPIRTargetCodeGenInfo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109144

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/SPIR.cpp
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h
  clang/test/CodeGenOpenCL/spirv_target.cl
  clang/test/Headers/opencl-c-header.cl
  clang/test/Preprocessor/predefined-macros.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp
  llvm/unittests/ADT/TripleTest.cpp

Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -224,6 +224,16 @@
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::UnknownOS, T.getOS());
 
+  T = Triple("spirv32-unknown-unknown");
+  EXPECT_EQ(Triple::spirv32, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UnknownOS, T.getOS());
+
+  T = Triple("spirv64-unknown-unknown");
+  EXPECT_EQ(Triple::spirv64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UnknownOS, T.getOS());
+
   T = Triple("x86_64-unknown-ananas");
   EXPECT_EQ(Triple::x86_64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
@@ -865,6 +875,16 @@
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_TRUE(T.isArch64Bit());
 
+  T.setArch(Triple::spirv32);
+  EXPECT_FALSE(T.isArch16Bit());
+  EXPECT_TRUE(T.isArch32Bit());
+  EXPECT_FALSE(T.isArch64Bit());
+
+  T.setArch(Triple::spirv64);
+  EXPECT_FALSE(T.isArch16Bit());
+  EXPECT_FALSE(T.isArch32Bit());
+  EXPECT_TRUE(T.isArch64Bit());
+
   T.setArch(Triple::sparc);
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
@@ -1000,6 +1020,14 @@
   EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
   EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
 
+  T.setArch(Triple::spirv32);
+  EXPECT_EQ(Triple::spirv32, T.get32BitArchVariant().getArch());
+  EXPECT_EQ(Triple::spirv64, T.get64BitArchVariant().getArch());
+
+  T.setArch(Triple::spirv64);
+  EXPECT_EQ(Triple::spirv32, T.get32BitArchVariant().getArch());
+  EXPECT_EQ(Triple::spirv64, T.get64BitArchVariant().getArch());
+
   T.setArch(Triple::wasm32);
   EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
   EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -67,6 +67,8 @@
   case sparcv9:return "sparcv9";
   case spir64: return "spir64";
   case spir:   return "spir";
+  case spirv32:return "spirv32";
+  case spirv64:return "spirv64";
   case systemz:return "s390x";
   case tce:return "tce";
   case tcele:  return "tcele";
@@ -147,6 +149,10 @@
 
   case spir:
   case spir64:  return "spir";
+
+  case spirv32:
+  case spirv64: return "spirv";
+
   case kalimba: return "kalimba";
   case lanai:   return "lanai";
   case shave:   return "shave";
@@ -323,6 +329,8 @@
 .Case("hsail64", hsail64)
 .Case("spir", spir)
 .Case("spir64", spir64)
+.Case("spirv32", spirv32)
+.Case("spirv64", spirv64)
 .Case("kalimba", kalimba)
 .Case("lanai", lanai)
 .Case("shave", shave)
@@ -456,6 +464,8 @@
 .Case("hsail64", Triple::hsail64)
 .Case("spir", Triple::spir)
 .Case("spir64", Triple::spir64)
+.Case("spirv32", Triple::spirv32)
+.Case("spirv64", Triple::spirv64)
 .StartsWith("kalimba", Triple::kalimba)
 .Case("lanai", Triple::lanai)
 .Case("renderscript32", Triple::renderscript32)
@@ -753,6 +763,11 @@
   case Triple::wasm32:
   case Triple::wasm64:
 return Triple::Wasm;
+
+  case Triple::spirv32:
+  case Triple::spirv64:
+// TODO: In future this will be Triple::SPIRV.
+return Triple::UnknownObjectFormat;
   }
   llvm_unreachable("unknown architecture");
 }
@@ -1298,6 +1313,7 @@
   case llvm::Triple::sparc:
   case llvm::Triple::sparcel:
   case llvm::Triple::spir:
+  case llvm::Triple::spirv32:
   case llvm::Triple::tce:
   case llvm::Triple::tcele:
   case llvm::Triple::thumb:
@@ -1324,6 +1340,7 @@
   case llvm::Triple::riscv64:
   case llvm::Triple::sparcv9:
   case llvm::Triple::spir64:
+  case llvm::Triple::spirv64:
   case llvm::Triple::systemz:
   case llvm::Triple::ve:
   case llvm::Triple::wasm64:
@@ -1383,6 +1400,7 @@
   case Triple::sparc:
   case Triple::sparcel:
   case Triple::spir:
+  case Triple::spirv32:

[PATCH] D110528: [clang][ASTImporter] Add import of thread safety attributes.

2021-09-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I appreciate the effort in working on the attribute imports.

Personally, I don't really like this change. IMO 
`AttrImporter::createImportedAttr()` should do the magic, and apply the 
necessary glue for the import.
Or we could even create a dedicated function, which would 'just do the right 
thing' and import the Attr, without the current noise of calling the individual 
imports than gluing the stuff to the constructor dispatch.

The proposed implementation involves too much code repetition for me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110528

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


[PATCH] D108621: [HIPSPV] Add CUDA->SPIR-V address space mapping

2021-09-27 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 375219.
linjamaki added a comment.
Herald added subscribers: llvm-commits, dexonsmith, hiraditya.
Herald added a project: LLVM.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108621

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/SPIR.cpp
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h
  clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
  clang/test/CodeGenOpenCL/spirv_target.cl
  clang/test/Headers/opencl-c-header.cl
  clang/test/Preprocessor/predefined-macros.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp
  llvm/unittests/ADT/TripleTest.cpp

Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -224,6 +224,16 @@
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::UnknownOS, T.getOS());
 
+  T = Triple("spirv32-unknown-unknown");
+  EXPECT_EQ(Triple::spirv32, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UnknownOS, T.getOS());
+
+  T = Triple("spirv64-unknown-unknown");
+  EXPECT_EQ(Triple::spirv64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UnknownOS, T.getOS());
+
   T = Triple("x86_64-unknown-ananas");
   EXPECT_EQ(Triple::x86_64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
@@ -865,6 +875,16 @@
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_TRUE(T.isArch64Bit());
 
+  T.setArch(Triple::spirv32);
+  EXPECT_FALSE(T.isArch16Bit());
+  EXPECT_TRUE(T.isArch32Bit());
+  EXPECT_FALSE(T.isArch64Bit());
+
+  T.setArch(Triple::spirv64);
+  EXPECT_FALSE(T.isArch16Bit());
+  EXPECT_FALSE(T.isArch32Bit());
+  EXPECT_TRUE(T.isArch64Bit());
+
   T.setArch(Triple::sparc);
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
@@ -1000,6 +1020,14 @@
   EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
   EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
 
+  T.setArch(Triple::spirv32);
+  EXPECT_EQ(Triple::spirv32, T.get32BitArchVariant().getArch());
+  EXPECT_EQ(Triple::spirv64, T.get64BitArchVariant().getArch());
+
+  T.setArch(Triple::spirv64);
+  EXPECT_EQ(Triple::spirv32, T.get32BitArchVariant().getArch());
+  EXPECT_EQ(Triple::spirv64, T.get64BitArchVariant().getArch());
+
   T.setArch(Triple::wasm32);
   EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
   EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -67,6 +67,8 @@
   case sparcv9:return "sparcv9";
   case spir64: return "spir64";
   case spir:   return "spir";
+  case spirv32:return "spirv32";
+  case spirv64:return "spirv64";
   case systemz:return "s390x";
   case tce:return "tce";
   case tcele:  return "tcele";
@@ -147,6 +149,10 @@
 
   case spir:
   case spir64:  return "spir";
+
+  case spirv32:
+  case spirv64: return "spirv";
+
   case kalimba: return "kalimba";
   case lanai:   return "lanai";
   case shave:   return "shave";
@@ -323,6 +329,8 @@
 .Case("hsail64", hsail64)
 .Case("spir", spir)
 .Case("spir64", spir64)
+.Case("spirv32", spirv32)
+.Case("spirv64", spirv64)
 .Case("kalimba", kalimba)
 .Case("lanai", lanai)
 .Case("shave", shave)
@@ -456,6 +464,8 @@
 .Case("hsail64", Triple::hsail64)
 .Case("spir", Triple::spir)
 .Case("spir64", Triple::spir64)
+.Case("spirv32", Triple::spirv32)
+.Case("spirv64", Triple::spirv64)
 .StartsWith("kalimba", Triple::kalimba)
 .Case("lanai", Triple::lanai)
 .Case("renderscript32", Triple::renderscript32)
@@ -753,6 +763,11 @@
   case Triple::wasm32:
   case Triple::wasm64:
 return Triple::Wasm;
+
+  case Triple::spirv32:
+  case Triple::spirv64:
+// TODO: In future this will be Triple::SPIRV.
+return Triple::UnknownObjectFormat;
   }
   llvm_unreachable("unknown architecture");
 }
@@ -1298,6 +1313,7 @@
   case llvm::Triple::sparc:
   case llvm::Triple::sparcel:
   case llvm::Triple::spir:
+  case llvm::Triple::spirv32:
   case llvm::Triple::tce:
   case llvm::Triple::tcele:
   case llvm::Triple::thumb:
@@ -1324,6 +1340,7 @@
   case llvm::Triple::riscv64:
   case llvm::Triple::sparcv9:
   case llvm::Triple::spir64:
+  case llvm::Triple::spirv64:
   case llvm::Triple::systemz:
   case llvm::Triple::ve:
   case llvm::Triple::wasm64:
@@ -1383,6 +1400,7 @@
   case Triple::sparc:
   case Triple::sparce

[PATCH] D108621: [HIPSPV] Add CUDA->SPIR-V address space mapping

2021-09-27 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 375221.
linjamaki added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108621

Files:
  clang/lib/Basic/Targets/SPIR.h
  clang/test/CodeGenHIP/hipspv-addr-spaces.cpp


Index: clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
===
--- /dev/null
+++ clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -triple spirv64 -x hip -emit-llvm -fcuda-is-device \
+// RUN:   -o - %s | FileCheck %s
+
+#define __device__ __attribute__((device))
+#define __shared__ __attribute__((shared))
+#define __constant__ __attribute__((constant))
+
+// CHECK: %struct.foo_t = type { i32, i32 addrspace(4)* }
+
+// CHECK: @d ={{.*}} addrspace(1) externally_initialized global
+__device__ int d;
+
+// CHECK: @c ={{.*}} addrspace(1) externally_initialized global
+__constant__ int c;
+
+// CHECK: @s ={{.*}} addrspace(3) global
+__shared__ int s;
+
+// CHECK: @foo ={{.*}} addrspace(1) externally_initialized global %struct.foo_t
+__device__ struct foo_t {
+  int i;
+  int* pi;
+} foo;
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z3barPi(i32 addrspace(4)*
+__device__ int* bar(int *x) {
+  return x;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_dv()
+__device__ int* baz_d() {
+  // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @d to i32 
addrspace(4)*
+  return &d;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_cv()
+__device__ int* baz_c() {
+  // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @c to i32 
addrspace(4)*
+  return &c;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_sv()
+__device__ int* baz_s() {
+  // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(3)* @s to i32 
addrspace(4)*
+  return &s;
+}
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -56,9 +56,14 @@
 0, // opencl_generic
 0, // opencl_global_device
 0, // opencl_global_host
-0, // cuda_device
-0, // cuda_constant
-0, // cuda_shared
+// cuda_* address space mapping is intended for HIPSPV (HIP to SPIR-V
+// translation). This mapping is enabled when the language mode is HIP.
+1, // cuda_device
+// cuda_constant pointer can be casted to default/"flat" pointer, but in
+// SPIR-V casts between constant and generic pointers are not allowed. For
+// this reason cuda_constant is mapped to SPIR-V CrossWorkgroup.
+1, // cuda_constant
+3, // cuda_shared
 1, // sycl_global
 5, // sycl_global_device
 6, // sycl_global_host
@@ -219,6 +224,16 @@
   bool hasFeature(StringRef Feature) const override {
 return Feature == "spirv";
   }
+
+  void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override {
+BaseSPIRTargetInfo::adjust(Diags, Opts);
+// Guarded so we don't override address space map setting set by
+// BaseSPIRTargetInfo::adjust.
+if (Opts.HIP && Opts.CUDAIsDevice)
+  // Enable address space mapping from HIP to SPIR-V.
+  // See comment on the SPIRDefIsGenMap table.
+  setAddressSpaceMap(/*DefaultIsGeneric=*/true);
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY SPIRV32TargetInfo : public SPIRVTargetInfo {


Index: clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
===
--- /dev/null
+++ clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -triple spirv64 -x hip -emit-llvm -fcuda-is-device \
+// RUN:   -o - %s | FileCheck %s
+
+#define __device__ __attribute__((device))
+#define __shared__ __attribute__((shared))
+#define __constant__ __attribute__((constant))
+
+// CHECK: %struct.foo_t = type { i32, i32 addrspace(4)* }
+
+// CHECK: @d ={{.*}} addrspace(1) externally_initialized global
+__device__ int d;
+
+// CHECK: @c ={{.*}} addrspace(1) externally_initialized global
+__constant__ int c;
+
+// CHECK: @s ={{.*}} addrspace(3) global
+__shared__ int s;
+
+// CHECK: @foo ={{.*}} addrspace(1) externally_initialized global %struct.foo_t
+__device__ struct foo_t {
+  int i;
+  int* pi;
+} foo;
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z3barPi(i32 addrspace(4)*
+__device__ int* bar(int *x) {
+  return x;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_dv()
+__device__ int* baz_d() {
+  // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @d to i32 addrspace(4)*
+  return &d;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_cv()
+__device__ int* baz_c() {
+  // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @c to i32 addrspace(4)*
+  return &c;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_sv()
+__device__ int* baz_s() {
+  // CHECK: ret i32 addrspace

[PATCH] D110458: [clang] Put original flags on 'Driver args:' crash report line

2021-09-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: clang/lib/Driver/Driver.cpp:1220
+  for (const auto *A : Args) {
+while (A->getAlias())
+  A = A->getAlias();

Could put a comment here about why it's calling getAlias() (Or maybe it's just 
me that finds the getAlias() name confusing.)



Comment at: clang/test/Driver/crash-report-clang-cl.c:2
+// RUN: rm -rf %t
+// RUN: mkdir %t
+

These always make me thing the test should "requires: shell", but I think for 
these commands it should work without, right?


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

https://reviews.llvm.org/D110458

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


[PATCH] D110458: [clang] Put original flags on 'Driver args:' crash report line

2021-09-27 Thread Nico Weber via Phabricator via cfe-commits
thakis marked an inline comment as done.
thakis added a comment.

Thanks!




Comment at: clang/test/Driver/crash-report-clang-cl.c:2
+// RUN: rm -rf %t
+// RUN: mkdir %t
+

hans wrote:
> These always make me thing the test should "requires: shell", but I think for 
> these commands it should work without, right?
Yes, these work without `REQUIRES: shell`. We require a whole bunch of unix 
utils on Windows, but we don't require a shell for most tests. That's usually 
required if doing advanced piping maybe? Actually, looking at `REQUIRES: shell` 
in tests, many put it there needlessly :/


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

https://reviews.llvm.org/D110458

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


[PATCH] D110528: [clang][ASTImporter] Add import of thread safety attributes.

2021-09-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The code can be made better in a way that only lines similar to

  Expected ToAttrOrErr = AI.createImportedAttr(
  From, AI.importArg(From->getSuccessValue()).value(),
  AI.importArrayArg(From->args(), From->args_size()).value(),
  From->args_size());

are needed. If there is an AttrVisitor the switch can be removed. No one import 
function is possible that works with every `Attr`, in the same way as there is 
a separate function for import of every `Stmt` (`Decl` and others are more 
complicated) there must be something for every `Attr` (if it has custom 
arguments). Even now the import of an `Attr` needs much less code than import 
of a `Stmt` (that could be done in similar way). There are cases that need 
special handling, like `AlignedAttr`. If the current code is included we can 
see enough cases to make a better generalization, but after splitting the 
**ASTImporter.cpp** into multiple files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110528

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


[PATCH] D110458: [clang] Put original flags on 'Driver args:' crash report line

2021-09-27 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 375232.
thakis added a comment.

add comment


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

https://reviews.llvm.org/D110458

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-report-clang-cl.c


Index: clang/test/Driver/crash-report-clang-cl.c
===
--- /dev/null
+++ clang/test/Driver/crash-report-clang-cl.c
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1   \
+// RUN: not %clang_cl -fsyntax-only /Brepro /source-charset:utf-8 \
+// RUN: -- %s 2>&1 | FileCheck %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
+// REQUIRES: crash-recovery
+
+#pragma clang __debug crash
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-clang-cl-{{.*}}.c
+// CHECKSH: # Crash reproducer
+// CHECKSH-NEXT: # Driver args: {{.*}}"-fsyntax-only"
+// CHECKSH-SAME: /Brepro
+// CHECKSH-SAME: /source-charset:utf-8
+// CHECKSH-NOT: -mno-incremental-linker-compatible
+// CHECKSH-NOT: -finput-charset=utf-8
+// CHECKSH-NEXT: # Original command: {{.*$}}
+// CHECKSH-NEXT: "-cc1"
+// CHECKSH: "-main-file-name" "crash-report-clang-cl.c"
+// CHECKSH: "crash-report-{{[^ ]*}}.c"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1216,8 +1216,14 @@
 
 static void printArgList(raw_ostream &OS, const llvm::opt::ArgList &Args) {
   llvm::opt::ArgStringList ASL;
-  for (const auto *A : Args)
+  for (const auto *A : Args) {
+// Use user's original spelling of flags. For example, use
+// `/source-charset:utf-8` instead of `-finput-charset=utf-8` if the user
+// wrote the former.
+while (A->getAlias())
+  A = A->getAlias();
 A->render(Args, ASL);
+  }
 
   for (auto I = ASL.begin(), E = ASL.end(); I != E; ++I) {
 if (I != ASL.begin())


Index: clang/test/Driver/crash-report-clang-cl.c
===
--- /dev/null
+++ clang/test/Driver/crash-report-clang-cl.c
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1   \
+// RUN: not %clang_cl -fsyntax-only /Brepro /source-charset:utf-8 \
+// RUN: -- %s 2>&1 | FileCheck %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
+// REQUIRES: crash-recovery
+
+#pragma clang __debug crash
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-clang-cl-{{.*}}.c
+// CHECKSH: # Crash reproducer
+// CHECKSH-NEXT: # Driver args: {{.*}}"-fsyntax-only"
+// CHECKSH-SAME: /Brepro
+// CHECKSH-SAME: /source-charset:utf-8
+// CHECKSH-NOT: -mno-incremental-linker-compatible
+// CHECKSH-NOT: -finput-charset=utf-8
+// CHECKSH-NEXT: # Original command: {{.*$}}
+// CHECKSH-NEXT: "-cc1"
+// CHECKSH: "-main-file-name" "crash-report-clang-cl.c"
+// CHECKSH: "crash-report-{{[^ ]*}}.c"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1216,8 +1216,14 @@
 
 static void printArgList(raw_ostream &OS, const llvm::opt::ArgList &Args) {
   llvm::opt::ArgStringList ASL;
-  for (const auto *A : Args)
+  for (const auto *A : Args) {
+// Use user's original spelling of flags. For example, use
+// `/source-charset:utf-8` instead of `-finput-charset=utf-8` if the user
+// wrote the former.
+while (A->getAlias())
+  A = A->getAlias();
 A->render(Args, ASL);
+  }
 
   for (auto I = ASL.begin(), E = ASL.end(); I != E; ++I) {
 if (I != ASL.begin())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109818: [HIPSPV] Convert HIP kernels to SPIR-V kernels

2021-09-27 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 375233.
linjamaki added a comment.

Put HIPSPV logic into new SPIRV{ABI,TargetCodeGen}Info subclassed from
CommonSPIR{ABI,TargetCodeGen}Info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109818

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenHIP/hipspv-kernel.cpp

Index: clang/test/CodeGenHIP/hipspv-kernel.cpp
===
--- /dev/null
+++ clang/test/CodeGenHIP/hipspv-kernel.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple spirv64 -x hip -emit-llvm -fcuda-is-device \
+// RUN:   -o - %s | FileCheck %s
+
+#define __global__ __attribute__((global))
+
+// CHECK: define {{.*}}spir_kernel void @_Z3fooPff(float addrspace(1)* {{.*}}, float {{.*}})
+__global__ void foo(float *a, float b) {
+  *a = b;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -10194,12 +10194,23 @@
 private:
   void setCCs();
 };
+
+class SPIRVABIInfo : public CommonSPIRABIInfo {
+public:
+  SPIRVABIInfo(CodeGenTypes &CGT) : CommonSPIRABIInfo(CGT) {}
+  void computeInfo(CGFunctionInfo &FI) const override;
+
+private:
+  ABIArgInfo classifyKernelArgumentType(QualType Ty) const;
+};
 } // end anonymous namespace
 namespace {
 class CommonSPIRTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   CommonSPIRTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
+  CommonSPIRTargetCodeGenInfo(std::unique_ptr ABIInfo)
+  : TargetCodeGenInfo(std::move(ABIInfo)) {}
 
   LangAS getASTAllocaAddressSpace() const override {
 return getLangASFromTargetAS(
@@ -10208,18 +10219,60 @@
 
   unsigned getOpenCLKernelCallingConv() const override;
 };
-
+class SPIRVTargetCodeGenInfo : public CommonSPIRTargetCodeGenInfo {
+public:
+  SPIRVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
+  : CommonSPIRTargetCodeGenInfo(std::make_unique(CGT)) {}
+  void setCUDAKernelCallingConvention(const FunctionType *&FT) const override;
+};
 } // End anonymous namespace.
+
 void CommonSPIRABIInfo::setCCs() {
   assert(getRuntimeCC() == llvm::CallingConv::C);
   RuntimeCC = llvm::CallingConv::SPIR_FUNC;
 }
 
+ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty) const {
+  if (getContext().getLangOpts().HIP) {
+// Coerce pointer arguments with default address space to CrossWorkGroup
+// pointers for HIPSPV. When the language mode is HIP, the SPIRTargetInfo
+// maps cuda_device to SPIR-V's CrossWorkGroup address space.
+llvm::Type *LTy = CGT.ConvertType(Ty);
+auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
+auto GlobalAS = getContext().getTargetAddressSpace(LangAS::cuda_device);
+if (LTy->isPointerTy() && LTy->getPointerAddressSpace() == DefaultAS) {
+  LTy = llvm::PointerType::get(
+  cast(LTy)->getElementType(), GlobalAS);
+  return ABIArgInfo::getDirect(LTy, 0, nullptr, false);
+}
+  }
+  return classifyArgumentType(Ty);
+}
+
+void SPIRVABIInfo::computeInfo(CGFunctionInfo &FI) const {
+  // The logic is same as in DefaultABIInfo with an exception on the kernel
+  // arguments handling.
+  llvm::CallingConv::ID CC = FI.getCallingConvention();
+
+  if (!getCXXABI().classifyReturnType(FI))
+FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+
+  for (auto &I : FI.arguments()) {
+if (CC == llvm::CallingConv::SPIR_KERNEL) {
+  I.info = classifyKernelArgumentType(I.type);
+} else {
+  I.info = classifyArgumentType(I.type);
+}
+  }
+}
+
 namespace clang {
 namespace CodeGen {
 void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI) {
-  DefaultABIInfo SPIRABI(CGM.getTypes());
-  SPIRABI.computeInfo(FI);
+  if (CGM.getTarget().getTriple().isSPIRV())
+SPIRVABIInfo(CGM.getTypes()).computeInfo(FI);
+  else
+CommonSPIRABIInfo(CGM.getTypes()).computeInfo(FI);
 }
 }
 }
@@ -10228,6 +10281,16 @@
   return llvm::CallingConv::SPIR_KERNEL;
 }
 
+void SPIRVTargetCodeGenInfo::setCUDAKernelCallingConvention(
+const FunctionType *&FT) const {
+  // Convert HIP kernels to SPIR-V kernels.
+  if (getABIInfo().getContext().getLangOpts().HIP) {
+FT = getABIInfo().getContext().adjustFunctionType(
+FT, FT->getExtInfo().withCallingConv(CC_OpenCLKernel));
+return;
+  }
+}
+
 static bool appendType(SmallStringEnc &Enc, QualType QType,
const CodeGen::CodeGenModule &CGM,
TypeStringCache &TSC);
@@ -11293,9 +11356,10 @@
 return SetCGInfo(new ARCTargetCodeGenInfo(Types));
   case llvm::Triple::spir:
   case llvm::Triple::spir64:
+return SetCGInfo(new CommonSPIRTargetCodeGenInfo(Types));
   case llvm::Triple::spirv32:
   case llvm::Triple::spirv64:
-return SetCGInfo(new CommonSPIRTargetCodeGenInfo(Types));
+retu

[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 375237.
kbobyrev marked 7 inline comments as done.
kbobyrev added a comment.

Resolve all but two comments, leave the clarification questions for these two.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110386

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -44,9 +44,11 @@
 namespace {
 
 using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::ElementsAreArray;
 using ::testing::IsEmpty;
+using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P(DeclNamed, Name, "") {
   if (NamedDecl *ND = dyn_cast(arg))
@@ -493,7 +495,7 @@
   auto EmptyPreamble =
   buildPreamble(testPath("foo.cpp"), *CI, Inputs, true, nullptr);
   ASSERT_TRUE(EmptyPreamble);
-  EXPECT_THAT(EmptyPreamble->Includes.MainFileIncludes, testing::IsEmpty());
+  EXPECT_THAT(EmptyPreamble->Includes.MainFileIncludes, IsEmpty());
 
   // Now build an AST using empty preamble and ensure patched includes worked.
   TU.Code = ModifiedContents.str();
@@ -507,18 +509,17 @@
   EXPECT_THAT(PatchedAST->getIncludeStructure().MainFileIncludes,
   testing::Pointwise(
   EqInc(), ExpectedAST.getIncludeStructure().MainFileIncludes));
-  auto StringMapToVector = [](const llvm::StringMap SM) {
-std::vector> Res;
-for (const auto &E : SM)
-  Res.push_back({E.first().str(), E.second});
-llvm::sort(Res);
-return Res;
-  };
   // Ensure file proximity signals are correct.
-  EXPECT_EQ(StringMapToVector(PatchedAST->getIncludeStructure().includeDepth(
-testPath("foo.cpp"))),
-StringMapToVector(ExpectedAST.getIncludeStructure().includeDepth(
-testPath("foo.cpp";
+  auto &FM = PatchedAST->getSourceManager().getFileManager();
+  // Copy so that we can use operator[] to get the children.
+  IncludeStructure Includes = PatchedAST->getIncludeStructure();
+  auto MainFE = FM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(MainFE);
+  auto MainID = Includes.getID(*MainFE);
+  auto AuxFE = FM.getFile(testPath("sub/aux.h"));
+  ASSERT_TRUE(AuxFE);
+  auto AuxID = Includes.getID(*AuxFE);
+  EXPECT_THAT(Includes.IncludeChildren[*MainID], Contains(AuxID));
 }
 
 TEST(ParsedASTTest, PatchesDeletedIncludes) {
@@ -551,18 +552,20 @@
   EXPECT_THAT(PatchedAST->getIncludeStructure().MainFileIncludes,
   testing::Pointwise(
   EqInc(), ExpectedAST.getIncludeStructure().MainFileIncludes));
-  auto StringMapToVector = [](const llvm::StringMap SM) {
-std::vector> Res;
-for (const auto &E : SM)
-  Res.push_back({E.first().str(), E.second});
-llvm::sort(Res);
-return Res;
-  };
   // Ensure file proximity signals are correct.
-  EXPECT_EQ(StringMapToVector(PatchedAST->getIncludeStructure().includeDepth(
-testPath("foo.cpp"))),
-StringMapToVector(ExpectedAST.getIncludeStructure().includeDepth(
-testPath("foo.cpp";
+  auto &FM = ExpectedAST.getSourceManager().getFileManager();
+  // Copy so that we can getOrCreateID().
+  IncludeStructure Includes = ExpectedAST.getIncludeStructure();
+  auto MainFE = FM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(MainFE);
+  auto MainID = Includes.getOrCreateID(*MainFE);
+  auto &PatchedFM = PatchedAST->getSourceManager().getFileManager();
+  IncludeStructure PatchedIncludes = PatchedAST->getIncludeStructure();
+  auto PatchedMainFE = PatchedFM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(PatchedMainFE);
+  auto PatchedMainID = PatchedIncludes.getOrCreateID(*PatchedMainFE);
+  EXPECT_EQ(Includes.includeDepth(MainID),
+PatchedIncludes.includeDepth(PatchedMainID));
 }
 
 // Returns Code guarded by #ifndef guards
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -17,6 +17,7 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
@@ -29,8 +30,10 @@
 using ::testing::AllOf;
 using ::testing::Contains;
 using ::testing::ElementsAre;
+using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::UnorderedElementsAre;
+using ::testing::UnorderedElementsAreArray;
 
 class Header

[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/Headers.cpp:205
   CurrentLevel.push_back(Child);
-  const auto &Name = RealPathNames[Child];
   // Can't include files if we don't have their real path.
+  if (!RealPathNames[static_cast(Child)].empty())

sammccall wrote:
> This is no longer true, we don't need the check.
Wait, why not? We still have unresolved includes, e.g. preamble patches are 
like that, their `RealPathName`s stay empty.



Comment at: clang-tools-extra/clangd/unittests/HeadersTests.cpp:234
+  auto Includes = collectIncludes();
+  EXPECT_THAT(Includes.IncludeChildren[getID(MainFile)],
+  UnorderedElementsAreArray({getID(FooHeader), getID(BarHeader)}));

sammccall wrote:
> Why are we asserting on every element of the map one at a time, instead of 
> the whole map at once? Seems like it would be more regular and easier to read.
> 
> I'd probably just write:
> ```
> DenseMap> Expected = { ... };
> EXPECT_EQ(Expected, Includes.IncludeChildren);
> ```
This would expect the elements in the map to be in a particular order, isn't 
this something we don't want?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110386

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


[PATCH] D110484: [clang-repl] Allow loading of plugins in clang-repl.

2021-09-27 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz added a comment.

Two minor comments. Otherwise LGTM.




Comment at: clang/include/clang/Frontend/CompilerInstance.h:223
+  void LoadRequestedPlugins();
+
   /// }

This could have a minimal doxygen comment now that it's part of the public 
interface.



Comment at: clang/test/Interpreter/plugins.cpp:5
+// RUN:'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' 2>&1 | FileCheck %s
+// REQUIRES: host-supports-jit, plugins, examples

You could write the code interleaved with the check-lines below and then do:
```
// RUN: cat %s | clang-repl | FileCheck %s
```

Is there a good reason not to do so?


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

https://reviews.llvm.org/D110484

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


[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Headers.cpp:205
   CurrentLevel.push_back(Child);
-  const auto &Name = RealPathNames[Child];
   // Can't include files if we don't have their real path.
+  if (!RealPathNames[static_cast(Child)].empty())

kbobyrev wrote:
> sammccall wrote:
> > This is no longer true, we don't need the check.
> Wait, why not? We still have unresolved includes, e.g. preamble patches are 
> like that, their `RealPathName`s stay empty.
Right, but why do we need to filter them out here?
Can't we just drop them when we use them to seed the proximity sources?



Comment at: clang-tools-extra/clangd/unittests/HeadersTests.cpp:234
+  auto Includes = collectIncludes();
+  EXPECT_THAT(Includes.IncludeChildren[getID(MainFile)],
+  UnorderedElementsAreArray({getID(FooHeader), getID(BarHeader)}));

kbobyrev wrote:
> sammccall wrote:
> > Why are we asserting on every element of the map one at a time, instead of 
> > the whole map at once? Seems like it would be more regular and easier to 
> > read.
> > 
> > I'd probably just write:
> > ```
> > DenseMap> Expected = { ... };
> > EXPECT_EQ(Expected, Includes.IncludeChildren);
> > ```
> This would expect the elements in the map to be in a particular order, isn't 
> this something we don't want?
`==` on DenseMap doesn't consider order.

If you mean the order within map values (i.e. lists of child edges): these are 
in the order the `#includes` appear in the file, which seems fine to depend on 
to me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110386

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


[PATCH] D110258: [AArch64] Always add -tune-cpu argument to -cc1 driver

2021-09-27 Thread David Sherwood via Phabricator via cfe-commits
david-arm added a comment.

Hi @dmgreen, would you be happy for me to do the splitting-out of arch and 
tuning features in a separate follow-on patch? I think it's a good idea and I 
don't object to doing it, but I'm not sure that it really needs to hold up this 
initial patch? I personally think it makes sense to live in a separate patch 
because it seems riskier in terms of possible effects on performance. As far as 
I understand it, this isn't a functional requirement, but more for completeness.


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

https://reviews.llvm.org/D110258

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


[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Should we also change this to parse an unevaluated string literal: 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/ModuleMap.cpp#L1594
Similar question for all the uses in OpenMP stemming from: 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseOpenMP.cpp#L825
 (https://www.openmp.org/spec-html/5.1/openmp.html is the OpenMP spec but I 
didn't see any mention of encoding prefixes when I peeked)

I think we still need to handle UDLs so that we parse the declaration's `""` as 
an unevaluated string literal.




Comment at: clang/include/clang/AST/Expr.h:1845
   StringRef getString() const {
-assert(getCharByteWidth() == 1 &&
+assert((isUnevaluated() || getCharByteWidth() == 1) &&
"This function is used in places that assume strings use char");

Do we also want to assert that if it is unevaluated, it's char byte width *is* 
one byte? (No such thing as a multibyte unevaluated string literal.)



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:58
 
+
 def warn_misleading_indentation : Warning<

You can revert the unintended whitespace change to drop this whole file from 
the review.



Comment at: clang/lib/AST/Expr.cpp:1082
   StringLiteralBits.NumConcatenated = NumConcatenated;
+  StringLiteralBits.CharByteWidth = 1;
+

This should be in an `else` clause along with `StringLiteralBits.IsPascal = 
false;`.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1648
 // have the same ud-suffix.
-if (UDSuffixBuf != UDSuffix) {
+const bool UnevaluatedStringHasUDL = Unevaluated && !UDSuffix.empty();
+if (UDSuffixBuf != UDSuffix || UnevaluatedStringHasUDL) {





Comment at: clang/lib/Lex/LiteralSupport.cpp:95-96
+  case '?':
+  case 'n':
+  case 't':
+return true;

aaron.ballman wrote:
> cor3ntin wrote:
> > aaron.ballman wrote:
> > > Do you intend to miss a bunch of escapes like `\'` and `\r` (etc)?
> > \' is there. I am less sure about '\r' and '\a'. for example. This is 
> > something I realized after writing P2361.
> > what does '\a` in static assert mean? even '\r' is not so obvious
> Looking at the list again, I think only `\a` is really of interest here. I 
> know some folks like @jfb have mentioned that `\a` could be used to generate 
> an alert sound on a terminal, which is a somewhat useful feature for a failed 
> static assertion if you squint at it hard enough.
> 
> But the rest of the missing ones do seem more questionable to support.
@jfb and @cor3ntin -- any opinions on whether `\a` should be supported? My 
opinion is that it should be supported because it has some utility for anyone 
running the compiler from a command line, but it's a pretty weak opinion.



Comment at: clang/lib/Lex/Pragma.cpp:807
   if (Tok.is(tok::string_literal) && !Tok.hasUDSuffix()) {
 StringLiteralParser Literal(Tok, PP);
 if (Literal.hadError)

Should this also be modified?



Comment at: clang/lib/Parse/ParseDecl.cpp:374-376
+  ParsedAttr::Kind AttrKind =
+  ParsedAttr::getParsedKind(AttrName, ScopeName, Syntax);
+

I don't think this needed to move?



Comment at: clang/lib/Parse/ParseDecl.cpp:422-423
 
-ExprResult ArgExpr(
-Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression()));
+ExprResult ArgExpr(Actions.CorrectDelayedTyposInExpr(
+ParseAttributeArgAsUnevaluatedLiteralOrExpression(AttrKind)));
 if (ArgExpr.isInvalid()) {

cor3ntin wrote:
> aaron.ballman wrote:
> > cor3ntin wrote:
> > > aaron.ballman wrote:
> > > > Hmmm, I'm not certain about these changes.
> > > > 
> > > > For some attributes, the standard currently requires accepting any kind 
> > > > of string literal (like `[[deprecated]]` 
> > > > https://eel.is/c++draft/dcl.attr.deprecated#1). P2361 is proposing to 
> > > > change that, but it's not yet accepted by WG21 (let alone WG14). So 
> > > > giving errors in those cases is a bit of a hard sell -- I think 
> > > > warnings would be a bit more reasonable.
> > > > 
> > > > But for other attributes (like `annotate`), it's a bit less clear 
> > > > whether we should *prevent* literal prefixes because the attribute can 
> > > > be used to have runtime impacts (for example, I can imagine someone 
> > > > using `annotate` to emit the string literal bytes into the resulting 
> > > > binary). In some cases, I think it's very reasonable (e.g., 
> > > > `diagnose_if` should behave the same as `deprecated` and `nodiscard` 
> > > > because those are purely about generating diagnostics at compile time).
> > > > 
> > > > I kind of wonder whether we're going to want to tablegenerate whether 
> > > > the argument needs to be parsed as unevaluated or not on an 
> > > > attribute-by-a

[PATCH] D110493: [clang-tidy] Fix bug 51790 in readability-uppercase-literal-suffix

2021-09-27 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 375242.
carlosgalvezp added a comment.

Fixed review comments


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

https://reviews.llvm.org/D110493

Files:
  clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-uppercase-literal-suffix-integer.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-uppercase-literal-suffix-integer.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-uppercase-literal-suffix-integer.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-uppercase-literal-suffix-integer.cpp
@@ -270,3 +270,29 @@
 void d();
 void d() { c(); }
 } // namespace
+
+// Check that non-type template parameters do not cause any diags.
+// https://bugs.llvm.org/show_bug.cgi?id=51790
+template 
+struct Vector {
+  static constexpr int kCapacity = capacity;
+};
+
+template 
+constexpr int Vector::kCapacity;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:22: warning: integer literal has suffix 
'ity', which is not uppercase
+
+template 
+struct Foo {
+  static constexpr int kFoo = foo1u;
+};
+
+template 
+constexpr int Foo::kFoo;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:19: warning: integer literal has suffix 
'u', which is not uppercase
+
+// The template needs to be instantiated for diagnostics to show up
+void test_non_type_template_parameter() {
+  int x = Vector<10>::kCapacity;
+  int f = Foo<10>::kFoo;
+}
Index: clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -134,6 +134,11 @@
   CharSourceRange::getTokenRange(*Range), SM, LO, &Invalid);
   assert(!Invalid && "Failed to retrieve the source text.");
 
+  // Make sure the first character is actually a digit, instead of
+  // something else, like a non-type template parameter.
+  if (!std::isdigit(static_cast(LiteralSourceText.front(
+return llvm::None;
+
   size_t Skip = 0;
 
   // Do we need to ignore something before actually looking for the suffix?


Index: clang-tools-extra/test/clang-tidy/checkers/readability-uppercase-literal-suffix-integer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-uppercase-literal-suffix-integer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-uppercase-literal-suffix-integer.cpp
@@ -270,3 +270,29 @@
 void d();
 void d() { c(); }
 } // namespace
+
+// Check that non-type template parameters do not cause any diags.
+// https://bugs.llvm.org/show_bug.cgi?id=51790
+template 
+struct Vector {
+  static constexpr int kCapacity = capacity;
+};
+
+template 
+constexpr int Vector::kCapacity;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:22: warning: integer literal has suffix 'ity', which is not uppercase
+
+template 
+struct Foo {
+  static constexpr int kFoo = foo1u;
+};
+
+template 
+constexpr int Foo::kFoo;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:19: warning: integer literal has suffix 'u', which is not uppercase
+
+// The template needs to be instantiated for diagnostics to show up
+void test_non_type_template_parameter() {
+  int x = Vector<10>::kCapacity;
+  int f = Foo<10>::kFoo;
+}
Index: clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -134,6 +134,11 @@
   CharSourceRange::getTokenRange(*Range), SM, LO, &Invalid);
   assert(!Invalid && "Failed to retrieve the source text.");
 
+  // Make sure the first character is actually a digit, instead of
+  // something else, like a non-type template parameter.
+  if (!std::isdigit(static_cast(LiteralSourceText.front(
+return llvm::None;
+
   size_t Skip = 0;
 
   // Do we need to ignore something before actually looking for the suffix?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 38d0908 - Removing a default constructor argument; NFC

2021-09-27 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-09-27T09:41:28-04:00
New Revision: 38d09080c938c132279644e70001e8607a2998fb

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

LOG: Removing a default constructor argument; NFC

The argument is always used with its default value, so remove the
argument entirely.

Added: 


Modified: 
clang/include/clang/Lex/LiteralSupport.h
clang/lib/Lex/LiteralSupport.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/LiteralSupport.h 
b/clang/include/clang/Lex/LiteralSupport.h
index f131f045a73e..32471969f596 100644
--- a/clang/include/clang/Lex/LiteralSupport.h
+++ b/clang/include/clang/Lex/LiteralSupport.h
@@ -224,7 +224,7 @@ class StringLiteralParser {
   unsigned UDSuffixOffset;
 public:
   StringLiteralParser(ArrayRef StringToks,
-  Preprocessor &PP, bool Complain = true);
+  Preprocessor &PP);
   StringLiteralParser(ArrayRef StringToks,
   const SourceManager &sm, const LangOptions &features,
   const TargetInfo &target,

diff  --git a/clang/lib/Lex/LiteralSupport.cpp 
b/clang/lib/Lex/LiteralSupport.cpp
index 78e3e7d79a24..e3ae2ebd44a0 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -1654,9 +1654,9 @@ CharLiteralParser::CharLiteralParser(const char *begin, 
const char *end,
 ///
 StringLiteralParser::
 StringLiteralParser(ArrayRef StringToks,
-Preprocessor &PP, bool Complain)
+Preprocessor &PP)
   : SM(PP.getSourceManager()), Features(PP.getLangOpts()),
-Target(PP.getTargetInfo()), Diags(Complain ? &PP.getDiagnostics() 
:nullptr),
+Target(PP.getTargetInfo()), Diags(&PP.getDiagnostics()),
 MaxTokenLength(0), SizeBound(0), CharByteWidth(0), Kind(tok::unknown),
 ResultPtr(ResultBuf.data()), hadError(false), Pascal(false) {
   init(StringToks);



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


[PATCH] D108469: Improve handling of static assert messages.

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375244.
cor3ntin added a comment.

Rebasing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/Lexer/null-character-in-literal.c
  clang/test/Misc/diag-special-chars.c
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/static-assert.cpp
  llvm/include/llvm/Support/Unicode.h
  llvm/lib/Support/Unicode.cpp

Index: llvm/lib/Support/Unicode.cpp
===
--- llvm/lib/Support/Unicode.cpp
+++ llvm/lib/Support/Unicode.cpp
@@ -19,197 +19,271 @@
 namespace sys {
 namespace unicode {
 
+/// Unicode code points of the categories L, M, N, P, S and Zs are considered
+/// printable.
+/// In addition, U+00AD SOFT HYPHEN is also considered printable, as
+/// it's actually displayed on most terminals. \return true if the character is
+/// considered printable.
 bool isPrintable(int UCS) {
-  // Sorted list of non-overlapping intervals of code points that are not
-  // supposed to be printable.
-  static const UnicodeCharRange NonPrintableRanges[] = {
-{ 0x, 0x001F }, { 0x007F, 0x009F }, { 0x034F, 0x034F },
-{ 0x0378, 0x0379 }, { 0x037F, 0x0383 }, { 0x038B, 0x038B },
-{ 0x038D, 0x038D }, { 0x03A2, 0x03A2 }, { 0x0528, 0x0530 },
-{ 0x0557, 0x0558 }, { 0x0560, 0x0560 }, { 0x0588, 0x0588 },
-{ 0x058B, 0x058E }, { 0x0590, 0x0590 }, { 0x05C8, 0x05CF },
-{ 0x05EB, 0x05EF }, { 0x05F5, 0x0605 }, { 0x061C, 0x061D },
-{ 0x06DD, 0x06DD }, { 0x070E, 0x070F }, { 0x074B, 0x074C },
-{ 0x07B2, 0x07BF }, { 0x07FB, 0x07FF }, { 0x082E, 0x082F },
-{ 0x083F, 0x083F }, { 0x085C, 0x085D }, { 0x085F, 0x089F },
-{ 0x08A1, 0x08A1 }, { 0x08AD, 0x08E3 }, { 0x08FF, 0x08FF },
-{ 0x0978, 0x0978 }, { 0x0980, 0x0980 }, { 0x0984, 0x0984 },
-{ 0x098D, 0x098E }, { 0x0991, 0x0992 }, { 0x09A9, 0x09A9 },
-{ 0x09B1, 0x09B1 }, { 0x09B3, 0x09B5 }, { 0x09BA, 0x09BB },
-{ 0x09C5, 0x09C6 }, { 0x09C9, 0x09CA }, { 0x09CF, 0x09D6 },
-{ 0x09D8, 0x09DB }, { 0x09DE, 0x09DE }, { 0x09E4, 0x09E5 },
-{ 0x09FC, 0x0A00 }, { 0x0A04, 0x0A04 }, { 0x0A0B, 0x0A0E },
-{ 0x0A11, 0x0A12 }, { 0x0A29, 0x0A29 }, { 0x0A31, 0x0A31 },
-{ 0x0A34, 0x0A34 }, { 0x0A37, 0x0A37 }, { 0x0A3A, 0x0A3B },
-{ 0x0A3D, 0x0A3D }, { 0x0A43, 0x0A46 }, { 0x0A49, 0x0A4A },
-{ 0x0A4E, 0x0A50 }, { 0x0A52, 0x0A58 }, { 0x0A5D, 0x0A5D },
-{ 0x0A5F, 0x0A65 }, { 0x0A76, 0x0A80 }, { 0x0A84, 0x0A84 },
-{ 0x0A8E, 0x0A8E }, { 0x0A92, 0x0A92 }, { 0x0AA9, 0x0AA9 },
-{ 0x0AB1, 0x0AB1 }, { 0x0AB4, 0x0AB4 }, { 0x0ABA, 0x0ABB },
-{ 0x0AC6, 0x0AC6 }, { 0x0ACA, 0x0ACA }, { 0x0ACE, 0x0ACF },
-{ 0x0AD1, 0x0ADF }, { 0x0AE4, 0x0AE5 }, { 0x0AF2, 0x0B00 },
-{ 0x0B04, 0x0B04 }, { 0x0B0D, 0x0B0E }, { 0x0B11, 0x0B12 },
-{ 0x0B29, 0x0B29 }, { 0x0B31, 0x0B31 }, { 0x0B34, 0x0B34 },
-{ 0x0B3A, 0x0B3B }, { 0x0B45, 0x0B46 }, { 0x0B49, 0x0B4A },
-{ 0x0B4E, 0x0B55 }, { 0x0B58, 0x0B5B }, { 0x0B5E, 0x0B5E },
-{ 0x0B64, 0x0B65 }, { 0x0B78, 0x0B81 }, { 0x0B84, 0x0B84 },
-{ 0x0B8B, 0x0B8D }, { 0x0B91, 0x0B91 }, { 0x0B96, 0x0B98 },
-{ 0x0B9B, 0x0B9B }, { 0x0B9D, 0x0B9D }, { 0x0BA0, 0x0BA2 },
-{ 0x0BA5, 0x0BA7 }, { 0x0BAB, 0x0BAD }, { 0x0BBA, 0x0BBD },
-{ 0x0BC3, 0x0BC5 }, { 0x0BC9, 0x0BC9 }, { 0x0BCE, 0x0BCF },
-{ 0x0BD1, 0x0BD6 }, { 0x0BD8, 0x0BE5 }, { 0x0BFB, 0x0C00 },
-{ 0x0C04, 0x0C04 }, { 0x0C0D, 0x0C0D }, { 0x0C11, 0x0C11 },
-{ 0x0C29, 0x0C29 }, { 0x0C34, 0x0C34 }, { 0x0C3A, 0x0C3C },
-{ 0x0C45, 0x0C45 }, { 0x0C49, 0x0C49 }, { 0x0C4E, 0x0C54 },
-{ 0x0C57, 0x0C57 }, { 0x0C5A, 0x0C5F }, { 0x0C64, 0x0C65 },
-{ 0x0C70, 0x0C77 }, { 0x0C80, 0x0C81 }, { 0x0C84, 0x0C84 },
-{ 0x0C8D, 0x0C8D }, { 0x0C91, 0x0C91 }, { 0x0CA9, 0x0CA9 },
-{ 0x0CB4, 0x0CB4 }, { 0x0CBA, 0x0CBB }, { 0x0CC5, 0x0CC5 },
-{ 0x0CC9, 0x0CC9 }, { 0x0CCE, 0x0CD4 }, { 0x0CD7, 0x0CDD },
-{ 0x0CDF, 0x0CDF }, { 0x0CE4, 0x0CE5 }, { 0x0CF0, 0x0CF0 },
-{ 0x0CF3, 0x0D01 }, { 0x0D04, 0x0D04 }, { 0x0D0D, 0x0D0D },
-{ 0x0D11, 0x0D11 }, { 0x0D3B, 0x0D3C }, { 0x0D45, 0x0D45 },
-{ 0x0D49, 0x0D49 }, { 0x0D4F, 0x0D56 }, { 0x0D58, 0x0D5F },
-{ 0x0D64, 0x0D65 }, { 0x0D76, 0x0D78 }, { 0x0D80, 0x0D81 },
-{ 0x0D84, 0x0D84 }, { 0x0D97, 0x0D99 }, { 0x0DB2, 0x0DB2 },
-{ 0x0DBC, 0x0DBC }, { 0x0DBE, 0x0DBF }, { 0x0DC7, 0x0DC9 },
-{ 0x0DCB, 0x0DCE }, { 0x0DD5, 0x0DD5 }, { 0x0DD7, 0x0DD7 },
-{ 0x0DE0, 0x0DF1 }, { 0x0DF5, 0x0E00 }, { 0x0E3B, 0x0E3E },
-{ 0x0E5C, 0x0E80 }, { 0x0E83, 0x0E83 }, { 0x0E85, 0x0E86 },
-{ 0x0E89, 0x0E89 }, { 0x0E8B, 0x0E8C }, { 0x0E8E, 0x0E93 },
-{ 0x0E98, 0x0E98

[PATCH] D110422: [AIX] Enable PGO without LTO

2021-09-27 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

@MaskRay Do you have further comments or alternative solutions? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110422

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


[PATCH] D108560: [clang-tidy] Add support for NOLINTBEGIN ... NOLINTEND comments to suppress clang-tidy warnings over multiple lines

2021-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D108560#3020444 , @salman-javed-nz 
wrote:

> Also, in your example, you have begun all checks (`check`, `check2`, `check3` 
> ... `checkN`) but only ended one of them. The remaining checks are still 
> awaiting a `NOLINTEND` comment of some sort.

+1

> I say all this in the interest of keeping the Clang-Tidy code simple, and 
> reducing the amount of weird behavior that is possible (due to mistakes, lack 
> of knowledge, or "creative" use of the feature). I rather this feature be 
> strict and limited in scope, rather than flexible enough to be used in 
> unforeseen error-prone ways.

Thank you for the careful evaluation -- I agree with you!

> Perhaps this feature can be extended in the future (if need be) after it gets 
> some use and user feedback comes in?

Agreed.




Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:400-401
+  bool SuppressionIsSpecific;
+  for (const auto &Line : Lines) {
+if (isNOLINTFound("NOLINTBEGIN", CheckName, Line, &NolintIndex,
+  &SuppressionIsSpecific)) {

`List` is the same on every iteration through the loop, so we might as well set 
it once and reuse it.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:404-406
+  auto &List =
+  SuppressionIsSpecific ? SpecificNolintBegins : GlobalNolintBegins;
+  List.emplace_back(LinesLoc.getLocWithOffset(NolintIndex));





Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:410-412
+  auto &List =
+  SuppressionIsSpecific ? SpecificNolintBegins : GlobalNolintBegins;
+  if (!List.empty()) {





Comment at: clang-tools-extra/docs/clang-tidy/index.rst:306-308
+line*. The ``NOLINTBEGIN`` and ``NOLINTEND`` comments allow suppressing
+clang-tidy warnings on *multiple lines* (affecting all lines between the two
+comments).

We should also document the diagnostic behavior of the comments themselves (the 
fact that misusing these can generate diagnostics).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108560

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


[clang] 63bb2d5 - [clang] Put original flags on 'Driver args:' crash report line

2021-09-27 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-09-27T10:24:46-04:00
New Revision: 63bb2d585e9760cbc2251f95dfcc335506cad177

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

LOG: [clang] Put original flags on 'Driver args:' crash report line

We used to put the canonical spelling of flags after alias processing
on that line. For clang-cl in particular, that meant that we put flags
on that line that the clang-cl driver doesn't even accept, and the
"Driver args:" line wasn't usable.

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

Added: 
clang/test/Driver/crash-report-clang-cl.c

Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index b2fb21b7052a..b32fc6507464 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1216,8 +1216,14 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 
 static void printArgList(raw_ostream &OS, const llvm::opt::ArgList &Args) {
   llvm::opt::ArgStringList ASL;
-  for (const auto *A : Args)
+  for (const auto *A : Args) {
+// Use user's original spelling of flags. For example, use
+// `/source-charset:utf-8` instead of `-finput-charset=utf-8` if the user
+// wrote the former.
+while (A->getAlias())
+  A = A->getAlias();
 A->render(Args, ASL);
+  }
 
   for (auto I = ASL.begin(), E = ASL.end(); I != E; ++I) {
 if (I != ASL.begin())

diff  --git a/clang/test/Driver/crash-report-clang-cl.c 
b/clang/test/Driver/crash-report-clang-cl.c
new file mode 100644
index ..c4a89f974777
--- /dev/null
+++ b/clang/test/Driver/crash-report-clang-cl.c
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1   \
+// RUN: not %clang_cl -fsyntax-only /Brepro /source-charset:utf-8 \
+// RUN: -- %s 2>&1 | FileCheck %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
+// REQUIRES: crash-recovery
+
+#pragma clang __debug crash
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-clang-cl-{{.*}}.c
+// CHECKSH: # Crash reproducer
+// CHECKSH-NEXT: # Driver args: {{.*}}"-fsyntax-only"
+// CHECKSH-SAME: /Brepro
+// CHECKSH-SAME: /source-charset:utf-8
+// CHECKSH-NOT: -mno-incremental-linker-compatible
+// CHECKSH-NOT: -finput-charset=utf-8
+// CHECKSH-NEXT: # Original command: {{.*$}}
+// CHECKSH-NEXT: "-cc1"
+// CHECKSH: "-main-file-name" "crash-report-clang-cl.c"
+// CHECKSH: "crash-report-{{[^ ]*}}.c"



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


[PATCH] D110458: [clang] Put original flags on 'Driver args:' crash report line

2021-09-27 Thread Nico Weber 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 rG63bb2d585e97: [clang] Put original flags on 'Driver 
args:' crash report line (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110458

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-report-clang-cl.c


Index: clang/test/Driver/crash-report-clang-cl.c
===
--- /dev/null
+++ clang/test/Driver/crash-report-clang-cl.c
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1   \
+// RUN: not %clang_cl -fsyntax-only /Brepro /source-charset:utf-8 \
+// RUN: -- %s 2>&1 | FileCheck %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
+// REQUIRES: crash-recovery
+
+#pragma clang __debug crash
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-clang-cl-{{.*}}.c
+// CHECKSH: # Crash reproducer
+// CHECKSH-NEXT: # Driver args: {{.*}}"-fsyntax-only"
+// CHECKSH-SAME: /Brepro
+// CHECKSH-SAME: /source-charset:utf-8
+// CHECKSH-NOT: -mno-incremental-linker-compatible
+// CHECKSH-NOT: -finput-charset=utf-8
+// CHECKSH-NEXT: # Original command: {{.*$}}
+// CHECKSH-NEXT: "-cc1"
+// CHECKSH: "-main-file-name" "crash-report-clang-cl.c"
+// CHECKSH: "crash-report-{{[^ ]*}}.c"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1216,8 +1216,14 @@
 
 static void printArgList(raw_ostream &OS, const llvm::opt::ArgList &Args) {
   llvm::opt::ArgStringList ASL;
-  for (const auto *A : Args)
+  for (const auto *A : Args) {
+// Use user's original spelling of flags. For example, use
+// `/source-charset:utf-8` instead of `-finput-charset=utf-8` if the user
+// wrote the former.
+while (A->getAlias())
+  A = A->getAlias();
 A->render(Args, ASL);
+  }
 
   for (auto I = ASL.begin(), E = ASL.end(); I != E; ++I) {
 if (I != ASL.begin())


Index: clang/test/Driver/crash-report-clang-cl.c
===
--- /dev/null
+++ clang/test/Driver/crash-report-clang-cl.c
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1   \
+// RUN: not %clang_cl -fsyntax-only /Brepro /source-charset:utf-8 \
+// RUN: -- %s 2>&1 | FileCheck %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
+// REQUIRES: crash-recovery
+
+#pragma clang __debug crash
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-clang-cl-{{.*}}.c
+// CHECKSH: # Crash reproducer
+// CHECKSH-NEXT: # Driver args: {{.*}}"-fsyntax-only"
+// CHECKSH-SAME: /Brepro
+// CHECKSH-SAME: /source-charset:utf-8
+// CHECKSH-NOT: -mno-incremental-linker-compatible
+// CHECKSH-NOT: -finput-charset=utf-8
+// CHECKSH-NEXT: # Original command: {{.*$}}
+// CHECKSH-NEXT: "-cc1"
+// CHECKSH: "-main-file-name" "crash-report-clang-cl.c"
+// CHECKSH: "crash-report-{{[^ ]*}}.c"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1216,8 +1216,14 @@
 
 static void printArgList(raw_ostream &OS, const llvm::opt::ArgList &Args) {
   llvm::opt::ArgStringList ASL;
-  for (const auto *A : Args)
+  for (const auto *A : Args) {
+// Use user's original spelling of flags. For example, use
+// `/source-charset:utf-8` instead of `-finput-charset=utf-8` if the user
+// wrote the former.
+while (A->getAlias())
+  A = A->getAlias();
 A->render(Args, ASL);
+  }
 
   for (auto I = ASL.begin(), E = ASL.end(); I != E; ++I) {
 if (I != ASL.begin())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108469: Improve handling of static assert messages.

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375251.
cor3ntin added a comment.

Fix build and address most of Aaron's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/Lexer/null-character-in-literal.c
  clang/test/Misc/diag-special-chars.c
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/static-assert.cpp
  llvm/include/llvm/Support/Unicode.h
  llvm/lib/Support/Unicode.cpp

Index: llvm/lib/Support/Unicode.cpp
===
--- llvm/lib/Support/Unicode.cpp
+++ llvm/lib/Support/Unicode.cpp
@@ -19,197 +19,271 @@
 namespace sys {
 namespace unicode {
 
+/// Unicode code points of the categories L, M, N, P, S and Zs are considered
+/// printable.
+/// In addition, U+00AD SOFT HYPHEN is also considered printable, as
+/// it's actually displayed on most terminals. \return true if the character is
+/// considered printable.
 bool isPrintable(int UCS) {
-  // Sorted list of non-overlapping intervals of code points that are not
-  // supposed to be printable.
-  static const UnicodeCharRange NonPrintableRanges[] = {
-{ 0x, 0x001F }, { 0x007F, 0x009F }, { 0x034F, 0x034F },
-{ 0x0378, 0x0379 }, { 0x037F, 0x0383 }, { 0x038B, 0x038B },
-{ 0x038D, 0x038D }, { 0x03A2, 0x03A2 }, { 0x0528, 0x0530 },
-{ 0x0557, 0x0558 }, { 0x0560, 0x0560 }, { 0x0588, 0x0588 },
-{ 0x058B, 0x058E }, { 0x0590, 0x0590 }, { 0x05C8, 0x05CF },
-{ 0x05EB, 0x05EF }, { 0x05F5, 0x0605 }, { 0x061C, 0x061D },
-{ 0x06DD, 0x06DD }, { 0x070E, 0x070F }, { 0x074B, 0x074C },
-{ 0x07B2, 0x07BF }, { 0x07FB, 0x07FF }, { 0x082E, 0x082F },
-{ 0x083F, 0x083F }, { 0x085C, 0x085D }, { 0x085F, 0x089F },
-{ 0x08A1, 0x08A1 }, { 0x08AD, 0x08E3 }, { 0x08FF, 0x08FF },
-{ 0x0978, 0x0978 }, { 0x0980, 0x0980 }, { 0x0984, 0x0984 },
-{ 0x098D, 0x098E }, { 0x0991, 0x0992 }, { 0x09A9, 0x09A9 },
-{ 0x09B1, 0x09B1 }, { 0x09B3, 0x09B5 }, { 0x09BA, 0x09BB },
-{ 0x09C5, 0x09C6 }, { 0x09C9, 0x09CA }, { 0x09CF, 0x09D6 },
-{ 0x09D8, 0x09DB }, { 0x09DE, 0x09DE }, { 0x09E4, 0x09E5 },
-{ 0x09FC, 0x0A00 }, { 0x0A04, 0x0A04 }, { 0x0A0B, 0x0A0E },
-{ 0x0A11, 0x0A12 }, { 0x0A29, 0x0A29 }, { 0x0A31, 0x0A31 },
-{ 0x0A34, 0x0A34 }, { 0x0A37, 0x0A37 }, { 0x0A3A, 0x0A3B },
-{ 0x0A3D, 0x0A3D }, { 0x0A43, 0x0A46 }, { 0x0A49, 0x0A4A },
-{ 0x0A4E, 0x0A50 }, { 0x0A52, 0x0A58 }, { 0x0A5D, 0x0A5D },
-{ 0x0A5F, 0x0A65 }, { 0x0A76, 0x0A80 }, { 0x0A84, 0x0A84 },
-{ 0x0A8E, 0x0A8E }, { 0x0A92, 0x0A92 }, { 0x0AA9, 0x0AA9 },
-{ 0x0AB1, 0x0AB1 }, { 0x0AB4, 0x0AB4 }, { 0x0ABA, 0x0ABB },
-{ 0x0AC6, 0x0AC6 }, { 0x0ACA, 0x0ACA }, { 0x0ACE, 0x0ACF },
-{ 0x0AD1, 0x0ADF }, { 0x0AE4, 0x0AE5 }, { 0x0AF2, 0x0B00 },
-{ 0x0B04, 0x0B04 }, { 0x0B0D, 0x0B0E }, { 0x0B11, 0x0B12 },
-{ 0x0B29, 0x0B29 }, { 0x0B31, 0x0B31 }, { 0x0B34, 0x0B34 },
-{ 0x0B3A, 0x0B3B }, { 0x0B45, 0x0B46 }, { 0x0B49, 0x0B4A },
-{ 0x0B4E, 0x0B55 }, { 0x0B58, 0x0B5B }, { 0x0B5E, 0x0B5E },
-{ 0x0B64, 0x0B65 }, { 0x0B78, 0x0B81 }, { 0x0B84, 0x0B84 },
-{ 0x0B8B, 0x0B8D }, { 0x0B91, 0x0B91 }, { 0x0B96, 0x0B98 },
-{ 0x0B9B, 0x0B9B }, { 0x0B9D, 0x0B9D }, { 0x0BA0, 0x0BA2 },
-{ 0x0BA5, 0x0BA7 }, { 0x0BAB, 0x0BAD }, { 0x0BBA, 0x0BBD },
-{ 0x0BC3, 0x0BC5 }, { 0x0BC9, 0x0BC9 }, { 0x0BCE, 0x0BCF },
-{ 0x0BD1, 0x0BD6 }, { 0x0BD8, 0x0BE5 }, { 0x0BFB, 0x0C00 },
-{ 0x0C04, 0x0C04 }, { 0x0C0D, 0x0C0D }, { 0x0C11, 0x0C11 },
-{ 0x0C29, 0x0C29 }, { 0x0C34, 0x0C34 }, { 0x0C3A, 0x0C3C },
-{ 0x0C45, 0x0C45 }, { 0x0C49, 0x0C49 }, { 0x0C4E, 0x0C54 },
-{ 0x0C57, 0x0C57 }, { 0x0C5A, 0x0C5F }, { 0x0C64, 0x0C65 },
-{ 0x0C70, 0x0C77 }, { 0x0C80, 0x0C81 }, { 0x0C84, 0x0C84 },
-{ 0x0C8D, 0x0C8D }, { 0x0C91, 0x0C91 }, { 0x0CA9, 0x0CA9 },
-{ 0x0CB4, 0x0CB4 }, { 0x0CBA, 0x0CBB }, { 0x0CC5, 0x0CC5 },
-{ 0x0CC9, 0x0CC9 }, { 0x0CCE, 0x0CD4 }, { 0x0CD7, 0x0CDD },
-{ 0x0CDF, 0x0CDF }, { 0x0CE4, 0x0CE5 }, { 0x0CF0, 0x0CF0 },
-{ 0x0CF3, 0x0D01 }, { 0x0D04, 0x0D04 }, { 0x0D0D, 0x0D0D },
-{ 0x0D11, 0x0D11 }, { 0x0D3B, 0x0D3C }, { 0x0D45, 0x0D45 },
-{ 0x0D49, 0x0D49 }, { 0x0D4F, 0x0D56 }, { 0x0D58, 0x0D5F },
-{ 0x0D64, 0x0D65 }, { 0x0D76, 0x0D78 }, { 0x0D80, 0x0D81 },
-{ 0x0D84, 0x0D84 }, { 0x0D97, 0x0D99 }, { 0x0DB2, 0x0DB2 },
-{ 0x0DBC, 0x0DBC }, { 0x0DBE, 0x0DBF }, { 0x0DC7, 0x0DC9 },
-{ 0x0DCB, 0x0DCE }, { 0x0DD5, 0x0DD5 }, { 0x0DD7, 0x0DD7 },
-{ 0x0DE0, 0x0DF1 }, { 0x0DF5, 0

[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin marked 5 inline comments as done.
cor3ntin added inline comments.



Comment at: clang/include/clang/AST/Expr.h:1845
   StringRef getString() const {
-assert(getCharByteWidth() == 1 &&
+assert((isUnevaluated() || getCharByteWidth() == 1) &&
"This function is used in places that assume strings use char");

aaron.ballman wrote:
> Do we also want to assert that if it is unevaluated, it's char byte width 
> *is* one byte? (No such thing as a multibyte unevaluated string literal.)
This test is there because unevaluated strings don't have bytes at all! (trying 
to call `getCharByteWidth()` on them would assert)



Comment at: clang/lib/Lex/Pragma.cpp:807
   if (Tok.is(tok::string_literal) && !Tok.hasUDSuffix()) {
 StringLiteralParser Literal(Tok, PP);
 if (Literal.hadError)

aaron.ballman wrote:
> Should this also be modified?
Probably but because I'm not super familiar with module map things I preferred 
being conservative



Comment at: clang/lib/Parse/ParseDecl.cpp:374-376
+  ParsedAttr::Kind AttrKind =
+  ParsedAttr::getParsedKind(AttrName, ScopeName, Syntax);
+

aaron.ballman wrote:
> I don't think this needed to move?
We use attrKind in the else close after


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:422-423
 
-ExprResult ArgExpr(
-Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression()));
+ExprResult ArgExpr(Actions.CorrectDelayedTyposInExpr(
+ParseAttributeArgAsUnevaluatedLiteralOrExpression(AttrKind)));
 if (ArgExpr.isInvalid()) {

aaron.ballman wrote:
> cor3ntin wrote:
> > aaron.ballman wrote:
> > > cor3ntin wrote:
> > > > aaron.ballman wrote:
> > > > > Hmmm, I'm not certain about these changes.
> > > > > 
> > > > > For some attributes, the standard currently requires accepting any 
> > > > > kind of string literal (like `[[deprecated]]` 
> > > > > https://eel.is/c++draft/dcl.attr.deprecated#1). P2361 is proposing to 
> > > > > change that, but it's not yet accepted by WG21 (let alone WG14). So 
> > > > > giving errors in those cases is a bit of a hard sell -- I think 
> > > > > warnings would be a bit more reasonable.
> > > > > 
> > > > > But for other attributes (like `annotate`), it's a bit less clear 
> > > > > whether we should *prevent* literal prefixes because the attribute 
> > > > > can be used to have runtime impacts (for example, I can imagine 
> > > > > someone using `annotate` to emit the string literal bytes into the 
> > > > > resulting binary). In some cases, I think it's very reasonable (e.g., 
> > > > > `diagnose_if` should behave the same as `deprecated` and `nodiscard` 
> > > > > because those are purely about generating diagnostics at compile 
> > > > > time).
> > > > > 
> > > > > I kind of wonder whether we're going to want to tablegenerate whether 
> > > > > the argument needs to be parsed as unevaluated or not on an 
> > > > > attribute-by-attribute basis.
> > > > Yep, I would not expect this to get merge before P2361 but I think the 
> > > > implementation experience is useful and raised a bunch of good 
> > > > questions.
> > > > I don't think it ever makes sense to have `L` outside of literals - but 
> > > > people *might* do it currently, in which case there is a concern about 
> > > > whether it breaks code (I have found no evidence of that though).
> > > > 
> > > > If we wanted to inject these strings in the binary - in some form, then 
> > > > we might have to transcode them at that point.
> > > > I don't think the user would know if the string would be injected as 
> > > > wide or narrow (or something else) by the compiler.
> > > > 
> > > > `L` is really is want to convert that string _at that point_. in an 
> > > > attribute, strings might have multiple usages so it's better to delay 
> > > > any transcoding.
> > > > Does that make sense?
> > > > 
> > > > But I agree that a survey of what each attribute expects is in order.
> > > > 
> > > > 
> > > > 
> > > > Yep, I would not expect this to get merge before P2361 but I think the 
> > > > implementation experience is useful and raised a bunch of good 
> > > > questions.
> > > 
> > > Absolutely agreed, this is worthwhile effort!
> > > 
> > > > If we wanted to inject these strings in the binary - in some form, then 
> > > > we might have to transcode them at that point.
> > > > I don't think the user would know if the string would be injected as 
> > > > wide or narrow (or something else) by the compiler.
> > > 
> > > My intuition is that a user who writes `L"foo"` will expect a wide 
> > > `"foo"` to appear in the binary in the cases where the string ends up 
> > > making it that far.
> > > 
> > > > L is really is want to convert that string _at that point_. in an 
> > > > attribute, strings might have multiple usages so it's better to delay 
> > > > any transcoding.
> > > > Does that make sense?
> > > 
> > > Not yet, but I might get there eventually. :-D My concern is that vendor 
> > > attributes can basically do anything, so there's no reason to assume that 
> > > any given string literal usage should or should not transcode. I think we 
> > > have to decide on a case by case basis by letting the attributes specify 
> > > what they intend in their argument lists. However, my intuition is that 
> > > *most* attributes will expect unevaluated string literals because the 
> > > string argument doesn't get passed to LLVM.
> > The status quo is that everything transcodes.
> > 
> > But not transcoding, we do not destroy any information as to what is in the 
> > source.
> > 
> > If an attribute then wants to use the string later in such a way that it 
> > needs to transcode to a literal encoding (or something else, for example, 
> > one might imagine a fun scenario where literal are ASCII encoded and debug 
> > information are EBCDIC encoded), then that can be done, because the string 
> > still exists.
> > 
> > Whereas for literal specifically, we assume they will be evaluated by the 
> > abstract machine as per phase 5 so we transcode them immediately. which is 
> > destructive. we get away with it because the original spelling is in the 
> > source if we need 

[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 375253.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Switch to full DenseMap comparison in the tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110386

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -44,9 +44,11 @@
 namespace {
 
 using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::ElementsAreArray;
 using ::testing::IsEmpty;
+using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P(DeclNamed, Name, "") {
   if (NamedDecl *ND = dyn_cast(arg))
@@ -493,7 +495,7 @@
   auto EmptyPreamble =
   buildPreamble(testPath("foo.cpp"), *CI, Inputs, true, nullptr);
   ASSERT_TRUE(EmptyPreamble);
-  EXPECT_THAT(EmptyPreamble->Includes.MainFileIncludes, testing::IsEmpty());
+  EXPECT_THAT(EmptyPreamble->Includes.MainFileIncludes, IsEmpty());
 
   // Now build an AST using empty preamble and ensure patched includes worked.
   TU.Code = ModifiedContents.str();
@@ -507,18 +509,17 @@
   EXPECT_THAT(PatchedAST->getIncludeStructure().MainFileIncludes,
   testing::Pointwise(
   EqInc(), ExpectedAST.getIncludeStructure().MainFileIncludes));
-  auto StringMapToVector = [](const llvm::StringMap SM) {
-std::vector> Res;
-for (const auto &E : SM)
-  Res.push_back({E.first().str(), E.second});
-llvm::sort(Res);
-return Res;
-  };
   // Ensure file proximity signals are correct.
-  EXPECT_EQ(StringMapToVector(PatchedAST->getIncludeStructure().includeDepth(
-testPath("foo.cpp"))),
-StringMapToVector(ExpectedAST.getIncludeStructure().includeDepth(
-testPath("foo.cpp";
+  auto &FM = PatchedAST->getSourceManager().getFileManager();
+  // Copy so that we can use operator[] to get the children.
+  IncludeStructure Includes = PatchedAST->getIncludeStructure();
+  auto MainFE = FM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(MainFE);
+  auto MainID = Includes.getID(*MainFE);
+  auto AuxFE = FM.getFile(testPath("sub/aux.h"));
+  ASSERT_TRUE(AuxFE);
+  auto AuxID = Includes.getID(*AuxFE);
+  EXPECT_THAT(Includes.IncludeChildren[*MainID], Contains(AuxID));
 }
 
 TEST(ParsedASTTest, PatchesDeletedIncludes) {
@@ -551,18 +552,20 @@
   EXPECT_THAT(PatchedAST->getIncludeStructure().MainFileIncludes,
   testing::Pointwise(
   EqInc(), ExpectedAST.getIncludeStructure().MainFileIncludes));
-  auto StringMapToVector = [](const llvm::StringMap SM) {
-std::vector> Res;
-for (const auto &E : SM)
-  Res.push_back({E.first().str(), E.second});
-llvm::sort(Res);
-return Res;
-  };
   // Ensure file proximity signals are correct.
-  EXPECT_EQ(StringMapToVector(PatchedAST->getIncludeStructure().includeDepth(
-testPath("foo.cpp"))),
-StringMapToVector(ExpectedAST.getIncludeStructure().includeDepth(
-testPath("foo.cpp";
+  auto &FM = ExpectedAST.getSourceManager().getFileManager();
+  // Copy so that we can getOrCreateID().
+  IncludeStructure Includes = ExpectedAST.getIncludeStructure();
+  auto MainFE = FM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(MainFE);
+  auto MainID = Includes.getOrCreateID(*MainFE);
+  auto &PatchedFM = PatchedAST->getSourceManager().getFileManager();
+  IncludeStructure PatchedIncludes = PatchedAST->getIncludeStructure();
+  auto PatchedMainFE = PatchedFM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(PatchedMainFE);
+  auto PatchedMainID = PatchedIncludes.getOrCreateID(*PatchedMainFE);
+  EXPECT_EQ(Includes.includeDepth(MainID),
+PatchedIncludes.includeDepth(PatchedMainID));
 }
 
 // Returns Code guarded by #ifndef guards
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -17,6 +17,7 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
@@ -29,8 +30,10 @@
 using ::testing::AllOf;
 using ::testing::Contains;
 using ::testing::ElementsAre;
+using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::UnorderedElementsAre;
+using ::testing::UnorderedElementsAreArray;
 
 class HeadersTest : public ::testing::Test

[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/Headers.cpp:205
   CurrentLevel.push_back(Child);
-  const auto &Name = RealPathNames[Child];
   // Can't include files if we don't have their real path.
+  if (!RealPathNames[static_cast(Child)].empty())

sammccall wrote:
> kbobyrev wrote:
> > sammccall wrote:
> > > This is no longer true, we don't need the check.
> > Wait, why not? We still have unresolved includes, e.g. preamble patches are 
> > like that, their `RealPathName`s stay empty.
> Right, but why do we need to filter them out here?
> Can't we just drop them when we use them to seed the proximity sources?
I feel like producing them in the first place is kind of redundant, what signal 
does it give to the user through such API?

Getting some "hidden"/"unresolved" includes certainly feels rather confusing to 
me, post-filtering outside probably requires understanding of the internals 
which does not look like a good idea. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110386

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


[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/unittests/HeadersTests.cpp:234
+  auto Includes = collectIncludes();
+  EXPECT_THAT(Includes.IncludeChildren[getID(MainFile)],
+  UnorderedElementsAreArray({getID(FooHeader), getID(BarHeader)}));

sammccall wrote:
> kbobyrev wrote:
> > sammccall wrote:
> > > Why are we asserting on every element of the map one at a time, instead 
> > > of the whole map at once? Seems like it would be more regular and easier 
> > > to read.
> > > 
> > > I'd probably just write:
> > > ```
> > > DenseMap> Expected = { ... };
> > > EXPECT_EQ(Expected, Includes.IncludeChildren);
> > > ```
> > This would expect the elements in the map to be in a particular order, 
> > isn't this something we don't want?
> `==` on DenseMap doesn't consider order.
> 
> If you mean the order within map values (i.e. lists of child edges): these 
> are in the order the `#includes` appear in the file, which seems fine to 
> depend on to me
Yes, I initially meant the `SmallVector` order, but yeah, this seems 
reasonable, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110386

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


[clang] 1f5b60a - Explicitly specify -fintegrated-as to clang/test/Driver/compilation_database.c test case.

2021-09-27 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2021-09-27T09:56:18-05:00
New Revision: 1f5b60ad47f1fa0493e4c9d8080eace56f87ee0c

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

LOG: Explicitly specify -fintegrated-as to 
clang/test/Driver/compilation_database.c test case.

It appears that this test assumes that the toolchain utilizes the integrated
assembler by default, since the expected output in the CHECKs are
compilation_database.o.

However, this test fails on AIX as AIX does not utilize the integrated 
assembler.
On AIX, the output instead is of the form /tmp/compilation_database-*.s.
Thus, this patch explicitly adds the -fintegrated-as option to match the
assumption that the integrated assembler is used by default.

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

Added: 


Modified: 
clang/test/Driver/compilation_database.c

Removed: 




diff  --git a/clang/test/Driver/compilation_database.c 
b/clang/test/Driver/compilation_database.c
index 343b76aa44f3..da4d1c287cf2 100644
--- a/clang/test/Driver/compilation_database.c
+++ b/clang/test/Driver/compilation_database.c
@@ -1,9 +1,9 @@
 // RUN: mkdir -p %t.workdir && cd %t.workdir
-// RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 
-no-canonical-prefixes 2>&1 | FileCheck %s
+// RUN: %clang -fintegrated-as -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s 
-Wall -MJ - -no-canonical-prefixes 2>&1 | FileCheck %s
 // RUN: not %clang -c -x c %s -MJ %s/non-existant -no-canonical-prefixes 2>&1 
| FileCheck --check-prefix=ERROR %s
 
-// CHECK: { "directory": "{{[^"]*}}workdir",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
-// CHECK: { "directory": "{{.*}}",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{[^"]*}}workdir",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "-fintegrated-as", "--sysroot=somewhere", "-c", "-Wall",{{.*}} 
"--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{.*}}",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "-fintegrated-as", "--sysroot=somewhere", "-c", "-Wall",{{.*}} 
"--target={{[^"]+}}"]},
 // ERROR: error: compilation database '{{.*}}/non-existant' could not be 
opened:
 
 int main(void) {



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


[PATCH] D110431: Explicitly specify -fintegrated-as to clang/test/Driver/compilation_database.c test case.

2021-09-27 Thread Amy Kwan 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 rG1f5b60ad47f1: Explicitly specify -fintegrated-as to 
clang/test/Driver/compilation_database.c… (authored by amyk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110431

Files:
  clang/test/Driver/compilation_database.c


Index: clang/test/Driver/compilation_database.c
===
--- clang/test/Driver/compilation_database.c
+++ clang/test/Driver/compilation_database.c
@@ -1,9 +1,9 @@
 // RUN: mkdir -p %t.workdir && cd %t.workdir
-// RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 
-no-canonical-prefixes 2>&1 | FileCheck %s
+// RUN: %clang -fintegrated-as -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s 
-Wall -MJ - -no-canonical-prefixes 2>&1 | FileCheck %s
 // RUN: not %clang -c -x c %s -MJ %s/non-existant -no-canonical-prefixes 2>&1 
| FileCheck --check-prefix=ERROR %s
 
-// CHECK: { "directory": "{{[^"]*}}workdir",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
-// CHECK: { "directory": "{{.*}}",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{[^"]*}}workdir",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "-fintegrated-as", "--sysroot=somewhere", "-c", "-Wall",{{.*}} 
"--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{.*}}",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "-fintegrated-as", "--sysroot=somewhere", "-c", "-Wall",{{.*}} 
"--target={{[^"]+}}"]},
 // ERROR: error: compilation database '{{.*}}/non-existant' could not be 
opened:
 
 int main(void) {


Index: clang/test/Driver/compilation_database.c
===
--- clang/test/Driver/compilation_database.c
+++ clang/test/Driver/compilation_database.c
@@ -1,9 +1,9 @@
 // RUN: mkdir -p %t.workdir && cd %t.workdir
-// RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - -no-canonical-prefixes 2>&1 | FileCheck %s
+// RUN: %clang -fintegrated-as -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - -no-canonical-prefixes 2>&1 | FileCheck %s
 // RUN: not %clang -c -x c %s -MJ %s/non-existant -no-canonical-prefixes 2>&1 | FileCheck --check-prefix=ERROR %s
 
-// CHECK: { "directory": "{{[^"]*}}workdir",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", "[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
-// CHECK: { "directory": "{{.*}}",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", "[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{[^"]*}}workdir",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", "[[SRC]]", "-fintegrated-as", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{.*}}",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", "[[SRC]]", "-fintegrated-as", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
 // ERROR: error: compilation database '{{.*}}/non-existant' could not be opened:
 
 int main(void) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Pls update the description of the patch and also make sure it passes internal 
CI.




Comment at: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu:1
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -x hip -emit-llvm -S 
-o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm 
-amdgpu-function-calls=false | \

this test needs

// REQUIRES: amdgpu-registered-target, clang-driver



Comment at: llvm/test/CodeGen/AMDGPU/inline-calls.ll:2-3
 ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck  
%s
-; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck  %s
-; RUN: llc -march=r600 -mcpu=redwood -verify-machineinstrs < %s | FileCheck %s
 

why these two lines are removed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-27 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

In D109707#3016438 , @gandhi21299 
wrote:

> - replaced a `cast` with a `dyn_cast` since the return value from 
> `getCalleeFunction()` is not always a Function
> - `RUN on line 2` was causing 2 more scalar registers to be used on tonga due 
> to @func_alias not being inlined, hence I eliminated that test
> - `RUN on line 3` generated a call instruction to an aliased function which 
> is not supported on r600 (according to @arsenm ), hence I eliminated that 
> test as well

@yaxunl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D105759#3024419 , @aaron.ballman 
wrote:

> Should we also change this to parse an unevaluated string literal: 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/ModuleMap.cpp#L1594
> Similar question for all the uses in OpenMP stemming from: 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseOpenMP.cpp#L825
>  (https://www.openmp.org/spec-html/5.1/openmp.html is the OpenMP spec but I 
> didn't see any mention of encoding prefixes when I peeked)

Maybe - but I don't know anything about OpenMP.
I tried to be conservative in where I apply the change

> I think we still need to handle UDLs so that we parse the declaration's `""` 
> as an unevaluated string literal.

There is a different diagnostic, but the semantic is correct.  Not sure it 
would be worth it to change it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375265.
cor3ntin added a comment.

Address Aaron's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

Files:
  clang-tools-extra/test/clang-tidy/checkers/modernize-unary-static-assert.cpp
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/FixIt/fixit-static-assert.cpp
  clang/test/Parser/asm.c
  clang/test/Parser/asm.cpp
  clang/test/Parser/attr-availability-xcore.c
  clang/test/Parser/attr-availability.c
  clang/test/Sema/asm.c
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -28,12 +28,12 @@
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{static_assert failed L"\x"}}
-static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u"\U000317FF"}}
+static_assert(false, L"\x"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, u"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 // FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}}
-static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}}
-static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFgoop"}}
+static_assert(false, u8"Ω"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\u1234"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 
 template struct AlwaysFails {
   // Only give one error here.
Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -37,14 +37,17 @@
   asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
-  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
+  asm("nop"
+  : "=a"(a)
+  : "b"(b)
+  : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
 }
 
 // rdar://6094010
 void test3() {
   int x;
-  asm(L"foo" : "=r"(x)); // expected-error {{wide string}}
-  asm("foo" : L"=r"(x)); // expected-error {{wide string}}
+  asm(L"foo" : "=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+  asm("foo" : L"=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 }
 
 // 
Index: clang/test/Parser/attr-availability.c
===
--- clang/test/Parser/attr-availability.c
+++ clang/test/Parser/attr-availability.c
@@ -18,21 +18,25 @@
 
 void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
 
-void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{an unevaluated string literal cannot have an 

[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375267.
cor3ntin added a comment.

Address Aaron's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

Files:
  clang-tools-extra/test/clang-tidy/checkers/modernize-unary-static-assert.cpp
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/FixIt/fixit-static-assert.cpp
  clang/test/Parser/asm.c
  clang/test/Parser/asm.cpp
  clang/test/Parser/attr-availability-xcore.c
  clang/test/Parser/attr-availability.c
  clang/test/Sema/asm.c
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -28,12 +28,12 @@
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{static_assert failed L"\x"}}
-static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u"\U000317FF"}}
+static_assert(false, L"\x"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, u"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 // FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}}
-static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}}
-static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFgoop"}}
+static_assert(false, u8"Ω"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\u1234"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 
 template struct AlwaysFails {
   // Only give one error here.
Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -37,14 +37,17 @@
   asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
-  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
+  asm("nop"
+  : "=a"(a)
+  : "b"(b)
+  : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
 }
 
 // rdar://6094010
 void test3() {
   int x;
-  asm(L"foo" : "=r"(x)); // expected-error {{wide string}}
-  asm("foo" : L"=r"(x)); // expected-error {{wide string}}
+  asm(L"foo" : "=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+  asm("foo" : L"=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 }
 
 // 
Index: clang/test/Parser/attr-availability.c
===
--- clang/test/Parser/attr-availability.c
+++ clang/test/Parser/attr-availability.c
@@ -18,21 +18,25 @@
 
 void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
 
-void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{an unevaluated string literal cannot have an e

[PATCH] D110429: [OpenMP] Introduce a new worksharing RTL function for distribute

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

LG.

We might be able to revert/simplify this eventually again but for now it makes 
it much simpler to distinguish the distribute and workshare (=for) via their 
call site.




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2879
+StaticInitFunction =
+createForStaticInitFunction(Values.IVSize, Values.IVSigned);
+

Could we pass the 4 potential functions to `createForStaticInitFunction` (or 
similar name) to avoid the duplication? Or just pass a flag.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110429

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


[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Expr.h:1845
   StringRef getString() const {
-assert(getCharByteWidth() == 1 &&
+assert((isUnevaluated() || getCharByteWidth() == 1) &&
"This function is used in places that assume strings use char");

cor3ntin wrote:
> aaron.ballman wrote:
> > Do we also want to assert that if it is unevaluated, it's char byte width 
> > *is* one byte? (No such thing as a multibyte unevaluated string literal.)
> This test is there because unevaluated strings don't have bytes at all! 
> (trying to call `getCharByteWidth()` on them would assert)
Ah, good point!



Comment at: clang/lib/Lex/Pragma.cpp:807
   if (Tok.is(tok::string_literal) && !Tok.hasUDSuffix()) {
 StringLiteralParser Literal(Tok, PP);
 if (Literal.hadError)

cor3ntin wrote:
> aaron.ballman wrote:
> > Should this also be modified?
> Probably but because I'm not super familiar with module map things I 
> preferred being conservative
Paging @rsmith for opinions.

Lacking those opinions, I think being conservative here is fine.



Comment at: clang/lib/Parse/ParseDecl.cpp:374-376
+  ParsedAttr::Kind AttrKind =
+  ParsedAttr::getParsedKind(AttrName, ScopeName, Syntax);
+

cor3ntin wrote:
> aaron.ballman wrote:
> > I don't think this needed to move?
> We use attrKind in the else close after
Derp, my eyes when crossed, I thought the scope was still fine. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D106876: Remove non-affecting module maps from PCM files.

2021-09-27 Thread Ilya Kuteev via Phabricator via cfe-commits
ilyakuteev updated this revision to Diff 375272.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106876

Files:
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
  clang/test/Modules/add-remove-irrelevant-mobile-map.m
  clang/test/SemaCXX/Inputs/compare.modulemap
  clang/test/SemaCXX/compare-modules-cxx2a.cpp

Index: clang/test/SemaCXX/compare-modules-cxx2a.cpp
===
--- clang/test/SemaCXX/compare-modules-cxx2a.cpp
+++ clang/test/SemaCXX/compare-modules-cxx2a.cpp
@@ -1,15 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -I%S/Inputs %s -fno-modules-error-recovery
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
 
-#pragma clang module build compare
-module compare {
-  explicit module cmp {}
-  explicit module other {}
-}
-#pragma clang module contents
-#pragma clang module begin compare.cmp
-#include "std-compare.h"
-#pragma clang module end
-#pragma clang module endbuild
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -fmodules-cache-path=%t.mcp -I%S/Inputs %s -fno-modules-error-recovery -fmodule-map-file=%S/Inputs/compare.modulemap
 
 struct CC { CC(...); };
 
@@ -24,10 +16,10 @@
 
 // expected-note@std-compare.h:* 2+{{not reachable}}
 
-void b() { void(0 <=> 0); } // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+void b() { void(0 <=> 0); } // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 
 struct B {
-  CC operator<=>(const B&) const = default; // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+  CC operator<=>(const B&) const = default; // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 };
 auto vb = B() <=> B(); // expected-note {{required here}}
 
Index: clang/test/SemaCXX/Inputs/compare.modulemap
===
--- /dev/null
+++ clang/test/SemaCXX/Inputs/compare.modulemap
@@ -0,0 +1,6 @@
+module compare {
+  explicit module cmp {
+header "std-compare.h"
+  }
+  explicit module other {}
+}
Index: clang/test/Modules/add-remove-irrelevant-mobile-map.m
===
--- /dev/null
+++ clang/test/Modules/add-remove-irrelevant-mobile-map.m
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
+
+// Build without b.modulemap
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap %s -verify
+// RUN: cp %t.mcp/a.pcm %t/a.pcm
+
+// Build with b.modulemap
+// RUN: rm -rf %t.mcp
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap %s -verify
+// RUN: not diff %t.mcp/a.pcm %t/a.pcm
+
+// expected-no-diagnostics
+
+@import a;
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
@@ -0,0 +1 @@
+module b { }
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
@@ -0,0 +1 @@
+module a { }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -149,6 +149,59 @@
 
 namespace {
 
+std::set GetAllModuleMaps(const HeaderSearch &HS,
+ Module *RootModule) {
+  std::set ModuleMaps{};
+  std::set ProcessedModules;
+  SmallVector ModulesToProcess{RootModule};
+
+  SmallVector FilesByUID;
+  HS.getFileMgr().GetUniqueIDMapping(FilesByUID);
+
+  if (FilesByUID.size() > HS.header_file_size())
+FilesByUID.resize(HS.header_file_size());
+
+  for (unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
+const FileEntry *File = FilesByUID[UID];
+if (!File)
+  continue;
+
+const HeaderFileInfo *HFI =
+HS.getExistingFileInfo(File, /*WantExternal*/ false);
+if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
+  continue;
+
+for (const auto &KH : HS.findAllModulesForHead

[PATCH] D108469: Improve handling of static assert messages.

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375273.
cor3ntin added a comment.

Correctly rebase on top of D105759 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/Lexer/null-character-in-literal.c
  clang/test/Misc/diag-special-chars.c
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/static-assert.cpp
  llvm/include/llvm/Support/Unicode.h
  llvm/lib/Support/Unicode.cpp

Index: llvm/lib/Support/Unicode.cpp
===
--- llvm/lib/Support/Unicode.cpp
+++ llvm/lib/Support/Unicode.cpp
@@ -19,197 +19,271 @@
 namespace sys {
 namespace unicode {
 
+/// Unicode code points of the categories L, M, N, P, S and Zs are considered
+/// printable.
+/// In addition, U+00AD SOFT HYPHEN is also considered printable, as
+/// it's actually displayed on most terminals. \return true if the character is
+/// considered printable.
 bool isPrintable(int UCS) {
-  // Sorted list of non-overlapping intervals of code points that are not
-  // supposed to be printable.
-  static const UnicodeCharRange NonPrintableRanges[] = {
-{ 0x, 0x001F }, { 0x007F, 0x009F }, { 0x034F, 0x034F },
-{ 0x0378, 0x0379 }, { 0x037F, 0x0383 }, { 0x038B, 0x038B },
-{ 0x038D, 0x038D }, { 0x03A2, 0x03A2 }, { 0x0528, 0x0530 },
-{ 0x0557, 0x0558 }, { 0x0560, 0x0560 }, { 0x0588, 0x0588 },
-{ 0x058B, 0x058E }, { 0x0590, 0x0590 }, { 0x05C8, 0x05CF },
-{ 0x05EB, 0x05EF }, { 0x05F5, 0x0605 }, { 0x061C, 0x061D },
-{ 0x06DD, 0x06DD }, { 0x070E, 0x070F }, { 0x074B, 0x074C },
-{ 0x07B2, 0x07BF }, { 0x07FB, 0x07FF }, { 0x082E, 0x082F },
-{ 0x083F, 0x083F }, { 0x085C, 0x085D }, { 0x085F, 0x089F },
-{ 0x08A1, 0x08A1 }, { 0x08AD, 0x08E3 }, { 0x08FF, 0x08FF },
-{ 0x0978, 0x0978 }, { 0x0980, 0x0980 }, { 0x0984, 0x0984 },
-{ 0x098D, 0x098E }, { 0x0991, 0x0992 }, { 0x09A9, 0x09A9 },
-{ 0x09B1, 0x09B1 }, { 0x09B3, 0x09B5 }, { 0x09BA, 0x09BB },
-{ 0x09C5, 0x09C6 }, { 0x09C9, 0x09CA }, { 0x09CF, 0x09D6 },
-{ 0x09D8, 0x09DB }, { 0x09DE, 0x09DE }, { 0x09E4, 0x09E5 },
-{ 0x09FC, 0x0A00 }, { 0x0A04, 0x0A04 }, { 0x0A0B, 0x0A0E },
-{ 0x0A11, 0x0A12 }, { 0x0A29, 0x0A29 }, { 0x0A31, 0x0A31 },
-{ 0x0A34, 0x0A34 }, { 0x0A37, 0x0A37 }, { 0x0A3A, 0x0A3B },
-{ 0x0A3D, 0x0A3D }, { 0x0A43, 0x0A46 }, { 0x0A49, 0x0A4A },
-{ 0x0A4E, 0x0A50 }, { 0x0A52, 0x0A58 }, { 0x0A5D, 0x0A5D },
-{ 0x0A5F, 0x0A65 }, { 0x0A76, 0x0A80 }, { 0x0A84, 0x0A84 },
-{ 0x0A8E, 0x0A8E }, { 0x0A92, 0x0A92 }, { 0x0AA9, 0x0AA9 },
-{ 0x0AB1, 0x0AB1 }, { 0x0AB4, 0x0AB4 }, { 0x0ABA, 0x0ABB },
-{ 0x0AC6, 0x0AC6 }, { 0x0ACA, 0x0ACA }, { 0x0ACE, 0x0ACF },
-{ 0x0AD1, 0x0ADF }, { 0x0AE4, 0x0AE5 }, { 0x0AF2, 0x0B00 },
-{ 0x0B04, 0x0B04 }, { 0x0B0D, 0x0B0E }, { 0x0B11, 0x0B12 },
-{ 0x0B29, 0x0B29 }, { 0x0B31, 0x0B31 }, { 0x0B34, 0x0B34 },
-{ 0x0B3A, 0x0B3B }, { 0x0B45, 0x0B46 }, { 0x0B49, 0x0B4A },
-{ 0x0B4E, 0x0B55 }, { 0x0B58, 0x0B5B }, { 0x0B5E, 0x0B5E },
-{ 0x0B64, 0x0B65 }, { 0x0B78, 0x0B81 }, { 0x0B84, 0x0B84 },
-{ 0x0B8B, 0x0B8D }, { 0x0B91, 0x0B91 }, { 0x0B96, 0x0B98 },
-{ 0x0B9B, 0x0B9B }, { 0x0B9D, 0x0B9D }, { 0x0BA0, 0x0BA2 },
-{ 0x0BA5, 0x0BA7 }, { 0x0BAB, 0x0BAD }, { 0x0BBA, 0x0BBD },
-{ 0x0BC3, 0x0BC5 }, { 0x0BC9, 0x0BC9 }, { 0x0BCE, 0x0BCF },
-{ 0x0BD1, 0x0BD6 }, { 0x0BD8, 0x0BE5 }, { 0x0BFB, 0x0C00 },
-{ 0x0C04, 0x0C04 }, { 0x0C0D, 0x0C0D }, { 0x0C11, 0x0C11 },
-{ 0x0C29, 0x0C29 }, { 0x0C34, 0x0C34 }, { 0x0C3A, 0x0C3C },
-{ 0x0C45, 0x0C45 }, { 0x0C49, 0x0C49 }, { 0x0C4E, 0x0C54 },
-{ 0x0C57, 0x0C57 }, { 0x0C5A, 0x0C5F }, { 0x0C64, 0x0C65 },
-{ 0x0C70, 0x0C77 }, { 0x0C80, 0x0C81 }, { 0x0C84, 0x0C84 },
-{ 0x0C8D, 0x0C8D }, { 0x0C91, 0x0C91 }, { 0x0CA9, 0x0CA9 },
-{ 0x0CB4, 0x0CB4 }, { 0x0CBA, 0x0CBB }, { 0x0CC5, 0x0CC5 },
-{ 0x0CC9, 0x0CC9 }, { 0x0CCE, 0x0CD4 }, { 0x0CD7, 0x0CDD },
-{ 0x0CDF, 0x0CDF }, { 0x0CE4, 0x0CE5 }, { 0x0CF0, 0x0CF0 },
-{ 0x0CF3, 0x0D01 }, { 0x0D04, 0x0D04 }, { 0x0D0D, 0x0D0D },
-{ 0x0D11, 0x0D11 }, { 0x0D3B, 0x0D3C }, { 0x0D45, 0x0D45 },
-{ 0x0D49, 0x0D49 }, { 0x0D4F, 0x0D56 }, { 0x0D58, 0x0D5F },
-{ 0x0D64, 0x0D65 }, { 0x0D76, 0x0D78 }, { 0x0D80, 0x0D81 },
-{ 0x0D84, 0x0D84 }, { 0x0D97, 0x0D99 }, { 0x0DB2, 0x0DB2 },
-{ 0x0DBC, 0x0DBC }, { 0x0DBE, 0x0DBF }, { 0x0DC7, 0x0DC9 },
-{ 0x0DCB, 0x0DCE }, { 0x0DD5, 0x0DD5 }, { 0x0DD7, 0x0DD7 },
-{ 0x0DE0, 0x0DF1 }, { 0x0DF5, 0x0E00 }, { 0x0E3B, 0x0E3E },
-{ 0x0E5C, 0x0E80 }, { 0x0E83, 0x0E83 }, { 0x0E85, 0x0E86 },
-{ 0x0E89, 0x0E89 }, 

[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: erichkeane, rjmccall.
aaron.ballman added a comment.

In general, I think this is shaping up nicely and is almost complete.  I'm 
adding some additional reviewer though, as this is a somewhat experimental 
patch for a WG21 proposal that has not been accepted yet and I want to make 
sure that I'm not missing something. That may also solve the few open questions 
that still remain.




Comment at: clang/lib/AST/Expr.cpp:1110-
+StringLiteralBits.IsPascal = Pascal;
+  }
+  else {
+  StringLiteralBits.CharByteWidth = 1;

I'd recommend running the entire patch through clang-format though: 
https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting



Comment at: clang/lib/Lex/LiteralSupport.cpp:1542
+  for (const auto &Tok : StringToks) {
+// Unevaluated string literals can never have a prefix
+if (Unevaluated && Tok.getKind() != tok::string_literal) {

aaron.ballman wrote:
> 
Looks like this comment is still missing punctuation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 375277.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Resolve the last comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110386

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -44,9 +44,11 @@
 namespace {
 
 using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::ElementsAreArray;
 using ::testing::IsEmpty;
+using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P(DeclNamed, Name, "") {
   if (NamedDecl *ND = dyn_cast(arg))
@@ -493,7 +495,7 @@
   auto EmptyPreamble =
   buildPreamble(testPath("foo.cpp"), *CI, Inputs, true, nullptr);
   ASSERT_TRUE(EmptyPreamble);
-  EXPECT_THAT(EmptyPreamble->Includes.MainFileIncludes, testing::IsEmpty());
+  EXPECT_THAT(EmptyPreamble->Includes.MainFileIncludes, IsEmpty());
 
   // Now build an AST using empty preamble and ensure patched includes worked.
   TU.Code = ModifiedContents.str();
@@ -507,18 +509,17 @@
   EXPECT_THAT(PatchedAST->getIncludeStructure().MainFileIncludes,
   testing::Pointwise(
   EqInc(), ExpectedAST.getIncludeStructure().MainFileIncludes));
-  auto StringMapToVector = [](const llvm::StringMap SM) {
-std::vector> Res;
-for (const auto &E : SM)
-  Res.push_back({E.first().str(), E.second});
-llvm::sort(Res);
-return Res;
-  };
   // Ensure file proximity signals are correct.
-  EXPECT_EQ(StringMapToVector(PatchedAST->getIncludeStructure().includeDepth(
-testPath("foo.cpp"))),
-StringMapToVector(ExpectedAST.getIncludeStructure().includeDepth(
-testPath("foo.cpp";
+  auto &FM = PatchedAST->getSourceManager().getFileManager();
+  // Copy so that we can use operator[] to get the children.
+  IncludeStructure Includes = PatchedAST->getIncludeStructure();
+  auto MainFE = FM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(MainFE);
+  auto MainID = Includes.getID(*MainFE);
+  auto AuxFE = FM.getFile(testPath("sub/aux.h"));
+  ASSERT_TRUE(AuxFE);
+  auto AuxID = Includes.getID(*AuxFE);
+  EXPECT_THAT(Includes.IncludeChildren[*MainID], Contains(AuxID));
 }
 
 TEST(ParsedASTTest, PatchesDeletedIncludes) {
@@ -551,18 +552,20 @@
   EXPECT_THAT(PatchedAST->getIncludeStructure().MainFileIncludes,
   testing::Pointwise(
   EqInc(), ExpectedAST.getIncludeStructure().MainFileIncludes));
-  auto StringMapToVector = [](const llvm::StringMap SM) {
-std::vector> Res;
-for (const auto &E : SM)
-  Res.push_back({E.first().str(), E.second});
-llvm::sort(Res);
-return Res;
-  };
   // Ensure file proximity signals are correct.
-  EXPECT_EQ(StringMapToVector(PatchedAST->getIncludeStructure().includeDepth(
-testPath("foo.cpp"))),
-StringMapToVector(ExpectedAST.getIncludeStructure().includeDepth(
-testPath("foo.cpp";
+  auto &FM = ExpectedAST.getSourceManager().getFileManager();
+  // Copy so that we can getOrCreateID().
+  IncludeStructure Includes = ExpectedAST.getIncludeStructure();
+  auto MainFE = FM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(MainFE);
+  auto MainID = Includes.getOrCreateID(*MainFE);
+  auto &PatchedFM = PatchedAST->getSourceManager().getFileManager();
+  IncludeStructure PatchedIncludes = PatchedAST->getIncludeStructure();
+  auto PatchedMainFE = PatchedFM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(PatchedMainFE);
+  auto PatchedMainID = PatchedIncludes.getOrCreateID(*PatchedMainFE);
+  EXPECT_EQ(Includes.includeDepth(MainID)[MainID],
+PatchedIncludes.includeDepth(PatchedMainID)[PatchedMainID]);
 }
 
 // Returns Code guarded by #ifndef guards
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -17,6 +17,7 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
@@ -29,8 +30,10 @@
 using ::testing::AllOf;
 using ::testing::Contains;
 using ::testing::ElementsAre;
+using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::UnorderedElementsAre;
+using ::testing::UnorderedElementsAreArray;
 
 class HeadersTest : public ::testing::Test 

[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375278.
cor3ntin added a comment.

Formatting and missing punctuation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

Files:
  clang-tools-extra/test/clang-tidy/checkers/modernize-unary-static-assert.cpp
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/FixIt/fixit-static-assert.cpp
  clang/test/Parser/asm.c
  clang/test/Parser/asm.cpp
  clang/test/Parser/attr-availability-xcore.c
  clang/test/Parser/attr-availability.c
  clang/test/Sema/asm.c
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -28,12 +28,12 @@
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{static_assert failed L"\x"}}
-static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u"\U000317FF"}}
+static_assert(false, L"\x"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, u"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 // FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}}
-static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}}
-static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFgoop"}}
+static_assert(false, u8"Ω"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\u1234"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 
 template struct AlwaysFails {
   // Only give one error here.
Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -37,14 +37,17 @@
   asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
-  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
+  asm("nop"
+  : "=a"(a)
+  : "b"(b)
+  : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
 }
 
 // rdar://6094010
 void test3() {
   int x;
-  asm(L"foo" : "=r"(x)); // expected-error {{wide string}}
-  asm("foo" : L"=r"(x)); // expected-error {{wide string}}
+  asm(L"foo" : "=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+  asm("foo" : L"=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 }
 
 // 
Index: clang/test/Parser/attr-availability.c
===
--- clang/test/Parser/attr-availability.c
+++ clang/test/Parser/attr-availability.c
@@ -18,21 +18,25 @@
 
 void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
 
-void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{an unevaluated string literal cannot

[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:257
+
+def err_unevaluated_string_prefix : Error<
+  "an unevaluated string literal cannot have an encoding prefix">;

Is there value to combining these two diagnostics with a %select?



Comment at: clang/lib/Lex/LiteralSupport.cpp:108
+  unsigned CharWidth, DiagnosticsEngine *Diags,
+  const LangOptions &Features, bool Unevaluated) {
   const char *EscapeBegin = ThisTokBuf;

This is like the 3rd time we're using 'Unevaluated' as a bool parameter.  I 
have a pretty strong preference for making it a scoped-enum in 'Basic' 
somewhere.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1813
+Diags->Report(TokLoc, UnevaluatedStringHasUDL
+  ? diag::err_unevaluated_string_udl
+  : diag::err_string_concat_mixed_suffix)

Is this OK?  It looks like we're passing a ton of parameters to a diag type 
that doesn't have any wildcards?  



Comment at: clang/lib/Lex/LiteralSupport.cpp:95-96
+  case '?':
+  case 'n':
+  case 't':
+return true;

aaron.ballman wrote:
> aaron.ballman wrote:
> > cor3ntin wrote:
> > > aaron.ballman wrote:
> > > > Do you intend to miss a bunch of escapes like `\'` and `\r` (etc)?
> > > \' is there. I am less sure about '\r' and '\a'. for example. This is 
> > > something I realized after writing P2361.
> > > what does '\a` in static assert mean? even '\r' is not so obvious
> > Looking at the list again, I think only `\a` is really of interest here. I 
> > know some folks like @jfb have mentioned that `\a` could be used to 
> > generate an alert sound on a terminal, which is a somewhat useful feature 
> > for a failed static assertion if you squint at it hard enough.
> > 
> > But the rest of the missing ones do seem more questionable to support.
> @jfb and @cor3ntin -- any opinions on whether `\a` should be supported? My 
> opinion is that it should be supported because it has some utility for anyone 
> running the compiler from a command line, but it's a pretty weak opinion.
I might consider rejecting ANY character escape in the less-than-32 part of the 
table.  

For consistency at least, I don't see value in allowing \a if we're rejecting 
layout things like \t.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D106959: [PowerPC] swdiv builtins for XL compatibility

2021-09-27 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 375285.
quinnp added a comment.

Added a backend testcase which goes from `fdiv fast` to software estimate. 
Added a runline in the front end testcase that sets the fast math flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106959

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-swdiv.c
  llvm/test/CodeGen/PowerPC/fdiv.ll

Index: llvm/test/CodeGen/PowerPC/fdiv.ll
===
--- llvm/test/CodeGen/PowerPC/fdiv.ll
+++ llvm/test/CodeGen/PowerPC/fdiv.ll
@@ -23,3 +23,16 @@
   %3 = fdiv contract reassoc arcp nsz ninf float %0, %1
   ret float %3
 }
+
+define dso_local float @fdiv_fast(float %0, float %1) local_unnamed_addr {
+; CHECK-LABEL: fdiv_fast:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:xsresp 3, 2
+; CHECK-NEXT:xsmulsp 0, 1, 3
+; CHECK-NEXT:xsnmsubasp 1, 2, 0
+; CHECK-NEXT:xsmaddasp 0, 3, 1
+; CHECK-NEXT:fmr 1, 0
+; CHECK-NEXT:blr
+  %3 = fdiv fast float %0, %1
+  ret float %3
+}
Index: clang/test/CodeGen/builtins-ppc-xlcompat-swdiv.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-swdiv.c
@@ -0,0 +1,80 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -ffast-math -ffp-contract=fast \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s --check-prefix CHECK-OFAST
+
+extern double a;
+extern double b;
+extern float c;
+extern float d;
+
+// CHECK-LABEL:   @test_swdiv(
+// CHECK: [[TMP0:%.*]] = load double, double* @a
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b
+// CHECK-NEXT:[[SWDIV:%.*]] = fdiv double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[SWDIV]]
+//
+// CHECK-OFAST-LABEL:   @test_swdiv(
+// CHECK-OFAST: [[TMP0:%.*]] = load double, double* @a
+// CHECK-OFAST-NEXT:[[TMP1:%.*]] = load double, double* @b
+// CHECK-OFAST-NEXT:[[SWDIV:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-OFAST-NEXT:ret double [[SWDIV]]
+//
+double test_swdiv() {
+  return __swdiv(a, b);
+}
+
+// CHECK-LABEL:   @test_swdivs(
+// CHECK: [[TMP0:%.*]] = load float, float* @c
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @d
+// CHECK-NEXT:[[SWDIVS:%.*]] = fdiv float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret float [[SWDIVS]]
+//
+// CHECK-OFAST-LABEL:   @test_swdivs(
+// CHECK-OFAST: [[TMP0:%.*]] = load float, float* @c
+// CHECK-OFAST-NEXT:[[TMP1:%.*]] = load float, float* @d
+// CHECK-OFAST-NEXT:[[SWDIVS:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-OFAST-NEXT:ret float [[SWDIVS]]
+//
+float test_swdivs() {
+  return __swdivs(c, d);
+}
+
+// CHECK-LABEL:   @test_builtin_ppc_swdiv(
+// CHECK: [[TMP0:%.*]] = load double, double* @a
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b
+// CHECK-NEXT:[[SWDIV:%.*]] = fdiv double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[SWDIV]]
+//
+// CHECK-OFAST-LABEL:   @test_builtin_ppc_swdiv(
+// CHECK-OFAST: [[TMP0:%.*]] = load double, double* @a
+// CHECK-OFAST-NEXT:[[TMP1:%.*]] = load double, double* @b
+// CHECK-OFAST-NEXT:[[SWDIV:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-OFAST-NEXT:ret double [[SWDIV]]
+//
+double test_builtin_ppc_swdiv() {
+  return __builtin_ppc_swdiv(a, b);
+}
+
+// CHECK-LABEL:   @test_builtin_ppc_swdivs(
+// CHECK: [[TMP0:%.*]] = load float, float* @c
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @d
+// CHECK-NEXT:[[SWDIVS:%.*]] = fdiv float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret float [[SWDIVS]]
+//
+// CHECK-OFAST-LABEL:   @test_builtin_ppc_swdivs(
+// CHECK-OFAST: [[TMP0:%.*]] = load float, float* @c
+// CHECK-OFAST-NEXT:[[TMP1:%.*]] = load float, float* @d
+// CHECK-OFAST-NEXT:[[SWDIVS:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-OFAST-NEXT:ret float [[SWDIVS]]
+//
+float test_builtin_ppc_swdivs() {
+  return __builtin_ppc_swdivs(c, d);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -16035,6 +16035,9 @@
*this, E, Intrinsic::sqrt,
Intrinsic::experimental_constrained_s

[PATCH] D106959: [PowerPC] swdiv builtins for XL compatibility

2021-09-27 Thread Quinn Pham via Phabricator via cfe-commits
quinnp added a comment.

In D106959#3021069 , @NeHuang wrote:

> Do we already have a backend test case for `fdiv` emitting a software 
> estimate when `-Ofast` is used?

I've added a testcase in `llvm/test/CodeGen/PowerPC/fdiv.ll` which goes from 
`fdiv fast` to the assembly for the software divide estimate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106959

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


[PATCH] D110387: [Analyzer][NFC] Move RangeConstraintManager's def before ConstraintAssignor's def

2021-09-27 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision.
ASDenysPetrov added a comment.

LGTM. ?Should mention this as //NFC//.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110387

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


[clang-tools-extra] 0b1eff1 - [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-09-27T17:50:53+02:00
New Revision: 0b1eff1bc5d004b1964bb9b1667e3efc034f3f62

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

LOG: [clangd] Refactor IncludeStructure: use File (unsigned) for most 
computations

Preparation for D108194.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Headers.cpp
clang-tools-extra/clangd/Headers.h
clang-tools-extra/clangd/unittests/HeadersTests.cpp
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 69338814ebdd2..1033e5e92dcde 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1379,14 +1379,16 @@ class CodeCompleteFlow {
   FileDistanceOptions ProxOpts{}; // Use defaults.
   const auto &SM = Recorder->CCSema->getSourceManager();
   llvm::StringMap ProxSources;
-  for (auto &Entry : Includes.includeDepth(
-   SM.getFileEntryForID(SM.getMainFileID())->getName())) {
-auto &Source = ProxSources[Entry.getKey()];
-Source.Cost = Entry.getValue() * ProxOpts.IncludeCost;
+  auto MainFileID =
+  Includes.getOrCreateID(SM.getFileEntryForID(SM.getMainFileID()));
+  for (auto &HeaderIDAndDepth : Includes.includeDepth(MainFileID)) {
+auto &Source =
+ProxSources[Includes.getRealPath(HeaderIDAndDepth.getFirst())];
+Source.Cost = HeaderIDAndDepth.getSecond() * ProxOpts.IncludeCost;
 // Symbols near our transitive includes are good, but only consider
 // things in the same directory or below it. Otherwise there can be
 // many false positives.
-if (Entry.getValue() > 0)
+if (HeaderIDAndDepth.getSecond() > 0)
   Source.MaxUpTraversals = 1;
   }
   FileProximity.emplace(ProxSources, ProxOpts);

diff  --git a/clang-tools-extra/clangd/Headers.cpp 
b/clang-tools-extra/clangd/Headers.cpp
index 111b05849b81b..33304b818d6f4 100644
--- a/clang-tools-extra/clangd/Headers.cpp
+++ b/clang-tools-extra/clangd/Headers.cpp
@@ -67,8 +67,9 @@ class RecordHeaders : public PPCallbacks {
 // Treat as if included from the main file.
 IncludingFileEntry = SM.getFileEntryForID(MainFID);
   }
-  Out->recordInclude(IncludingFileEntry->getName(), File->getName(),
- File->tryGetRealPathName());
+  auto IncludingID = Out->getOrCreateID(IncludingFileEntry),
+   IncludedID = Out->getOrCreateID(File);
+  Out->IncludeChildren[IncludingID].push_back(IncludedID);
 }
   }
 
@@ -154,38 +155,41 @@ collectIncludeStructureCallback(const SourceManager &SM,
   return std::make_unique(SM, Out);
 }
 
-void IncludeStructure::recordInclude(llvm::StringRef IncludingName,
- llvm::StringRef IncludedName,
- llvm::StringRef IncludedRealName) {
-  auto Child = fileIndex(IncludedName);
-  if (!IncludedRealName.empty() && RealPathNames[Child].empty())
-RealPathNames[Child] = std::string(IncludedRealName);
-  auto Parent = fileIndex(IncludingName);
-  IncludeChildren[Parent].push_back(Child);
+llvm::Optional
+IncludeStructure::getID(const FileEntry *Entry) const {
+  auto It = NameToIndex.find(Entry->getName());
+  if (It == NameToIndex.end())
+return llvm::None;
+  return It->second;
 }
 
-unsigned IncludeStructure::fileIndex(llvm::StringRef Name) {
-  auto R = NameToIndex.try_emplace(Name, RealPathNames.size());
+IncludeStructure::HeaderID
+IncludeStructure::getOrCreateID(const FileEntry *Entry) {
+  auto R = NameToIndex.try_emplace(
+  Entry->getName(),
+  static_cast(RealPathNames.size()));
   if (R.second)
 RealPathNames.emplace_back();
-  return R.first->getValue();
+  IncludeStructure::HeaderID Result = R.first->getValue();
+  std::string &RealPathName = RealPathNames[static_cast(Result)];
+  if (RealPathName.empty())
+RealPathName = Entry->tryGetRealPathName().str();
+  return Result;
 }
 
-llvm::StringMap
-IncludeStructure::includeDepth(llvm::StringRef Root) const {
+llvm::DenseMap
+IncludeStructure::includeDepth(HeaderID Root) const {
   // Include depth 0 is the main file only.
-  llvm::StringMap Result;
+  llvm::DenseMap Result;
+  assert(static_cast(Root) < RealPathNames.size());
   Result[Root] = 0;
-  std::vector CurrentLevel;
-  llvm::DenseSet Seen;
-  auto It = NameToIndex.find(Root);
-  if (It != NameToIndex.end()) {
-CurrentLevel.push_back(It->second);
-Seen.insert(It->second);
-  }
+  std::vector CurrentLevel;
+  CurrentLevel.push_back(Root);

[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Kirill Bobyrev 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 rG0b1eff1bc5d0: [clangd] Refactor IncludeStructure: use File 
(unsigned) for most computations (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110386

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -44,9 +44,11 @@
 namespace {
 
 using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::ElementsAreArray;
 using ::testing::IsEmpty;
+using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P(DeclNamed, Name, "") {
   if (NamedDecl *ND = dyn_cast(arg))
@@ -493,7 +495,7 @@
   auto EmptyPreamble =
   buildPreamble(testPath("foo.cpp"), *CI, Inputs, true, nullptr);
   ASSERT_TRUE(EmptyPreamble);
-  EXPECT_THAT(EmptyPreamble->Includes.MainFileIncludes, testing::IsEmpty());
+  EXPECT_THAT(EmptyPreamble->Includes.MainFileIncludes, IsEmpty());
 
   // Now build an AST using empty preamble and ensure patched includes worked.
   TU.Code = ModifiedContents.str();
@@ -507,18 +509,17 @@
   EXPECT_THAT(PatchedAST->getIncludeStructure().MainFileIncludes,
   testing::Pointwise(
   EqInc(), ExpectedAST.getIncludeStructure().MainFileIncludes));
-  auto StringMapToVector = [](const llvm::StringMap SM) {
-std::vector> Res;
-for (const auto &E : SM)
-  Res.push_back({E.first().str(), E.second});
-llvm::sort(Res);
-return Res;
-  };
   // Ensure file proximity signals are correct.
-  EXPECT_EQ(StringMapToVector(PatchedAST->getIncludeStructure().includeDepth(
-testPath("foo.cpp"))),
-StringMapToVector(ExpectedAST.getIncludeStructure().includeDepth(
-testPath("foo.cpp";
+  auto &FM = PatchedAST->getSourceManager().getFileManager();
+  // Copy so that we can use operator[] to get the children.
+  IncludeStructure Includes = PatchedAST->getIncludeStructure();
+  auto MainFE = FM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(MainFE);
+  auto MainID = Includes.getID(*MainFE);
+  auto AuxFE = FM.getFile(testPath("sub/aux.h"));
+  ASSERT_TRUE(AuxFE);
+  auto AuxID = Includes.getID(*AuxFE);
+  EXPECT_THAT(Includes.IncludeChildren[*MainID], Contains(AuxID));
 }
 
 TEST(ParsedASTTest, PatchesDeletedIncludes) {
@@ -551,18 +552,20 @@
   EXPECT_THAT(PatchedAST->getIncludeStructure().MainFileIncludes,
   testing::Pointwise(
   EqInc(), ExpectedAST.getIncludeStructure().MainFileIncludes));
-  auto StringMapToVector = [](const llvm::StringMap SM) {
-std::vector> Res;
-for (const auto &E : SM)
-  Res.push_back({E.first().str(), E.second});
-llvm::sort(Res);
-return Res;
-  };
   // Ensure file proximity signals are correct.
-  EXPECT_EQ(StringMapToVector(PatchedAST->getIncludeStructure().includeDepth(
-testPath("foo.cpp"))),
-StringMapToVector(ExpectedAST.getIncludeStructure().includeDepth(
-testPath("foo.cpp";
+  auto &FM = ExpectedAST.getSourceManager().getFileManager();
+  // Copy so that we can getOrCreateID().
+  IncludeStructure Includes = ExpectedAST.getIncludeStructure();
+  auto MainFE = FM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(MainFE);
+  auto MainID = Includes.getOrCreateID(*MainFE);
+  auto &PatchedFM = PatchedAST->getSourceManager().getFileManager();
+  IncludeStructure PatchedIncludes = PatchedAST->getIncludeStructure();
+  auto PatchedMainFE = PatchedFM.getFile(testPath("foo.cpp"));
+  ASSERT_TRUE(PatchedMainFE);
+  auto PatchedMainID = PatchedIncludes.getOrCreateID(*PatchedMainFE);
+  EXPECT_EQ(Includes.includeDepth(MainID)[MainID],
+PatchedIncludes.includeDepth(PatchedMainID)[PatchedMainID]);
 }
 
 // Returns Code guarded by #ifndef guards
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -17,6 +17,7 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
@@ -29,8 +30,10 @@
 using ::testing::AllOf;
 using ::testing::Contains;
 using ::testing::ElementsAre;
+using ::testing::IsEmpty;
 using ::testing::Not;
 using :

[PATCH] D110482: [clang] Implement if consteval (P1938)

2021-09-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:166
 
+/// True if this if statement is a if consteval statement.
+unsigned IsConsteval : 1;

Not sure how others feel here, but for me, I kinda hate that we're using 
'unsigned' bitfields for all of this, particularly because these two are 
mutually exclusive.  I'd prefer (though listen to others here first) if the 
type of this was something more like:

IfEvalKind EvalKind : 2; // where IfEvalKind is enum class IfEvalKind {None, 
Constexpr, Consteval};



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:5942
   "jump bypasses initialization of VLA type alias">;
 def note_protected_by_constexpr_if : Note<
   "jump enters controlled statement of constexpr if">;

Oh boy this section of 'notes' seem like they deserve some level of merging 
with a %select.  I'd not want anything other than the `jump enters controlled 
statemennt of `  variants for this patch though.



Comment at: clang/include/clang/Sema/Sema.h:1320
+
+bool isImmediate() const {
+  return Context == ExpressionEvaluationContext::ImmediateFunctionContext;

I get this NOW that I'm looking at it, but `isImmediate` made me go to 
assembly-immediate, though perhaps this is only misleading to me.  I might 
bikeshed this to `isImmediatelyEvaluated` or something.
Anyone else, WDYT?  



Comment at: clang/include/clang/Sema/Sema.h:4723
   class ConditionResult;
-  StmtResult ActOnIfStmt(SourceLocation IfLoc, bool IsConstexpr,
+  enum IfKind {
+IfKind_Default,

can this be a scoped enum?

Also, perhaps pulled into the AST in a way that it can be reused for the IfStmt 
state.



Comment at: clang/include/clang/Sema/Sema.h:9137
+   "Must be in an expression evaluation context");
+for (auto it = ExprEvalContexts.rbegin(); it != ExprEvalContexts.rend();
+ it++) {

What is our iterator type?  I THINK at minimum require this to be `auto *`



Comment at: clang/lib/AST/Stmt.cpp:927
 
+  assert((!IsConsteval && !IsConstexpr) || IsConsteval != IsConstexpr);
+

Oh dear... I'm not quite sure I want this as a scoped enum.



Comment at: clang/lib/AST/StmtPrinter.cpp:246
+  OS << "else";
+  PrintStmt(If->getThen());
+  OS << NL;

should this be `If->getElse`?



Comment at: clang/lib/Parse/ParseStmt.cpp:1363
+if (Tok.is(tok::kw_consteval)) {
+  Diag(Tok, getLangOpts().CPlusPlus17 ? 
diag::warn_cxx14_compat_constexpr_if
+  : diag::ext_constexpr_if);

Is this diag here right?  We're in the `kw_consteval` branch, but it seems 
we're warning about constexpr-if?



Comment at: clang/lib/Parse/ParseStmt.cpp:1382
 
+  if (IsConsteval) {
+Diag(Tok, getLangOpts().CPlusPlus2b ? diag::warn_cxx20_compat_consteval_if

Why is this here instead of with the `kw_consteval` handling?



Comment at: clang/lib/Sema/SemaStmt.cpp:874
 
   Expr *CondExpr = Cond.get().second;
   // Only call the CommaVisitor when not C89 due to differences in scope flags.

perhaps an assert here: `assert((CondExpr || Kind == IfKind_Consteval) && 
"")`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110482

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


[PATCH] D110429: [OpenMP] Introduce a new worksharing RTL function for distribute

2021-09-27 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb added a comment.

hi, we seem to have a link time error after this patch in our buildbot

https://lab.llvm.org/staging/#/builders/182/builds/2023

- TEST 'libomptarget :: amdgcn-amd-amdhsa :: mapping/private_mapping.c' FAILED 


Script:
---

: 'RUN: at line 1';   
/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/./bin/clang 
-fopenmp  -fno-experimental-isel   -I 
/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.src/openmp/libomptarget/test
 -I 
/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget
 -L 
/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
  
-Wl,-rpath,/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget
 
-Wl,-rpath,/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 
--libomptarget-amdgcn-bc-path=/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget
 -fopenmp-targets=amdgcn-amd-amdhsa 
/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.src/openmp/libomptarget/test/mapping/private_mapping.c
 -o 
/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget/test/amdgcn-amd-amdhsa/mapping/Output/private_mapping.c.tmp
 && 
/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget/test/amdgcn-amd-amdhsa/mapping/Output/private_mapping.c.tmp
 | /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/./bin/FileCheck 
/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.src/openmp/libomptarget/test/mapping/private_mapping.c
--

Exit Code: 1

Command Output (stdout):


$ ":" "RUN: at line 1"
$ "/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/./bin/clang" 
"-fopenmp" "-fno-experimental-isel" "-I" 
"/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.src/openmp/libomptarget/test"
 "-I" 
"/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src"
 "-L" 
"/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget"
 "-L" 
"/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src"
 
"-Wl,-rpath,/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget"
 
"-Wl,-rpath,/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src"
 
"--libomptarget-amdgcn-bc-path=/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget"
 "-fopenmp-targets=amdgcn-amd-amdhsa" 
"/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.src/openmp/libomptarget/test/mapping/private_mapping.c"
 "-o" 
"/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget/test/amdgcn-amd-amdhsa/mapping/Output/private_mapping.c.tmp"

command stderr:
===

lld: error: undefined symbol: __kmpc_distribute_static_init_4

>>> referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__)
>>> referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__)

lld: error:

[PATCH] D108469: Improve handling of static assert messages.

2021-09-27 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Can you test all the values in this? https://godbolt.org/z/h7n54fa5x




Comment at: clang/lib/Basic/Diagnostic.cpp:792
+static void pushEscapedString(StringRef Str, SmallVectorImpl &OutStr) {
+  OutStr.reserve(OutStr.size() + Str.size());
+  const unsigned char *Begin =

Can this addition overflow?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

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


[PATCH] D110429: [OpenMP] Introduce a new worksharing RTL function for distribute

2021-09-27 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb added a comment.

apologies, that pasted very poorly ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110429

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


[PATCH] D110429: [OpenMP] Introduce a new worksharing RTL function for distribute

2021-09-27 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb added a comment.

lld: error: undefined symbol: __kmpc_distribute_static_init_4

>>> referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__)
>>> referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__)

lld: error: undefined symbol: __kmpc_distribute_static_fini

>>> referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__)
>>> referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__)
>>> referenced by 
>>> /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__.1)
>>> referenced 1 more times

clang-14: error: amdgcn-link command failed with exit code 1 (use -v to see 
invocation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110429

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


[PATCH] D110429: [OpenMP] Introduce a new worksharing RTL function for distribute

2021-09-27 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb added a comment.

looks like subsequent builders passed. we might have an issue where the runtime 
was not fully built when the test ran.
please disregard , your patch is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110429

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


[PATCH] D110429: [OpenMP] Introduce a new worksharing RTL function for distribute

2021-09-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D110429#3024884 , @ronlieb wrote:

> lld: error: undefined symbol: __kmpc_distribute_static_init_4
>
 referenced by 
 /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__)
 referenced by 
 /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__)
>
> lld: error: undefined symbol: __kmpc_distribute_static_fini
>
 referenced by 
 /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__)
 referenced by 
 /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__)
 referenced by 
 /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__.1)
 referenced 1 more times
>
> clang-14: error: amdgcn-link command failed with exit code 1 (use -v to see 
> invocation)

I'm guessing this has D110430  applied as 
well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110429

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


[PATCH] D110429: [OpenMP] Introduce a new worksharing RTL function for distribute

2021-09-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D110429#3024886 , @ronlieb wrote:

> looks like subsequent builders passed. we might have an issue where the 
> runtime was not fully built when the test ran.
> please disregard , your patch is fine.

two dependent patches and you probably picked up only one. Should resolve 
itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110429

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


[PATCH] D103938: Diagnose -Wunused-value based on CFG reachability

2021-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D103938#3018918 , @ychen wrote:

> In D103938#3018588 , @aaron.ballman 
> wrote:
>
>> In D103938#3013503 , @thakis wrote:
>>
>>> This flags this code from absl:
>>>
>>>   template >> typename std::enable_if::value, 
>>> int>::type =
>>> (GenT{}, 0)>
>>>   constexpr FlagDefaultArg DefaultArg(int) {
>>> return {FlagDefaultSrc(GenT{}.value), FlagDefaultKind::kOneWord};
>>>   }
>>>
>>> (https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/flags/internal/flag.h;l=293?q=third_party%2Fabseil-cpp%2Fabsl%2Fflags%2Finternal%2Fflag.h)
>>>
>>>   ../../third_party/abseil-cpp/absl/flags/internal/flag.h:293:16: warning: 
>>> left operand of comma operator has no effect [-Wunused-value]
>>> (GenT{}, 0)>
>>>  ^   ~~
>>>   ../../third_party/abseil-cpp/absl/flags/internal/flag.h:293:16: warning: 
>>> left operand of comma operator has no effect [-Wunused-value]
>>> (GenT{}, 0)>
>>>  ^   ~~
>>>
>>> I guess it has a SFINAE effect there?
>>
>> Sorry for having missed this comment before when reviewing the code @thakis, 
>> thanks for pinging on it! That does look like a false positive assuming it's 
>> being used for SFINAE. @ychen, can you take a look (and revert if it looks 
>> like it'll take a while to resolve)?
>
> @thakis sorry for missing that. Reverted. I'll take a look.

Diagnoses are suppressed in SFINAE context by default 
(https://github.com/llvm/llvm-project/blob/3dbf27e762008757c0de7034c778d941bfeb0388/clang/include/clang/Basic/Diagnostic.td#L83).
 The test case triggered the warning because the substitution is successful for 
that overload candidate. When substitution failed, the warning is suppressed as 
expected. The test case I used is

  #include
  
  struct A {
int value;
  };
  
  template ::value, int>::type 
=
 (GenT{},0)>
  constexpr int DefaultArg(int) {
return GenT{}.value;
  }
  
  template 
  constexpr int DefaultArg(double) {
return 1;
  }
  
  int foo() {
  return DefaultArg(0);
  }
  int bar() {
  return DefaultArg(0);
  }

So I think the behavior is expected and it seems absl already patch that code 
with `(void)`. Is it ok with you to reland the patch @aaron.ballman  @thakis ? 
Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-09-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1591-1595
   template 
   LLVM_NODISCARD static ProgramStateRef
-  assign(ProgramStateRef State, SValBuilder &Builder, RangeSet::Factory &F,
- ClassOrSymbol CoS, RangeSet NewConstraint) {
+  assign(ProgramStateRef State, RangeConstraintManager *RCM,
+ SValBuilder &Builder, RangeSet::Factory &F, ClassOrSymbol CoS,
+ RangeSet NewConstraint) {

steakhal wrote:
> Hm, why don't we acquire `RCM`, `Builder`, `F` in the constructor? I'm 
> expecting all of them to remain the same for all the `assign()` calls.
My bad. It's a static method. Ignore this thread.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110357

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


[PATCH] D110482: [clang] Implement if consteval (P1938)

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375306.
cor3ntin marked 3 inline comments as done.
cor3ntin added a comment.



- Rename isImmediate to isImmediateFunctionContext
- Fix And cleanup Diagnostics in ParseStmt.cpp
- Add assert in SemaStmt.cpp
- Fix StmtPrinter.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110482

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
  clang/test/CodeGenCXX/cxx2b-consteval-if.cpp

Index: clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++2b %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used
+
+void should_be_used_1();
+void should_be_used_2();
+void should_be_used_3();
+constexpr void should_not_be_used() {}
+
+constexpr void f() {
+  if consteval {
+should_not_be_used();
+  } else {
+should_be_used_1();
+  }
+
+  if !consteval {
+should_be_used_2();
+  }
+
+  if !consteval {
+should_be_used_3();
+  } else {
+should_not_be_used();
+  }
+}
+
+void g() {
+  f();
+}
+
+// CHECK: should_be_used_1
+// CHECK: should_be_used_2
+// CHECK: should_be_used_3
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
===
--- /dev/null
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
@@ -0,0 +1,106 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+void test_consteval() {
+  if consteval (void) 0; // expected-error {{expected { after consteval}}
+  if consteval {
+(void)0;
+  } else (void)0; // expected-error {{expected { after else}}
+
+  static_assert([] {
+if consteval {
+  return 0;
+}
+return 1;
+  }() == 0);
+
+  static_assert([] {
+if consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 0);
+
+  static_assert([] {
+if !consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 1);
+
+  static_assert([] {
+if not consteval {
+  return 0;
+}
+return 1;
+  }() == 1);
+}
+
+void test_consteval_jumps() {
+  if consteval { // expected-note 4{{jump enters controlled statement of if consteval}}
+goto a;
+goto b; // expected-error {{cannot jump from this goto statement to its label}}
+  a:;
+  } else {
+goto b;
+goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  b:;
+  }
+  goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  goto b; // expected-error {{cannot jump from this goto statement to its label}}
+}
+
+void test_consteval_switch() {
+  int x = 42;
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+case 1:;   // expected-error {{cannot jump from switch statement to this case label}}
+default:;  // expected-error {{cannot jump from switch statement to this case label}}
+} else {
+}
+  }
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+} else {
+case 2:;  // expected-error {{cannot jump from switch statement to this case label}}
+default:; // expected-error {{cannot jump from switch statement to this case label}}
+}
+  }
+}
+
+consteval int f(int i) { return i; }
+constexpr int g(int i) {
+  if consteval {
+return f(i);
+  } else {
+return 42;
+  }
+}
+static_assert(g(10) == 10);
+
+constexpr int h(int i) { // expected-note {{declared here}}
+  if !consteval {
+return f(i); // expected-error {{call to consteval function 'f' is not a constant expression}}\
+ // expected-note  {{cannot be used in a constant expression}}
+  }
+  return 0;
+}
+
+consteval void warn_in_consteval() {
+  if consteval { // expected-warning {{if consteval is always true in an immediate context}}
+if consteval {} // e

[PATCH] D110216: [clang] retain type sugar in auto / template argument deduction

2021-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

FYI I just realized some other tests I never run locally relied on the former 
behavior of the ElaboratedType printer.

I will see what looks more reasonable, but I think the defaults are tuned so 
the type printer will output code that looks close to what it was as written,
and this InlayHints was relying on behavior that was not actually supported 
there. We might have to split this off into a separate policy flag or something 
like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110216

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


[PATCH] D110482: [clang] Implement if consteval (P1938)

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:166
 
+/// True if this if statement is a if consteval statement.
+unsigned IsConsteval : 1;

erichkeane wrote:
> Not sure how others feel here, but for me, I kinda hate that we're using 
> 'unsigned' bitfields for all of this, particularly because these two are 
> mutually exclusive.  I'd prefer (though listen to others here first) if the 
> type of this was something more like:
> 
> IfEvalKind EvalKind : 2; // where IfEvalKind is enum class IfEvalKind {None, 
> Constexpr, Consteval};
I was not quite sure where to put an enum I could reuse in different place.
But I think I'd agree with you otherwise.
Any suggestion for where to put it?



Comment at: clang/include/clang/Sema/Sema.h:9137
+   "Must be in an expression evaluation context");
+for (auto it = ExprEvalContexts.rbegin(); it != ExprEvalContexts.rend();
+ it++) {

erichkeane wrote:
> What is our iterator type?  I THINK at minimum require this to be `auto *`
The iterator type is ungodly. Likely 
`SmallVector::reverse_iterator`. I think 
auto here is more readable but I can change if you want to




Comment at: clang/lib/Parse/ParseStmt.cpp:1363
+if (Tok.is(tok::kw_consteval)) {
+  Diag(Tok, getLangOpts().CPlusPlus17 ? 
diag::warn_cxx14_compat_constexpr_if
+  : diag::ext_constexpr_if);

erichkeane wrote:
> Is this diag here right?  We're in the `kw_consteval` branch, but it seems 
> we're warning about constexpr-if?
Yup, forgot to remove that



Comment at: clang/lib/Parse/ParseStmt.cpp:1382
 
+  if (IsConsteval) {
+Diag(Tok, getLangOpts().CPlusPlus2b ? diag::warn_cxx20_compat_consteval_if

erichkeane wrote:
> Why is this here instead of with the `kw_consteval` handling?
To not have a warning when there is an error. Maybe we don't care?
In any case, I've cleanup that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110482

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


[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations

2021-09-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on Windows: http://45.33.8.238/win/45971/step_9.txt

PTAL!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110386

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


[PATCH] D110482: [clang] Implement if consteval (P1938)

2021-09-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Note I didn't have a good chance to re-review this, but wanted to give my 
feedback to the comments right away.




Comment at: clang/include/clang/AST/Stmt.h:166
 
+/// True if this if statement is a if consteval statement.
+unsigned IsConsteval : 1;

cor3ntin wrote:
> erichkeane wrote:
> > Not sure how others feel here, but for me, I kinda hate that we're using 
> > 'unsigned' bitfields for all of this, particularly because these two are 
> > mutually exclusive.  I'd prefer (though listen to others here first) if the 
> > type of this was something more like:
> > 
> > IfEvalKind EvalKind : 2; // where IfEvalKind is enum class IfEvalKind 
> > {None, Constexpr, Consteval};
> I was not quite sure where to put an enum I could reuse in different place.
> But I think I'd agree with you otherwise.
> Any suggestion for where to put it?
My best suggestion is somewhere in include/Basic.

We don't have a great file I think to fit it, but we DO have a ton where we've 
created files for smal lthings (see ExceptionSpecificationType.h, Linkage.h, or 
Lambda.h).

Looking through, there _IS_ a similar enum in Specifiers.h (perhaps the best 
place for this) that might work well, ConstexprSpecKind might actually just be 
what we want and could replace the other enum you created later.



Comment at: clang/include/clang/Sema/Sema.h:9137
+   "Must be in an expression evaluation context");
+for (auto it = ExprEvalContexts.rbegin(); it != ExprEvalContexts.rend();
+ it++) {

cor3ntin wrote:
> erichkeane wrote:
> > What is our iterator type?  I THINK at minimum require this to be `auto *`
> The iterator type is ungodly. Likely 
> `SmallVector::reverse_iterator`. I 
> think auto here is more readable but I can change if you want to
> 
I more questioned due to the lack of the `*`, I see it is the reverse-iterator 
now, so i don't think that makes it a pointer type, so I don't think it is 
valuable here.  @aaron.ballman is our 'auto nitpicker', so I'll let him to 
suggest the right answer.



Comment at: clang/lib/Parse/ParseStmt.cpp:1367
+  }
+  if(IsConsteval)
+  {

So I still meant here putting it inside the 'if (Tok.is(tok::kw_consteval)' 
bit, I have a slight preference to match the rest of these sorts of warnings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110482

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-27 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 375284.
gandhi21299 marked an inline comment as done.
gandhi21299 added a comment.

- added the `REQUIRES` line as requested by Sam


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
  llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/test/CodeGen/AMDGPU/inline-calls.ll

Index: llvm/test/CodeGen/AMDGPU/inline-calls.ll
===
--- llvm/test/CodeGen/AMDGPU/inline-calls.ll
+++ llvm/test/CodeGen/AMDGPU/inline-calls.ll
@@ -1,6 +1,4 @@
 ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck  %s
-; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck  %s
-; RUN: llc -march=r600 -mcpu=redwood -verify-machineinstrs < %s | FileCheck %s
 
 ; ALL-NOT: {{^}}func:
 define internal i32 @func(i32 %a) {
@@ -18,8 +16,8 @@
   ret void
 }
 
-; CHECK-NOT: func_alias
-; ALL-NOT: func_alias
+; CHECK: func_alias
+; ALL: func_alias
 @func_alias = alias i32 (i32), i32 (i32)* @func
 
 ; ALL: {{^}}kernel3:
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -3007,6 +3007,13 @@
   bool IsSibCall = false;
   bool IsThisReturn = false;
   MachineFunction &MF = DAG.getMachineFunction();
+  GlobalAddressSDNode *GSD = dyn_cast(Callee);
+
+  if (GSD) {
+const GlobalValue *GV = GSD->getGlobal();
+if (!isa(GV))
+  return lowerUnhandledCall(CLI, InVals, "callee is not a function ");
+  }
 
   if (Callee.isUndef() || isNullConstant(Callee)) {
 if (!CLI.IsTailCall) {
@@ -3264,7 +3271,7 @@
   Ops.push_back(Callee);
   // Add a redundant copy of the callee global which will not be legalized, as
   // we need direct access to the callee later.
-  if (GlobalAddressSDNode *GSD = dyn_cast(Callee)) {
+  if (GSD) {
 const GlobalValue *GV = GSD->getGlobal();
 Ops.push_back(DAG.getTargetGlobalAddress(GV, DL, MVT::i64));
   } else {
Index: llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
@@ -93,6 +93,8 @@
 
   for (GlobalAlias &A : M.aliases()) {
 if (Function* F = dyn_cast(A.getAliasee())) {
+  if (A.getLinkage() != GlobalValue::InternalLinkage)
+continue;
   A.replaceAllUsesWith(F);
   AliasesToRemove.push_back(&A);
 }
Index: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
@@ -0,0 +1,17 @@
+// REQUIRES: amdgpu-registered-target, clang-driver
+
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -x hip -emit-llvm -S -o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5107,9 +5107,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: [PATCH] D110429: [OpenMP] Introduce a new worksharing RTL function for distribute

2021-09-27 Thread Lieberman, Ron via cfe-commits
[AMD Official Use Only]

Yes, thank you, it was two dependent patches 
Builder 1 only saw 1st patch, failed, then 2nd patch arrived, and passed.
Builder 2 picked up both and passed

All good.

-Original Message-
From: Johannes Doerfert via Phabricator  
Sent: Monday, September 27, 2021 12:07 PM
To: jhub...@vols.utk.edu; jdoerf...@anl.gov; tianshilei1...@gmail.com
Cc: Lieberman, Ron ; stefomeis...@gmail.com; 
cfe-commits@lists.llvm.org; llvm-comm...@lists.llvm.org; Liu, Yaxun (Sam) 
; zhang.guans...@gmail.com; Kumar N, Bhuvanendra 
; yanliang...@intel.com; dougp...@gmail.com; 
mlek...@skidmore.edu; blitzrak...@gmail.com; shen...@google.com; 
david.gr...@arm.com; t...@google.com; Song, Ruiling 
Subject: [PATCH] D110429: [OpenMP] Introduce a new worksharing RTL function for 
distribute

[CAUTION: External Email]

jdoerfert added a comment.

In D110429#3024886 
,
 @ronlieb wrote:

> looks like subsequent builders passed. we might have an issue where the 
> runtime was not fully built when the test ran.
> please disregard , your patch is fine.

two dependent patches and you probably picked up only one. Should resolve 
itself.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD110429%2Fnew%2F&data=04%7C01%7Cron.lieberman%40amd.com%7C3712fe9761b14dbbe0d208d981d0cac1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637683556037623058%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Mx06vT2zOUb1zF50rqbgWhHTKH%2Ba2dIunlcB4BGxwqU%3D&reserved=0

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD110429&data=04%7C01%7Cron.lieberman%40amd.com%7C3712fe9761b14dbbe0d208d981d0cac1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637683556037623058%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Eq%2FRXJpykvyBfM6x9grzFOac39xI9BnKua1fJZkfL5g%3D&reserved=0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-27 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

@yaxunl Should inline-calls.ll be converted into an expected failing test or 
removed? (to avoid cast failure in AMDGPUResourceAnalysis to break the test)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375319.
cor3ntin added a comment.

Replace `Unevaluated` by an enum.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

Files:
  clang-tools-extra/test/clang-tidy/checkers/modernize-unary-static-assert.cpp
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/FixIt/fixit-static-assert.cpp
  clang/test/Parser/asm.c
  clang/test/Parser/asm.cpp
  clang/test/Parser/attr-availability-xcore.c
  clang/test/Parser/attr-availability.c
  clang/test/Sema/asm.c
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -28,12 +28,12 @@
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{static_assert failed L"\x"}}
-static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u"\U000317FF"}}
+static_assert(false, L"\x"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, u"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 // FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}}
-static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}}
-static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFgoop"}}
+static_assert(false, u8"Ω"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\u1234"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 
 template struct AlwaysFails {
   // Only give one error here.
Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -37,14 +37,17 @@
   asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
-  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
+  asm("nop"
+  : "=a"(a)
+  : "b"(b)
+  : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
 }
 
 // rdar://6094010
 void test3() {
   int x;
-  asm(L"foo" : "=r"(x)); // expected-error {{wide string}}
-  asm("foo" : L"=r"(x)); // expected-error {{wide string}}
+  asm(L"foo" : "=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+  asm("foo" : L"=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 }
 
 // 
Index: clang/test/Parser/attr-availability.c
===
--- clang/test/Parser/attr-availability.c
+++ clang/test/Parser/attr-availability.c
@@ -18,21 +18,25 @@
 
 void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
 
-void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{an unevaluated string literal cannot 

[PATCH] D110216: [clang] retain type sugar in auto / template argument deduction

2021-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov marked an inline comment as not done.
mizvekov added inline comments.



Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:470
+  ExpectedHint{": S1", "x"},
+  ExpectedHint{": S2::Inner", "y"});
 }

mizvekov wrote:
> nridge wrote:
> > This test expectation change is suspicious. The type is being printed with 
> > `PrintingPolicy::SuppressScope=true`, shouldn't that still be respected?
> Thanks for pointing that out, I will take a look, but I suspect this to be 
> some TypePrinter issue.
Could you explain to me why the former behavior is more desirable here?

I initially understood that this hint should provide the type written in a form 
that would actually work if it replaced the 'auto'.
It is strange, but if it is just meant as a hint, it's still fine I guess.

Or maybe this was broken in the first place and just was just missing a FIXME?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110216

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


[PATCH] D110422: [AIX] Enable PGO without LTO

2021-09-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

The description isn't clear why the previous `weak` symbol usage does not work. 
Have you verified that it does not work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110422

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


[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:257
+
+def err_unevaluated_string_prefix : Error<
+  "an unevaluated string literal cannot have an encoding prefix">;

erichkeane wrote:
> Is there value to combining these two diagnostics with a %select?
I waffled when doing this review, so it's funny you mention it. :-D

We could do: `an unevaluated string literal cannot %select{have an encoding 
prefix|be a user-defined literal}0` but there was just enough text in the 
`select` that I felt it wasn't critical to combine. But I don't feel strongly 
either way.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1813
+Diags->Report(TokLoc, UnevaluatedStringHasUDL
+  ? diag::err_unevaluated_string_udl
+  : diag::err_string_concat_mixed_suffix)

erichkeane wrote:
> Is this OK?  It looks like we're passing a ton of parameters to a diag type 
> that doesn't have any wildcards?  
Good catch! The first two are not helpful (the diag engine will silently ignore 
them), but the second two are for underlines in the diagnostic and are useful.



Comment at: clang/lib/Lex/LiteralSupport.cpp:95-96
+  case '?':
+  case 'n':
+  case 't':
+return true;

erichkeane wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > cor3ntin wrote:
> > > > aaron.ballman wrote:
> > > > > Do you intend to miss a bunch of escapes like `\'` and `\r` (etc)?
> > > > \' is there. I am less sure about '\r' and '\a'. for example. This is 
> > > > something I realized after writing P2361.
> > > > what does '\a` in static assert mean? even '\r' is not so obvious
> > > Looking at the list again, I think only `\a` is really of interest here. 
> > > I know some folks like @jfb have mentioned that `\a` could be used to 
> > > generate an alert sound on a terminal, which is a somewhat useful feature 
> > > for a failed static assertion if you squint at it hard enough.
> > > 
> > > But the rest of the missing ones do seem more questionable to support.
> > @jfb and @cor3ntin -- any opinions on whether `\a` should be supported? My 
> > opinion is that it should be supported because it has some utility for 
> > anyone running the compiler from a command line, but it's a pretty weak 
> > opinion.
> I might consider rejecting ANY character escape in the less-than-32 part of 
> the table.  
> 
> For consistency at least, I don't see value in allowing \a if we're rejecting 
> layout things like \t.
But that's just it, we're accepting `\t` and `\n` with this code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-09-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Lex/LiteralSupport.cpp:95-96
+  case '?':
+  case 'n':
+  case 't':
+return true;

aaron.ballman wrote:
> erichkeane wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > cor3ntin wrote:
> > > > > aaron.ballman wrote:
> > > > > > Do you intend to miss a bunch of escapes like `\'` and `\r` (etc)?
> > > > > \' is there. I am less sure about '\r' and '\a'. for example. This is 
> > > > > something I realized after writing P2361.
> > > > > what does '\a` in static assert mean? even '\r' is not so obvious
> > > > Looking at the list again, I think only `\a` is really of interest 
> > > > here. I know some folks like @jfb have mentioned that `\a` could be 
> > > > used to generate an alert sound on a terminal, which is a somewhat 
> > > > useful feature for a failed static assertion if you squint at it hard 
> > > > enough.
> > > > 
> > > > But the rest of the missing ones do seem more questionable to support.
> > > @jfb and @cor3ntin -- any opinions on whether `\a` should be supported? 
> > > My opinion is that it should be supported because it has some utility for 
> > > anyone running the compiler from a command line, but it's a pretty weak 
> > > opinion.
> > I might consider rejecting ANY character escape in the less-than-32 part of 
> > the table.  
> > 
> > For consistency at least, I don't see value in allowing \a if we're 
> > rejecting layout things like \t.
> But that's just it, we're accepting `\t` and `\n` with this code.
Ah!  I missed that this is an allow-list instead of a deny-list.  That makes me 
way more comfortable with this code.

IMO, I'd suggest we we allow '\r' (since wouldn't we have problems on Windows 
at that point, being unable to accept a printable newline for windows?), but 
disallow `\a` for now unless someone comes up with a really good reason to 
allow it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[clang] c4afb5f - [HIP] Fix linking of asanrt.bc

2021-09-27 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-09-27T13:25:46-04:00
New Revision: c4afb5f81b62b903e4af8a92235e1b901e184040

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

LOG: [HIP] Fix linking of asanrt.bc

HIP currently uses -mlink-builtin-bitcode to link all bitcode libraries, which
changes the linkage of functions to be internal once they are linked in. This
works for common bitcode libraries since these functions are not intended
to be exposed for external callers.

However, the functions in the sanitizer bitcode library is intended to be
called by instructions generated by the sanitizer pass. If their linkage is
changed to internal, their parameters may be altered by optimizations before
the sanitizer pass, which renders them unusable by the sanitizer pass.

To fix this issue, HIP toolchain links the sanitizer bitcode library with
-mlink-bitcode-file, which does not change the linkage.

A struct BitCodeLibraryInfo is introduced in ToolChain as a generic
approach to pass the bitcode library information between ToolChain and Tool.

Reviewed by: Artem Belevich

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

Added: 
clang/test/CodeGenCUDA/Inputs/amdgpu-asanrtl.ll

Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/HIP.cpp
clang/lib/Driver/ToolChains/HIP.h
clang/test/CodeGenCUDA/amdgpu-asan.cu
clang/test/Driver/hip-sanitize-options.hip

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 882ae40086cea..fa5095e98018b 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -113,6 +113,13 @@ class ToolChain {
 RM_Disabled,
   };
 
+  struct BitCodeLibraryInfo {
+std::string Path;
+bool ShouldInternalize;
+BitCodeLibraryInfo(StringRef Path, bool ShouldInternalize = true)
+: Path(Path), ShouldInternalize(ShouldInternalize) {}
+  };
+
   enum FileType { FT_Object, FT_Static, FT_Shared };
 
 private:
@@ -681,7 +688,7 @@ class ToolChain {
   const llvm::opt::ArgList &Args) 
const;
 
   /// Get paths of HIP device libraries.
-  virtual llvm::SmallVector
+  virtual llvm::SmallVector
   getHIPDeviceLibs(const llvm::opt::ArgList &Args) const;
 
   /// Return sanitizers which are available in this toolchain.

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 7272cc29cc7c0..302bfb348b29f 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1026,7 +1026,7 @@ void ToolChain::AddCudaIncludeArgs(const ArgList 
&DriverArgs,
 void ToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {}
 
-llvm::SmallVector
+llvm::SmallVector
 ToolChain::getHIPDeviceLibs(const ArgList &DriverArgs) const {
   return {};
 }

diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index c4e840de86e15..665d5bab7218d 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -88,8 +88,8 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, 
const JobAction &JA,
 
   if (Args.hasFlag(options::OPT_fgpu_sanitize, options::OPT_fno_gpu_sanitize,
false))
-llvm::for_each(TC.getHIPDeviceLibs(Args), [&](StringRef BCFile) {
-  LldArgs.push_back(Args.MakeArgString(BCFile));
+llvm::for_each(TC.getHIPDeviceLibs(Args), [&](auto BCFile) {
+  LldArgs.push_back(Args.MakeArgString(BCFile.Path));
 });
 
   const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
@@ -276,9 +276,10 @@ void HIPToolChain::addClangTargetOptions(
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
 
-  llvm::for_each(getHIPDeviceLibs(DriverArgs), [&](StringRef BCFile) {
-CC1Args.push_back("-mlink-builtin-bitcode");
-CC1Args.push_back(DriverArgs.MakeArgString(BCFile));
+  llvm::for_each(getHIPDeviceLibs(DriverArgs), [&](auto BCFile) {
+CC1Args.push_back(BCFile.ShouldInternalize ? "-mlink-builtin-bitcode"
+   : "-mlink-bitcode-file");
+CC1Args.push_back(DriverArgs.MakeArgString(BCFile.Path));
   });
 }
 
@@ -359,9 +360,9 @@ VersionTuple HIPToolChain::computeMSVCVersion(const Driver 
*D,
   return HostTC.computeMSVCVersion(D, Args);
 }
 
-llvm::SmallVector
+llvm::SmallVector
 HIPToolChain::getHIPDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
-  llvm::SmallVector BCLibs;
+  llvm::SmallVector BCLibs;
   if (DriverArgs.hasArg(options::OPT_nogpulib))
 return {};
   ArgStringList LibraryPaths;
@@ -382,7 +383,7 @@ HIPToolChain::getHIPDeviceLibs(const llvm::opt::ArgList 
&Dr

[PATCH] D110304: [HIP] Fix linking of asanrt.bc

2021-09-27 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rGc4afb5f81b62: [HIP] Fix linking of asanrt.bc (authored by 
yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D110304?vs=374868&id=375329#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110304

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/HIP.h
  clang/test/CodeGenCUDA/Inputs/amdgpu-asanrtl.ll
  clang/test/CodeGenCUDA/amdgpu-asan.cu
  clang/test/Driver/hip-sanitize-options.hip

Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -34,7 +34,7 @@
 // CHECK-NOT: {{"[^"]*lld(\.exe){0,1}".* ".*hip.bc"}}
 // CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
 
-// NORDC: {{"[^"]*clang[^"]*".* "-emit-obj".* "-fcuda-is-device".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.o]]"
+// NORDC: {{"[^"]*clang[^"]*".* "-emit-obj".* "-fcuda-is-device".* "-mlink-bitcode-file" ".*asanrtl.bc".* "-mlink-builtin-bitcode" ".*hip.bc".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.o]]"
 // NORDC: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 // NORDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
 
Index: clang/test/CodeGenCUDA/amdgpu-asan.cu
===
--- clang/test/CodeGenCUDA/amdgpu-asan.cu
+++ clang/test/CodeGenCUDA/amdgpu-asan.cu
@@ -1,6 +1,20 @@
+// Create a sample address sanitizer bitcode library.
+
+// RUN: %clang_cc1 -x ir -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm-bc \
+// RUN:   -disable-llvm-passes -o %t.asanrtl.bc %S/Inputs/amdgpu-asanrtl.ll
+
+// Check sanitizer runtime library functions survive
+// optimizations without being removed or parameters altered.
+
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
+// RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
+// RUN:   -mlink-bitcode-file %t.asanrtl.bc -x hip \
+// RUN:   | FileCheck -check-prefix=ASAN %s
+
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
 // RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
-// RUN:   -x hip | FileCheck -check-prefix=ASAN %s
+// RUN:   -O3 -mlink-bitcode-file %t.asanrtl.bc -x hip \
+// RUN:   | FileCheck -check-prefix=ASAN %s
 
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
 // RUN:   -fcuda-is-device -target-cpu gfx906 -x hip \
@@ -8,8 +22,10 @@
 
 // REQUIRES: amdgpu-registered-target
 
-// ASAN-DAG: declare void @__amdgpu_device_library_preserve_asan_functions()
+// ASAN-DAG: define weak void @__amdgpu_device_library_preserve_asan_functions()
 // ASAN-DAG: @__amdgpu_device_library_preserve_asan_functions_ptr = weak addrspace(1) constant void ()* @__amdgpu_device_library_preserve_asan_functions
 // ASAN-DAG: @llvm.compiler.used = {{.*}}@__amdgpu_device_library_preserve_asan_functions_ptr
+// ASAN-DAG: define weak void @__asan_report_load1(i64 %{{.*}})
 
-// CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions_ptr
+// CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions
+// CHECK-NOT: @__asan_report_load1
Index: clang/test/CodeGenCUDA/Inputs/amdgpu-asanrtl.ll
===
--- /dev/null
+++ clang/test/CodeGenCUDA/Inputs/amdgpu-asanrtl.ll
@@ -0,0 +1,13 @@
+; Sample code for amdgpu address sanitizer runtime.
+
+; Note the runtime functions need to have weak linkage and default
+; visibility, otherwise they may be internalized and removed by GlobalOptPass.
+
+define weak void @__amdgpu_device_library_preserve_asan_functions() {
+  tail call void @__asan_report_load1(i64 0)
+  ret void
+}
+
+define weak void @__asan_report_load1(i64 %0) {
+  ret void
+}
Index: clang/lib/Driver/ToolChains/HIP.h
===
--- clang/lib/Driver/ToolChains/HIP.h
+++ clang/lib/Driver/ToolChains/HIP.h
@@ -83,7 +83,7 @@
llvm::opt::ArgStringList &CC1Args) const override;
   void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  llvm::opt::ArgStringList &CC1Args) const override;
-  llvm::SmallVector
+  llvm::SmallVector
   getHIPDeviceLibs(const llvm::opt::ArgList &Args) const override;
 
   SanitizerMask getSupportedSanitizers() const override;
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -88,8 +88,8 @@
 
  

[PATCH] D108247: [CUDA] Improve CUDA version detection and diagnostics.

2021-09-27 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

So, what's the current state of affairs regarding CUDA SDK layout in debian?
Clang does rely on very particular ordering of includes, so having CUDA headers 
in a location clang does not expect will lead to issues sooner or later.
If the headers are not available where --cuda-path points clang to, I'm not 
sure what clang is supposed to do. Second-guessing explicit user input is not a 
good idea in general.

CUDA SDK no longer ships version.txt, so cuda.h is the only reliable mechanism 
for detecting CUDA version and clang does need to know it.

In case the version has not been found we also can not choose an arbitrary old 
version as the default.

So, one workaround would be to install CUDA-11.4. AFAICT, we do find the 
headers and ptxas, but misdetect CUDA version.
Another workaround would be to place a fake /usr/lib/cuda/include/cuda.h with 
something like this:

  #pragma push_macro("CUDA_VERSION")
  #define CUDA_VERSION 11030
  #pragma pop_macro("CUDA_VERSION")
  #include_next 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108247

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


[PATCH] D103938: Diagnose -Wunused-value based on CFG reachability

2021-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D103938#3024938 , @ychen wrote:

> In D103938#3018918 , @ychen wrote:
>
>> In D103938#3018588 , 
>> @aaron.ballman wrote:
>>
>>> In D103938#3013503 , @thakis 
>>> wrote:
>>>
 This flags this code from absl:

   template >>> typename std::enable_if::value, 
 int>::type =
 (GenT{}, 0)>
   constexpr FlagDefaultArg DefaultArg(int) {
 return {FlagDefaultSrc(GenT{}.value), FlagDefaultKind::kOneWord};
   }

 (https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/flags/internal/flag.h;l=293?q=third_party%2Fabseil-cpp%2Fabsl%2Fflags%2Finternal%2Fflag.h)

   ../../third_party/abseil-cpp/absl/flags/internal/flag.h:293:16: warning: 
 left operand of comma operator has no effect [-Wunused-value]
 (GenT{}, 0)>
  ^   ~~
   ../../third_party/abseil-cpp/absl/flags/internal/flag.h:293:16: warning: 
 left operand of comma operator has no effect [-Wunused-value]
 (GenT{}, 0)>
  ^   ~~

 I guess it has a SFINAE effect there?
>>>
>>> Sorry for having missed this comment before when reviewing the code 
>>> @thakis, thanks for pinging on it! That does look like a false positive 
>>> assuming it's being used for SFINAE. @ychen, can you take a look (and 
>>> revert if it looks like it'll take a while to resolve)?
>>
>> @thakis sorry for missing that. Reverted. I'll take a look.
>
> Diagnoses are suppressed in SFINAE context by default 
> (https://github.com/llvm/llvm-project/blob/3dbf27e762008757c0de7034c778d941bfeb0388/clang/include/clang/Basic/Diagnostic.td#L83,
>  related code is `Sema::EmitCurrentDiagnostic`). The test case triggered the 
> warning because the substitution is successful for that overload candidate. 
> When substitution failed, the warning is suppressed as expected. The test 
> case I used is
>
>   #include
>   
>   struct A {
> int value;
>   };
>   
>   template  typename std::enable_if::value, 
> int>::type =
>  (GenT{},0)>
>   constexpr int DefaultArg(int) {
> return GenT{}.value;
>   }
>   
>   template 
>   constexpr int DefaultArg(double) {
> return 1;
>   }
>   
>   int foo() {
>   return DefaultArg(0);
>   }
>   int bar() {
>   return DefaultArg(0);
>   }
>
> So I think the behavior is expected and it seems absl already patch that code 
> with `(void)`. Is it ok with you to reland the patch @aaron.ballman  @thakis 
> ? Thanks

That will only help users who have newer versions of abseil. Also, I'm a bit 
worried this may be a code pattern used by more than just abseil.

The diagnostic text says that the comma operator has no effect, but this is a 
case where it does have a compile-time effect so the diagnostic sounds 
misleading. This suggests to me that we should silence the diagnostic in this 
case (because we want on-by-default diagnostics to be as close to free from 
false positives as possible). However, does silencing this cause significant 
issues with false negatives in other code examples?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


  1   2   >