[PATCH] D135439: Keep configuration file search directories in ExpansionContext. NFC

2022-10-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I am not familiar with `ExpansionContext`. Is there any behavior difference 
which can be demonstrated by a test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135439

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


[PATCH] D135707: [clang-format] Correctly annotate star/amp in function pointer params

2022-10-17 Thread Emilia Dreamer 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 rG94215d2b2103: [clang-format] Correctly annotate star/amp in 
function pointer params (authored by rymiel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135707

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -131,6 +131,20 @@
   Tokens = annotate("delete[] *(ptr);");
   EXPECT_EQ(Tokens.size(), 9u) << Tokens;
   EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+
+  Tokens = annotate("void f() { void (*fnptr)(char* foo); }");
+  EXPECT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
+  // FIXME: The star of a function pointer probably makes more sense as
+  // TT_PointerOrReference.
+  EXPECT_TOKEN(Tokens[7], tok::star, TT_UnaryOperator);
+  EXPECT_TOKEN(Tokens[12], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("void f() { void (*fnptr)(t* foo); }");
+  EXPECT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
+  EXPECT_TOKEN(Tokens[7], tok::star, TT_UnaryOperator);
+  EXPECT_TOKEN(Tokens[12], tok::star, TT_PointerOrReference);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10459,6 +10459,7 @@
   verifyFormat("#define MACRO() [](A *a) { return 1; }");
   verifyFormat("Constructor() : member([](A *a, B *b) {}) {}");
   verifyIndependentOfContext("typedef void (*f)(int *a);");
+  verifyIndependentOfContext("typedef void (*f)(Type *a);");
   verifyIndependentOfContext("int i{a * b};");
   verifyIndependentOfContext("aaa && aaa->f();");
   verifyIndependentOfContext("int x = ~*p;");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -302,7 +302,8 @@
   Contexts.back().ContextType = Context::ForEachMacro;
   Contexts.back().IsExpression = false;
 } else if (OpeningParen.Previous && OpeningParen.Previous->MatchingParen &&
-   OpeningParen.Previous->MatchingParen->is(TT_ObjCBlockLParen)) {
+   OpeningParen.Previous->MatchingParen->isOneOf(
+   TT_ObjCBlockLParen, TT_FunctionTypeLParen)) {
   Contexts.back().IsExpression = false;
 } else if (!Line.MustBeDeclaration && !Line.InPPDirective) {
   bool IsForOrCatch =


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -131,6 +131,20 @@
   Tokens = annotate("delete[] *(ptr);");
   EXPECT_EQ(Tokens.size(), 9u) << Tokens;
   EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+
+  Tokens = annotate("void f() { void (*fnptr)(char* foo); }");
+  EXPECT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
+  // FIXME: The star of a function pointer probably makes more sense as
+  // TT_PointerOrReference.
+  EXPECT_TOKEN(Tokens[7], tok::star, TT_UnaryOperator);
+  EXPECT_TOKEN(Tokens[12], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("void f() { void (*fnptr)(t* foo); }");
+  EXPECT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
+  EXPECT_TOKEN(Tokens[7], tok::star, TT_UnaryOperator);
+  EXPECT_TOKEN(Tokens[12], tok::star, TT_PointerOrReference);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10459,6 +10459,7 @@
   verifyFormat("#define MACRO() [](A *a) { return 1; }");
   verifyFormat("Constructor() : member([](A *a, B *b) {}) {}");
   verifyIndependentOfContext("typedef void (*f)(int *a);");
+  verifyIndependentOfContext("typedef void (*f)(Type *a);");
   verifyIndependentOfContext("int i{a * b};");
   verifyIndependentOfContext("aaa && aaa->f();");
   verifyIndependentOfContext("int x = ~*p;");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -302,7 +302,8 @@

[clang] 94215d2 - [clang-format] Correctly annotate star/amp in function pointer params

2022-10-17 Thread Emilia Dreamer via cfe-commits

Author: Emilia Dreamer
Date: 2022-10-18T08:17:23+03:00
New Revision: 94215d2b2103c5ad74596dd51704836f92afec89

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

LOG: [clang-format] Correctly annotate star/amp in function pointer params

Inside the arguments part of a function pointer declaration,
`determineStarAmpUsage` results in a binary operator rather than
pointers, because said parens are assumed to be an expression.

This patch correctly marks the argument parens of a function
pointer type as not an expression. Note that this fix already
existed for Objective-C blocks as part of 
f1f267b447f60528440d2c066b29ab014ae7f90f.
As Objective-C blocks and C/C++ function pointers share a lot
of the same logic, that fix also makes sense here.

Fixes https://github.com/llvm/llvm-project/issues/31659

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 597d7b64625f3..8eef2be404d18 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -302,7 +302,8 @@ class AnnotatingParser {
   Contexts.back().ContextType = Context::ForEachMacro;
   Contexts.back().IsExpression = false;
 } else if (OpeningParen.Previous && OpeningParen.Previous->MatchingParen &&
-   OpeningParen.Previous->MatchingParen->is(TT_ObjCBlockLParen)) {
+   OpeningParen.Previous->MatchingParen->isOneOf(
+   TT_ObjCBlockLParen, TT_FunctionTypeLParen)) {
   Contexts.back().IsExpression = false;
 } else if (!Line.MustBeDeclaration && !Line.InPPDirective) {
   bool IsForOrCatch =

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index a777382e762a0..e9f5d66d8c566 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -10459,6 +10459,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   verifyFormat("#define MACRO() [](A *a) { return 1; }");
   verifyFormat("Constructor() : member([](A *a, B *b) {}) {}");
   verifyIndependentOfContext("typedef void (*f)(int *a);");
+  verifyIndependentOfContext("typedef void (*f)(Type *a);");
   verifyIndependentOfContext("int i{a * b};");
   verifyIndependentOfContext("aaa && aaa->f();");
   verifyIndependentOfContext("int x = ~*p;");

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index c8de8a2a2abe4..14918c7e6ff96 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -131,6 +131,20 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {
   Tokens = annotate("delete[] *(ptr);");
   EXPECT_EQ(Tokens.size(), 9u) << Tokens;
   EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+
+  Tokens = annotate("void f() { void (*fnptr)(char* foo); }");
+  EXPECT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
+  // FIXME: The star of a function pointer probably makes more sense as
+  // TT_PointerOrReference.
+  EXPECT_TOKEN(Tokens[7], tok::star, TT_UnaryOperator);
+  EXPECT_TOKEN(Tokens[12], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("void f() { void (*fnptr)(t* foo); }");
+  EXPECT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
+  EXPECT_TOKEN(Tokens[7], tok::star, TT_UnaryOperator);
+  EXPECT_TOKEN(Tokens[12], tok::star, TT_PointerOrReference);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {



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


[clang] 8e7d5d5 - [NFC] Add missing ABI requirement from the previous patch

2022-10-17 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-10-18T13:16:04+08:00
New Revision: 8e7d5d5863105aa2c0610bc5d00e5cfad683c7fd

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

LOG: [NFC] Add missing ABI requirement from the previous patch

Added: 


Modified: 
clang/test/CodeGenCXX/module-funcs-from-imports.cppm

Removed: 




diff  --git a/clang/test/CodeGenCXX/module-funcs-from-imports.cppm 
b/clang/test/CodeGenCXX/module-funcs-from-imports.cppm
index 4d3e558e220e..3b415bd9c457 100644
--- a/clang/test/CodeGenCXX/module-funcs-from-imports.cppm
+++ b/clang/test/CodeGenCXX/module-funcs-from-imports.cppm
@@ -4,12 +4,14 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/M.cppm \
 // RUN:-emit-module-interface -o %t/M.pcm
 // RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t \
+// RUN:-triple %itanium_abi_triple \
 // RUN:-S -emit-llvm -o - -disable-llvm-passes \
 // RUN:| FileCheck %t/Use.cpp --check-prefix=CHECK-O0
 //
 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -O1 %t/M.cppm \
 // RUN:-emit-module-interface -o %t/M.pcm
 // RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t -O1 \
+// RUN:-triple %itanium_abi_triple \
 // RUN:-S -emit-llvm -o - -disable-llvm-passes | \
 // RUN:FileCheck %t/Use.cpp --check-prefix=CHECK-O1
 



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


[PATCH] D129443: [clang-format] Add option for aligning requires clause body

2022-10-17 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel updated this revision to Diff 468414.
rymiel added a comment.

Swap the default for LLVM style, and adjust tests which depended on the 
previous style to still use it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129443

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -24308,6 +24308,12 @@
 TEST_F(FormatTest, Concepts) {
   EXPECT_EQ(getLLVMStyle().BreakBeforeConceptDeclarations,
 FormatStyle::BBCDS_Always);
+
+  // The default in LLVM style is REI_OuterScope, but these tests were written
+  // when the default was REI_Keyword.
+  FormatStyle Style = getLLVMStyle();
+  Style.RequiresExpressionIndentation = FormatStyle::REI_Keyword;
+
   verifyFormat("template \n"
"concept True = true;");
 
@@ -24324,13 +24330,15 @@
"concept DelayedCheck = true && requires(T t) {\n"
" t.bar();\n"
" t.baz();\n"
-   "   } && sizeof(T) <= 8;");
+   "   } && sizeof(T) <= 8;",
+   Style);
 
   verifyFormat("template \n"
"concept DelayedCheck = true && requires(T t) { // Comment\n"
" t.bar();\n"
" t.baz();\n"
-   "   } && sizeof(T) <= 8;");
+   "   } && sizeof(T) <= 8;",
+   Style);
 
   verifyFormat("template \n"
"concept DelayedCheck = false || requires(T t) { t.bar(); } && "
@@ -24432,26 +24440,30 @@
"concept Hashable = requires(T a) {\n"
" { std::hash{}(a) } -> "
"std::convertible_to;\n"
-   "   };");
+   "   };",
+   Style);
 
   verifyFormat(
   "template \n"
   "concept EqualityComparable = requires(T a, T b) {\n"
   "   { a == b } -> std::same_as;\n"
-  " };");
+  " };",
+  Style);
 
   verifyFormat(
   "template \n"
   "concept EqualityComparable = requires(T a, T b) {\n"
   "   { a == b } -> std::same_as;\n"
   "   { a != b } -> std::same_as;\n"
-  " };");
+  " };",
+  Style);
 
   verifyFormat("template \n"
"concept WeakEqualityComparable = requires(T a, T b) {\n"
"   { a == b };\n"
"   { a != b };\n"
-   " };");
+   " };",
+   Style);
 
   verifyFormat("template \n"
"concept HasSizeT = requires { typename T::size_t; };");
@@ -24467,7 +24479,8 @@
"  requires Same;\n"
"  { delete new T; };\n"
"  { delete new T[n]; };\n"
-   "};");
+   "};",
+   Style);
 
   verifyFormat("template \n"
"concept Semiregular =\n"
@@ -24480,7 +24493,8 @@
"  { delete new T[n]; };\n"
"  { new T } -> std::same_as;\n"
"} && DefaultConstructible && CopyConstructible && "
-   "CopyAssignable;");
+   "CopyAssignable;",
+   Style);
 
   verifyFormat(
   "template \n"
@@ -24494,14 +24508,16 @@
   " { delete new T; };\n"
   " { delete new T[n]; };\n"
   "   } && CopyConstructible && "
-  "CopyAssignable;");
+  "CopyAssignable;",
+  Style);
 
   verifyFormat("template \n"
"concept Two = requires(T t) {\n"
"{ t.foo() } -> std::same_as;\n"
"  } && requires(T &) {\n"
" { t.foo() } -> std::same_as;\n"
-   "   };");
+   "   };",
+   Style);
 
   verifyFormat(
   "template \n"
@@ -24509,7 +24525,8 @@
   "  { *x } -> std::convertible_to;\n"
   "  { x + 1 } noexcept -> std::same_as;\n"
   "

[PATCH] D134853: [clang-format] Correctly annotate UDLs as OverloadedOperator

2022-10-17 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added inline comments.



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:413
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::identifier, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);

owenpan wrote:
> We need/should not annotate the suffix.
Unless I change the logic in `rParenEndsCast`, the suffix does need to be an 
OverloadedOperator, since it goes off of the token immediately before left 
paren (https://reviews.llvm.org/D134853#3822842)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134853

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


[PATCH] D136018: [Clang] Fix crash when checking misaligned member with dependent type

2022-10-17 Thread Jun Zhang via Phabricator via cfe-commits
junaire marked 5 inline comments as done.
junaire added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:17398-17399
+  const bool IsDiscardMisalignedPointer =
+  T->isPointerType() &&
+  (T->getPointeeType()->isIncompleteType() || T->isDependentType() ||
+   Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment);

aaron.ballman wrote:
> shafik wrote:
> > aaron.ballman wrote:
> > > Hmm, is this logic correct? Don't we want:
> > > 
> > > ```
> > > T->isDependentType() ||
> > >   (T->isPointerType() &&
> > > (T->getPointeeType()->isIncompleteType() || 
> > > Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment))
> > > ```
> > Why did you drop the `T->isIntegerType()`?
> Whoops! That's totally a typo on my part, I didn't intend to drop it.
> Why did you drop the T->isIntegerType()?

There may be some misunderstanding here. So previously I hoist the 
pointer-related checks and put `T->isDependentType()` into it. After Aaron's 
words, I realized it was wrong so I changed the whole check condition to `is T 
an integer type? || is T a dependent type ?|| is T a pointer type and other 
constraints` (put them on the same level)

That said you're looking at the old diff so there's nothing need to worried 
about :)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136018

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


[PATCH] D136018: [Clang] Fix crash when checking misaligned member with dependent type

2022-10-17 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 468409.
junaire added a comment.

Add the original mailformed test case, thanks Shafik!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136018

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp


Index: clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct __attribute__((packed)) {
+  unsigned options;
+  template 
+  void getOptions() {
+  (T *)
+  }
+  template 
+   void getOptions2() {
+  (U)
+   }
+} s;
+
+struct __attribute__((packed)) { // expected-error {{anonymous structs and 
classes must be class members}}
+   unsigned options ;
+  template  getOptions() // expected-error {{a type specifier is 
required for all declarations}}
+{
+  (T *) & options;
+}
+};
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -17387,15 +17387,15 @@
 
 void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
   E = E->IgnoreParens();
-  if (!T->isPointerType() && !T->isIntegerType())
+  if (!T->isPointerType() && !T->isIntegerType() && !T->isDependentType())
 return;
   if (isa(E) &&
   cast(E)->getOpcode() == UO_AddrOf) {
 auto *Op = cast(E)->getSubExpr()->IgnoreParens();
 if (isa(Op)) {
-  auto MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
+  auto *MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
   if (MA != MisalignedMembers.end() &&
-  (T->isIntegerType() ||
+  (T->isDependentType() || T->isIntegerType() ||
(T->isPointerType() && (T->getPointeeType()->isIncompleteType() ||
Context.getTypeAlignInChars(
T->getPointeeType()) <= 
MA->Alignment


Index: clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct __attribute__((packed)) {
+  unsigned options;
+  template 
+  void getOptions() {
+  (T *)
+  }
+  template 
+	void getOptions2() {
+  (U)
+	}
+} s;
+
+struct __attribute__((packed)) { // expected-error {{anonymous structs and classes must be class members}}
+   unsigned options ;
+  template  getOptions() // expected-error {{a type specifier is required for all declarations}}
+{
+  (T *) & options;
+}
+};
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -17387,15 +17387,15 @@
 
 void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
   E = E->IgnoreParens();
-  if (!T->isPointerType() && !T->isIntegerType())
+  if (!T->isPointerType() && !T->isIntegerType() && !T->isDependentType())
 return;
   if (isa(E) &&
   cast(E)->getOpcode() == UO_AddrOf) {
 auto *Op = cast(E)->getSubExpr()->IgnoreParens();
 if (isa(Op)) {
-  auto MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
+  auto *MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
   if (MA != MisalignedMembers.end() &&
-  (T->isIntegerType() ||
+  (T->isDependentType() || T->isIntegerType() ||
(T->isPointerType() && (T->getPointeeType()->isIncompleteType() ||
Context.getTypeAlignInChars(
T->getPointeeType()) <= MA->Alignment
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136007: [clang][modules][deps] System module maps might not be affecting

2022-10-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/test/ClangScanDeps/modules-redefinition.m:37
+// RUN: %clang @%t/third.cc1.rsp
+// RUN: %clang @%t/first.cc1.rsp

Before this patch, this would fail with duplicate definition of module 'X'. It 
would be reached from the explicitly-provided 
`-fmodule-map-file=%t/zeroth/module.modulemap` and the implicitly discovered 
`%t/second/module.modulemap`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136007

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


[clang] db82096 - [NFC] [C++20] [Modules] Test if the functions in importee are generated

2022-10-17 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-10-18T11:40:49+08:00
New Revision: db82096ff0aaadd4ce9b76ea3ffb188c9e5a0a64

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

LOG: [NFC] [C++20] [Modules] Test if the functions in importee are generated

In O0, all the functions (except the always-inline-functions) in the importee
shouldn't be imported for compilation speeds.

But with optimizations, all the potentially called function in the
importee should be imported to not prevent any inter-procedural
optimizations (primarily inline), which is pretty important for runtime
performances.

This patch adds the tests for the feature.

Added: 
clang/test/CodeGenCXX/module-funcs-from-imports.cppm

Modified: 


Removed: 




diff  --git a/clang/test/CodeGenCXX/module-funcs-from-imports.cppm 
b/clang/test/CodeGenCXX/module-funcs-from-imports.cppm
new file mode 100644
index 0..4d3e558e220e0
--- /dev/null
+++ b/clang/test/CodeGenCXX/module-funcs-from-imports.cppm
@@ -0,0 +1,74 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/M.cppm \
+// RUN:-emit-module-interface -o %t/M.pcm
+// RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t \
+// RUN:-S -emit-llvm -o - -disable-llvm-passes \
+// RUN:| FileCheck %t/Use.cpp --check-prefix=CHECK-O0
+//
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -O1 %t/M.cppm \
+// RUN:-emit-module-interface -o %t/M.pcm
+// RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t -O1 \
+// RUN:-S -emit-llvm -o - -disable-llvm-passes | \
+// RUN:FileCheck %t/Use.cpp --check-prefix=CHECK-O1
+
+//--- foo.h
+int func_in_gmf() {
+return 43;
+}
+int func_in_gmf_not_called() {
+return 44;
+}
+
+//--- M.cppm
+module;
+#include "foo.h"
+export module M;
+int non_exported_func() {
+return 43 + func_in_gmf();
+}
+export int exported_func() {
+return non_exported_func();
+}
+
+int non_exported_func_not_called() {
+return 44;
+}
+export int func_not_called() {
+return non_exported_func_not_called();
+}
+
+export 
+__attribute__((always_inline))
+int always_inline_func() {
+return 45;
+}
+
+//--- Use.cpp
+import M;
+int use() {
+return exported_func() + always_inline_func();
+}
+
+// Checks that none of the function (except the always_inline_func) in the 
importees
+// are generated in the importer's code.
+// CHECK-O0: define{{.*}}_Z3usev(
+// CHECK-O0: declare{{.*}}_ZW1M13exported_funcv(
+// CHECK-O0: define{{.*}}available_externally{{.*}}_ZW1M18always_inline_funcv(
+// CHECK-O0-NOT: func_in_gmf
+// CHECK-O0-NOT: func_in_gmf_not_called
+// CHECK-O0-NOT: non_exported_func
+// CHECK-O0-NOT: non_exported_func_not_called
+// CHECK-O0-NOT: func_not_called
+
+// Checks that all the potentially called function in the importees are 
generated in the importer's code
+// with available_externally attribute.
+// CHECK-O1: define{{.*}}_Z3usev(
+// CHECK-O1: define{{.*}}available_externally{{.*}}_ZW1M13exported_funcv(
+// CHECK-O1: define{{.*}}available_externally{{.*}}_ZW1M18always_inline_funcv(
+// CHECK-O1: define{{.*}}available_externally{{.*}}_ZW1M17non_exported_funcv(
+// CHECK-O1: define{{.*}}available_externally{{.*}}_Z11func_in_gmfv(
+// CHECK-O1-NOT: func_in_gmf_not_called
+// CHECK-O1-NOT: non_exported_func_not_called
+// CHECK-O1-NOT: func_not_called



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


[PATCH] D135938: [X86] Add AVX-VNNI-INT8 instructions.

2022-10-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/X86/X86InstrSSE.td:8141
+   i128mem, X86vpdpbssd, SchedWriteVecIMul.XMM,
+   1>,  T8XD;
+  defm VPDPBSSDY  : avx_dotprod_rm<0x50,"vpdpbssd",  v8i32, VR256, loadv8i32,

There are two spaces before T8XD. Same the next few instructions



Comment at: llvm/test/CodeGen/X86/avxvnniint8-intrinsics.ll:1
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avxvnniint8  
--show-mc-encoding | FileCheck %s --check-prefixes=X86

This is only testing half the intrinsics. I think you test the non-S for 128 
and the S for 256.



Comment at: llvm/test/CodeGen/X86/avxvnniint8-intrinsics.ll:6
+
+declare <4 x i32> @llvm.x86.avx2.vpdpbssd.128(<4 x i32>, <4 x i32>, <4 x i32>)
+

Are there tests for commuting?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135938

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


[PATCH] D136124: [clang][deps] Remove unintentional `move`

2022-10-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: DavidSpickett.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is a fix related to D135414 . The 
original intention was to keep `BaseFS` as a member of the worker and 
conditionally overlay it with local in-memory FS. The `move` of ref-counted 
`BaseFS` was not intended, and it's a bug.

Disabling parallelism in the "by-module-name" test reliably reproduces this, 
and the test itself doesn't *need* parallelism. (I think `-j 4` was cargo 
culted from another test.) Reusing that test to check for correct behavior...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136124

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/modules-full-by-mod-name.cpp


Index: clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
===
--- clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
+++ clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
@@ -11,11 +11,11 @@
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb_by_mod_name.json > 
%t.cdb
 // RUN: sed -e "s|DIR|%/t.dir|g" 
%S/Inputs/modules_cdb_clangcl_by_mod_name.json > %t_clangcl.cdb
 //
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -format 
experimental-full \
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format 
experimental-full \
 // RUN:   -mode preprocess-dependency-directives -module-name=header1 > 
%t.result
 // RUN: cat %t.result | sed 's:\?:/:g' | FileCheck -DPREFIX=%/t.dir 
--check-prefixes=CHECK %s
 //
-// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 4 -format 
experimental-full \
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -format 
experimental-full \
 // RUN:   -mode preprocess-dependency-directives -module-name=header1 > 
%t_clangcl.result
 // RUN: cat %t_clangcl.result | sed 's:\?:/:g' | FileCheck 
-DPREFIX=%/t.dir --check-prefixes=CHECK %s
 
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -396,8 +396,8 @@
 ModifiedCommandLine = CommandLine;
 ModifiedCommandLine->emplace_back(*ModuleName);
 
-auto OverlayFS = llvm::makeIntrusiveRefCnt(
-std::move(BaseFS));
+auto OverlayFS =
+llvm::makeIntrusiveRefCnt(BaseFS);
 auto InMemoryFS =
 llvm::makeIntrusiveRefCnt();
 InMemoryFS->setCurrentWorkingDirectory(WorkingDirectory);


Index: clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
===
--- clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
+++ clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
@@ -11,11 +11,11 @@
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb_by_mod_name.json > %t.cdb
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb_clangcl_by_mod_name.json > %t_clangcl.cdb
 //
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -format experimental-full \
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
 // RUN:   -mode preprocess-dependency-directives -module-name=header1 > %t.result
 // RUN: cat %t.result | sed 's:\?:/:g' | FileCheck -DPREFIX=%/t.dir --check-prefixes=CHECK %s
 //
-// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 4 -format experimental-full \
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -format experimental-full \
 // RUN:   -mode preprocess-dependency-directives -module-name=header1 > %t_clangcl.result
 // RUN: cat %t_clangcl.result | sed 's:\?:/:g' | FileCheck -DPREFIX=%/t.dir --check-prefixes=CHECK %s
 
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -396,8 +396,8 @@
 ModifiedCommandLine = CommandLine;
 ModifiedCommandLine->emplace_back(*ModuleName);
 
-auto OverlayFS = llvm::makeIntrusiveRefCnt(
-std::move(BaseFS));
+auto OverlayFS =
+llvm::makeIntrusiveRefCnt(BaseFS);
 auto InMemoryFS =
 llvm::makeIntrusiveRefCnt();
 InMemoryFS->setCurrentWorkingDirectory(WorkingDirectory);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135938: [X86] Add AVX-VNNI-INT8 instructions.

2022-10-17 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 468398.
FreddyYe added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135938

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/avxvnniint8intrin.h
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/immintrin.h
  clang/test/CodeGen/attr-target-x86.c
  clang/test/CodeGen/avxvnniint8-builtins.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrFoldTables.cpp
  llvm/lib/Target/X86/X86InstrFragmentsSIMD.td
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86IntrinsicsInfo.h
  llvm/test/CodeGen/X86/avxvnniint8-intrinsics.ll
  llvm/test/MC/Disassembler/X86/avx-vnni_int8-intel.txt
  llvm/test/MC/Disassembler/X86/x86-64-avx-vnni_int8-att.txt
  llvm/test/MC/X86/avx-vnni-int8-intel.s
  llvm/test/MC/X86/x86-64-avx-vnni-int8-att.s

Index: llvm/test/MC/X86/x86-64-avx-vnni-int8-att.s
===
--- /dev/null
+++ llvm/test/MC/X86/x86-64-avx-vnni-int8-att.s
@@ -0,0 +1,242 @@
+// RUN: llvm-mc -triple=x86_64-unknown-unknown -mattr=+avxvnniint8 --show-encoding < %s  | FileCheck %s
+
+// CHECK: vpdpbssd %ymm14, %ymm13, %ymm12
+// CHECK: encoding: [0xc4,0x42,0x17,0x50,0xe6]
+ vpdpbssd %ymm14, %ymm13, %ymm12
+
+// CHECK: vpdpbssd %xmm14, %xmm13, %xmm12
+// CHECK: encoding: [0xc4,0x42,0x13,0x50,0xe6]
+ vpdpbssd %xmm14, %xmm13, %xmm12
+
+// CHECK: vpdpbssd  268435456(%rbp,%r14,8), %ymm13, %ymm12
+// CHECK: encoding: [0xc4,0x22,0x17,0x50,0xa4,0xf5,0x00,0x00,0x00,0x10]
+ vpdpbssd  268435456(%rbp,%r14,8), %ymm13, %ymm12
+
+// CHECK: vpdpbssd  291(%r8,%rax,4), %ymm13, %ymm12
+// CHECK: encoding: [0xc4,0x42,0x17,0x50,0xa4,0x80,0x23,0x01,0x00,0x00]
+ vpdpbssd  291(%r8,%rax,4), %ymm13, %ymm12
+
+// CHECK: vpdpbssd  (%rip), %ymm13, %ymm12
+// CHECK: encoding: [0xc4,0x62,0x17,0x50,0x25,0x00,0x00,0x00,0x00]
+ vpdpbssd  (%rip), %ymm13, %ymm12
+
+// CHECK: vpdpbssd  -1024(,%rbp,2), %ymm13, %ymm12
+// CHECK: encoding: [0xc4,0x62,0x17,0x50,0x24,0x6d,0x00,0xfc,0xff,0xff]
+ vpdpbssd  -1024(,%rbp,2), %ymm13, %ymm12
+
+// CHECK: vpdpbssd  268435456(%rbp,%r14,8), %xmm13, %xmm12
+// CHECK: encoding: [0xc4,0x22,0x13,0x50,0xa4,0xf5,0x00,0x00,0x00,0x10]
+ vpdpbssd  268435456(%rbp,%r14,8), %xmm13, %xmm12
+
+// CHECK: vpdpbssd  291(%r8,%rax,4), %xmm13, %xmm12
+// CHECK: encoding: [0xc4,0x42,0x13,0x50,0xa4,0x80,0x23,0x01,0x00,0x00]
+ vpdpbssd  291(%r8,%rax,4), %xmm13, %xmm12
+
+// CHECK: vpdpbssd  (%rip), %xmm13, %xmm12
+// CHECK: encoding: [0xc4,0x62,0x13,0x50,0x25,0x00,0x00,0x00,0x00]
+ vpdpbssd  (%rip), %xmm13, %xmm12
+
+// CHECK: vpdpbssd  -512(,%rbp,2), %xmm13, %xmm12
+// CHECK: encoding: [0xc4,0x62,0x13,0x50,0x24,0x6d,0x00,0xfe,0xff,0xff]
+ vpdpbssd  -512(,%rbp,2), %xmm13, %xmm12
+
+// CHECK: vpdpbssds %ymm14, %ymm13, %ymm12
+// CHECK: encoding: [0xc4,0x42,0x17,0x51,0xe6]
+ vpdpbssds %ymm14, %ymm13, %ymm12
+
+// CHECK: vpdpbssds %xmm14, %xmm13, %xmm12
+// CHECK: encoding: [0xc4,0x42,0x13,0x51,0xe6]
+ vpdpbssds %xmm14, %xmm13, %xmm12
+
+// CHECK: vpdpbssds  268435456(%rbp,%r14,8), %ymm13, %ymm12
+// CHECK: encoding: [0xc4,0x22,0x17,0x51,0xa4,0xf5,0x00,0x00,0x00,0x10]
+ vpdpbssds  268435456(%rbp,%r14,8), %ymm13, %ymm12
+
+// CHECK: vpdpbssds  291(%r8,%rax,4), %ymm13, %ymm12
+// CHECK: encoding: [0xc4,0x42,0x17,0x51,0xa4,0x80,0x23,0x01,0x00,0x00]
+ vpdpbssds  291(%r8,%rax,4), %ymm13, %ymm12
+
+// CHECK: vpdpbssds  (%rip), %ymm13, %ymm12
+// CHECK: encoding: [0xc4,0x62,0x17,0x51,0x25,0x00,0x00,0x00,0x00]
+ vpdpbssds  (%rip), %ymm13, %ymm12
+
+// CHECK: vpdpbssds  -1024(,%rbp,2), %ymm13, %ymm12
+// CHECK: encoding: [0xc4,0x62,0x17,0x51,0x24,0x6d,0x00,0xfc,0xff,0xff]
+ vpdpbssds  -1024(,%rbp,2), %ymm13, %ymm12
+
+// CHECK: vpdpbssds  268435456(%rbp,%r14,8), %xmm13, %xmm12
+// CHECK: encoding: [0xc4,0x22,0x13,0x51,0xa4,0xf5,0x00,0x00,0x00,0x10]
+ vpdpbssds  268435456(%rbp,%r14,8), %xmm13, %xmm12
+
+// CHECK: vpdpbssds  291(%r8,%rax,4), %xmm13, %xmm12
+// CHECK: encoding: [0xc4,0x42,0x13,0x51,0xa4,0x80,0x23,0x01,0x00,0x00]
+ vpdpbssds  291(%r8,%rax,4), %xmm13, %xmm12
+
+// CHECK: vpdpbssds  (%rip), %xmm13, %xmm12
+// CHECK: encoding: [0xc4,0x62,0x13,0x51,0x25,0x00,0x00,0x00,0x00]
+ vpdpbssds  (%rip), %xmm13, %xmm12
+
+// CHECK: vpdpbssds  

[PATCH] D135933: [X86] Add CMPCCXADD instructions.

2022-10-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/X86/X86InstrSSE.td:8118
 
+let Predicates = [HasCMPCCXADD, In64BitMode], Constraints = "$dstsrc2 = $dst" 
in
+multiclass CMPCCXADD_BASE Opc, string OpcodeStr> {

craig.topper wrote:
> This feels like it belongs somewhere other than X86InstrSSE.td since it's not 
> vector related.
Missing `Defs = [EFLAGS]` I think


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135933

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


[PATCH] D135938: [X86] Add AVX-VNNI-INT8 instructions.

2022-10-17 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe marked 2 inline comments as done.
FreddyYe added inline comments.



Comment at: llvm/test/MC/Disassembler/X86/avx-vnni_int8-att.txt:1
+# RUN: llvm-mc --disassemble %s -triple=i686 | FileCheck %s
+

RKSimon wrote:
> I think we'd be better off merging the att/intel test files and using 
> --check-prefix 
I see many old tests split them into two files. What about remove 32bit att 
test and 64 bit intel test, it can also help reduce code base?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135938

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


[PATCH] D135933: [X86] Add CMPCCXADD instructions.

2022-10-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsX86_64.def:138
+TARGET_BUILTIN(__builtin_ia32_cmpccxadd64, "SLLiv*SLLiSLLiIi", "n", 
"cmpccxadd")
 #undef BUILTIN
 #undef TARGET_BUILTIN

There was a blank line here. Put it back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135933

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


[PATCH] D135933: [X86] Add CMPCCXADD instructions.

2022-10-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:781
+Builder.defineMacro("__CMPCCXADD__");
+  Builder.defineMacro("__CMPCCXADD_SUPPORTED__");
   if (HasAVXVNNI)

What is __CMPCCXADD_SUPPORTED__ for?



Comment at: llvm/lib/Target/X86/X86.td:259
+"Support CMPCCXADD instructions",
+[FeatureAVX2]>;
 def FeatureINVPCID : SubtargetFeature<"invpcid", "HasINVPCID", "true",

Why AVX2?



Comment at: llvm/lib/Target/X86/X86InstrSSE.td:8118
 
+let Predicates = [HasCMPCCXADD, In64BitMode], Constraints = "$dstsrc2 = $dst" 
in
+multiclass CMPCCXADD_BASE Opc, string OpcodeStr> {

This feels like it belongs somewhere other than X86InstrSSE.td since it's not 
vector related.



Comment at: llvm/lib/Target/X86/X86InstrSSE.td:8131
+
+defm CMPBEXADD : CMPCCXADD_BASE<0xe6, "cmpbexadd">;
+defm CMPBXADD  : CMPCCXADD_BASE<0xe2, "cmpbxadd">;

Any possibility of doing this like how JCC_1, SETCCr, and CMOV32rr using an 
immediate for the lower 4 bits of the opcode?



Comment at: llvm/lib/Target/X86/X86InstrSSE.td:8145-8146
+defm CMPPXADD : CMPCCXADD_BASE<0xea, "cmppxadd">;
+defm CMPSXADD : CMPCCXADD_BASE<0xe8, "cmpsxadd">;
+defm CMPZXADD : CMPCCXADD_BASE<0xe4, "cmpzxadd">;
+

Should there be aliases for consistency with Jcc, Setcc, and cmovcc. To support 
A, AE, GT, GE etc.?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135933

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


[PATCH] D134267: [C++] [Modules] Support one phase compilation model for named modules

2022-10-17 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added subscribers: ruoso, ben.boeckel.
ChuanqiXu added a comment.

>> Although modular code is user-facing - BMIs are an implementational detail, 
>> right?
>
> but I don't think BMIs are an implementation detail, anymore than object 
> files are - users should/will be as aware of BMIs as they are of .o files - 
> there build artifacts that need to be cached, can be out of date, can be 
> deleted/maybe copied/moved around in limited ways, have to be passed to other 
> tools in the build pipeline. Not sure what term to use, I guess compilers 
> don't often have warnings/errors/diagnostics that explicitly talk about 
> "object files" - so maybe in a similar sense they won't explicitly talk about 
> "binary module artifact files" but maybe?

Yeah, agreed. I guess @iains 's meaning may be "if the tool chains are ready 
enough one day, then the end user won't need to touch BMIs directly". Yeah, it 
looks true. Nowadays, many c++ programmers don't need to touch the `.o` files 
since the build systems have taken care for it (from my personal experience). 
But from the perspective of a compiler, the concept of `BMI` may be necessary. 
I remember when I wrote the documents for modules, I used the term "module 
file" at first. Then @ruoso corrected me that we should use `BMI` here. So I 
think the use of the term `BMI` may be correct here.

> The build system still needs to know that B.cppm depends on A.cppm - and once 
> it knows that, it's not a huge cost for it to know the name of the file that 
> represents that dependency and is produced by A.cppm and passed to B.cppm, I 
> think?

In a private chat with Kitware guys, they told me if the one phase compilation 
wasn't supported, they can mock it by replacing the original command by the 
combination of:

  clang++ -std=c++20 --precompile src.cppm -o src.pcm
  clang++ -std=c++20 src.pcm --precompile src.o

but the `pcm` files won't be depended directly. So it may be harder, I am not 
sure. @ben.boeckel any update?

> In short - seems like we should separate out the cache discussion from the 
> "one phase" compilation in the sense of a single build action that takes a 
> .cppm and generates both a .o and a .pcm in one compiler/driver invocation. 
> (maybe something like this is what @iains has already sent out in another 
> review?)

Agreed.

> to @iains point about "it'd be good if we didn't have to invoke two 
> underlying commands from the one drivter invocation" - yeah, agreed. Though I 
> wouldn't mind one step being "add the driver interface" and another being 
> "fix whatever serialization isuse/etc/ might stand in the way of doing 
> .cppm->{.o,.pcm} in a single action without serialization, so we can then 
> start stripping stuff out of the .pcm since it'll only need to contain the 
> interface, and not have to worry about having enough info for .o generation 
> anymore"

(I guess you're saying `without deserialization`)

Agreed in the higher level.

But what do you mean about `stripping stuff out of the .pcm`? Do you mean to 
remove some function bodies when writing the BMI? If yes, it'll be problematic. 
 When we did so, when other TU imports the BMI, it won't see the function 
bodies it could see before. This will prevent optimization. It'll be good as an 
optional flag so that the user know what the effect is. But it might not be 
good to  do so by default. (Although this paragraph starts to talk about other 
topics)


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

https://reviews.llvm.org/D134267

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


[PATCH] D135908: [clang][LTO] Setting Desired Default AIX Debugging Options

2022-10-17 Thread ChenZheng via Phabricator via cfe-commits
shchenz accepted this revision.
shchenz added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.




Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:588
+else if (A->getOption().matches(options::OPT_ggdb) ||
+ Args.getLastArg(options::OPT_ggdbN_Group))
   CmdArgs.push_back(

nit: maybe we don't need to change this. `OPT_gTune_Group` will check the four 
debugger types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135908

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


[PATCH] D126908: [VerifyDiagnosticConsumer] Fix last line being discarded when parsing newline

2022-10-17 Thread Vang Thao via Phabricator via cfe-commits
vangthao added inline comments.



Comment at: clang/test/SemaCXX/references.cpp:93
 
-struct C : B, A { }; // expected-warning {{direct base 'A' is inaccessible due 
to ambiguity:\nstruct C -> struct B -> struct A\nstruct C -> struct A}}
+struct C : B, A { }; // expected-warning {{direct base 'A' is inaccessible due 
to ambiguity:\nstruct C -> struct B -> struct A\nstruct C -> struct A}}
 

jkorous wrote:
> Can you please explain in detail what bug are you fixing?
> In my understanding if we stop parsing after the last newline then the 
> existing test would have failed. The difference seems to be only the 
> white-space.
> Am I missing something?
>In my understanding if we stop parsing after the last newline then the 
>existing test would have failed.
The reason it does not fail is because we do not perform an exact match. We 
only do a partial match since `contains()` is used here when matching 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp#L102.

We parsed the following from the expected-warning check:
  direct base 'A' is inaccessible due to ambiguity:
  struct C -> B -> A

and the actual output from clang is:
  direct base 'A' is inaccessible due to ambiguity:
  struct C -> B -> A
  struct C -> A

The output from clang does contain the expected warning that we parsed but not 
all of it since we discarded the last line of `\nstruct C -> struct A` from the 
check. You can verify that by adding anything on this line. It will not fail 
the test because we are not checking for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126908

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


[PATCH] D135772: Stop evaluating trailing requires clause after overload resolution

2022-10-17 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

LGTM then.


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

https://reviews.llvm.org/D135772

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


[PATCH] D130325: [ODRHash] Hash `ObjCMethodDecl` and diagnose discovered mismatches.

2022-10-17 Thread Volodymyr Sapsai 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 rG2662009c87f4: [ODRHash] Hash `ObjCMethodDecl` and diagnose 
discovered mismatches. (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D130325?vs=465952=468391#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130325

Files:
  clang/include/clang/AST/ODRDiagsEmitter.h
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/AST/ODRHash.cpp
  clang/test/Modules/compare-objc-protocol.m

Index: clang/test/Modules/compare-objc-protocol.m
===
--- clang/test/Modules/compare-objc-protocol.m
+++ clang/test/Modules/compare-objc-protocol.m
@@ -111,3 +111,134 @@
 // expected-error@first.h:* {{'CompareProtocolOrder' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 1st referenced protocol with name 'CommonProtocol'}}
 // expected-note@second.h:* {{but in 'Second' found 1st referenced protocol with different name 'ExtraProtocol'}}
 #endif
+
+#if defined(FIRST)
+@protocol CompareMatchingMethods
+- (float)matchingMethod:(int)arg;
+@end
+
+@protocol CompareMethodPresence1
+- (void)presenceMethod1;
+@end
+@protocol CompareMethodPresence2
+@end
+
+@protocol CompareMethodName
+- (void)methodNameA;
+@end
+
+@protocol CompareMethodArgCount
+- (void)methodArgCount:(int)arg0 :(int)arg1;
+@end
+@protocol CompareMethodArgName
+- (void)methodArgName:(int)argNameA;
+@end
+@protocol CompareMethodArgType
+- (void)methodArgType:(int)argType;
+@end
+
+@protocol CompareMethodReturnType
+- (int)methodReturnType;
+@end
+
+@protocol CompareMethodOrder
+- (void)methodOrderFirst;
+- (void)methodOrderSecond;
+@end
+
+@protocol CompareMethodClassInstance
+- (void)methodClassInstance;
+@end
+
+@protocol CompareMethodRequirednessExplicit
+@optional
+- (void)methodRequiredness;
+@end
+@protocol CompareMethodRequirednessDefault
+// @required is default
+- (void)methodRequiredness;
+@end
+#elif defined(SECOND)
+@protocol CompareMatchingMethods
+- (float)matchingMethod:(int)arg;
+@end
+
+@protocol CompareMethodPresence1
+@end
+@protocol CompareMethodPresence2
+- (void)presenceMethod2;
+@end
+
+@protocol CompareMethodName
+- (void)methodNameB;
+@end
+
+@protocol CompareMethodArgCount
+- (void)methodArgCount:(int)arg0;
+@end
+@protocol CompareMethodArgName
+- (void)methodArgName:(int)argNameB;
+@end
+@protocol CompareMethodArgType
+- (void)methodArgType:(float)argType;
+@end
+
+@protocol CompareMethodReturnType
+- (float)methodReturnType;
+@end
+
+@protocol CompareMethodOrder
+- (void)methodOrderSecond;
+- (void)methodOrderFirst;
+@end
+
+@protocol CompareMethodClassInstance
++ (void)methodClassInstance;
+@end
+
+@protocol CompareMethodRequirednessExplicit
+@required
+- (void)methodRequiredness;
+@end
+@protocol CompareMethodRequirednessDefault
+@required
+- (void)methodRequiredness;
+@end
+#else
+id compareMatchingMethods; // no error
+id compareMethodPresence1;
+// expected-error@first.h:* {{'CompareMethodPresence1' has different definitions in different modules; first difference is definition in module 'First.Hidden' found method}}
+// expected-note@second.h:* {{but in 'Second' found end of class}}
+id compareMethodPresence2;
+// expected-error@first.h:* {{'CompareMethodPresence2' has different definitions in different modules; first difference is definition in module 'First.Hidden' found end of class}}
+// expected-note@second.h:* {{but in 'Second' found method}}
+id compareMethodName;
+// expected-error@first.h:* {{'CompareMethodName' has different definitions in different modules; first difference is definition in module 'First.Hidden' found method 'methodNameA'}}
+// expected-note@second.h:* {{but in 'Second' found different method 'methodNameB'}}
+
+id compareMethodArgCount;
+// expected-error@first.h:* {{'CompareMethodArgCount' has different definitions in different modules; first difference is definition in module 'First.Hidden' found method 'methodArgCount::' that has 2 parameters}}
+// expected-note@second.h:* {{but in 'Second' found method 'methodArgCount:' that has 1 parameter}}
+id compareMethodArgName;
+// expected-error@first.h:* {{'CompareMethodArgName' has different definitions in different modules; first difference is definition in module 'First.Hidden' found method 'methodArgName:' with 1st parameter named 'argNameA'}}
+// expected-note@second.h:* {{but in 'Second' found method 'methodArgName:' with 1st parameter named 'argNameB'}}
+id compareMethodArgType;
+// expected-error@first.h:* {{'CompareMethodArgType' has different definitions in different modules; first difference is definition in module 'First.Hidden' found method 'methodArgType:' with 1st parameter of type 'int'}}
+// expected-note@second.h:* {{but in 

[clang] 2662009 - [ODRHash] Hash `ObjCMethodDecl` and diagnose discovered mismatches.

2022-10-17 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2022-10-17T18:48:24-07:00
New Revision: 2662009c87f470ec5bc13c237cd62c57b28e4032

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

LOG: [ODRHash] Hash `ObjCMethodDecl` and diagnose discovered mismatches.

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

Added: 


Modified: 
clang/include/clang/AST/ODRDiagsEmitter.h
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/lib/AST/ODRDiagsEmitter.cpp
clang/lib/AST/ODRHash.cpp
clang/test/Modules/compare-objc-protocol.m

Removed: 




diff  --git a/clang/include/clang/AST/ODRDiagsEmitter.h 
b/clang/include/clang/AST/ODRDiagsEmitter.h
index d79b3e1c0649..cbabaa7e69b4 100644
--- a/clang/include/clang/AST/ODRDiagsEmitter.h
+++ b/clang/include/clang/AST/ODRDiagsEmitter.h
@@ -62,8 +62,10 @@ class ODRDiagsEmitter {
 private:
   using DeclHashes = llvm::SmallVector, 4>;
 
-  // Used with err_module_odr_violation_mismatch_decl and
-  // note_module_odr_violation_mismatch_decl
+  // Used with err_module_odr_violation_mismatch_decl,
+  // note_module_odr_violation_mismatch_decl,
+  // err_module_odr_violation_mismatch_decl_unknown,
+  // and note_module_odr_violation_mismatch_decl_unknown
   // This list should be the same Decl's as in ODRHash::isSubDeclToBeProcessed
   enum ODRMismatchDecl {
 EndOfClass,
@@ -78,6 +80,7 @@ class ODRDiagsEmitter {
 Var,
 Friend,
 FunctionTemplate,
+ObjCMethod,
 Other
   };
 
@@ -137,6 +140,15 @@ class ODRDiagsEmitter {
 const ObjCContainerDecl *SecondContainer,
 StringRef SecondModule) const;
 
+  /// Check if Objective-C methods are the same and diagnose if 
diff erent.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  bool diagnoseSubMismatchObjCMethod(const NamedDecl *FirstObjCContainer,
+ StringRef FirstModule,
+ StringRef SecondModule,
+ const ObjCMethodDecl *FirstMethod,
+ const ObjCMethodDecl *SecondMethod) const;
+
 private:
   DiagnosticsEngine 
   const ASTContext 

diff  --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index 2517f52a7cf7..c4f520442549 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -621,11 +621,11 @@ def err_module_odr_violation_mismatch_decl : Error<
   "%select{definition in module '%2'|defined here}1 found "
   "%select{end of class|public access specifier|private access specifier|"
   "protected access specifier|static assert|field|method|type alias|typedef|"
-  "data member|friend declaration|function template}3">;
+  "data member|friend declaration|function template|method}3">;
 def note_module_odr_violation_mismatch_decl : Note<"but in '%0' found "
   "%select{end of class|public access specifier|private access specifier|"
   "protected access specifier|static assert|field|method|type alias|typedef|"
-  "data member|friend declaration|function template}1">;
+  "data member|friend declaration|function template|method}1">;
 
 def err_module_odr_violation_record : Error<
   "%q0 has 
diff erent definitions in 
diff erent modules; first 
diff erence is "
@@ -649,12 +649,6 @@ def err_module_odr_violation_record : Error<
 "is %select{not const|const}6|"
   "%select{method %5|constructor|destructor}4 "
 "is %select{not inline|inline}6|"
-  "%select{method %5|constructor|destructor}4 "
-"that has %6 parameter%s6|"
-  "%select{method %5|constructor|destructor}4 "
-"with %ordinal6 parameter of type %7%select{| decayed from %9}8|"
-  "%select{method %5|constructor|destructor}4 "
-"with %ordinal6 parameter named %7|"
   "%select{method %5|constructor|destructor}4 "
 "with %ordinal6 parameter with%select{out|}7 a default argument|"
   "%select{method %5|constructor|destructor}4 "
@@ -706,12 +700,6 @@ def note_module_odr_violation_record : Note<"but in '%0' 
found "
 "is %select{not const|const}4|"
   "%select{method %3|constructor|destructor}2 "
 "is %select{not inline|inline}4|"
-  "%select{method %3|constructor|destructor}2 "
-"that has %4 parameter%s4|"
-  "%select{method %3|constructor|destructor}2 "
-"with %ordinal4 parameter of type %5%select{| decayed from %7}6|"
-  "%select{method %3|constructor|destructor}2 "
-"with %ordinal4 parameter named %5|"
   "%select{method %3|constructor|destructor}2 "
 "with %ordinal4 parameter with%select{out|}5 a default argument|"
   "%select{method %3|constructor|destructor}2 "
@@ -861,17 +849,59 @@ def note_module_odr_violation_referenced_protocols : Note 
<"but in '%0' 

[PATCH] D135937: [X86] Support -march=meteorlake

2022-10-17 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe marked 3 inline comments as done.
FreddyYe added a comment.

THX for review! Gcc is also recently reviewing related patches. So to align 
with the compiler-rt and libgcc, let's wait for their land first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135937

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


[PATCH] D135937: [X86] Support -march=meteorlake

2022-10-17 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 468387.
FreddyYe added a comment.

Merge raptorlake patch and address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135937

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/X86.cpp
  clang/test/CodeGen/attr-target-mv.c
  clang/test/CodeGen/target-builtin-noerror.c
  clang/test/Driver/x86-march.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/predefined-arch-macros.c
  compiler-rt/lib/builtins/cpu_model.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/include/llvm/Support/X86TargetParser.h
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -17,6 +17,8 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=yonah 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=prescott 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=lakemont 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=raptorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=meteorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -52,6 +54,8 @@
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=tremont 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=knl 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=knm 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=raptorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=meteorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 define void @foo() {
   ret void
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1481,6 +1481,10 @@
 ProcessorFeatures.SPRFeatures, ProcessorFeatures.SPRTuning>;
 def : ProcModel<"alderlake", AlderlakePModel,
 ProcessorFeatures.ADLFeatures, ProcessorFeatures.ADLTuning>;
+def : ProcModel<"raptorlake", AlderlakePModel,
+ProcessorFeatures.ADLFeatures, ProcessorFeatures.ADLTuning>;
+def : ProcModel<"meteorlake", AlderlakePModel,
+ProcessorFeatures.ADLFeatures, ProcessorFeatures.ADLTuning>;
 
 // AMD CPUs.
 
Index: llvm/lib/Support/X86TargetParser.cpp
===
--- llvm/lib/Support/X86TargetParser.cpp
+++ llvm/lib/Support/X86TargetParser.cpp
@@ -370,6 +370,10 @@
   { {"sapphirerapids"}, CK_SapphireRapids, FEATURE_AVX512BF16, FeaturesSapphireRapids },
   // Alderlake microarchitecture based processors.
   { {"alderlake"}, CK_Alderlake, FEATURE_AVX2, FeaturesAlderlake },
+  // Raptorlake microarchitecture based processors.
+  { {"raptorlake"}, CK_Raptorlake, FEATURE_AVX2, FeaturesAlderlake },
+  // Meteorlake microarchitecture based processors.
+  { {"meteorlake"}, CK_Meteorlake, FEATURE_AVX2, FeaturesAlderlake },
   // Knights Landing processor.
   { {"knl"}, CK_KNL, FEATURE_AVX512F, FeaturesKNL },
   // Knights Mill processor.
Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -820,6 +820,21 @@
   *Subtype = X86::INTEL_COREI7_ALDERLAKE;
   break;
 
+// Raptorlake:
+case 0xb7:
+  CPU = "raptorlake";
+  *Type = X86::INTEL_COREI7;
+  *Subtype = X86::INTEL_COREI7_RAPTORLAKE;
+  break;
+
+// Meteorlake:
+case 0xb5:
+case 0xaa:
+case 0xac:
+  CPU = "meteorlake";
+  *Type = X86::INTEL_COREI7;
+  *Subtype = X86::INTEL_COREI7_METEORLAKE;
+
 // Icelake Xeon:
 case 0x6a:
 case 0x6c:
Index: llvm/include/llvm/Support/X86TargetParser.h
===
--- 

[PATCH] D135936: [X86] Support -march=raptorlake

2022-10-17 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe marked 4 inline comments as done.
FreddyYe added a comment.

THX for review! Merged to https://reviews.llvm.org/D135937 and addressed there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135936

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


[PATCH] D130324: [ODRHash] Hash `ObjCProtocolDecl` and diagnose discovered mismatches.

2022-10-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130324

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


[clang] 37fdca2 - [ODRHash] Rename `isDeclToBeProcessed` to `isSubDeclToBeProcessed`. NFC intended.

2022-10-17 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2022-10-17T18:24:44-07:00
New Revision: 37fdca21f7f61dee5426f55b0ee7bf601d95afcd

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

LOG: [ODRHash] Rename `isDeclToBeProcessed` to `isSubDeclToBeProcessed`. NFC 
intended.

The method is used only for sub-Decls, so reflect that in the name.

Added: 


Modified: 
clang/include/clang/AST/ODRDiagsEmitter.h
clang/include/clang/AST/ODRHash.h
clang/lib/AST/ODRDiagsEmitter.cpp
clang/lib/AST/ODRHash.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ODRDiagsEmitter.h 
b/clang/include/clang/AST/ODRDiagsEmitter.h
index af345310c3a4..d79b3e1c0649 100644
--- a/clang/include/clang/AST/ODRDiagsEmitter.h
+++ b/clang/include/clang/AST/ODRDiagsEmitter.h
@@ -64,7 +64,7 @@ class ODRDiagsEmitter {
 
   // Used with err_module_odr_violation_mismatch_decl and
   // note_module_odr_violation_mismatch_decl
-  // This list should be the same Decl's as in ODRHash::isDeclToBeProcessed
+  // This list should be the same Decl's as in ODRHash::isSubDeclToBeProcessed
   enum ODRMismatchDecl {
 EndOfClass,
 PublicSpecifer,

diff  --git a/clang/include/clang/AST/ODRHash.h 
b/clang/include/clang/AST/ODRHash.h
index 59b74cf477dd..1ab20013a367 100644
--- a/clang/include/clang/AST/ODRHash.h
+++ b/clang/include/clang/AST/ODRHash.h
@@ -93,7 +93,7 @@ class ODRHash {
   // Save booleans until the end to lower the size of data to process.
   void AddBoolean(bool value);
 
-  static bool isDeclToBeProcessed(const Decl* D, const DeclContext *Parent);
+  static bool isSubDeclToBeProcessed(const Decl *D, const DeclContext *Parent);
 
 private:
   void AddDeclarationNameImpl(DeclarationName Name);

diff  --git a/clang/lib/AST/ODRDiagsEmitter.cpp 
b/clang/lib/AST/ODRDiagsEmitter.cpp
index 3cc280a53a8c..1fda502e323b 100644
--- a/clang/lib/AST/ODRDiagsEmitter.cpp
+++ b/clang/lib/AST/ODRDiagsEmitter.cpp
@@ -630,7 +630,7 @@ bool ODRDiagsEmitter::diagnoseMismatch(
   auto PopulateHashes = [](DeclHashes , const RecordDecl *Record,
const DeclContext *DC) {
 for (const Decl *D : Record->decls()) {
-  if (!ODRHash::isDeclToBeProcessed(D, DC))
+  if (!ODRHash::isSubDeclToBeProcessed(D, DC))
 continue;
   Hashes.emplace_back(D, computeODRHash(D));
 }
@@ -1538,7 +1538,7 @@ bool ODRDiagsEmitter::diagnoseMismatch(const EnumDecl 
*FirstEnum,
 for (const Decl *D : Enum->decls()) {
   // Due to decl merging, the first EnumDecl is the parent of
   // Decls in both records.
-  if (!ODRHash::isDeclToBeProcessed(D, FirstEnum))
+  if (!ODRHash::isSubDeclToBeProcessed(D, FirstEnum))
 continue;
   assert(isa(D) && "Unexpected Decl kind");
   Hashes.emplace_back(cast(D), computeODRHash(D));
@@ -1620,7 +1620,7 @@ bool ODRDiagsEmitter::diagnoseMismatch(
   auto PopulateHashes = [](DeclHashes , const ObjCProtocolDecl *ID,
const DeclContext *DC) {
 for (const Decl *D : ID->decls()) {
-  if (!ODRHash::isDeclToBeProcessed(D, DC))
+  if (!ODRHash::isSubDeclToBeProcessed(D, DC))
 continue;
   Hashes.emplace_back(D, computeODRHash(D));
 }

diff  --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index cbb3e8730517..b485e93f76c2 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -441,7 +441,7 @@ class ODRDeclVisitor : public 
ConstDeclVisitor {
 
 // Only allow a small portion of Decl's to be processed.  Remove this once
 // all Decl's can be handled.
-bool ODRHash::isDeclToBeProcessed(const Decl *D, const DeclContext *Parent) {
+bool ODRHash::isSubDeclToBeProcessed(const Decl *D, const DeclContext *Parent) 
{
   if (D->isImplicit()) return false;
   if (D->getDeclContext() != Parent) return false;
 
@@ -488,7 +488,7 @@ void ODRHash::AddCXXRecordDecl(const CXXRecordDecl *Record) 
{
   // accurate count of Decl's.
   llvm::SmallVector Decls;
   for (Decl *SubDecl : Record->decls()) {
-if (isDeclToBeProcessed(SubDecl, Record)) {
+if (isSubDeclToBeProcessed(SubDecl, Record)) {
   Decls.push_back(SubDecl);
   if (auto *Function = dyn_cast(SubDecl)) {
 // Compute/Preload ODRHash into FunctionDecl.
@@ -589,7 +589,7 @@ void ODRHash::AddFunctionDecl(const FunctionDecl *Function,
   // accurate count of Decl's.
   llvm::SmallVector Decls;
   for (Decl *SubDecl : Function->decls()) {
-if (isDeclToBeProcessed(SubDecl, Function)) {
+if (isSubDeclToBeProcessed(SubDecl, Function)) {
   Decls.push_back(SubDecl);
 }
   }
@@ -615,7 +615,7 @@ void ODRHash::AddEnumDecl(const EnumDecl *Enum) {
   // accurate count of Decl's.
   llvm::SmallVector Decls;
   for (Decl *SubDecl : Enum->decls()) {
-if (isDeclToBeProcessed(SubDecl, Enum)) {
+if 

Re: [clang] 0674f2e - [NFC] Fix warning on no return after switch.

2022-10-17 Thread David Blaikie via cfe-commits
On Mon, Oct 17, 2022 at 5:52 PM stan li  wrote:
>
> Thanks for the suggestion.
>
>
>
> Updated llvm_unreachable.
>
>
>
> The static_cast not only check the switch cases all covered, also make sure 2 
> enums not out of sync.


Ah, OK  - thanks for explaining!

>
>
>
>
>
>
>
> Sent from Mail for Windows
>
>
>
> From: David Blaikie
> Sent: Monday, October 17, 2022 5:42 PM
> To: Xiang Li; Xiang Li
> Cc: cfe-commits@lists.llvm.org
> Subject: Re: [clang] 0674f2e - [NFC] Fix warning on no return after switch.
>
>
>
> Also the static_assert is probably not needed - Clang builds with
> -Wswitch-enum, which will warn if a switch over an enum doesn't cover
> all the enumerators. We have lots of other switches over enums that
> depend on this warning to detect code that needs to be updated when an
> enum is modified.
>
> On Mon, Oct 17, 2022 at 5:40 PM David Blaikie  wrote:
> >
> > If the switch is exhaustive (covers all the enumerators in an
> > enumeration), we usually use an llvm_unreachable at the end, rather
> > than a return. Could you change this to an llvm_unreachable?
> >
> > On Mon, Oct 17, 2022 at 3:52 PM Xiang Li via cfe-commits
> >  wrote:
> > >
> > >
> > > Author: Xiang Li
> > > Date: 2022-10-17T15:52:23-07:00
> > > New Revision: 0674f2ec96422131abde0c042fbf2c11267db210
> > >
> > > URL: 
> > > https://github.com/llvm/llvm-project/commit/0674f2ec96422131abde0c042fbf2c11267db210
> > > DIFF: 
> > > https://github.com/llvm/llvm-project/commit/0674f2ec96422131abde0c042fbf2c11267db210.diff
> > >
> > > LOG: [NFC] Fix warning on no return after switch.
> > >
> > > Added:
> > >
> > >
> > > Modified:
> > > clang/lib/CodeGen/CGHLSLRuntime.cpp
> > >
> > > Removed:
> > >
> > >
> > >
> > > 
> > > diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
> > > b/clang/lib/CodeGen/CGHLSLRuntime.cpp
> > > index 7a80dedb8133..6f32136b49de 100644
> > > --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
> > > +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
> > > @@ -270,6 +270,7 @@ 
> > > castResourceShapeToResourceKind(HLSLResourceAttr::ResourceKind RK) {
> > >static_cast(
> > >HLSLResourceAttr::ResourceKind::FeedbackTexture2DArray) ==
> > >(static_cast(llvm::hlsl::ResourceKind::NumEntries) - 2));
> > > +  return llvm::hlsl::ResourceKind::Invalid;
> > >  }
> > >
> > >  void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, 
> > > GlobalVariable *GV) {
> > >
> > >
> > >
> > > ___
> > > cfe-commits mailing list
> > > cfe-commits@lists.llvm.org
> > > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134267: [C++] [Modules] Support one phase compilation model for named modules

2022-10-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D134267#3851479 , @ChuanqiXu wrote:

> In D134267#3849629 , @dblaikie 
> wrote:
>
>> To the original point I was making about implicit modules (which might've 
>> been my own confusion due to the term being brought up in D134269 
>> ):
>>
>> Implicit modules is the situation where the compiler, finding that it needs 
>> a module while compiling some usage, knows how to go out and spawn a new 
>> process to create that module and then cache it. The build system never 
>> knows about modules, their builds or their dependencies.
>>
>> This patch had some superficial similarities - specifically around having an 
>> on-disk cache of modules that the user/build system/etc invoking the 
>> compiler isn't necessarily aware of/managing/invalidating/observing/etc. But 
>> it does differ in an important way from implicit modules in that the 
>> compiler won't implicitly build modules - you still have to specify the 
>> modules and their usage as separate compilations in-order (ie: modules need 
>> to be explicitly built before their usage). I think that makes a big 
>> difference to this being feasible, at least in the small scale.
>
> Oh, now I got your point. It is caused by the imprecise name. My bad.
>
>> The remaining concern is that this feature should likely not be used by a 
>> build system - because it won't know the dependencies (or, if it does know 
>> the dependencies then the build system, not the compiler, should be managing 
>> the BMIs) & so won't know how to schedule things for maximum parallelism 
>> without incorrect ordering, and correct rebuilding of dependencies when 
>> necessary.
>
> I agree it won't reach the maximum parallelism. But I think it should be able 
> to rebuild correctly if the build system understands the dependencies between 
> module unit. For example, if B.cpp imports module A, and A is defined in 
> A.cppm. And when A.cppm changes, it will be fine if the build system will 
> compile A.cppm first and compile B.cpp then. I think this is achievable by 
> the build system. (For example, the P1689  
> proposal I'm working on). So the problem becomes a performance problem 
> instead of a correctness problem. So it looks not bad to me. I still feel it 
> is not good to make perfect as the enemy of better.

The build system still needs to know that B.cppm depends on A.cppm - and once 
it knows that, it's not a huge cost for it to know the name of the file that 
represents that dependency and is produced by A.cppm and passed to B.cppm, I 
think?

In short - seems like we should separate out the cache discussion from the "one 
phase" compilation in the sense of a single build action that takes a .cppm and 
generates both a .o and a .pcm in one compiler/driver invocation. (maybe 
something like this is what @iains has already sent out in another review?)

to @iains point about "it'd be good if we didn't have to invoke two underlying 
commands from the one drivter invocation" - yeah, agreed. Though I wouldn't 
mind one step being "add the driver interface" and another being "fix whatever 
serialization isuse/etc/ might stand in the way of doing .cppm->{.o,.pcm} in a 
single action without serialization, so we can then start stripping stuff out 
of the .pcm since it'll only need to contain the interface, and not have to 
worry about having enough info for .o generation anymore"


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

https://reviews.llvm.org/D134267

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


[PATCH] D134267: [C++] [Modules] Support one phase compilation model for named modules

2022-10-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

(sorry I've not been following all this as closely as I should - but I don't 
think BMIs are an implementation detail, anymore than object files are - users 
should/will be as aware of BMIs as they are of .o files - there build artifacts 
that need to be cached, can be out of date, can be deleted/maybe copied/moved 
around in limited ways, have to be passed to other tools in the build pipeline. 
Not sure what term to use, I guess compilers don't often have 
warnings/errors/diagnostics that explicitly talk about "object files" - so 
maybe in a similar sense they won't explicitly talk about "binary module 
artifact files" but maybe?)


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

https://reviews.llvm.org/D134267

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


[clang] 3a671c8 - [NFC] use llvm_unreachable instead of return on switch which all cases are covered.

2022-10-17 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-10-17T17:47:48-07:00
New Revision: 3a671c8e91c04a3288357f088adcd364a6cd6b22

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

LOG: [NFC] use llvm_unreachable instead of return on switch which all cases are 
covered.

Added: 


Modified: 
clang/lib/CodeGen/CGHLSLRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 6f32136b49de..cfdc1f68a03d 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -270,7 +270,7 @@ 
castResourceShapeToResourceKind(HLSLResourceAttr::ResourceKind RK) {
   static_cast(
   HLSLResourceAttr::ResourceKind::FeedbackTexture2DArray) ==
   (static_cast(llvm::hlsl::ResourceKind::NumEntries) - 2));
-  return llvm::hlsl::ResourceKind::Invalid;
+  llvm_unreachable("all switch cases should be covered");
 }
 
 void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable *GV) 
{



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


Re: [clang] 0674f2e - [NFC] Fix warning on no return after switch.

2022-10-17 Thread David Blaikie via cfe-commits
Also the static_assert is probably not needed - Clang builds with
-Wswitch-enum, which will warn if a switch over an enum doesn't cover
all the enumerators. We have lots of other switches over enums that
depend on this warning to detect code that needs to be updated when an
enum is modified.

On Mon, Oct 17, 2022 at 5:40 PM David Blaikie  wrote:
>
> If the switch is exhaustive (covers all the enumerators in an
> enumeration), we usually use an llvm_unreachable at the end, rather
> than a return. Could you change this to an llvm_unreachable?
>
> On Mon, Oct 17, 2022 at 3:52 PM Xiang Li via cfe-commits
>  wrote:
> >
> >
> > Author: Xiang Li
> > Date: 2022-10-17T15:52:23-07:00
> > New Revision: 0674f2ec96422131abde0c042fbf2c11267db210
> >
> > URL: 
> > https://github.com/llvm/llvm-project/commit/0674f2ec96422131abde0c042fbf2c11267db210
> > DIFF: 
> > https://github.com/llvm/llvm-project/commit/0674f2ec96422131abde0c042fbf2c11267db210.diff
> >
> > LOG: [NFC] Fix warning on no return after switch.
> >
> > Added:
> >
> >
> > Modified:
> > clang/lib/CodeGen/CGHLSLRuntime.cpp
> >
> > Removed:
> >
> >
> >
> > 
> > diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
> > b/clang/lib/CodeGen/CGHLSLRuntime.cpp
> > index 7a80dedb8133..6f32136b49de 100644
> > --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
> > +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
> > @@ -270,6 +270,7 @@ 
> > castResourceShapeToResourceKind(HLSLResourceAttr::ResourceKind RK) {
> >static_cast(
> >HLSLResourceAttr::ResourceKind::FeedbackTexture2DArray) ==
> >(static_cast(llvm::hlsl::ResourceKind::NumEntries) - 2));
> > +  return llvm::hlsl::ResourceKind::Invalid;
> >  }
> >
> >  void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable 
> > *GV) {
> >
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 0674f2e - [NFC] Fix warning on no return after switch.

2022-10-17 Thread David Blaikie via cfe-commits
If the switch is exhaustive (covers all the enumerators in an
enumeration), we usually use an llvm_unreachable at the end, rather
than a return. Could you change this to an llvm_unreachable?

On Mon, Oct 17, 2022 at 3:52 PM Xiang Li via cfe-commits
 wrote:
>
>
> Author: Xiang Li
> Date: 2022-10-17T15:52:23-07:00
> New Revision: 0674f2ec96422131abde0c042fbf2c11267db210
>
> URL: 
> https://github.com/llvm/llvm-project/commit/0674f2ec96422131abde0c042fbf2c11267db210
> DIFF: 
> https://github.com/llvm/llvm-project/commit/0674f2ec96422131abde0c042fbf2c11267db210.diff
>
> LOG: [NFC] Fix warning on no return after switch.
>
> Added:
>
>
> Modified:
> clang/lib/CodeGen/CGHLSLRuntime.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
> b/clang/lib/CodeGen/CGHLSLRuntime.cpp
> index 7a80dedb8133..6f32136b49de 100644
> --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
> +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
> @@ -270,6 +270,7 @@ 
> castResourceShapeToResourceKind(HLSLResourceAttr::ResourceKind RK) {
>static_cast(
>HLSLResourceAttr::ResourceKind::FeedbackTexture2DArray) ==
>(static_cast(llvm::hlsl::ResourceKind::NumEntries) - 2));
> +  return llvm::hlsl::ResourceKind::Invalid;
>  }
>
>  void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable 
> *GV) {
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136041: [clang][DebugInfo] Emit DISubprogram for extern functions with reserved names

2022-10-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Hmm - this does mean linking IR can produce invalid code, though, right (you 
link in a definition of the function, so what was valid is now invalid - 
because it now has a definition, can be inlined, etc)? Is that new? concerning?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136041

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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs

2022-10-17 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In what scenarios will clang load the clang.cfg file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134337

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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs

2022-10-17 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added inline comments.



Comment at: clang/docs/UsersManual.rst:954
+
+For example, ``x86_64-pc-linux-gnu-clang-g++`` will attempt to load two
+configuration files named respectively::

Is `x86_64-pc-linux-gnu-clang-g++ ` being passed to --driver= in this example?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134337

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


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

2022-10-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

It's certainly possible that other targets will want to support multiple C++ 
ABIs in the future, but it's okay for us to design things around the situation 
we've got today.  A lot of these "ABIs" are just target-specific variants; if 
it simplifies code to just make ABI queries just be target queries instead of 
abstracting the target C++ ABI, and the resulting burden on targets with 
multiple supported ABIs is very small, that seems like an acceptable trade-off. 
 If things change and we get a lot of targets asking to support multiple ABIs, 
there's no reason we can't revisit this decision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

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


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-10-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D127403#3863686 , @thakis wrote:

> In D127403#3863641 , @nridge wrote:
>
>> Landed https://reviews.llvm.org/rGc93430bae4fc
>
> Still failing with that: http://45.33.8.238/linux/89240/step_9.txt

Fixed in https://reviews.llvm.org/rGd5a99bf5e134, and confirmed via a local 
build and test run that the tests are passing. Apologies for the breakage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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


[PATCH] D135713: [cmake][Fuchsia] Add -ftrivial-auto-var-init=zero to runtimes build

2022-10-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

any chance of using pattern init rather than zero init, so this doesn't hide 
uninitialized bugs?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135713

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


[clang-tools-extra] d5a99bf - [clangd] Update 'using enum' semantic highlighting testcase to use the 'definition' modifier

2022-10-17 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2022-10-17T20:15:52-04:00
New Revision: d5a99bf5e134b31cf6ef3219313fa7d2fc480629

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

LOG: [clangd] Update 'using enum' semantic highlighting testcase to use the 
'definition' modifier

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 5bc458b90311..d08deecb23eb 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -842,7 +842,7 @@ sizeof...($TemplateParameter[[Elements]]);
   enum class $Enum_decl[[Color]] { $EnumConstant_decl_readonly[[Black]] };
   namespace $Namespace_decl[[ns]] {
 using enum $Enum[[Color]];
-$Enum[[Color]] $Variable_decl[[ModelT]] = $EnumConstant[[Black]];
+$Enum[[Color]] $Variable_def[[ModelT]] = $EnumConstant[[Black]];
   }
   )cpp",
   // Issue 1096



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


[PATCH] D134902: [clang] Implement -fstrict-flex-arrays=3

2022-10-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/test/CodeGen/bounds-checking-fam.c:2
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fstrict-flex-arrays=0 
-fsanitize=array-bounds%s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-STRICT-0
-// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fstrict-flex-arrays=0 
-fsanitize=array-bounds -x c++ %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-STRICT-0,CXX,CXX-STRICT-0
-// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fstrict-flex-arrays=1 
-fsanitize=array-bounds%s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-STRICT-1
-// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fstrict-flex-arrays=1 
-fsanitize=array-bounds -x c++ %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-STRICT-1,CXX
-// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fstrict-flex-arrays=2 
-fsanitize=array-bounds%s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-STRICT-2
-// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fstrict-flex-arrays=2 
-fsanitize=array-bounds -x c++ %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-STRICT-2,CXX
+// RUN: %clang_cc1 -O2 -emit-llvm -triple x86_64 -fstrict-flex-arrays=0 
-fsanitize=array-bounds%s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-STRICT-0
+// RUN: %clang_cc1 -O2 -emit-llvm -triple x86_64 -fstrict-flex-arrays=0 
-fsanitize=array-bounds -x c++ %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-STRICT-0,CXX,CXX-STRICT-0

void wrote:
> serge-sans-paille wrote:
> > Why adding -02 here?
> Mostly because that's how Linux compiles its files. It also mirrors the test 
> below. I'm not super married to it if you'd rather I omit it.
Yeah, generally Clang tests don't run LLVM optimizations - clang should be 
checking the output of Clang's IRGen, not the optimizations that LLVM performs.

Not sure how many Clang codegen tests disable llvm optimizations entirely, but 
that's basically/should be the default (-disable-llvm-optzns, I think that's 
the flag anyway).

If LLVM's output is so verbose it's hard to check reliably/non-brittally then 
maybe running some optimizations to simplify things might be acceptable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134902

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


[PATCH] D136120: [Clang] follow-up D128745, remove all ClangABICompat checks

2022-10-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: aaron.ballman, erichkeane, hubert.reinterpretcast.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Per discussions in D128745 , remove 
ClangABICompat checks for implementations
of DR692/DR1395/DR1432. This is a potentially breaking changes, so the release
note is updated accordingly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136120

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateDeduction.cpp

Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1128,9 +1128,7 @@
   // During partial ordering, if Ai was originally a function parameter pack:
   // - if P does not contain a function parameter type corresponding to Ai then
   //   Ai is ignored;
-  bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
-  LangOptions::ClangABI::Ver15;
-  if (!ClangABICompat15 && PartialOrdering && ArgIdx + 1 == NumArgs &&
+  if (PartialOrdering && ArgIdx + 1 == NumArgs &&
   isa(Args[ArgIdx]))
 return Sema::TDK_Success;
 
@@ -2466,9 +2464,6 @@
   if (X.getKind() != Y.getKind())
 return false;
 
-  bool ClangABICompat15 =
-  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
-
   switch (X.getKind()) {
 case TemplateArgument::Null:
   llvm_unreachable("Comparing NULL template argument");
@@ -2500,45 +2495,33 @@
   return XID == YID;
 }
 
-case TemplateArgument::Pack:
-  if (ClangABICompat15) {
-if (X.pack_size() != Y.pack_size())
+case TemplateArgument::Pack: {
+  unsigned PackIterationSize = X.pack_size();
+  if (X.pack_size() != Y.pack_size()) {
+if (!PartialOrdering)
   return false;
 
-for (TemplateArgument::pack_iterator XP = X.pack_begin(),
- XPEnd = X.pack_end(),
- YP = Y.pack_begin();
- XP != XPEnd; ++XP, ++YP)
-  if (!isSameTemplateArg(Context, *XP, *YP, PartialOrdering,
- PackExpansionMatchesPack))
-return false;
-  } else {
-unsigned PackIterationSize = X.pack_size();
-if (X.pack_size() != Y.pack_size()) {
-  if (!PartialOrdering)
-return false;
-
-  // C++0x [temp.deduct.type]p9:
-  // During partial ordering, if Ai was originally a pack expansion:
-  // - if P does not contain a template argument corresponding to Ai
-  //   then Ai is ignored;
-  bool XHasMoreArg = X.pack_size() > Y.pack_size();
-  if (!(XHasMoreArg && X.pack_elements().back().isPackExpansion()) &&
-  !(!XHasMoreArg && Y.pack_elements().back().isPackExpansion()))
-return false;
-
-  if (XHasMoreArg)
-PackIterationSize = Y.pack_size();
-}
+// C++0x [temp.deduct.type]p9:
+// During partial ordering, if Ai was originally a pack expansion:
+// - if P does not contain a template argument corresponding to Ai
+//   then Ai is ignored;
+bool XHasMoreArg = X.pack_size() > Y.pack_size();
+if (!(XHasMoreArg && X.pack_elements().back().isPackExpansion()) &&
+!(!XHasMoreArg && Y.pack_elements().back().isPackExpansion()))
+  return false;
 
-ArrayRef XP = X.pack_elements();
-ArrayRef YP = Y.pack_elements();
-for (unsigned i = 0; i < PackIterationSize; ++i)
-  if (!isSameTemplateArg(Context, XP[i], YP[i], PartialOrdering,
- PackExpansionMatchesPack))
-return false;
+if (XHasMoreArg)
+  PackIterationSize = Y.pack_size();
   }
+
+  ArrayRef XP = X.pack_elements();
+  ArrayRef YP = Y.pack_elements();
+  for (unsigned i = 0; i < PackIterationSize; ++i)
+if (!isSameTemplateArg(Context, XP[i], YP[i], PartialOrdering,
+   PackExpansionMatchesPack))
+  return false;
   return true;
+}
   }
 
   llvm_unreachable("Invalid TemplateArgument Kind!");
@@ -5229,33 +5212,29 @@
 
   // This a speculative fix for CWG1432 (Similar to the fix for CWG1395) that
   // there is no wording or even resolution for this issue.
-  bool ClangABICompat15 =
-  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
-  if (!ClangABICompat15) {
-for (int i = 0, e = std::min(NumParams1, NumParams2); i < e; ++i) {
-  QualType T1 = FD1->getParamDecl(i)->getType().getCanonicalType();
-  QualType T2 = FD2->getParamDecl(i)->getType().getCanonicalType();
-  auto *TST1 = dyn_cast(T1);
-  auto *TST2 = dyn_cast(T2);
-  if 

[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-10-17 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D127403#3863641 , @nridge wrote:

> Landed https://reviews.llvm.org/rGc93430bae4fc

Still failing with that: http://45.33.8.238/linux/89240/step_9.txt

Time to revert to green? Things have been broken for a few hours now. Maybe 
time to regroup and analyze async?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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


[PATCH] D135920: [clang][Sema] Use correct array size for diagnostic

2022-10-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik requested changes to this revision.
shafik added a comment.
This revision now requires changes to proceed.

The current approach of mixing bytes and indices in the same diagnostic is too 
confusing. I think we see some acceptable messages for out of bounds access by 
looking at three different implementations diagnostic for OOB access in a 
constant expression context:

  int main() {
  constexpr int arr[1]{};
  constexpr int x = arr[3];
  }

We have clang which produces:

  :3:23: note: cannot refer to element 3 of array of 1 element in a 
constant expression
  constexpr int x = arr[3];
^

gcc produces:

  :3:28: error: array subscript value '3' is outside the bounds of 
array 'arr' of type 'const int [1]'
  3 | constexpr int x = arr[3];
|   ~^

and MSVC produces:

  (3): note: failure was caused by out of range index 3; allowed range 
is 0 <= index < 1

I think any approach similar to this would be acceptable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135920

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


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-10-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Landed https://reviews.llvm.org/rGc93430bae4fc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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


[clang-tools-extra] c93430b - [clangd] Update testcase for issue 1222 to use the 'definition' modifier

2022-10-17 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2022-10-17T19:56:19-04:00
New Revision: c93430bae4fc95b58185900aa5f0ccbc037de031

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

LOG: [clangd] Update testcase for issue 1222 to use the 'definition' modifier

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index d3219617d4000..5bc458b903119 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -864,12 +864,12 @@ sizeof...($TemplateParameter[[Elements]]);
 const char *$LocalVariable_def_readonly[[s]] = 
$LocalVariable_readonly_static[[__func__]];
 }
   )cpp",
-  // Issue 1022: readonly modifier for generic parameter
+  // Issue 1222: readonly modifier for generic parameter
   R"cpp(
-template 
-auto $Function_decl[[foo]](const $TemplateParameter[[T]] 
$Parameter_decl_readonly[[template_type]], 
-   const $TemplateParameter[[auto]] 
$Parameter_decl_readonly[[auto_type]], 
-   const int 
$Parameter_decl_readonly[[explicit_type]]) {
+template 
+auto $Function_def[[foo]](const $TemplateParameter[[T]] 
$Parameter_def_readonly[[template_type]], 
+  const $TemplateParameter[[auto]] 
$Parameter_def_readonly[[auto_type]], 
+  const int 
$Parameter_def_readonly[[explicit_type]]) {
 return $Parameter_readonly[[template_type]] 
  + $Parameter_readonly[[auto_type]] 
  + $Parameter_readonly[[explicit_type]];



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


[PATCH] D131594: WORK IN PROGRESS Add Clang UEFI target to support "x86_64-unknown-uefi" triple

2022-10-17 Thread Prabhu Karthikeyan Rajasekaran via Phabricator via cfe-commits
Prabhuk updated this revision to Diff 468370.
Prabhuk added a comment.
Herald added a subscriber: MaskRay.

Added changes to the Driver.cpp.
This version uses underlying MSVC toolchain to compile UEFI target introduced 
here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131594

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Driver/Driver.cpp
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp


Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -235,6 +235,7 @@
   case RTEMS: return "rtems";
   case Solaris: return "solaris";
   case TvOS: return "tvos";
+  case UEFI: return "uefi";
   case WASI: return "wasi";
   case WatchOS: return "watchos";
   case Win32: return "windows";
@@ -562,6 +563,7 @@
 .StartsWith("netbsd", Triple::NetBSD)
 .StartsWith("openbsd", Triple::OpenBSD)
 .StartsWith("solaris", Triple::Solaris)
+.StartsWith("uefi", Triple::UEFI)
 .StartsWith("win32", Triple::Win32)
 .StartsWith("windows", Triple::Win32)
 .StartsWith("zos", Triple::ZOS)
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -195,6 +195,7 @@
 NetBSD,
 OpenBSD,
 Solaris,
+UEFI,
 Win32,
 ZOS,
 Haiku,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -6019,6 +6019,9 @@
 case llvm::Triple::Mesa3D:
   TC = std::make_unique(*this, Target, Args);
   break;
+case llvm::Triple::UEFI:
+  TC = std::make_unique(*this, Target, Args); 
TODO(prabhukr): Replace with a new UEFI toolchain
+  break;
 case llvm::Triple::Win32:
   switch (Target.getEnvironment()) {
   default:
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -575,6 +575,9 @@
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Solaris:
   return new SolarisTargetInfo(Triple, Opts);
+case llvm::Triple::UEFI:
+   //TODO(prabhukr): UEFITargetInfo need to be introduced
+  return new MicrosoftX86_64TargetInfo(Triple, Opts);
 case llvm::Triple::Win32: {
   switch (Triple.getEnvironment()) {
   case llvm::Triple::Cygnus:


Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -235,6 +235,7 @@
   case RTEMS: return "rtems";
   case Solaris: return "solaris";
   case TvOS: return "tvos";
+  case UEFI: return "uefi";
   case WASI: return "wasi";
   case WatchOS: return "watchos";
   case Win32: return "windows";
@@ -562,6 +563,7 @@
 .StartsWith("netbsd", Triple::NetBSD)
 .StartsWith("openbsd", Triple::OpenBSD)
 .StartsWith("solaris", Triple::Solaris)
+.StartsWith("uefi", Triple::UEFI)
 .StartsWith("win32", Triple::Win32)
 .StartsWith("windows", Triple::Win32)
 .StartsWith("zos", Triple::ZOS)
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -195,6 +195,7 @@
 NetBSD,
 OpenBSD,
 Solaris,
+UEFI,
 Win32,
 ZOS,
 Haiku,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -6019,6 +6019,9 @@
 case llvm::Triple::Mesa3D:
   TC = std::make_unique(*this, Target, Args);
   break;
+case llvm::Triple::UEFI:
+  TC = std::make_unique(*this, Target, Args); TODO(prabhukr): Replace with a new UEFI toolchain
+  break;
 case llvm::Triple::Win32:
   switch (Target.getEnvironment()) {
   default:
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -575,6 +575,9 @@
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Solaris:
   return new SolarisTargetInfo(Triple, Opts);
+case llvm::Triple::UEFI:
+   //TODO(prabhukr): UEFITargetInfo need to be introduced
+  return new MicrosoftX86_64TargetInfo(Triple, Opts);
 case llvm::Triple::Win32: {
   switch (Triple.getEnvironment()) {
   case llvm::Triple::Cygnus:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-10-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Landing the fix now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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


[PATCH] D136103: OpenMP asynchronous memory copy support

2022-10-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

First set of comments.




Comment at: clang/docs/ReleaseNotes.rst:253
+  `Issue 47177 `_
+  `Issue 47179 `_
 

Unrelated, probably bad diff origin.



Comment at: openmp/libomptarget/src/api.cpp:204
+// The helper function that calls omp_target_memcpy 
+int __kmpc_target_memcpy_async_helper(kmp_int32 gtid, kmp_task_t *task) {
+  if (task == 0)

`static` also below.



Comment at: openmp/libomptarget/src/api.cpp:208
+
+  TargetMemcpyArgsTy* args = (TargetMemcpyArgsTy *)task->shareds;
+

LLVM codeing style, please. So here, `Args`



Comment at: openmp/libomptarget/src/api.cpp:211
+  if (args == 0)
+return -1;
+

not 0 but nullptr, also lots of other places.



Comment at: openmp/libomptarget/src/api.cpp:217
+
+  return 0;
+}

Why ignore the return value of memcpy and return 0 here?



Comment at: openmp/libomptarget/src/api.cpp:233
+  if (Dst == 0 || Src == 0)
+return 5;
+

5? Why 5?



Comment at: openmp/libomptarget/src/api.cpp:238
+  int errsz = sizeof(kmp_task_t);
+  int errhr = 0;
+  int gtid = __kmpc_global_thread_num(NULL);

Proper names, please. Also coding style.



Comment at: openmp/libomptarget/src/api.cpp:243
+  kmp_int32 flags = 0;
+  kmp_tasking_flags_t *input_flags = (kmp_tasking_flags_t *)
+  input_flags->hidden_helper = 1;

This is very suspicious. Why can't we have a `kmp_tasking_flags_t` object?



Comment at: openmp/libomptarget/src/api.cpp:256
+  // omp_target_memcpy(Dst, Src, Length, DstOffset, SrcOffset, DstDevice, 
SrcDevice);
+  __kmpc_omp_task_with_deps(NULL, gtid, ptr, Depobj_count, args_->Depobjs, 0, 
NULL);
+

Does this return anything? The use of Rc seems useless. Why do you access args_ 
for some parts and not for others? That said, where does the hidden helper need 
access to the dependences anyway?



Comment at: openmp/libomptarget/src/api.cpp:387
+  return Rc;
+}
+

This screams helper as it is literally the same code modulo 5 characters in a 
few places. Please refactor and run clang-format on the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136103

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


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-10-17 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks check-clangd everywhere, eg 
http://45.33.8.238/linux/89237/step_9.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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


[PATCH] D129531: [clang][C++20] P0960R3: Allow initializing aggregates from a parenthesized list of values

2022-10-17 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 468366.
ayzhao added a comment.

accidentally removed an extra curly brace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  clang/test/CodeGen/P0960R3.cpp
  clang/test/SemaCXX/P0960R3.cpp
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,10 @@
 K = CXCursor_RequiresExpr;
 break;
 
+  case Stmt::CXXParenListInitExprClass:
+K = CXCursor_CXXParenListInitExpr;
+break;
+
   case Stmt::MSDependentExistsStmtClass:
 K = CXCursor_UnexposedStmt;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2139,6 +2139,7 @@
   void VisitLambdaExpr(const LambdaExpr *E);
   void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E);
   void VisitRequiresExpr(const RequiresExpr *E);
+  void VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
   void VisitOMPExecutableDirective(const OMPExecutableDirective *D);
   void VisitOMPLoopBasedDirective(const OMPLoopBasedDirective *D);
   void VisitOMPLoopDirective(const OMPLoopDirective *D);
@@ -2999,6 +3000,9 @@
   for (ParmVarDecl *VD : E->getLocalParameters())
 AddDecl(VD);
 }
+void EnqueueVisitor::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E) {
+  EnqueueChildren(E);
+}
 void EnqueueVisitor::VisitPseudoObjectExpr(const PseudoObjectExpr *E) {
   // Treat the expression like its syntactic form.
   Visit(E->getSyntacticForm());
@@ -5574,6 +5578,8 @@
 return cxstring::createRef("ConceptSpecializationExpr");
   case CXCursor_RequiresExpr:
 return cxstring::createRef("RequiresExpr");
+  case CXCursor_CXXParenListInitExpr:
+return cxstring::createRef("CXXParenListInitExpr");
   case CXCursor_UnexposedStmt:
 return cxstring::createRef("UnexposedStmt");
   case CXCursor_DeclStmt:
Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify -Wno-c++2a-extensions
-// RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify=expected,pre20 -Wno-c++2a-extensions
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify=expected,pro20
 
 template  struct enable_ifv {};
 
@@ -20,7 +20,7 @@
 
 template
 struct A {
-// expected-note@-1+ {{candidate constructor}}
+// pre20-note@-1+ {{candidate constructor}}
   explicit(1 << a)
 // expected-note@-1 {{negative shift count -1}}
 // expected-error@-2 {{explicit specifier argument is not a constant expression}}
@@ -28,8 +28,9 @@
 };
 
 A<-1> a(0);
-// expected-error@-1 {{no matching constructor}}
-// expected-note@-2 {{in instantiation of template class}}
+// pre20-error@-1 {{no matching constructor}}
+// pro20-error@-2 {{excess elements in struct initializer}}
+// expected-note@-3 {{in instantiation of template class}}
 
 template
 struct B {
Index: clang/test/SemaCXX/P0960R3.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/P0960R3.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s -fsyntax-only
+
+struct A { // expected-note 4{{candidate constructor}}
+  char i;
+  double j;
+};
+
+struct B {
+  A a;
+  int b[20];
+  int & // expected-note {{reference member declared here}}
+};
+
+struct C { // expected-note 2{{candidate constructor}}
+  A a;
+  int b[20];
+};
+

[PATCH] D130324: [ODRHash] Hash `ObjCProtocolDecl` and diagnose discovered mismatches.

2022-10-17 Thread Volodymyr Sapsai 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 rG9c79eab7fdd5: [ODRHash] Hash `ObjCProtocolDecl` and diagnose 
discovered mismatches. (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D130324?vs=465950=468365#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130324

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/ODRDiagsEmitter.h
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/compare-objc-protocol.m

Index: clang/test/Modules/compare-objc-protocol.m
===
--- /dev/null
+++ clang/test/Modules/compare-objc-protocol.m
@@ -0,0 +1,113 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// Build first header file
+// RUN: echo "#define FIRST" >> %t/include/first.h
+// RUN: cat %t/test.m>> %t/include/first.h
+// RUN: echo "#undef FIRST"  >> %t/include/first.h
+
+// Build second header file
+// RUN: echo "#define SECOND" >> %t/include/second.h
+// RUN: cat %t/test.m >> %t/include/second.h
+// RUN: echo "#undef SECOND"  >> %t/include/second.h
+
+// Test that each header can compile
+// RUN: %clang_cc1 -fsyntax-only -x objective-c %t/include/first.h -fblocks -fobjc-arc
+// RUN: %clang_cc1 -fsyntax-only -x objective-c %t/include/second.h -fblocks -fobjc-arc
+
+// Run test
+// RUN: %clang_cc1 -I%t/include -verify %t/test.m -fblocks -fobjc-arc \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// In non-modular case we ignore protocol redefinitions. But with modules
+// previous definition can come from a hidden [sub]module. And in this case we
+// allow a new definition if it is equivalent to the hidden one.
+//
+// This test case is to verify equivalence checks.
+
+//--- include/common.h
+#ifndef COMMON_H
+#define COMMON_H
+@protocol CommonProtocol @end
+@protocol ExtraProtocol @end
+#endif
+
+//--- include/first-empty.h
+//--- include/module.modulemap
+module Common {
+  header "common.h"
+  export *
+}
+module First {
+  module Empty {
+header "first-empty.h"
+  }
+  module Hidden {
+header "first.h"
+export *
+  }
+}
+module Second {
+  header "second.h"
+  export *
+}
+
+//--- test.m
+#if defined(FIRST) || defined(SECOND)
+# include "common.h"
+#endif
+
+#if !defined(FIRST) && !defined(SECOND)
+# include "first-empty.h"
+# include "second.h"
+#endif
+
+#if defined(FIRST)
+@protocol CompareForwardDeclaration1;
+@protocol CompareForwardDeclaration2 @end
+#elif defined(SECOND)
+@protocol CompareForwardDeclaration1 @end
+@protocol CompareForwardDeclaration2;
+#else
+id compareForwardDeclaration1;
+id compareForwardDeclaration2;
+#endif
+
+#if defined(FIRST)
+@protocol CompareMatchingConformingProtocols @end
+@protocol ForwardProtocol;
+@protocol CompareMatchingConformingForwardProtocols @end
+
+@protocol CompareProtocolPresence1 @end
+@protocol CompareProtocolPresence2 @end
+
+@protocol CompareDifferentProtocols @end
+@protocol CompareProtocolOrder @end
+#elif defined(SECOND)
+@protocol CompareMatchingConformingProtocols @end
+@protocol ForwardProtocol @end
+@protocol CompareMatchingConformingForwardProtocols @end
+
+@protocol CompareProtocolPresence1 @end
+@protocol CompareProtocolPresence2 @end
+
+@protocol CompareDifferentProtocols @end
+@protocol CompareProtocolOrder @end
+#else
+id compareMatchingConformingProtocols;
+id compareMatchingConformingForwardProtocols;
+
+id compareProtocolPresence1;
+// expected-error@first.h:* {{'CompareProtocolPresence1' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 1 referenced protocol}}
+// expected-note@second.h:* {{but in 'Second' found 0 referenced protocols}}
+id compareProtocolPresence2;
+// expected-error@first.h:* {{'CompareProtocolPresence2' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 0 referenced protocols}}
+// expected-note@second.h:* {{but in 'Second' found 1 referenced protocol}}
+
+id compareDifferentProtocols;
+// expected-error@first.h:* {{'CompareDifferentProtocols' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 1st referenced protocol with name 'CommonProtocol'}}
+// expected-note@second.h:* {{but in 'Second' found 1st referenced protocol with different name 'ExtraProtocol'}}
+id compareProtocolOrder;
+// expected-error@first.h:* {{'CompareProtocolOrder' has different definitions in 

[clang] 9c79eab - [ODRHash] Hash `ObjCProtocolDecl` and diagnose discovered mismatches.

2022-10-17 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2022-10-17T16:29:52-07:00
New Revision: 9c79eab7fdd5e2bc413e9c4510f759716cd09184

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

LOG: [ODRHash] Hash `ObjCProtocolDecl` and diagnose discovered mismatches.

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

Added: 
clang/test/Modules/compare-objc-protocol.m

Modified: 
clang/include/clang/AST/DeclObjC.h
clang/include/clang/AST/ODRDiagsEmitter.h
clang/include/clang/AST/ODRHash.h
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/include/clang/Serialization/ASTReader.h
clang/lib/AST/DeclObjC.cpp
clang/lib/AST/ODRDiagsEmitter.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclObjC.h 
b/clang/include/clang/AST/DeclObjC.h
index 210b7adebe4cd..3d20d172dc631 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -2055,6 +2055,12 @@ class ObjCProtocolDecl : public ObjCContainerDecl,
 
 /// Referenced protocols
 ObjCProtocolList ReferencedProtocols;
+
+/// Tracks whether a ODR hash has been computed for this protocol.
+unsigned HasODRHash : 1;
+
+/// A hash of parts of the class to help in ODR checking.
+unsigned ODRHash = 0;
   };
 
   /// Contains a pointer to the data associated with this class,
@@ -2091,10 +2097,15 @@ class ObjCProtocolDecl : public ObjCContainerDecl,
 return getMostRecentDecl();
   }
 
+  /// True if a valid hash is stored in ODRHash.
+  bool hasODRHash() const;
+  void setHasODRHash(bool HasHash);
+
 public:
   friend class ASTDeclReader;
   friend class ASTDeclWriter;
   friend class ASTReader;
+  friend class ODRDiagsEmitter;
 
   static ObjCProtocolDecl *Create(ASTContext , DeclContext *DC,
   IdentifierInfo *Id,
@@ -2250,6 +2261,9 @@ class ObjCProtocolDecl : public ObjCContainerDecl,
   ProtocolPropertySet ,
   PropertyDeclOrder ) const;
 
+  /// Get precomputed ODRHash or add a new one.
+  unsigned getODRHash();
+
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == ObjCProtocol; }
 };

diff  --git a/clang/include/clang/AST/ODRDiagsEmitter.h 
b/clang/include/clang/AST/ODRDiagsEmitter.h
index 37e7dd4b05c9d..af345310c3a40 100644
--- a/clang/include/clang/AST/ODRDiagsEmitter.h
+++ b/clang/include/clang/AST/ODRDiagsEmitter.h
@@ -11,6 +11,7 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LangOptions.h"
 
@@ -44,6 +45,16 @@ class ODRDiagsEmitter {
const CXXRecordDecl *SecondRecord,
const struct CXXRecordDecl::DefinitionData *SecondDD) const;
 
+  /// Diagnose ODR mismatch between 2 ObjCProtocolDecl.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  /// To compare 2 declarations with merged and identical definition data
+  /// you need to provide pre-merge definition data in \p SecondDD.
+  bool diagnoseMismatch(
+  const ObjCProtocolDecl *FirstProtocol,
+  const ObjCProtocolDecl *SecondProtocol,
+  const struct ObjCProtocolDecl::DefinitionData *SecondDD) const;
+
   /// Get the best name we know for the module that owns the given
   /// declaration, or an empty string if the declaration is not from a module.
   static std::string getOwningModuleNameForDiagnostic(const Decl *D);
@@ -116,6 +127,16 @@ class ODRDiagsEmitter {
   const VarDecl *FirstVD,
   const VarDecl *SecondVD) const;
 
+  /// Check if protocol lists are the same and diagnose if they are 
diff erent.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  bool diagnoseSubMismatchProtocols(const ObjCProtocolList ,
+const ObjCContainerDecl *FirstContainer,
+StringRef FirstModule,
+const ObjCProtocolList ,
+const ObjCContainerDecl *SecondContainer,
+StringRef SecondModule) const;
+
 private:
   DiagnosticsEngine 
   const ASTContext 

diff  --git a/clang/include/clang/AST/ODRHash.h 
b/clang/include/clang/AST/ODRHash.h
index 2e8593e0b8355..59b74cf477dd0 100644
--- a/clang/include/clang/AST/ODRHash.h
+++ b/clang/include/clang/AST/ODRHash.h
@@ -64,6 +64,10 @@ class ODRHash {
   // more information than the AddDecl class.
   void AddEnumDecl(const 

[PATCH] D135920: [clang][Sema] Use correct array size for diagnostic

2022-10-17 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 468356.
void added a comment.

Fix rogue test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135920

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/array-bounds-ptr-arith.c
  clang/test/Sema/integer-overflow.c
  clang/test/SemaCXX/array-bounds-ptr-arith.cpp
  clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
  clang/test/SemaCXX/array-bounds.cpp
  clang/test/SemaCXX/integer-overflow.cpp
  clang/test/SemaObjC/flexible-array-bounds.m

Index: clang/test/SemaObjC/flexible-array-bounds.m
===
--- clang/test/SemaObjC/flexible-array-bounds.m
+++ clang/test/SemaObjC/flexible-array-bounds.m
@@ -23,5 +23,4 @@
 
 char readit(Flexible *p) { return p->flexible[2]; }
 char readit0(Flexible0 *p) { return p->flexible[2]; }
-char readit1(Flexible1 *p) { return p->flexible[2]; } // warn-warning {{array index 2 is past the end of the array (which contains 1 element)}}
-
+char readit1(Flexible1 *p) { return p->flexible[2]; } // warn-warning {{array index 2 is 1 byte past the end of the array (that has type 'char[1]')}}
Index: clang/test/SemaCXX/integer-overflow.cpp
===
--- clang/test/SemaCXX/integer-overflow.cpp
+++ clang/test/SemaCXX/integer-overflow.cpp
@@ -167,7 +167,7 @@
   uint64_t a[10];
   a[4608 * 1024 * 1024] = 1;
 #if __cplusplus < 201103L
-// expected-warning@-2 {{array index 536870912 is past the end of the array (which contains 10 elements)}}
+// expected-warning@-2 {{array index 536870912 is 4294967216 bytes past the end of the array (that has type 'uint64_t[10]' (aka 'unsigned long long[10]'))}}
 // expected-note@-4 {{array 'a' declared here}}
 #endif
 
Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -8,16 +8,16 @@
   int v[1][1][1]; // expected-note {{array 'v' declared here}}
   int *p = [2]; // no-warning
   (void) sizeof(x[2]); // no-warning
-  y[2] = 2; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
-  z[1] = 'x'; // expected-warning {{array index 1 is past the end of the array (which contains 1 element)}}
-  w[0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
-  v[0][0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
-  return x[2] +  // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+  y[2] = 2; // expected-warning {{array index 2 is 0 bytes past the end of the array (that has type 'int[2]')}}
+  z[1] = 'x'; // expected-warning {{array index 1 is 0 bytes past the end of the array (that has type 'int[1]')}}
+  w[0][2] = 0; // expected-warning {{array index 2 is 4 bytes past the end of the array (that has type 'int[1]')}}
+  v[0][0][2] = 0; // expected-warning {{array index 2 is 4 bytes past the end of the array (that has type 'int[1]')}}
+  return x[2] +  // expected-warning {{array index 2 is 0 bytes past the end of the array (that has type 'int[2]')}}
  y[-1] + // expected-warning {{array index -1 is before the beginning of the array}}
- x[sizeof(x)] +  // expected-warning {{array index 8 is past the end of the array (which contains 2 elements)}}
- x[sizeof(x) / sizeof(x[0])] +  // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ x[sizeof(x)] +  // expected-warning {{array index 8 is 24 bytes past the end of the array (that has type 'int[2]')}}
+ x[sizeof(x) / sizeof(x[0])] +  // expected-warning {{array index 2 is 0 bytes past the end of the array (that has type 'int[2]')}}
  x[sizeof(x) / sizeof(x[0]) - 1] + // no-warning
- x[sizeof(x[2])]; // expected-warning {{array index 4 is past the end of the array (which contains 2 elements)}}
+ x[sizeof(x[2])]; // expected-warning {{array index 4 is 8 bytes past the end of the array (that has type 'int[2]')}}
 }
 
 // This code example tests that -Warray-bounds works with arrays that
@@ -31,7 +31,7 @@
 }
 
 void f2(const int ()[2]) { // expected-note {{declared here}}
-  int val = a[3];  // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+  int val = a[3];  // expected-warning {{array index 3 is 4 bytes past the end of the array (that has type 'const int[2]')}}
 }
 
 void test() {
@@ -44,33 +44,33 @@
 short a[2]; // expected-note 4 {{declared here}}
 char c[4];
   } u;
-  u.a[3] = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+  u.a[3] = 1; // expected-warning {{array index 3 is 2 bytes past the 

[PATCH] D135920: [clang][Sema] Use correct array size for diagnostic

2022-10-17 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

The messages that's a bit annoying are the ones reporting "0 bytes past the end 
of the array":

  warning: array index 2 is 0 bytes past the end of the array (that has type 
'int[2]')

I'm not sure what to do with these (except to leave them alone).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135920

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


[PATCH] D136111: [OpenMP] Make device functions have hidden visibility

2022-10-17 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, should be fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136111

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


[PATCH] D135920: [clang][Sema] Use correct array size for diagnostic

2022-10-17 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 468355.
void added a comment.

Update more testcases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135920

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/array-bounds-ptr-arith.c
  clang/test/Sema/integer-overflow.c
  clang/test/SemaCXX/array-bounds-ptr-arith.cpp
  clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
  clang/test/SemaCXX/array-bounds.cpp
  clang/test/SemaCXX/integer-overflow.cpp
  clang/test/SemaObjC/flexible-array-bounds.m

Index: clang/test/SemaObjC/flexible-array-bounds.m
===
--- clang/test/SemaObjC/flexible-array-bounds.m
+++ clang/test/SemaObjC/flexible-array-bounds.m
@@ -23,5 +23,4 @@
 
 char readit(Flexible *p) { return p->flexible[2]; }
 char readit0(Flexible0 *p) { return p->flexible[2]; }
-char readit1(Flexible1 *p) { return p->flexible[2]; } // warn-warning {{array index 2 is past the end of the array (which contains 1 element)}}
-
+char readit1(Flexible1 *p) { return p->flexible[2]; } // warn-warning {{array index 2 is 1 byte past the end of the array (that has type 'char[1]')}}
Index: clang/test/SemaCXX/integer-overflow.cpp
===
--- clang/test/SemaCXX/integer-overflow.cpp
+++ clang/test/SemaCXX/integer-overflow.cpp
@@ -167,7 +167,7 @@
   uint64_t a[10];
   a[4608 * 1024 * 1024] = 1;
 #if __cplusplus < 201103L
-// expected-warning@-2 {{array index 536870912 is past the end of the array (which contains 10 elements)}}
+// expected-warning@-2 {{array index 536870912 is 4294967216 bytes past the end of the array (that has type 'uint64_t[10]' (aka 'unsigned long long[10]'))}}
 // expected-note@-4 {{array 'a' declared here}}
 #endif
 
Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -8,16 +8,16 @@
   int v[1][1][1]; // expected-note {{array 'v' declared here}}
   int *p = [2]; // no-warning
   (void) sizeof(x[2]); // no-warning
-  y[2] = 2; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
-  z[1] = 'x'; // expected-warning {{array index 1 is past the end of the array (which contains 1 element)}}
-  w[0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
-  v[0][0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
-  return x[2] +  // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+  y[2] = 2; // expected-warning {{array index 2 is 0 bytes past the end of the array (that has type 'int[2]')}}
+  z[1] = 'x'; // expected-warning {{array index 1 is 0 bytes past the end of the array (that has type 'int[1]')}}
+  w[0][2] = 0; // expected-warning {{array index 2 is 4 bytes past the end of the array (that has type 'int[1]')}}
+  v[0][0][2] = 0; // expected-warning {{array index 2 is 4 bytes past the end of the array (that has type 'int[1]')}}
+  return x[2] +  // expected-warning {{array index 2 is 0 bytes past the end of the array (that has type 'int[2]')}}
  y[-1] + // expected-warning {{array index -1 is before the beginning of the array}}
- x[sizeof(x)] +  // expected-warning {{array index 8 is past the end of the array (which contains 2 elements)}}
- x[sizeof(x) / sizeof(x[0])] +  // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ x[sizeof(x)] +  // expected-warning {{array index 8 is 24 bytes past the end of the array (that has type 'int[2]')}}
+ x[sizeof(x) / sizeof(x[0])] +  // expected-warning {{array index 2 is 0 bytes past the end of the array (that has type 'int[2]')}}
  x[sizeof(x) / sizeof(x[0]) - 1] + // no-warning
- x[sizeof(x[2])]; // expected-warning {{array index 4 is past the end of the array (which contains 2 elements)}}
+ x[sizeof(x[2])]; // expected-warning {{array index 4 is 8 bytes past the end of the array (that has type 'int[2]')}}
 }
 
 // This code example tests that -Warray-bounds works with arrays that
@@ -31,7 +31,7 @@
 }
 
 void f2(const int ()[2]) { // expected-note {{declared here}}
-  int val = a[3];  // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+  int val = a[3];  // expected-warning {{array index 3 is 4 bytes past the end of the array (that has type 'const int[2]')}}
 }
 
 void test() {
@@ -44,33 +44,33 @@
 short a[2]; // expected-note 4 {{declared here}}
 char c[4];
   } u;
-  u.a[3] = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+  u.a[3] = 1; // expected-warning {{array index 3 is 2 bytes 

[PATCH] D135920: [clang][Sema] Use correct array size for diagnostic

2022-10-17 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 468353.
void added a comment.

Improve the error message to include how many bytes the index goes over

  warning: the pointer incremented by 14 refers 1 byte past the end of the 
array (that has type 'const char[13]')


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135920

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/array-bounds-ptr-arith.c
  clang/test/SemaCXX/array-bounds-ptr-arith.cpp
  clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
  clang/test/SemaCXX/array-bounds.cpp
  clang/test/SemaCXX/integer-overflow.cpp

Index: clang/test/SemaCXX/integer-overflow.cpp
===
--- clang/test/SemaCXX/integer-overflow.cpp
+++ clang/test/SemaCXX/integer-overflow.cpp
@@ -167,7 +167,7 @@
   uint64_t a[10];
   a[4608 * 1024 * 1024] = 1;
 #if __cplusplus < 201103L
-// expected-warning@-2 {{array index 536870912 is past the end of the array (which contains 10 elements)}}
+// expected-warning@-2 {{array index 536870912 is 4294967216 bytes past the end of the array (that has type 'uint64_t[10]' (aka 'unsigned long long[10]'))}}
 // expected-note@-4 {{array 'a' declared here}}
 #endif
 
Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -8,16 +8,16 @@
   int v[1][1][1]; // expected-note {{array 'v' declared here}}
   int *p = [2]; // no-warning
   (void) sizeof(x[2]); // no-warning
-  y[2] = 2; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
-  z[1] = 'x'; // expected-warning {{array index 1 is past the end of the array (which contains 1 element)}}
-  w[0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
-  v[0][0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
-  return x[2] +  // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+  y[2] = 2; // expected-warning {{array index 2 is 0 bytes past the end of the array (that has type 'int[2]')}}
+  z[1] = 'x'; // expected-warning {{array index 1 is 0 bytes past the end of the array (that has type 'int[1]')}}
+  w[0][2] = 0; // expected-warning {{array index 2 is 4 bytes past the end of the array (that has type 'int[1]')}}
+  v[0][0][2] = 0; // expected-warning {{array index 2 is 4 bytes past the end of the array (that has type 'int[1]')}}
+  return x[2] +  // expected-warning {{array index 2 is 0 bytes past the end of the array (that has type 'int[2]')}}
  y[-1] + // expected-warning {{array index -1 is before the beginning of the array}}
- x[sizeof(x)] +  // expected-warning {{array index 8 is past the end of the array (which contains 2 elements)}}
- x[sizeof(x) / sizeof(x[0])] +  // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ x[sizeof(x)] +  // expected-warning {{array index 8 is 24 bytes past the end of the array (that has type 'int[2]')}}
+ x[sizeof(x) / sizeof(x[0])] +  // expected-warning {{array index 2 is 0 bytes past the end of the array (that has type 'int[2]')}}
  x[sizeof(x) / sizeof(x[0]) - 1] + // no-warning
- x[sizeof(x[2])]; // expected-warning {{array index 4 is past the end of the array (which contains 2 elements)}}
+ x[sizeof(x[2])]; // expected-warning {{array index 4 is 8 bytes past the end of the array (that has type 'int[2]')}}
 }
 
 // This code example tests that -Warray-bounds works with arrays that
@@ -31,7 +31,7 @@
 }
 
 void f2(const int ()[2]) { // expected-note {{declared here}}
-  int val = a[3];  // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+  int val = a[3];  // expected-warning {{array index 3 is 4 bytes past the end of the array (that has type 'const int[2]')}}
 }
 
 void test() {
@@ -44,33 +44,33 @@
 short a[2]; // expected-note 4 {{declared here}}
 char c[4];
   } u;
-  u.a[3] = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+  u.a[3] = 1; // expected-warning {{array index 3 is 2 bytes past the end of the array (that has type 'short[2]')}}
   u.c[3] = 1; // no warning
   short *p = [2]; // no warning
-  p = [3]; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
-  *([2]) = 1; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
-  *([3]) = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+  p = [3]; // expected-warning {{array index 3 is 2 bytes past the end of the array (that has type 'short[2]')}}
+  

[clang] 0674f2e - [NFC] Fix warning on no return after switch.

2022-10-17 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-10-17T15:52:23-07:00
New Revision: 0674f2ec96422131abde0c042fbf2c11267db210

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

LOG: [NFC] Fix warning on no return after switch.

Added: 


Modified: 
clang/lib/CodeGen/CGHLSLRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 7a80dedb8133..6f32136b49de 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -270,6 +270,7 @@ 
castResourceShapeToResourceKind(HLSLResourceAttr::ResourceKind RK) {
   static_cast(
   HLSLResourceAttr::ResourceKind::FeedbackTexture2DArray) ==
   (static_cast(llvm::hlsl::ResourceKind::NumEntries) - 2));
+  return llvm::hlsl::ResourceKind::Invalid;
 }
 
 void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable *GV) 
{



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


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-10-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Looks like an error introduced when rebasing the patch: a recently added test 
case (for https://github.com/clangd/clangd/issues/1222) needs to be updated to 
reflect the `_decl` to `_def` change that this patch makes to all semantic 
highlighting tests. I'll land a fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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


[PATCH] D136036: [Clang] Add __has_constexpr_builtin support

2022-10-17 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added a comment.

> It looks like unrelated formatting changes snuck in to this file.

@aaron.ballman JFYI after I reverted what `git clang-format HEAD~1` did to the 
code, the build has failed

  ERROR   git-clang-format returned an non-zero exit code 1
  Build completed with failures

https://buildkite.com/llvm-project/premerge-checks/builds/117202#0183e7ca-7aa7-4838-aa21-ae5ec717a18a

Can I apply `git clang-format HEAD~1` again?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136036

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


[PATCH] D126908: [VerifyDiagnosticConsumer] Fix last line being discarded when parsing newline

2022-10-17 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

Thank you for the patch!




Comment at: clang/test/SemaCXX/references.cpp:93
 
-struct C : B, A { }; // expected-warning {{direct base 'A' is inaccessible due 
to ambiguity:\nstruct C -> struct B -> struct A\nstruct C -> struct A}}
+struct C : B, A { }; // expected-warning {{direct base 'A' is inaccessible due 
to ambiguity:\nstruct C -> struct B -> struct A\nstruct C -> struct A}}
 

Can you please explain in detail what bug are you fixing?
In my understanding if we stop parsing after the last newline then the existing 
test would have failed. The difference seems to be only the white-space.
Am I missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126908

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


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-10-17 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

Looks like there are some test failures associated with this commit: 
https://lab.llvm.org/buildbot/#/builders/123/builds/13698

The change list is a bit confusing, as it's only showing LLVM commits. But the 
change list includes the commit before and the commit after this one.

The tests in this patch are also failing in our internal CI. @ckandeler, could 
you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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


[PATCH] D135832: Do not append terminating NUL to the string with embedded GPU binary.

2022-10-17 Thread Artem Belevich 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 rGa10eb07d1acc: Do not append terminating NUL to the binary 
string with embedded fatbin. (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135832

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/test/CodeGenCUDA/device-stub.cu

Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -1,4 +1,4 @@
-// RUN: echo "GPU binary would be here" > %t
+// RUN: echo -n "GPU binary would be here." > %t
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=8.0 -fcuda-include-gpubinary %t -o - \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s \
@@ -159,8 +159,8 @@
 // ALL: @3 = private unnamed_addr constant [19 x i8] c"ext_device_var_def\00"
 // ALL: @4 = private unnamed_addr constant [21 x i8] c"ext_constant_var_def\00"
 // * constant unnamed string with GPU binary
-// CUDA: @[[FATBIN:.*]] = private constant{{.*GPU binary would be here.*}}\00",
-// HIPEF: @[[FATBIN:.*]] = private constant{{.*GPU binary would be here.*}}\00",{{.*}}align 4096
+// CUDA: @[[FATBIN:.*]] = private constant{{.*}} c"GPU binary would be here.",
+// HIPEF: @[[FATBIN:.*]] = private constant{{.*}} c"GPU binary would be here.",{{.*}}align 4096
 // HIPNEF: @[[FATBIN:__hip_fatbin]] = external constant i8, section ".hip_fatbin"
 // CUDANORDC-SAME: section ".nv_fatbin", align 8
 // CUDARDC-SAME: section "__nv_relfatbin", align 8
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -69,6 +69,8 @@
   bool RelocatableDeviceCode;
   /// Mangle context for device.
   std::unique_ptr DeviceMC;
+  /// Some zeros used for GEPs.
+  llvm::Constant *Zeros[2];
 
   llvm::FunctionCallee getSetupArgumentFn() const;
   llvm::FunctionCallee getLaunchFn() const;
@@ -86,14 +88,25 @@
   /// the start of the string.  The result of this function can be used anywhere
   /// where the C code specifies const char*.
   llvm::Constant *makeConstantString(const std::string ,
- const std::string  = "",
- const std::string  = "",
- unsigned Alignment = 0) {
-llvm::Constant *Zeros[] = {llvm::ConstantInt::get(SizeTy, 0),
-   llvm::ConstantInt::get(SizeTy, 0)};
+ const std::string  = "") {
 auto ConstStr = CGM.GetAddrOfConstantCString(Str, Name.c_str());
-llvm::GlobalVariable *GV =
-cast(ConstStr.getPointer());
+return llvm::ConstantExpr::getGetElementPtr(ConstStr.getElementType(),
+ConstStr.getPointer(), Zeros);
+  }
+
+  /// Helper function which generates an initialized constant array from Str,
+  /// and optionally sets section name and alignment. AddNull specifies whether
+  /// the array should nave NUL termination.
+  llvm::Constant *makeConstantArray(StringRef Str,
+StringRef Name = "",
+StringRef SectionName = "",
+unsigned Alignment = 0,
+bool AddNull = false) {
+llvm::Constant *Value =
+llvm::ConstantDataArray::getString(Context, Str, AddNull);
+auto *GV = new llvm::GlobalVariable(
+TheModule, Value->getType(), /*isConstant=*/true,
+llvm::GlobalValue::PrivateLinkage, Value, Name);
 if (!SectionName.empty()) {
   GV->setSection(SectionName);
   // Mark the address as used which make sure that this section isn't
@@ -102,9 +115,7 @@
 }
 if (Alignment)
   GV->setAlignment(llvm::Align(Alignment));
-
-return llvm::ConstantExpr::getGetElementPtr(ConstStr.getElementType(),
-ConstStr.getPointer(), Zeros);
+return llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros);
   }
 
   /// Helper function that generates an empty dummy function returning void.
@@ -220,6 +231,8 @@
   IntTy = CGM.IntTy;
   SizeTy = CGM.SizeTy;
   VoidTy = CGM.VoidTy;
+  Zeros[0] = llvm::ConstantInt::get(SizeTy, 0);
+  Zeros[1] = Zeros[0];
 
   CharPtrTy = llvm::PointerType::getUnqual(Types.ConvertType(Ctx.CharTy));
   VoidPtrTy = cast(Types.ConvertType(Ctx.VoidPtrTy));
@@ -744,9 +757,8 @@
   // If fatbin is available from early finalization, create a string
   // literal containing the fat binary loaded from the given file.
   const unsigned HIPCodeObjectAlign = 4096;
-  FatBinStr =
-  

[clang] a10eb07 - Do not append terminating NUL to the binary string with embedded fatbin.

2022-10-17 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2022-10-17T15:39:39-07:00
New Revision: a10eb07d1acc2f132b4d0cf522097814a8340b47

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

LOG: Do not append terminating NUL to the binary string with embedded fatbin.

Extra NUL does not impact functionality of the generated code, but it confuses
various NVIDIA tools used to examine embedded GPU binaries.

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

Added: 


Modified: 
clang/lib/CodeGen/CGCUDANV.cpp
clang/test/CodeGenCUDA/device-stub.cu

Removed: 




diff  --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index a8bb0dd65d1a..abf320996dc4 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -69,6 +69,8 @@ class CGNVCUDARuntime : public CGCUDARuntime {
   bool RelocatableDeviceCode;
   /// Mangle context for device.
   std::unique_ptr DeviceMC;
+  /// Some zeros used for GEPs.
+  llvm::Constant *Zeros[2];
 
   llvm::FunctionCallee getSetupArgumentFn() const;
   llvm::FunctionCallee getLaunchFn() const;
@@ -86,14 +88,25 @@ class CGNVCUDARuntime : public CGCUDARuntime {
   /// the start of the string.  The result of this function can be used 
anywhere
   /// where the C code specifies const char*.
   llvm::Constant *makeConstantString(const std::string ,
- const std::string  = "",
- const std::string  = "",
- unsigned Alignment = 0) {
-llvm::Constant *Zeros[] = {llvm::ConstantInt::get(SizeTy, 0),
-   llvm::ConstantInt::get(SizeTy, 0)};
+ const std::string  = "") {
 auto ConstStr = CGM.GetAddrOfConstantCString(Str, Name.c_str());
-llvm::GlobalVariable *GV =
-cast(ConstStr.getPointer());
+return llvm::ConstantExpr::getGetElementPtr(ConstStr.getElementType(),
+ConstStr.getPointer(), Zeros);
+  }
+
+  /// Helper function which generates an initialized constant array from Str,
+  /// and optionally sets section name and alignment. AddNull specifies whether
+  /// the array should nave NUL termination.
+  llvm::Constant *makeConstantArray(StringRef Str,
+StringRef Name = "",
+StringRef SectionName = "",
+unsigned Alignment = 0,
+bool AddNull = false) {
+llvm::Constant *Value =
+llvm::ConstantDataArray::getString(Context, Str, AddNull);
+auto *GV = new llvm::GlobalVariable(
+TheModule, Value->getType(), /*isConstant=*/true,
+llvm::GlobalValue::PrivateLinkage, Value, Name);
 if (!SectionName.empty()) {
   GV->setSection(SectionName);
   // Mark the address as used which make sure that this section isn't
@@ -102,9 +115,7 @@ class CGNVCUDARuntime : public CGCUDARuntime {
 }
 if (Alignment)
   GV->setAlignment(llvm::Align(Alignment));
-
-return llvm::ConstantExpr::getGetElementPtr(ConstStr.getElementType(),
-ConstStr.getPointer(), Zeros);
+return llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros);
   }
 
   /// Helper function that generates an empty dummy function returning void.
@@ -220,6 +231,8 @@ CGNVCUDARuntime::CGNVCUDARuntime(CodeGenModule )
   IntTy = CGM.IntTy;
   SizeTy = CGM.SizeTy;
   VoidTy = CGM.VoidTy;
+  Zeros[0] = llvm::ConstantInt::get(SizeTy, 0);
+  Zeros[1] = Zeros[0];
 
   CharPtrTy = llvm::PointerType::getUnqual(Types.ConvertType(Ctx.CharTy));
   VoidPtrTy = cast(Types.ConvertType(Ctx.VoidPtrTy));
@@ -744,9 +757,8 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
   // If fatbin is available from early finalization, create a string
   // literal containing the fat binary loaded from the given file.
   const unsigned HIPCodeObjectAlign = 4096;
-  FatBinStr =
-  makeConstantString(std::string(CudaGpuBinary->getBuffer()), "",
- FatbinConstantName, HIPCodeObjectAlign);
+  FatBinStr = makeConstantArray(std::string(CudaGpuBinary->getBuffer()), 
"",
+FatbinConstantName, HIPCodeObjectAlign);
 } else {
   // If fatbin is not available, create an external symbol
   // __hip_fatbin in section .hip_fatbin. The external symbol is supposed
@@ -780,8 +792,8 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
 
 // For CUDA, create a string literal containing the fat binary loaded from
 // the given file.
-FatBinStr = makeConstantString(std::string(CudaGpuBinary->getBuffer()), "",
-

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

2022-10-17 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr added a comment.

I'm quite sure that we will always want a means to select the original Itanium 
ABI. It's also quite likely that there will be future innovations in the 
Fuchsia C++ ABI and we'll go through migration periods of supporting additional 
variants and changing the default for Fuchsia targets.

My earlier comment referred to `-fc++-abi` generally: that each target would be 
expected to enable a specific set of selections available, the Fuchsia targets 
being the first to have a set defined.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

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


[PATCH] D135920: [clang][Sema] Use correct array size for diagnostic

2022-10-17 Thread Bill Wendling via Phabricator via cfe-commits
void added inline comments.



Comment at: clang/test/SemaCXX/array-bounds.cpp:240
 
-((char*)foo)[sizeof(foo)] = '\0';  // expected-warning {{array index 32768 
is past the end of the array (which contains 32768 elements)}}
+((char*)foo)[sizeof(foo)] = '\0';  // expected-warning {{array index 32768 
is past the end of the array (which contains 4096 elements)}}
 

serge-sans-paille wrote:
> kees wrote:
> > serge-sans-paille wrote:
> > > I find this new message quite confusing, because the array index is given 
> > > in terms of char elements, while the array size is given in terms of 
> > > double elements. I actually find the original message more consistent to 
> > > that respect.
> > Perhaps show both element count and byte offset?
> > 
> > `array index $count is $(bytes - end_of_array_in_bytes) past the end of the 
> > array (which contains $end_of_array_in_bytes bytes of $array_max_index 
> > elements)`
> if we have no cast, I find the version without the patch  just fine.
> 
> If we have a cast, I suggest we just express the result in bytes, something 
> along those lines (inspired by your suggestion):
> 
> array index $count is $(bytes - end_of_array_in_bytes) bytes past the end 
> of the allocated memory for that array (which contains $end_of_array_in_bytes 
> bytes)
I so far have this. It looks not too bad even for the non-cast. Thoughts?

```
$ cat ab.c
void test_pr10771() {
double foo[4096];  // expected-note {{array 'foo' declared here}}

((char*)foo)[sizeof(foo)] = '\0';  // expected-warning {{array index 32768 
is past the end of the array (which contains 4096 elements of type 
'double[4096])}}
foo[4098] = '\0';  // expected-warning {{array index 32768 is past the end 
of the array (which contains 4096 elements of type 'double[4096])}}
}
$ clang++ -x c++ -o /dev/null -S -std=c++14 ~/llvm/ab.c
/home/morbo/llvm/ab.c:4:13: warning: array index 32768 is 0 bytes past the end 
of the array (that has type 'double[4096]') [-Warray-bounds]
((char*)foo)[sizeof(foo)] = '\0';  // expected-warning {{array index 32768 
is past the end of the array (which contains 4096 elements of type 
'double[4096])}}
^~~~
/home/morbo/llvm/ab.c:2:5: note: array 'foo' declared here
double foo[4096];  // expected-note {{array 'foo' declared here}}
^
/home/morbo/llvm/ab.c:5:5: warning: array index 4098 is 16 bytes past the end 
of the array (that has type 'double[4096]') [-Warray-bounds]
foo[4098] = '\0';  // expected-warning {{array index 32768 is past the end 
of the array (which contains 4096 elements of type 'double[4096])}}
^   
/home/morbo/llvm/ab.c:2:5: note: array 'foo' declared here
double foo[4096];  // expected-note {{array 'foo' declared here}}
^
2 warnings generated.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135920

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


[PATCH] D135269: [AMDGPU] Disable bool range metadata to workaround backend issue

2022-10-17 Thread Nikita Popov via Phabricator via cfe-commits
nikic added subscribers: arsenm, nikic.
nikic added a comment.

Checking back here, have you made any progress on reducing the issue?

cc @arsenm for awareness


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135269

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


[PATCH] D129531: [clang][C++20] P0960R3: Allow initializing aggregates from a parenthesized list of values

2022-10-17 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 468347.
ayzhao added a comment.

Fill out ItaniumMangle.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  clang/test/CodeGen/P0960R3.cpp
  clang/test/SemaCXX/P0960R3.cpp
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,10 @@
 K = CXCursor_RequiresExpr;
 break;
 
+  case Stmt::CXXParenListInitExprClass:
+K = CXCursor_CXXParenListInitExpr;
+break;
+
   case Stmt::MSDependentExistsStmtClass:
 K = CXCursor_UnexposedStmt;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2139,6 +2139,7 @@
   void VisitLambdaExpr(const LambdaExpr *E);
   void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E);
   void VisitRequiresExpr(const RequiresExpr *E);
+  void VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
   void VisitOMPExecutableDirective(const OMPExecutableDirective *D);
   void VisitOMPLoopBasedDirective(const OMPLoopBasedDirective *D);
   void VisitOMPLoopDirective(const OMPLoopDirective *D);
@@ -2999,6 +3000,9 @@
   for (ParmVarDecl *VD : E->getLocalParameters())
 AddDecl(VD);
 }
+void EnqueueVisitor::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E) {
+  EnqueueChildren(E);
+}
 void EnqueueVisitor::VisitPseudoObjectExpr(const PseudoObjectExpr *E) {
   // Treat the expression like its syntactic form.
   Visit(E->getSyntacticForm());
@@ -5574,6 +5578,8 @@
 return cxstring::createRef("ConceptSpecializationExpr");
   case CXCursor_RequiresExpr:
 return cxstring::createRef("RequiresExpr");
+  case CXCursor_CXXParenListInitExpr:
+return cxstring::createRef("CXXParenListInitExpr");
   case CXCursor_UnexposedStmt:
 return cxstring::createRef("UnexposedStmt");
   case CXCursor_DeclStmt:
Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify -Wno-c++2a-extensions
-// RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify=expected,pre20 -Wno-c++2a-extensions
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify=expected,pro20
 
 template  struct enable_ifv {};
 
@@ -20,7 +20,7 @@
 
 template
 struct A {
-// expected-note@-1+ {{candidate constructor}}
+// pre20-note@-1+ {{candidate constructor}}
   explicit(1 << a)
 // expected-note@-1 {{negative shift count -1}}
 // expected-error@-2 {{explicit specifier argument is not a constant expression}}
@@ -28,8 +28,9 @@
 };
 
 A<-1> a(0);
-// expected-error@-1 {{no matching constructor}}
-// expected-note@-2 {{in instantiation of template class}}
+// pre20-error@-1 {{no matching constructor}}
+// pro20-error@-2 {{excess elements in struct initializer}}
+// expected-note@-3 {{in instantiation of template class}}
 
 template
 struct B {
Index: clang/test/SemaCXX/P0960R3.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/P0960R3.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s -fsyntax-only
+
+struct A { // expected-note 4{{candidate constructor}}
+  char i;
+  double j;
+};
+
+struct B {
+  A a;
+  int b[20];
+  int & // expected-note {{reference member declared here}}
+};
+
+struct C { // expected-note 2{{candidate constructor}}
+  A a;
+  int b[20];
+};
+
+struct D : public 

[PATCH] D136106: [clang][RISCV] Set vscale_range attribute based on VLEN

2022-10-17 Thread Philip Reames via Phabricator via cfe-commits
reames updated this revision to Diff 468344.
reames edited the summary of this revision.

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

https://reviews.llvm.org/D136106

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/CodeGen/riscv-vector-bits-vscale-range.c
  llvm/include/llvm/Support/RISCVISAInfo.h


Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -60,6 +60,7 @@
   unsigned getXLen() const { return XLen; };
   unsigned getFLen() const { return FLen; };
   unsigned getMinVLen() const { return MinVLen; }
+  unsigned getMaxVLen() const { return 65536; }
   unsigned getMaxELen() const { return MaxELen; }
   unsigned getMaxELenFp() const { return MaxELenFp; }
 
Index: clang/test/CodeGen/riscv-vector-bits-vscale-range.c
===
--- clang/test/CodeGen/riscv-vector-bits-vscale-range.c
+++ clang/test/CodeGen/riscv-vector-bits-vscale-range.c
@@ -9,11 +9,17 @@
 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +v 
-mvscale-min=8 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=8 
--check-prefix=CHECK-NOMAX
 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +v 
-mvscale-min=16 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=16 
--check-prefix=CHECK-NOMAX
 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +v 
-mvscale-min=1 -mvscale-max=0 -S -emit-llvm -o - %s | FileCheck %s 
--check-prefix=CHECK-UNBOUNDED
-// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +v -S 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-NONE
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +v -S 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-V
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +v 
-target-feature +zvl512b -S -emit-llvm -o - %s | FileCheck %s 
--check-prefix=CHECK-ZVL
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +zve64x -S 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-ZVE64
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +zve64f 
-target-feature +f -S -emit-llvm -o - %s | FileCheck %s 
--check-prefix=CHECK-ZVE64
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +zve64d 
-target-feature +f -target-feature +d -S -emit-llvm -o - %s | FileCheck %s 
--check-prefix=CHECK-ZVE64
 
 // CHECK-LABEL: @func() #0
 // CHECK: attributes #0 = { {{.*}} vscale_range([[#VBITS]],[[#VBITS]]) {{.*}} }
 // CHECK-NOMAX: attributes #0 = { {{.*}} vscale_range([[#VBITS]],0) {{.*}} }
 // CHECK-UNBOUNDED: attributes #0 = { {{.*}} vscale_range(1,0) {{.*}} }
-// CHECK-NONE: attributes #0 = { {{.*}} vscale_range(2,1024) {{.*}} }
+// CHECK-V: attributes #0 = { {{.*}} vscale_range(2,1024) {{.*}} }
+// CHECK-ZVL: attributes #0 = { {{.*}} vscale_range(8,1024) {{.*}} }
+// CHECK-ZVE64: attributes #0 = { {{.*}} vscale_range(1,1024) {{.*}} }
 void func(void) {}
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -252,9 +252,11 @@
 return std::pair(
 LangOpts.VScaleMin ? LangOpts.VScaleMin : 1, LangOpts.VScaleMax);
 
-  if (hasFeature("v"))
-// Minimum VLEN=128, Maximum VLEN=64k, and RISCV::RVVBitsPerBlock is 64.
-return std::pair(2, 1024);
+  if (unsigned MinVLen = ISAInfo->getMinVLen()) {
+unsigned MaxVLen = ISAInfo->getMaxVLen();
+// RISCV::RVVBitsPerBlock is 64.
+return std::pair(MinVLen/64, MaxVLen/64);
+  }
 
   return None;
 }


Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -60,6 +60,7 @@
   unsigned getXLen() const { return XLen; };
   unsigned getFLen() const { return FLen; };
   unsigned getMinVLen() const { return MinVLen; }
+  unsigned getMaxVLen() const { return 65536; }
   unsigned getMaxELen() const { return MaxELen; }
   unsigned getMaxELenFp() const { return MaxELenFp; }
 
Index: clang/test/CodeGen/riscv-vector-bits-vscale-range.c
===
--- clang/test/CodeGen/riscv-vector-bits-vscale-range.c
+++ clang/test/CodeGen/riscv-vector-bits-vscale-range.c
@@ -9,11 +9,17 @@
 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +v -mvscale-min=8 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=8 --check-prefix=CHECK-NOMAX
 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +v -mvscale-min=16 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=16 --check-prefix=CHECK-NOMAX
 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +v -mvscale-min=1 -mvscale-max=0 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-UNBOUNDED

[PATCH] D135956: [include-cleaner] Add include-cleaner tool, with initial HTML report

2022-10-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Hooks.h:9
+//
+// Where Analysis.h analyzes AST nodes and recorded preprocessor events, this
+// file defines ways to capture AST and preprocessor information from a parse.

hokein wrote:
> I assume we are all on the same page of the design -- I'd create the 
> Analysis.h file, and move the `writeHTMLReport` function there in this patch.
This patch already does a fair amount of yak-shaving, and writeHTMLReport is 
very tangential to that header - I don't think it's possible to review e.g. a 
good file comment at this point.



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Hooks.h:39
+  // (Traversing the TranslationUnitDecl would find uses inside headers!)
+  std::vector TopLevelDecls;
+};

hokein wrote:
> nit: I'd probably mention the "main file" bit in the name, MainTopLevelDecls?
Agree it's missing detail, but I think `MainTopLevelDecls` is too wordy.
How about `Roots` instead? It needs a bit more context to understand, but it's 
in the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135956

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


[PATCH] D135956: [include-cleaner] Add include-cleaner tool, with initial HTML report

2022-10-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 468343.
sammccall marked 2 inline comments as done.
sammccall added a comment.
Herald added a project: clang.

address comments, add tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135956

Files:
  clang-tools-extra/include-cleaner/CMakeLists.txt
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
  clang-tools-extra/include-cleaner/lib/AnalysisInternal.h
  clang-tools-extra/include-cleaner/lib/CMakeLists.txt
  clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
  clang-tools-extra/include-cleaner/lib/Record.cpp
  clang-tools-extra/include-cleaner/test/Inputs/bar.h
  clang-tools-extra/include-cleaner/test/Inputs/foo.h
  clang-tools-extra/include-cleaner/test/html.cpp
  clang-tools-extra/include-cleaner/tool/CMakeLists.txt
  clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
  clang-tools-extra/include-cleaner/unittests/CMakeLists.txt
  clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
  clang/include/clang/Testing/TestAST.h
  clang/lib/Testing/TestAST.cpp

Index: clang/lib/Testing/TestAST.cpp
===
--- clang/lib/Testing/TestAST.cpp
+++ clang/lib/Testing/TestAST.cpp
@@ -114,7 +114,8 @@
   // Running the FrontendAction creates the other components: SourceManager,
   // Preprocessor, ASTContext, Sema. Preprocessor needs TargetInfo to be set.
   EXPECT_TRUE(Clang->createTarget());
-  Action = std::make_unique();
+  Action =
+  In.MakeAction ? In.MakeAction() : std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs.front();
   if (!Action->BeginSourceFile(*Clang, Main)) {
 ADD_FAILURE() << "Failed to BeginSourceFile()";
Index: clang/include/clang/Testing/TestAST.h
===
--- clang/include/clang/Testing/TestAST.h
+++ clang/include/clang/Testing/TestAST.h
@@ -53,6 +53,10 @@
   /// To suppress this, set ErrorOK or include "error-ok" in a comment in Code.
   /// In either case, all diagnostics appear in TestAST::diagnostics().
   bool ErrorOK = false;
+
+  /// The action used to parse the code.
+  /// By default, a SyntaxOnlyAction is used.
+  std::function()> MakeAction;
 };
 
 /// The result of parsing a file specified by TestInputs.
@@ -78,6 +82,7 @@
   SourceManager () { return Clang->getSourceManager(); }
   FileManager () { return Clang->getFileManager(); }
   Preprocessor () { return Clang->getPreprocessor(); }
+  FrontendAction () { return *Action; }
 
   /// Returns diagnostics emitted during parsing.
   /// (By default, errors cause test failures, see TestInputs::ErrorOK).
Index: clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
===
--- /dev/null
+++ clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
@@ -0,0 +1,84 @@
+#include "clang-include-cleaner/Record.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Testing/TestAST.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang::include_cleaner {
+namespace {
+
+// Matches a Decl* if it is a NamedDecl with the given name.
+MATCHER_P(Named, N, "") {
+  if (const NamedDecl *ND = llvm::dyn_cast(arg)) {
+if (N == ND->getNameAsString())
+  return true;
+  }
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+  arg->dump(OS);
+  *result_listener << S;
+  return false;
+}
+
+class RecordASTTest : public ::testing::Test {
+protected:
+  TestInputs Inputs;
+  RecordedAST Recorded;
+
+  RecordASTTest() {
+struct RecordAction : public ASTFrontendAction {
+  RecordedAST 
+  RecordAction(RecordedAST ) : Out(Out) {}
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ StringRef) override {
+return Out.record();
+  }
+};
+Inputs.MakeAction = [this] {
+  return std::make_unique(Recorded);
+};
+  }
+
+  TestAST build() { return TestAST(Inputs); }
+};
+
+// Top-level decl from the main file is a root, nested ones aren't.
+TEST_F(RecordASTTest, Namespace) {
+  Inputs.Code =
+  R"cpp(
+  namespace ns {
+int x;
+namespace {
+  int y;
+}
+  }
+)cpp";
+  auto AST = build();
+  EXPECT_THAT(Recorded.Roots, testing::ElementsAre(Named("ns")));
+}
+
+// Decl in included file is not a root.
+TEST_F(RecordASTTest, Inclusion) {
+  Inputs.ExtraFiles["header.h"] = "void headerFunc();";
+  Inputs.Code = R"cpp(
+#include "header.h"
+void mainFunc();
+  )cpp";
+  auto AST = build();
+  EXPECT_THAT(Recorded.Roots, testing::ElementsAre(Named("mainFunc")));
+}
+
+// Decl from macro expanded into the main file is a root.
+TEST_F(RecordASTTest, Macros) {
+  Inputs.ExtraFiles["header.h"] = "#define X void x();";
+  Inputs.Code = R"cpp(
+#include "header.h"

[PATCH] D135707: [clang-format] Correctly annotate star/amp in function pointer params

2022-10-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I learn a lot from watching the others code review. Definitely not an expert 
here either, just try to help where I can.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135707

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


[PATCH] D135908: [clang][LTO] Setting Desired Default AIX Debugging Options

2022-10-17 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 468341.
qiongsiwu1 added a comment.

Clean up testcases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135908

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/lto-aix.c


Index: clang/test/Driver/lto-aix.c
===
--- clang/test/Driver/lto-aix.c
+++ clang/test/Driver/lto-aix.c
@@ -4,3 +4,30 @@
 //
 // LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
 // MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
+//
+// Test debugging options
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -gdbx 2>&1 \
+// RUN:   | FileCheck -check-prefix=DBX -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb0 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb1 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -g0 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 
-gno-strict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -gstrict-dwarf 
2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+//
+// DBX:"-bplugin_opt:-debugger-tune=dbx"
+// GDB:"-bplugin_opt:-debugger-tune=gdb"
+// NODEBUGGER-TUNE-NOT: "-bplugin_opt:-debugger-tune="
+//
+// STRICT:   "-bplugin_opt:-strict-dwarf=true"
+// NOSTRICT-NOT: "-bplugin_opt:-strict-dwarf=true"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -584,9 +584,24 @@
 else if (A->getOption().matches(options::OPT_gdbx))
   CmdArgs.push_back(
   Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=dbx"));
-else
+else if (A->getOption().matches(options::OPT_ggdb) ||
+ Args.getLastArg(options::OPT_ggdbN_Group))
   CmdArgs.push_back(
   Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=gdb"));
+else
+  llvm_unreachable("Unknown debugger-tune option");
+  }
+
+  if (IsOSAIX) {
+// On AIX, strict-dwarf is assumed to be true if any debug option is
+// specified, unless clang is told explicitly not to assume so.
+Arg *A = Args.getLastArg(options::OPT_g_Group);
+bool EnableDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+   !A->getOption().matches(options::OPT_ggdb0);
+if (EnableDebugInfo && Args.hasFlag(options::OPT_gstrict_dwarf,
+options::OPT_gno_strict_dwarf, true))
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine(PluginOptPrefix) + "-strict-dwarf=true"));
   }
 
   bool UseSeparateSections =


Index: clang/test/Driver/lto-aix.c
===
--- clang/test/Driver/lto-aix.c
+++ clang/test/Driver/lto-aix.c
@@ -4,3 +4,30 @@
 //
 // LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
 // MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
+//
+// Test debugging options
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -gdbx 2>&1 \
+// RUN:   | FileCheck -check-prefix=DBX -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb0 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb1 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -g0 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -gno-strict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang 

[PATCH] D136100: [clang-format] Do not parse certain characters in pragma directives

2022-10-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Pretty interesting, it looks ok from what I can tell, let the others take a look


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136100

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-10-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.






Comment at: clang/lib/CodeGen/CGExpr.cpp:1746
 
+  if (auto TyPtr = Ty.getTypePtrOrNull()) {
+if (!(TyPtr->isSpecificBuiltinType(BuiltinType::UChar) ||

Taking into account potantial risks from pre-existing UB, I believe we need 
clang switch to be able to shutdown this branch, similar to 
enable_noundef_analysis.
User with large code bases maybe need some time for transition.

I have no opinion if this should be ON or OFF by default


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134410

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-10-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D134410#3860646 , @xbolva00 wrote:

>> I assume with this patch landed, many such cases may change code behavior. 
>> So we will need to update msan to have a tool to detect cases like this 
>> anyway.
>
> I believe that updated msan should come first.

Yes, we can do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134410

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


[PATCH] D129531: [clang][C++20] P0960R3: Allow initializing aggregates from a parenthesized list of values

2022-10-17 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 468333.
ayzhao added a comment.

implement CIndex.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  clang/test/CodeGen/P0960R3.cpp
  clang/test/SemaCXX/P0960R3.cpp
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,10 @@
 K = CXCursor_RequiresExpr;
 break;
 
+  case Stmt::CXXParenListInitExprClass:
+K = CXCursor_CXXParenListInitExpr;
+break;
+
   case Stmt::MSDependentExistsStmtClass:
 K = CXCursor_UnexposedStmt;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2139,6 +2139,7 @@
   void VisitLambdaExpr(const LambdaExpr *E);
   void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E);
   void VisitRequiresExpr(const RequiresExpr *E);
+  void VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
   void VisitOMPExecutableDirective(const OMPExecutableDirective *D);
   void VisitOMPLoopBasedDirective(const OMPLoopBasedDirective *D);
   void VisitOMPLoopDirective(const OMPLoopDirective *D);
@@ -2999,6 +3000,9 @@
   for (ParmVarDecl *VD : E->getLocalParameters())
 AddDecl(VD);
 }
+void EnqueueVisitor::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E) {
+  EnqueueChildren(E);
+}
 void EnqueueVisitor::VisitPseudoObjectExpr(const PseudoObjectExpr *E) {
   // Treat the expression like its syntactic form.
   Visit(E->getSyntacticForm());
@@ -5574,6 +5578,8 @@
 return cxstring::createRef("ConceptSpecializationExpr");
   case CXCursor_RequiresExpr:
 return cxstring::createRef("RequiresExpr");
+  case CXCursor_CXXParenListInitExpr:
+return cxstring::createRef("CXXParenListInitExpr");
   case CXCursor_UnexposedStmt:
 return cxstring::createRef("UnexposedStmt");
   case CXCursor_DeclStmt:
Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify -Wno-c++2a-extensions
-// RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify=expected,pre20 -Wno-c++2a-extensions
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify=expected,pro20
 
 template  struct enable_ifv {};
 
@@ -20,7 +20,7 @@
 
 template
 struct A {
-// expected-note@-1+ {{candidate constructor}}
+// pre20-note@-1+ {{candidate constructor}}
   explicit(1 << a)
 // expected-note@-1 {{negative shift count -1}}
 // expected-error@-2 {{explicit specifier argument is not a constant expression}}
@@ -28,8 +28,9 @@
 };
 
 A<-1> a(0);
-// expected-error@-1 {{no matching constructor}}
-// expected-note@-2 {{in instantiation of template class}}
+// pre20-error@-1 {{no matching constructor}}
+// pro20-error@-2 {{excess elements in struct initializer}}
+// expected-note@-3 {{in instantiation of template class}}
 
 template
 struct B {
Index: clang/test/SemaCXX/P0960R3.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/P0960R3.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s -fsyntax-only
+
+struct A { // expected-note 4{{candidate constructor}}
+  char i;
+  double j;
+};
+
+struct B {
+  A a;
+  int b[20];
+  int & // expected-note {{reference member declared here}}
+};
+
+struct C { // expected-note 2{{candidate constructor}}
+  A a;
+  int b[20];
+};
+
+struct D : public C, 

[PATCH] D130951: [HLSL] CodeGen hlsl resource binding.

2022-10-17 Thread Xiang Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13163dd8abc5: [HLSL] CodeGen hlsl resource binding. 
(authored by python3kgae).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130951

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CGHLSLRuntime.h
  clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
  clang/test/CodeGenHLSL/cbuf.hlsl
  llvm/include/llvm/Frontend/HLSL/HLSLResource.h
  llvm/lib/Frontend/HLSL/HLSLResource.cpp
  llvm/lib/Target/DirectX/DXILResource.cpp
  llvm/lib/Target/DirectX/DXILResource.h
  llvm/test/CodeGen/DirectX/UAVMetadata.ll

Index: llvm/test/CodeGen/DirectX/UAVMetadata.ll
===
--- llvm/test/CodeGen/DirectX/UAVMetadata.ll
+++ llvm/test/CodeGen/DirectX/UAVMetadata.ll
@@ -13,15 +13,15 @@
 ; PRINT-NEXT:; Name Type  Format Dim  ID  HLSL Bind  Count
 ; PRINT-NEXT:; -- -- --- --- --- -- --
 ; PRINT-NEXT:;   UAV f16 buf  U0 u0 1
-; PRINT-NEXT:;   UAV f32 buf  U1 u0 1
-; PRINT-NEXT:;   UAV f64 buf  U2 u0 1
-; PRINT-NEXT:;   UAV  i1 buf  U3 u0 2
-; PRINT-NEXT:;   UAVbyte r/w  U4 u0 1
-; PRINT-NEXT:;   UAV  struct r/w  U5 u0 1
-; PRINT-NEXT:;   UAV i32 buf  U6 u0 1
-; PRINT-NEXT:;   UAV  struct r/w  U7 u0 1
-; PRINT-NEXT:;   UAVbyte r/w  U8 u0 1
-; PRINT-NEXT:;   UAV u64 buf  U9 u0 1
+; PRINT-NEXT:;   UAV f32 buf  U1 u1 1
+; PRINT-NEXT:;   UAV f64 buf  U2 u2 1
+; PRINT-NEXT:;   UAV  i1 buf  U3 u3 2
+; PRINT-NEXT:;   UAVbyte r/w  U4 u5 1
+; PRINT-NEXT:;   UAV  struct r/w  U5 u6 1
+; PRINT-NEXT:;   UAV i32 buf  U6 u7 1
+; PRINT-NEXT:;   UAV  struct r/w  U7 u8 1
+; PRINT-NEXT:;   UAVbyte r/w  U8 u9 1
+; PRINT-NEXT:;   UAV u64 buf  U9 u10,space2 1
 
 @Zero = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
 @One = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
@@ -37,16 +37,16 @@
 
 !hlsl.uavs = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
 
-!0 = !{ptr @Zero, !"RWBuffer", i32 0}
-!1 = !{ptr @One, !"Buffer>", i32 1}
-!2 = !{ptr @Two, !"Buffer", i32 2}
-!3 = !{ptr @Three, !"Buffer", i32 3}
-!4 = !{ptr @Four, !"ByteAddressBuffer", i32 4}
-!5 = !{ptr @Five, !"StructuredBuffer", i32 5}
-!6 = !{ptr @Six, !"RasterizerOrderedBuffer", i32 6}
-!7 = !{ptr @Seven, !"RasterizerOrderedStructuredBuffer", i32 7}
-!8 = !{ptr @Eight, !"RasterizerOrderedByteAddressBuffer", i32 8}
-!9 = !{ptr @Nine, !"RWBuffer", i32 9}
+!0 = !{ptr @Zero, !"RWBuffer", i32 0, i32 10, i32 0, i32 0}
+!1 = !{ptr @One, !"Buffer>", i32 1, i32 10, i32 1, i32 0}
+!2 = !{ptr @Two, !"Buffer", i32 2, i32 10, i32 2, i32 0}
+!3 = !{ptr @Three, !"Buffer", i32 3, i32 10, i32 3, i32 0}
+!4 = !{ptr @Four, !"ByteAddressBuffer", i32 4, i32 11, i32 5, i32 0}
+!5 = !{ptr @Five, !"StructuredBuffer", i32 5, i32 12, i32 6, i32 0}
+!6 = !{ptr @Six, !"RasterizerOrderedBuffer", i32 6, i32 10, i32 7, i32 0}
+!7 = !{ptr @Seven, !"RasterizerOrderedStructuredBuffer", i32 7, i32 12, i32 8, i32 0}
+!8 = !{ptr @Eight, !"RasterizerOrderedByteAddressBuffer", i32 8, i32 11, i32 9, i32 0}
+!9 = !{ptr @Nine, !"RWBuffer", i32 9, i32 10, i32 10, i32 2}
 
 ; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}
 
@@ -57,21 +57,21 @@
 ; CHECK-SAME: [[Eight:[!][0-9]+]], [[Nine:[!][0-9]+]]}
 ; CHECK: [[Zero]] = !{i32 0, ptr @Zero, !"", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, [[Half:[!][0-9]+]]}
 ; CHECK: [[Half]] = !{i32 0, i32 8}
-; CHECK: [[One]] = !{i32 1, ptr @One, !"", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, 

[clang] 13163dd - [HLSL] CodeGen hlsl resource binding.

2022-10-17 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-10-17T14:29:19-07:00
New Revision: 13163dd8abc57443bd0e931650a3c64fead5235e

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

LOG: [HLSL] CodeGen hlsl resource binding.

''register(ID, space)'' like register(t3, space1) will be translated into
i32 3, i32 1 as the last 2 operands for resource annotation metadata.

NamedMetadata for CBuffers and SRVs are added as "hlsl.srvs" and "hlsl.cbufs".

Reviewed By: beanz

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

Added: 


Modified: 
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/CodeGen/CGHLSLRuntime.h
clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
clang/test/CodeGenHLSL/cbuf.hlsl
llvm/include/llvm/Frontend/HLSL/HLSLResource.h
llvm/lib/Frontend/HLSL/HLSLResource.cpp
llvm/lib/Target/DirectX/DXILResource.cpp
llvm/lib/Target/DirectX/DXILResource.h
llvm/test/CodeGen/DirectX/UAVMetadata.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 2782ca8c9c5b1..7a80dedb8133f 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -17,7 +17,6 @@
 #include "CodeGenModule.h"
 #include "clang/AST/Decl.h"
 #include "clang/Basic/TargetOptions.h"
-#include "llvm/Frontend/HLSL/HLSLResource.h"
 #include "llvm/IR/IntrinsicsDirectX.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
@@ -90,16 +89,16 @@ void layoutBuffer(CGHLSLRuntime::Buffer , const 
DataLayout ) {
 
 GlobalVariable *replaceBuffer(CGHLSLRuntime::Buffer ) {
   // Create global variable for CB.
-  GlobalVariable *CBGV =
-  new GlobalVariable(Buf.LayoutStruct, /*isConstant*/ true,
- GlobalValue::LinkageTypes::ExternalLinkage, nullptr,
- Buf.Name + (Buf.IsCBuffer ? ".cb." : ".tb."),
- GlobalValue::NotThreadLocal);
+  GlobalVariable *CBGV = new GlobalVariable(
+  Buf.LayoutStruct, /*isConstant*/ true,
+  GlobalValue::LinkageTypes::ExternalLinkage, nullptr,
+  llvm::formatv("{0}{1}", Buf.Name, Buf.IsCBuffer ? ".cb." : ".tb."),
+  GlobalValue::NotThreadLocal);
 
   IRBuilder<> B(CBGV->getContext());
   Value *ZeroIdx = B.getInt32(0);
   // Replace Const use with CB use.
-  for (auto &[GV, Offset]: Buf.Constants) {
+  for (auto &[GV, Offset] : Buf.Constants) {
 Value *GEP =
 B.CreateGEP(Buf.LayoutStruct, CBGV, {ZeroIdx, B.getInt32(Offset)});
 
@@ -177,25 +176,100 @@ void CGHLSLRuntime::finishCodeGen() {
 layoutBuffer(Buf, DL);
 GlobalVariable *GV = replaceBuffer(Buf);
 M.getGlobalList().push_back(GV);
-// FIXME: generate resource binding.
-// See https://github.com/llvm/llvm-project/issues/57915.
+hlsl::ResourceClass RC =
+Buf.IsCBuffer ? hlsl::ResourceClass::CBuffer : 
hlsl::ResourceClass::SRV;
+llvm::hlsl::ResourceKind RK = Buf.IsCBuffer
+  ? llvm::hlsl::ResourceKind::CBuffer
+  : llvm::hlsl::ResourceKind::TBuffer;
+std::string TyName =
+Buf.Name.str() + (Buf.IsCBuffer ? ".cb." : ".tb.") + "ty";
+addBufferResourceAnnotation(GV, TyName, RC, RK, Buf.Binding);
   }
 }
 
-CGHLSLRuntime::Buffer::Buffer(const HLSLBufferDecl *D) {
-  Name = D->getName();
-  IsCBuffer = D->isCBuffer();
-  if (auto *Binding = D->getAttr()) {
-llvm::APInt RegInt(64, 0);
-Binding->getSlot().substr(1).getAsInteger(10, RegInt);
-Reg = RegInt.getLimitedValue();
+CGHLSLRuntime::Buffer::Buffer(const HLSLBufferDecl *D)
+: Name(D->getName()), IsCBuffer(D->isCBuffer()),
+  Binding(D->getAttr()) {}
 
-llvm::APInt SpaceInt(64, 0);
-Binding->getSpace().substr(5).getAsInteger(10, RegInt);
-Space = SpaceInt.getLimitedValue();
-  } else {
-Space = 0;
+void CGHLSLRuntime::addBufferResourceAnnotation(llvm::GlobalVariable *GV,
+llvm::StringRef TyName,
+hlsl::ResourceClass RC,
+llvm::hlsl::ResourceKind RK,
+BufferResBinding ) {
+  uint32_t Counter = ResourceCounters[static_cast(RC)]++;
+  llvm::Module  = CGM.getModule();
+
+  NamedMDNode *ResourceMD = nullptr;
+  switch (RC) {
+  case hlsl::ResourceClass::UAV:
+ResourceMD = M.getOrInsertNamedMetadata("hlsl.uavs");
+break;
+  case hlsl::ResourceClass::SRV:
+ResourceMD = M.getOrInsertNamedMetadata("hlsl.srvs");
+break;
+  case hlsl::ResourceClass::CBuffer:
+ResourceMD = M.getOrInsertNamedMetadata("hlsl.cbufs");
+break;
+  default:
+assert(false && "Unsupported buffer type!");
+return;
   }
+
+  assert(ResourceMD != nullptr &&
+ 

[PATCH] D136111: [OpenMP] Make device functions have hidden visibility

2022-10-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 468328.
jhuber6 added a comment.

We can't make every function hidden for non-GPU offloading. So we only apply it 
to the functions inside the `declare target` clause there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136111

Files:
  clang/lib/AST/Decl.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
  clang/test/OpenMP/target_attribute_convergent.cpp

Index: clang/test/OpenMP/target_attribute_convergent.cpp
===
--- clang/test/OpenMP/target_attribute_convergent.cpp
+++ clang/test/OpenMP/target_attribute_convergent.cpp
@@ -9,5 +9,5 @@
 #pragma omp end declare target
 
 // CHECK: Function Attrs: {{.*}}convergent{{.*}}
-// CHECK: define protected void @_Z3foov() [[ATTRIBUTE_NUMBER:#[0-9]+]]
+// CHECK: define hidden void @_Z3foov() [[ATTRIBUTE_NUMBER:#[0-9]+]]
 // CHECK: attributes [[ATTRIBUTE_NUMBER]] = { {{.*}}convergent{{.*}} }
Index: clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
@@ -34,18 +34,18 @@
 #pragma omp declare target
 T a = T();
 T f = a;
-// CHECK: define{{ protected | }}void @{{.+}}foo{{.+}}([[T]]* noundef byval([[T]]) align {{.+}})
+// CHECK: define{{ hidden | }}void @{{.+}}foo{{.+}}([[T]]* noundef byval([[T]]) align {{.+}})
 void foo(T a = T()) {
   return;
 }
-// CHECK: define{{ protected | }}[6 x i64] @{{.+}}bar{{.+}}()
+// CHECK: define{{ hidden | }}[6 x i64] @{{.+}}bar{{.+}}()
 T bar() {
 // CHECK:  bitcast [[T]]* %{{.+}} to [6 x i64]*
 // CHECK-NEXT: load [6 x i64], [6 x i64]* %{{.+}},
 // CHECK-NEXT: ret [6 x i64]
   return T();
 }
-// CHECK: define{{ protected | }}void @{{.+}}baz{{.+}}()
+// CHECK: define{{ hidden | }}void @{{.+}}baz{{.+}}()
 void baz() {
 // CHECK:  call [6 x i64] @{{.+}}bar{{.+}}()
 // CHECK-NEXT: bitcast [[T]]* %{{.+}} to [6 x i64]*
@@ -54,17 +54,17 @@
 }
 T1 a1 = T1();
 T1 f1 = a1;
-// CHECK: define{{ protected | }}void @{{.+}}foo1{{.+}}([[T1]]* noundef byval([[T1]]) align {{.+}})
+// CHECK: define{{ hidden | }}void @{{.+}}foo1{{.+}}([[T1]]* noundef byval([[T1]]) align {{.+}})
 void foo1(T1 a = T1()) {
   return;
 }
-// CHECK: define{{ protected | }}[[T1]] @{{.+}}bar1{{.+}}()
+// CHECK: define{{ hidden | }}[[T1]] @{{.+}}bar1{{.+}}()
 T1 bar1() {
 // CHECK:  load [[T1]], [[T1]]*
 // CHECK-NEXT: ret [[T1]]
   return T1();
 }
-// CHECK: define{{ protected | }}void @{{.+}}baz1{{.+}}()
+// CHECK: define{{ hidden | }}void @{{.+}}baz1{{.+}}()
 void baz1() {
 // CHECK: call [[T1]] @{{.+}}bar1{{.+}}()
   T1 t = bar1();
Index: clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
===
--- clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
+++ clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
@@ -34,12 +34,12 @@
 #pragma omp declare target (bar)
 int caz() { return 0; }
 
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[FOO:@.*foo.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[BAR:@.*bar.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[BAZ:@.*baz.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[DOO:@.*doo.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[CAR:@.*car.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[CAZ:@.*caz.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[FOO:@.*foo.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[BAR:@.*bar.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[BAZ:@.*baz.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[DOO:@.*doo.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[CAR:@.*car.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[CAZ:@.*caz.*]]()
 
 static int c = foo() + bar() + baz();
 #pragma omp declare target (c)
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -835,6 +835,15 @@
 if (Function->getStorageClass() == SC_PrivateExtern)
   LV.mergeVisibility(HiddenVisibility, true);
 
+// OpenMP target declare device functions are not callable from the host so
+// they should not be exported from the device image. This applies to all
+// functions as the host-callable kernel functions are emitted at codegen.
+if (Context.getLangOpts().OpenMP && Context.getLangOpts().OpenMPIsDevice &&
+((Context.getTargetInfo().getTriple().isAMDGPU() ||
+  Context.getTargetInfo().getTriple().isNVPTX()) ||
+ OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Function)))
+  LV.mergeVisibility(HiddenVisibility, /*newExplicit=*/false);
+
 // Note that 

[PATCH] D128567: [WIP][Fuchsia] Set LLVM_TOOL_LLD_BUILD to allow some extra runtimes tests to run

2022-10-17 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D128567#3863222 , @abrachet wrote:

> In D128567#3863178 , @aeubanks 
> wrote:
>
>> I've noticed that we're skipping compiler-rt tests with `REQUIRED: 
>> lld-available` because `LLVM_TOOL_LLD_BUILD` needs to be defined. any update 
>> on the proposed alternative?
>
> I think the canonical way this is done throughout the code base is with
>
>   from lit.llvm import llvm_config
>   
>   if llvm_config.use_lld(required=False):
>   config.available_features.add('lld')
>
> Though, what I think we don't do currently here or elsewhere is conditionally 
> add test deps on `lld` if it is specified in `LLVM_ENABLE_PROJECTS`

I see things like

  if(NOT APPLE AND COMPILER_RT_HAS_LLD AND "lld" IN_LIST LLVM_ENABLE_PROJECTS)
list(APPEND ASAN_TEST_DEPS lld)
  endif()

in multiple places like `compiler-rt/test/asan/CMakeLists.txt`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128567

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


[PATCH] D130951: [HLSL] CodeGen hlsl resource binding.

2022-10-17 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added inline comments.



Comment at: clang/lib/CodeGen/CGHLSLRuntime.h:73
   CodeGenModule 
   uint32_t ResourceCounters[static_cast(
   hlsl::ResourceClass::NumClasses)] = {0};

beanz wrote:
> The `ResourceCounters` here was a stand-in for allocating resource indices.
> 
> If you have a different path for allocating these, we shouldn't need the 
> counter anymore. I'm a little concerned that it looks like you're not 
> allocating these in code generation. Can you explain how you intend to 
> allocate indices? Is there a reason not to do this in code gen?
The reason not to do it in codeGen is that we have to remove unused global 
resources even in Od and update the ID in the backend.

The plan is to allocate the ID after unused global resources are deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130951

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


[PATCH] D130951: [HLSL] CodeGen hlsl resource binding.

2022-10-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/CodeGen/CGHLSLRuntime.h:73
   CodeGenModule 
   uint32_t ResourceCounters[static_cast(
   hlsl::ResourceClass::NumClasses)] = {0};

beanz wrote:
> The `ResourceCounters` here was a stand-in for allocating resource indices.
> 
> If you have a different path for allocating these, we shouldn't need the 
> counter anymore. I'm a little concerned that it looks like you're not 
> allocating these in code generation. Can you explain how you intend to 
> allocate indices? Is there a reason not to do this in code gen?
Wait... I guess I actually fed the `ResourceCounter` to the ID, which is fine.

I don't like that we're not allocating the indices in codegen, but we can 
address that in a subsequent patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130951

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


[PATCH] D136036: [Clang] Add __has_constexpr_builtin support

2022-10-17 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:96
+the constant evaluation of the corresponding builtin (for example,
+``std::fmax`` calls ``__builtin_fmax``) is supported in Clang.
+

Izaron wrote:
> Just to be clear: this isn't a true statement now (`std::fmax calls 
> __builtin_fmax`), but soon will be, after @philnik commits this patch 
> https://reviews.llvm.org/D134584 part by part
> 
> ```
> inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { 
> return __builtin_fmaxf(__x, __y); }
> ```
BTW in future it could look something like this:
```
inline _LIBCPP_CONSTEXPR_CXX23_IF_CONSTEXPR_BUILTIN(__builtin_fmax) 
_LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { return 
__builtin_fmaxf(__x, __y); }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136036

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


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-10-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

I went ahead and landed this for you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-10-17 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4abc910a42e5: [clangd] Implement semantic token modifier 
definition (authored by ckandeler, committed by nridge).

Changed prior to commit:
  https://reviews.llvm.org/D127403?vs=466731=468318#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
@@ -18,18 +18,18 @@
 TEST_F(AnnotateHighlightingsTest, Test) {
   EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
   EXPECT_AVAILABLE("[[int a; int b;]]");
-  EXPECT_EQ("void /* Function [decl] [globalScope] */f() {}",
+  EXPECT_EQ("void /* Function [decl] [def] [globalScope] */f() {}",
 apply("void ^f() {}"));
 
   EXPECT_EQ(apply("[[int f1(); const int x = f1();]]"),
 "int /* Function [decl] [globalScope] */f1(); "
-"const int /* Variable [decl] [readonly] [fileScope] */x = "
+"const int /* Variable [decl] [def] [readonly] [fileScope] */x = "
 "/* Function [globalScope] */f1();");
 
   // Only the targeted range is annotated.
   EXPECT_EQ(apply("void f1(); void f2() {^}"),
 "void f1(); "
-"void /* Function [decl] [globalScope] */f2() {}");
+"void /* Function [decl] [def] [globalScope] */f2() {}");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -48,12 +48,21 @@
 assert(StartOffset <= EndOffset);
 assert(NextChar <= StartOffset);
 
+bool hasDef =
+T.Modifiers & (1 << uint32_t(HighlightingModifier::Definition));
+bool hasDecl =
+T.Modifiers & (1 << uint32_t(HighlightingModifier::Declaration));
+EXPECT_TRUE(!hasDef || hasDecl);
+
 OS << Input.substr(NextChar, StartOffset - NextChar);
 OS << '$' << T.Kind;
 for (unsigned I = 0;
  I <= static_cast(HighlightingModifier::LastModifier); ++I) {
-  if (T.Modifiers & (1 << I))
-OS << '_' << static_cast(I);
+  if (T.Modifiers & (1 << I)) {
+// _decl_def is common and redundant, just print _def instead.
+if (I != uint32_t(HighlightingModifier::Declaration) || !hasDef)
+  OS << '_' << static_cast(I);
+  }
 }
 OS << "[[" << Input.substr(StartOffset, EndOffset - StartOffset) << "]]";
 NextChar = EndOffset;
@@ -96,52 +105,52 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
   R"cpp(
-  struct $Class_decl[[AS]] {
+  struct $Class_def[[AS]] {
 double $Field_decl[[SomeMember]];
   };
   struct {
-  } $Variable_decl[[S]];
-  void $Function_decl[[foo]](int $Parameter_decl[[A]], $Class[[AS]] $Parameter_decl[[As]]) {
-$Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_decl[[VeryLongVariableName]] = 12312;
-$Class[[AS]] $LocalVariable_decl[[AA]];
-$Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_decl[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
-auto $LocalVariable_decl[[FN]] = [ $LocalVariable[[AA]]](int $Parameter_decl[[A]]) -> void {};
+  } $Variable_def[[S]];
+  void $Function_def[[foo]](int $Parameter_def[[A]], $Class[[AS]] $Parameter_def[[As]]) {
+$Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[VeryLongVariableName]] = 12312;
+$Class[[AS]] $LocalVariable_def[[AA]];
+$Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
+auto $LocalVariable_def[[FN]] = [ $LocalVariable[[AA]]](int $Parameter_def[[A]]) -> void {};
 $LocalVariable[[FN]](12312);
   }
 )cpp",
   R"cpp(
   void $Function_decl[[foo]](int);
   void $Function_decl[[Gah]]();
-  void $Function_decl[[foo]]() {
-auto $LocalVariable_decl[[Bou]] = $Function[[Gah]];
+  void $Function_def[[foo]]() {
+auto $LocalVariable_def[[Bou]] = $Function[[Gah]];
   }
-  struct $Class_decl[[A]] {
+  struct $Class_def[[A]] {
 void $Method_decl[[abc]]();
 

[clang-tools-extra] 4abc910 - [clangd] Implement semantic token modifier "definition"

2022-10-17 Thread Nathan Ridge via cfe-commits

Author: Christian Kandeler
Date: 2022-10-17T17:12:41-04:00
New Revision: 4abc910a42e50d278f64558acc20b346bf3013f4

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

LOG: [clangd] Implement semantic token modifier "definition"

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticHighlighting.h
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/test/semantic-tokens.test
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 2375d6f7dd355..1a6fa528acced 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -66,6 +66,23 @@ bool canHighlightName(DeclarationName Name) {
   llvm_unreachable("invalid name kind");
 }
 
+bool isUniqueDefinition(const NamedDecl *Decl) {
+  if (auto *Func = dyn_cast(Decl))
+return Func->isThisDeclarationADefinition();
+  if (auto *Klass = dyn_cast(Decl))
+return Klass->isThisDeclarationADefinition();
+  if (auto *Iface = dyn_cast(Decl))
+return Iface->isThisDeclarationADefinition();
+  if (auto *Proto = dyn_cast(Decl))
+return Proto->isThisDeclarationADefinition();
+  if (auto *Var = dyn_cast(Decl))
+return Var->isThisDeclarationADefinition();
+  return isa(Decl) ||
+ isa(Decl) ||
+ isa(Decl) || isa(Decl) ||
+ isa(Decl);
+}
+
 llvm::Optional kindForType(const Type *TP,
  const HeuristicResolver 
*Resolver);
 llvm::Optional
@@ -660,7 +677,7 @@ class CollectExtraHighlightings
   // We handle objective-C selectors specially, because one reference can
   // cover several non-contiguous tokens.
   void highlightObjCSelector(const ArrayRef , bool Decl,
- bool Class, bool DefaultLibrary) {
+ bool Def, bool Class, bool DefaultLibrary) {
 HighlightingKind Kind =
 Class ? HighlightingKind::StaticMethod : HighlightingKind::Method;
 for (SourceLocation Part : Locs) {
@@ -668,6 +685,8 @@ class CollectExtraHighlightings
   H.addToken(Part, Kind).addModifier(HighlightingModifier::ClassScope);
   if (Decl)
 Tok.addModifier(HighlightingModifier::Declaration);
+  if (Def)
+Tok.addModifier(HighlightingModifier::Definition);
   if (Class)
 Tok.addModifier(HighlightingModifier::Static);
   if (DefaultLibrary)
@@ -678,8 +697,9 @@ class CollectExtraHighlightings
   bool VisitObjCMethodDecl(ObjCMethodDecl *OMD) {
 llvm::SmallVector Locs;
 OMD->getSelectorLocs(Locs);
-highlightObjCSelector(Locs, /*Decl=*/true, OMD->isClassMethod(),
-  isDefaultLibrary(OMD));
+highlightObjCSelector(Locs, /*Decl=*/true,
+  OMD->isThisDeclarationADefinition(),
+  OMD->isClassMethod(), isDefaultLibrary(OMD));
 return true;
   }
 
@@ -689,8 +709,8 @@ class CollectExtraHighlightings
 bool DefaultLibrary = false;
 if (ObjCMethodDecl *OMD = OME->getMethodDecl())
   DefaultLibrary = isDefaultLibrary(OMD);
-highlightObjCSelector(Locs, /*Decl=*/false, OME->isClassMessage(),
-  DefaultLibrary);
+highlightObjCSelector(Locs, /*Decl=*/false, /*Def=*/false,
+  OME->isClassMessage(), DefaultLibrary);
 return true;
   }
 
@@ -859,11 +879,15 @@ std::vector 
getSemanticHighlightings(ParsedAST ) {
 Tok.addModifier(HighlightingModifier::DefaultLibrary);
   if (Decl->isDeprecated())
 Tok.addModifier(HighlightingModifier::Deprecated);
-  // Do not treat an UnresolvedUsingValueDecl as a declaration.
-  // It's more common to think of it as a reference to the
-  // underlying declaration.
-  if (R.IsDecl && !isa(Decl))
-Tok.addModifier(HighlightingModifier::Declaration);
+  if (R.IsDecl) {
+// Do not treat an UnresolvedUsingValueDecl as a declaration.
+// It's more common to think of it as a reference to the
+// underlying declaration.
+if (!isa(Decl))
+  Tok.addModifier(HighlightingModifier::Declaration);
+if (isUniqueDefinition(Decl))
+  Tok.addModifier(HighlightingModifier::Definition);
+  }
 }
   },
   AST.getHeuristicResolver());
@@ -934,6 +958,8 @@ llvm::raw_ostream <<(llvm::raw_ostream , 

[PATCH] D136036: [Clang] Add __has_constexpr_builtin support

2022-10-17 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:96
+the constant evaluation of the corresponding builtin (for example,
+``std::fmax`` calls ``__builtin_fmax``) is supported in Clang.
+

Just to be clear: this isn't a true statement now (`std::fmax calls 
__builtin_fmax`), but soon will be, after @philnik commits this patch 
https://reviews.llvm.org/D134584 part by part

```
inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { 
return __builtin_fmaxf(__x, __y); }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136036

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


[PATCH] D134589: [C++20][Modules] Elide unused guard variables in Itanium ABI module initializers.

2022-10-17 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added a comment.

It occurs to me that for systems that lack dynamic initialization (like PTX), 
it is trivial to implement the 'don't call NOP module inits', because we know 
that there can be no non-nop inits.  Any code emission that tries to create a 
global init fn with contents will fail to compile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134589

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


[PATCH] D130951: [HLSL] CodeGen hlsl resource binding.

2022-10-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/lib/CodeGen/CGHLSLRuntime.h:73
   CodeGenModule 
   uint32_t ResourceCounters[static_cast(
   hlsl::ResourceClass::NumClasses)] = {0};

The `ResourceCounters` here was a stand-in for allocating resource indices.

If you have a different path for allocating these, we shouldn't need the 
counter anymore. I'm a little concerned that it looks like you're not 
allocating these in code generation. Can you explain how you intend to allocate 
indices? Is there a reason not to do this in code gen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130951

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


[PATCH] D136036: [Clang] Add __has_constexpr_builtin support

2022-10-17 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added a comment.

In D136036#3862065 , @aaron.ballman 
wrote:

> Can you also add documentation and a release note for the new feature testing 
> macro?



In D136036#3862649 , @shafik wrote:

> Please add some of this context to the release notes and/or documentation, 
> thank you.

Hi! Added some text to the docs and to the release notes mentioning ``. 
Please look at my wording =)

In D136036#3862221 , @yaxunl wrote:

> need some Sema tests to verify a constexpr builtin is const evaluated.

Hi! If I understood you correctly, every (or over 95%?) such function already 
has its tests checking its constant evaluation. For example 
test/Sema/constant-builtins-fmax.cpp 

 checks constant `__builtin_fmax`.

In D136036#3862685 , @shafik wrote:

> The changes to the various `Vist*CallExpr` functions don't seem directly 
> related to supporting `__has_constexpr_builtin`, can you explain the purpose 
> of those changes? If they are not directly related maybe it makes more sense 
> for them to be split off into a follow-up PR?

We have a protocol that the `E` character in attributes marks that the builtin 
can be constant evaluated.

But the actual constant evaluation is done in `lib/AST/ExprConstant.cpp` and 
has little to do with builtin attributes.

So how do we keep the consistency of this protocol? In other words, how can we 
guarantee that IF the builtin is constant evaluated, it DOES have the `E` in 
`Builtins.def`?

I solved it with changes to `Visit*CallExpr`. Whenever we support constant 
evaluation in a builtin, we won't forget to mark its attributes with `E` 
(otherwise the evaluator returns early).

I was thinking to make a consistency test (outside the Clang code), but 
couldn't do it =(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136036

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


[PATCH] D136036: [Clang] Add __has_constexpr_builtin support

2022-10-17 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added inline comments.



Comment at: clang/lib/Lex/PPMacroExpansion.cpp:370
   // Clang Extensions.
-  Ident__FILE_NAME__  = RegisterBuiltinMacro(*this, "__FILE_NAME__");
-  Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
-  Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
-  Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
-  Ident__has_attribute= RegisterBuiltinMacro(*this, "__has_attribute");
+  Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__");
+  Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature");

aaron.ballman wrote:
> It looks like unrelated formatting changes snuck in to this file.
`git clang-format HEAD~1` did it =) I reformatted unrelated changes back to 
original state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136036

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


[PATCH] D136036: [Clang] Add __has_constexpr_builtin support

2022-10-17 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron updated this revision to Diff 468314.
Izaron marked 2 inline comments as done.
Izaron added a comment.

Add more parsing tests. Fix unrelated formatting changes. Add release notes and 
docs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136036

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/Builtins.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/Preprocessor/feature_tests.cpp

Index: clang/test/Preprocessor/feature_tests.cpp
===
--- clang/test/Preprocessor/feature_tests.cpp
+++ clang/test/Preprocessor/feature_tests.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -verify -DVERIFY
-// expected-no-diagnostics
 
 #ifndef __has_feature
 #error Should have __has_feature
@@ -42,3 +41,29 @@
 #if __has_builtin(__builtin_insanity)
 #error Clang should not have this
 #endif
+
+// Check __has_constexpr_builtin
+#if  !__has_constexpr_builtin(__builtin_fmax) || \
+ !__has_constexpr_builtin(__builtin_fmin)
+#error Clang should have these constexpr builtins
+#endif
+
+#if  __has_constexpr_builtin(__builtin_cbrt)
+#error This builtin should not be constexpr in Clang
+#endif
+
+#if  __has_constexpr_builtin(__builtin_insanity)
+#error This is not a builtin in Clang
+#endif
+
+// expected-error@+1 {{missing '(' after '__has_constexpr_builtin'}} expected-error@+1 {{expected value}}
+#if __has_constexpr_builtin
+#endif
+
+// expected-error@+1 {{builtin feature check macro requires a parenthesized identifier}}
+#if  __has_constexpr_builtin("__builtin_fmax")
+#endif
+
+// expected-error@+1 {{too many arguments}}
+#if __has_constexpr_builtin(__builtin_fmax, __builtin_fmin)
+#endif
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -371,6 +371,8 @@
   Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
   Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
   Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
+  Ident__has_constexpr_builtin =
+  RegisterBuiltinMacro(*this, "__has_constexpr_builtin");
   Ident__has_attribute= RegisterBuiltinMacro(*this, "__has_attribute");
   if (!getLangOpts().CPlusPlus)
 Ident__has_c_attribute = RegisterBuiltinMacro(*this, "__has_c_attribute");
@@ -1735,6 +1737,18 @@
   .Default(false);
 }
   });
+  } else if (II == Ident__has_constexpr_builtin) {
+EvaluateFeatureLikeBuiltinMacro(
+OS, Tok, II, *this, false,
+[this](Token , bool ) -> int {
+  IdentifierInfo *II = ExpectFeatureIdentifierInfo(
+  Tok, *this, diag::err_feature_check_malformed);
+  if (!II)
+return false;
+  unsigned BuiltinOp = II->getBuiltinID();
+  return BuiltinOp != 0 &&
+ this->getBuiltinInfo().isConstantEvaluated(BuiltinOp);
+});
   } else if (II == Ident__is_identifier) {
 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
   [](Token , bool ) -> int {
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1954,8 +1954,8 @@
   return true;
 }
 
-/// Should this call expression be treated as a constant?
-static bool IsConstantCall(const CallExpr *E) {
+/// Should this call expression be treated as a no-op?
+static bool IsNoOpCall(const CallExpr *E) {
   unsigned Builtin = E->getBuiltinCallee();
   return (Builtin == Builtin::BI__builtin___CFStringMakeConstantString ||
   Builtin == Builtin::BI__builtin___NSStringMakeConstantString ||
@@ -2006,7 +2006,7 @@
   case Expr::ObjCBoxedExprClass:
 return cast(E)->isExpressibleAsConstantInitializer();
   case Expr::CallExprClass:
-return IsConstantCall(cast(E));
+return IsNoOpCall(cast(E));
   // For GCC compatibility, & has static storage duration.
   case Expr::AddrLabelExprClass:
 return true;
@@ -7405,6 +7405,12 @@
 
   bool ZeroInitialization(const Expr *E) { return Error(E); }
 
+  bool IsConstantEvaluatedBuiltinCall(const CallExpr *E) {
+unsigned BuiltinOp = E->getBuiltinCallee();
+return BuiltinOp != 0 &&
+   Info.Ctx.BuiltinInfo.isConstantEvaluated(BuiltinOp);
+  }
+
 public:
   ExprEvaluatorBase(EvalInfo ) : Info(Info) {}
 
@@ -8317,7 +8323,12 @@
 }
 
 bool LValueExprEvaluator::VisitCallExpr(const CallExpr *E) {
+  if (!IsConstantEvaluatedBuiltinCall(E))
+return ExprEvaluatorBaseTy::VisitCallExpr(E);
+
   switch (E->getBuiltinCallee()) {
+  default:
+return false;
   case Builtin::BIas_const:
   case 

[PATCH] D136111: [OpenMP] Make device functions have hidden visibility

2022-10-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, saiislam, JonChesterfield, ABataev, 
tianshilei1992, RaviNarayanaswamy, gregrodgers.
Herald added subscribers: mattd, asavonic, guansong, yaxunl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

In OpenMP target offloading an in other offloading languages, we
maintain a difference between device functions and kernel functions.
Kernel functions must be visible to the host and act as the entry point
to the target device. Device functions however cannot be called directly
by the host and must be called by a kernel function. Currently, we make
all definitions on the device protected by default. Because device
functions cannot be called or used by the host they should have hidden
visibility. This allows for the definitions to be better optimized via
LTO or other passes.

This patch marks every device function in the AST as having `hidden`
visibility. The kernel function is generated later at code-gen and we
set its visibility explicitly so it should not be affected. This
prevents the user from overriding the visibility, but since the user
can't do anything with these symbols anyway there is no point exporting
them right now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136111

Files:
  clang/lib/AST/Decl.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
  clang/test/OpenMP/target_attribute_convergent.cpp


Index: clang/test/OpenMP/target_attribute_convergent.cpp
===
--- clang/test/OpenMP/target_attribute_convergent.cpp
+++ clang/test/OpenMP/target_attribute_convergent.cpp
@@ -9,5 +9,5 @@
 #pragma omp end declare target
 
 // CHECK: Function Attrs: {{.*}}convergent{{.*}}
-// CHECK: define protected void @_Z3foov() [[ATTRIBUTE_NUMBER:#[0-9]+]]
+// CHECK: define hidden void @_Z3foov() [[ATTRIBUTE_NUMBER:#[0-9]+]]
 // CHECK: attributes [[ATTRIBUTE_NUMBER]] = { {{.*}}convergent{{.*}} }
Index: clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
@@ -34,18 +34,18 @@
 #pragma omp declare target
 T a = T();
 T f = a;
-// CHECK: define{{ protected | }}void @{{.+}}foo{{.+}}([[T]]* noundef 
byval([[T]]) align {{.+}})
+// CHECK: define{{ hidden | }}void @{{.+}}foo{{.+}}([[T]]* noundef 
byval([[T]]) align {{.+}})
 void foo(T a = T()) {
   return;
 }
-// CHECK: define{{ protected | }}[6 x i64] @{{.+}}bar{{.+}}()
+// CHECK: define{{ hidden | }}[6 x i64] @{{.+}}bar{{.+}}()
 T bar() {
 // CHECK:  bitcast [[T]]* %{{.+}} to [6 x i64]*
 // CHECK-NEXT: load [6 x i64], [6 x i64]* %{{.+}},
 // CHECK-NEXT: ret [6 x i64]
   return T();
 }
-// CHECK: define{{ protected | }}void @{{.+}}baz{{.+}}()
+// CHECK: define{{ hidden | }}void @{{.+}}baz{{.+}}()
 void baz() {
 // CHECK:  call [6 x i64] @{{.+}}bar{{.+}}()
 // CHECK-NEXT: bitcast [[T]]* %{{.+}} to [6 x i64]*
@@ -54,17 +54,17 @@
 }
 T1 a1 = T1();
 T1 f1 = a1;
-// CHECK: define{{ protected | }}void @{{.+}}foo1{{.+}}([[T1]]* noundef 
byval([[T1]]) align {{.+}})
+// CHECK: define{{ hidden | }}void @{{.+}}foo1{{.+}}([[T1]]* noundef 
byval([[T1]]) align {{.+}})
 void foo1(T1 a = T1()) {
   return;
 }
-// CHECK: define{{ protected | }}[[T1]] @{{.+}}bar1{{.+}}()
+// CHECK: define{{ hidden | }}[[T1]] @{{.+}}bar1{{.+}}()
 T1 bar1() {
 // CHECK:  load [[T1]], [[T1]]*
 // CHECK-NEXT: ret [[T1]]
   return T1();
 }
-// CHECK: define{{ protected | }}void @{{.+}}baz1{{.+}}()
+// CHECK: define{{ hidden | }}void @{{.+}}baz1{{.+}}()
 void baz1() {
 // CHECK: call [[T1]] @{{.+}}bar1{{.+}}()
   T1 t = bar1();
Index: clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
===
--- clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
+++ clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
@@ -34,12 +34,12 @@
 #pragma omp declare target (bar)
 int caz() { return 0; }
 
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[FOO:@.*foo.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[BAR:@.*bar.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[BAZ:@.*baz.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[DOO:@.*doo.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[CAR:@.*car.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[CAZ:@.*caz.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[FOO:@.*foo.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[BAR:@.*bar.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[BAZ:@.*baz.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[DOO:@.*doo.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[CAR:@.*car.*]]()
+// DEVICE-DAG: 

[PATCH] D135908: [clang][LTO] Setting Desired Default AIX Debugging Options

2022-10-17 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 marked 3 inline comments as done.
qiongsiwu1 added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:589
+  // On platforms other than AIX, gdb is the default option.
+  // On AIX, dbx will be automatically pick up in the presense of the
+  // debugger tuning argument, so set gdb only if it is specified.

shchenz wrote:
> Typo: presense -> absence?
Thanks for the catch! I realized the original code was confusing (probably 
incorrect). The logic is rewritten and the comment is eliminated. 



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:590
+  // On AIX, dbx will be automatically pick up in the presense of the
+  // debugger tuning argument, so set gdb only if it is specified.
+  if (!IsOSAIX || A->getOption().matches(options::OPT_ggdb) ||

shchenz wrote:
> Could you also post another patch to fix the no-lto path to remove the 
> redundant `-debugger-tuning=dbx` on AIX? We should make the lto mode and 
> non-lto mode be consistent.
Yes will do! 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135908

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


[PATCH] D135908: [clang][LTO] Setting Desired Default AIX Debugging Options

2022-10-17 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 468307.
qiongsiwu1 edited the summary of this revision.
qiongsiwu1 added a comment.

Address code review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135908

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/lto-aix.c


Index: clang/test/Driver/lto-aix.c
===
--- clang/test/Driver/lto-aix.c
+++ clang/test/Driver/lto-aix.c
@@ -4,3 +4,30 @@
 //
 // LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
 // MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
+//
+// Test debugging options
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -gdbx 2>&1 \
+// RUN:   | FileCheck -check-prefix=DBX -check-prefix=STRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb0 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=NOSTRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb1 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -g0 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g 
-gno-strict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -gstrict-dwarf 2>&1 
\
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+//
+// DBX:"-bplugin_opt:-debugger-tune=dbx"
+// GDB:"-bplugin_opt:-debugger-tune=gdb"
+// NODEBUGGER-TUNE-NOT: "-bplugin_opt:-debugger-tune="
+//
+// STRICT:   "-bplugin_opt:-strict-dwarf=true"
+// NOSTRICT-NOT: "-bplugin_opt:-strict-dwarf=true"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -584,9 +584,24 @@
 else if (A->getOption().matches(options::OPT_gdbx))
   CmdArgs.push_back(
   Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=dbx"));
-else
+else if (A->getOption().matches(options::OPT_ggdb) ||
+ Args.getLastArg(options::OPT_ggdbN_Group))
   CmdArgs.push_back(
   Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=gdb"));
+else
+  llvm_unreachable("Unknown debugger-tune option");
+  }
+
+  if (IsOSAIX) {
+// On AIX, strict-dwarf is assumed to be true if any debug option is
+// specified, unless clang is told explicitly not to assume so.
+Arg *A = Args.getLastArg(options::OPT_g_Group);
+bool EnableDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+   !A->getOption().matches(options::OPT_ggdb0);
+if (EnableDebugInfo && Args.hasFlag(options::OPT_gstrict_dwarf,
+options::OPT_gno_strict_dwarf, true))
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine(PluginOptPrefix) + "-strict-dwarf=true"));
   }
 
   bool UseSeparateSections =


Index: clang/test/Driver/lto-aix.c
===
--- clang/test/Driver/lto-aix.c
+++ clang/test/Driver/lto-aix.c
@@ -4,3 +4,30 @@
 //
 // LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
 // MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
+//
+// Test debugging options
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -gdbx 2>&1 \
+// RUN:   | FileCheck -check-prefix=DBX -check-prefix=STRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb0 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=NOSTRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb1 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -g0 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -gno-strict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s

[PATCH] D135920: [clang][Sema] Use correct array size for diagnostic

2022-10-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille added inline comments.



Comment at: clang/test/SemaCXX/array-bounds.cpp:240
 
-((char*)foo)[sizeof(foo)] = '\0';  // expected-warning {{array index 32768 
is past the end of the array (which contains 32768 elements)}}
+((char*)foo)[sizeof(foo)] = '\0';  // expected-warning {{array index 32768 
is past the end of the array (which contains 4096 elements)}}
 

kees wrote:
> serge-sans-paille wrote:
> > I find this new message quite confusing, because the array index is given 
> > in terms of char elements, while the array size is given in terms of double 
> > elements. I actually find the original message more consistent to that 
> > respect.
> Perhaps show both element count and byte offset?
> 
> `array index $count is $(bytes - end_of_array_in_bytes) past the end of the 
> array (which contains $end_of_array_in_bytes bytes of $array_max_index 
> elements)`
if we have no cast, I find the version without the patch  just fine.

If we have a cast, I suggest we just express the result in bytes, something 
along those lines (inspired by your suggestion):

array index $count is $(bytes - end_of_array_in_bytes) bytes past the end 
of the allocated memory for that array (which contains $end_of_array_in_bytes 
bytes)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135920

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


[PATCH] D136071: [include-cleaner] WIP: Add PragmaIncludes which handles include-mapping pragmas.

2022-10-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(It's a bit hard to evaluate this without the other pieces, but I suppose we 
need to start somewhere)




Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Hooks.h:38
+// spelling header rather than the header directly defines the symbol.
+class PragmaIncludes {
+public:

IWYU pragmas requires a PP listener, we'll also need PP events for other 
purposes (determining which files are self-contained, finding #includes in the 
main file). Should these be the same listener and write into the same class?

The argument for fewer components is usability: the embedder (standalone tool, 
clangd, clang-tidy) is responsible for connecting these hooks to the compiler 
and feeding the results back into the analysis.

So the library is somewhat simpler to use if the number of parts is small.
We need (I think) at least one for the AST and one for the preprocessor, 
because they need to be connected at different parts of the lifecycle.

How much do we gain by splitting up further than that?



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Hooks.h:44
+
+  bool shouldKeep(FileEntryRef File) const;
+  // Returns the mapping include for the given physical header file.

At first glance, this signature doesn't look right: `keep` applies to 
directives, not to files.
e.g.
```
#include "foo.h" // keep
#include "foo.h"
```
the second should be removed

(it's a silly example, but in the past we've confused ourselves into doing IO 
or complicated string matching code for things that are about spelling).

I'd suggest some representation like the line number (where the `#` appears, 
not where the comment is), though the details probably matter less than the 
concept.



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Hooks.h:47
+  // Returns "" if there is no mapping.
+  llvm::StringRef getMapping(FileEntryRef File) const;
+

FileEntry* rather than FileEntryRef - we don't have different mappings when we 
open the same file using different names.

(This seems like a nit here but `Header` will be something like 
`variant` and inconsistency would be confusing)



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Hooks.h:53
+  // Main file headers that should be kept, decorated by "IWYU pragma: keep".
+  llvm::DenseSet ShouldKeep; // FIXME: implement
+

Why are these UniqueID rather than FileEntry*? Is the idea to try to use this 
in clangd?

We hadn't planned on doing this, because pushing clangd's weird requirements 
around not using FileEntry's to the library, ability to clone the data 
structure etc seemed pretty intrusive. Since we switched from name-based to 
UniqueID it might be doable...



Comment at: clang-tools-extra/include-cleaner/lib/Hooks.cpp:24
+static llvm::Optional parseIWYUPragma(const char *Text) {
+  constexpr llvm::StringLiteral IWYUPragma = "// IWYU pragma: ";
+  if (strncmp(Text, IWYUPragma.data(), IWYUPragma.size()))

while we're adding this, we should probably support `/*` as well as `//`, it's 
allowed per spec (I didn't add it to clangd just to keep NFC)



Comment at: clang-tools-extra/include-cleaner/lib/Hooks.cpp:42
+PP.getSourceManager().getCharacterData(Range.getBegin(), ));
+if (!Pragma || Invalid)
+  return false;

nit: there's no need to check Invalid, getCharacterData always returns a valid 
pointer and it will never have a spurious IWYU pragma


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136071

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


  1   2   3   >