[PATCH] D114317: [clang-tidy][WIP] Do not run perfect alias checks

2021-11-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D114317#3150615 , @carlosgalvezp 
wrote:

>> it is likely that the options were tuned, but most likely only for a single 
>> check.
>
> Yes, if the alias check has a different configuration than the primary check 
> then they are considered as "different" checks (as they should be, since they 
> produce potentially different outputs and some people might lose coverage).

Yep.

> Perhaps it would be interesting to add something to the "--explain-config" 
> flag so the user understands why some checks are/aren't enabled.



>> I still maintain that there should be a single opt-in option to completely 
>> disable all aliasee checks.
>
> By "aliasee" do you mean "alias" checks (as opposed to "primary" check)? I'm 
> a bit confused by the terminology :)

Yes.

> In order words, are you proposing to opt-in to disable all alias checks, 
> leaving only the primary check (regardless of configuration)? I suppose this 
> should be fairly easy to implement, just don't check the configuration when 
> removing aliases. We can support both options for people having different use 
> cases.

IMO that would be best, otherwise this still seems like a half a solution :/ 
(not that this is worse than currently)


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

https://reviews.llvm.org/D114317

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


[PATCH] D114418: [clang][ASTImporter] Update lookup table correctly at deduction guides.

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

If the test is changed to print AST:

  TEST_P(ASTImporterOptionSpecificTestBase, ImportDeductionGuide) {
TranslationUnitDecl *FromTU = getTuDecl(
R"(
template class A { };
template class B {
template> B(T1);
};
template
B(T, T) -> B;
)",
Lang_CXX17);
  
// Get the implicit deduction guide for (non-default) constructor of 'B'.
auto *FromDG1 = FirstDeclMatcher().match(
FromTU, functionTemplateDecl(templateParameterCountIs(3)));
  
FromTU->dumpColor();

llvm::errs()<(FromDG1->getTemplateParameters()->getParam(0)->getDeclContext())<<",";

llvm::errs()<(FromDG1->getTemplateParameters()->getParam(1)->getDeclContext())<<",";

llvm::errs()<(FromDG1->getTemplateParameters()->getParam(2)->getDeclContext())<<"\n";
  }

The output is:

  ...
  |-ClassTemplateDecl 0x17931e0  col:29 A
  | |-TemplateTypeParmDecl 0x1793090  col:21 class depth 0 index 0
  | `-CXXRecordDecl 0x1793150  col:29 class A definition
  |   |-DefinitionData empty aggregate standard_layout trivially_copyable pod 
trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
  |   | |-DefaultConstructor exists trivial constexpr needs_implicit 
defaulted_is_constexpr
  |   | |-CopyConstructor simple trivial has_const_param needs_implicit 
implicit_has_const_param
  |   | |-MoveConstructor exists simple trivial needs_implicit
  |   | |-CopyAssignment simple trivial has_const_param needs_implicit 
implicit_has_const_param
  |   | |-MoveAssignment exists simple trivial needs_implicit
  |   | `-Destructor simple irrelevant trivial needs_implicit
  |   `-CXXRecordDecl 0x1793420  col:29 implicit class A
  |-ClassTemplateDecl 0x17935f0  line:3:31 B
  | |-TemplateTypeParmDecl 0x17934c8  col:22 referenced class 
depth 0 index 0 T
  | |-CXXRecordDecl 0x1793560  line:3:31 class B definition
  | | |-DefinitionData empty standard_layout trivially_copyable 
has_user_declared_ctor can_const_default_init
  | | | |-DefaultConstructor defaulted_is_constexpr
  | | | |-CopyConstructor simple trivial has_const_param needs_implicit 
implicit_has_const_param
  | | | |-MoveConstructor exists simple trivial needs_implicit
  | | | |-CopyAssignment simple trivial has_const_param needs_implicit 
implicit_has_const_param
  | | | |-MoveAssignment exists simple trivial needs_implicit
  | | | `-Destructor simple irrelevant trivial needs_implicit
  | | |-CXXRecordDecl 0x1793830  col:31 implicit referenced 
class B
  | | `-FunctionTemplateDecl 0x1793cb0  col:47 B
  | |   |-TemplateTypeParmDecl 0x17938c0  col:26 referenced 
class depth 1 index 0 T1
  | |   |-TemplateTypeParmDecl 0x1793a00 :2:1> 
input.cc:4:39 typename depth 1 index 1
  | |   | `-TemplateArgument type 'A'
  | |   |   `-TemplateSpecializationType 0x1793980 'A' dependent A
  | |   | `-TemplateArgument type 'T'
  | |   |   `-TemplateTypeParmType 0x1793520 'T' dependent depth 0 index 0
  | |   | `-TemplateTypeParm 0x17934c8 'T'
  | |   `-CXXConstructorDecl 0x1793c08  col:47 B 'void (T1)'
  | | `-ParmVarDecl 0x1793ad8  col:51 'T1'
  | `-ClassTemplateSpecializationDecl 0x16faa28  line:3:31 
class B
  |   `-TemplateArgument type 'int'
  | `-BuiltinType 0x1728a70 'int'
  |-FunctionTemplateDecl 0x16fb050  col:47 implicit 

  | |-TemplateTypeParmDecl 0x17934c8  col:22 referenced 
class depth 0 index 0 T
  | |-TemplateTypeParmDecl 0x16fac88  col:26 class depth 0 
index 1 T1
  | |-TemplateTypeParmDecl 0x16fad38 :2:1> 
input.cc:4:39 typename depth 0 index 2
  | | `-TemplateArgument type 'A'
  | |   `-TemplateSpecializationType 0x16fae00 'A' dependent A
  | | `-TemplateArgument type 'T'
  | |   `-TemplateTypeParmType 0x1793520 'T' dependent depth 0 index 0
  | | `-TemplateTypeParm 0x17934c8 'T'
  | `-CXXDeductionGuideDecl 0x16faf98  col:47 implicit 
 'auto (type-parameter-0-1) -> B'
  |   `-ParmVarDecl 0x16faea8  col:51 'type-parameter-0-1'
  |-FunctionTemplateDecl 0x16fb268  col:31 implicit 

  | |-TemplateTypeParmDecl 0x17934c8  col:22 referenced class 
depth 0 index 0 T
  | `-CXXDeductionGuideDecl 0x16fb1b0  col:31 implicit  'auto (B) -> B'
  |   `-ParmVarDecl 0x16fb148  col:31 'B'
  `-FunctionTemplateDecl 0x16fb380  col:7 
|-TemplateTypeParmDecl 0x16fa860  col:22 referenced 
class depth 0 index 0 T
`-CXXDeductionGuideDecl 0x16fb2d0  col:7  'auto (T, T) -> B'
  |-ParmVarDecl 0x16fa930  col:10 'T'
  `-ParmVarDecl 0x16fa9a8  col:13 'T'
  0x16fb1b0,0x16faf98,0x16faf98
  In file included from output.cc:1:
  input.cc:4:11: warning: template parameter lists have a different number of 
parameters (1 vs 3) [-Wodr]
template> B(T1);
^
  input.cc:6:7: note: template parameter list also declared here
template

The interesting is the printed DeclContext: The first value is the deduction 
guide 'auto (B) -> B'. Not the class declaration and not the "correct" 
deduction guide. I think that when the deduction gui

[PATCH] D114317: [clang-tidy][WIP] Do not run perfect alias checks

2021-11-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

> this still seems like a half a solution

I see, thanks for the input! I took configuration into account due to the 
concerns raised in previous patch attempts and in the RFC. I believe both use 
cases are valid so it makes sense to me to support both as independent opt-in 
flags. What do you think, @aaron.ballman ?

Out of the scope of this patch, I think it's important to document what exactly 
we mean by "alias". Users currently think that they are "interchangeable" and 
they are not aware that they are configured with different options by default, 
producing different results. For example, the 
"cppcoreguidelines-non-private-members-in-classes" is less strict than 
"misc-non-private-members-in-classes".

As I was writing this patch, I was thinking that another possibility is to add 
an option for clang-tidy to print out the alias checks, if we don't want to 
disable them. As a user, my main goal is to get an answer to the question: 
"what checks can I safely disable to speed up clang-tidy without losing 
coverage"? If clang-tidy can print this list for me, I can copy-paste it into 
my .clang-tidy file and be happy. I don't want to manually look at the HTML 
docs (which are manually-written and thus error-prone) nor at the source code 
to find this out, each time I update clang-tidy.


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

https://reviews.llvm.org/D114317

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


[PATCH] D111639: [Sema] check PseudoObject when rebuilding CXXOperatorCallExpr in template instantiation

2021-11-24 Thread Bruno De Fraine via Phabricator via cfe-commits
brunodf added a comment.



In D111639#3081504 , @brunodf wrote:

> With regard to OO_Subscript, OO_Arrow and OO_Amp, I have tried a number of 
> things, but I have not succeeded in triggering that an CXXOperatorCallExpr is 
> created for these operators (they end up as an ArraySubscriptExpr, 
> CXXDependentScopeMemberExpr and UnaryOperator respectively). At the moment, I 
> don't know how to test the code paths for these operators in 
> RebuildCXXOperatorCallExpr.

After my submission, I still looked further into cases with these operators, 
but a CXXOperatorCallExpr is only used for these operators in case an 
overloaded operator has been determined (so not in case of a dependent type). 
Also, these operators are not allowed as non-members functions. While a 
property member could be of a type that has such an overloaded member operator, 
this would be dubious since it would work on a reference to the temporary 
returned by the getter of the property member.

So while it would be possible to add tests for CXXOperatorCallExpr involving 
invocation of these operators on property members, I think this would be 
artificial and not really contribute to the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111639

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


[clang] 93fc916 - [clang-format] NFC - recent changes caused clang-format to no longer be clang-formatted.

2021-11-24 Thread via cfe-commits

Author: mydeveloperday
Date: 2021-11-24T09:45:32Z
New Revision: 93fc91610f427f42b77fa36a65a70b9b86225c37

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

LOG: [clang-format] NFC - recent changes caused clang-format to no longer be 
clang-formatted.

The following 2 commits caused files in clang-format to no longer be 
clang-formatted.

we would lose our "clean" status 
https://releases.llvm.org/13.0.0/tools/clang/docs/ClangFormattedStatus.html

c2271926a4fc  - Make clang-format fuzz through Lexing with asserts enabled 
(https://github.com/llvm/llvm-project/commit/c2271926a4fc )

84bf5e328664 - Fix various problems found by fuzzing. 
(https://github.com/llvm/llvm-project/commit/84bf5e328664)

Reviewed By: HazardyKnusperkeks, owenpan

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/lib/Format/SortJavaScriptImports.cpp
clang/lib/Format/TokenAnalyzer.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/WhitespaceManager.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 8ae29c54a762..17de1075aeaa 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2988,9 +2988,8 @@ reformat(const FormatStyle &Style, StringRef Code,
   // JSON only needs the formatting passing.
   if (Style.isJson()) {
 std::vector Ranges(1, tooling::Range(0, Code.size()));
-auto Env =
-Environment::make(Code, FileName, Ranges, FirstStartColumn,
-  NextStartColumn, LastStartColumn);
+auto Env = Environment::make(Code, FileName, Ranges, FirstStartColumn,
+ NextStartColumn, LastStartColumn);
 if (!Env)
   return {};
 // Perform the actual formatting pass.
@@ -3118,9 +3117,7 @@ tooling::Replacements fixNamespaceEndComments(const 
FormatStyle &Style,
   auto Env = Environment::make(Code, FileName, Ranges);
   if (!Env)
 return {};
-  return NamespaceEndCommentsFixer(*Env, Style)
-  .process()
-  .first;
+  return NamespaceEndCommentsFixer(*Env, Style).process().first;
 }
 
 tooling::Replacements sortUsingDeclarations(const FormatStyle &Style,
@@ -3130,9 +3127,7 @@ tooling::Replacements sortUsingDeclarations(const 
FormatStyle &Style,
   auto Env = Environment::make(Code, FileName, Ranges);
   if (!Env)
 return {};
-  return UsingDeclarationsSorter(*Env, Style)
-  .process()
-  .first;
+  return UsingDeclarationsSorter(*Env, Style).process().first;
 }
 
 LangOptions getFormattingLangOpts(const FormatStyle &Style) {

diff  --git a/clang/lib/Format/SortJavaScriptImports.cpp 
b/clang/lib/Format/SortJavaScriptImports.cpp
index 515cfce725a4..77dc0d683e5f 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -553,9 +553,7 @@ tooling::Replacements sortJavaScriptImports(const 
FormatStyle &Style,
   auto Env = Environment::make(Code, FileName, Ranges);
   if (!Env)
 return {};
-  return JavaScriptImportSorter(*Env, Style)
-  .process()
-  .first;
+  return JavaScriptImportSorter(*Env, Style).process().first;
 }
 
 } // end namespace format

diff  --git a/clang/lib/Format/TokenAnalyzer.cpp 
b/clang/lib/Format/TokenAnalyzer.cpp
index a619c6d939e9..d83e837ca134 100644
--- a/clang/lib/Format/TokenAnalyzer.cpp
+++ b/clang/lib/Format/TokenAnalyzer.cpp
@@ -37,7 +37,7 @@ namespace format {
 
 // FIXME: Instead of printing the diagnostic we should store it and have a
 // better way to return errors through the format APIs.
-class FatalDiagnosticConsumer: public DiagnosticConsumer {
+class FatalDiagnosticConsumer : public DiagnosticConsumer {
 public:
   void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const Diagnostic &Info) override {
@@ -71,7 +71,8 @@ Environment::make(StringRef Code, StringRef FileName,
   }
   // Validate that we can get the buffer data without a fatal error.
   Env->SM.getBufferData(Env->ID);
-  if (Diags.fatalError()) return nullptr;
+  if (Diags.fatalError())
+return nullptr;
   return Env;
 }
 
@@ -80,8 +81,7 @@ Environment::Environment(StringRef Code, StringRef FileName,
  unsigned LastStartColumn)
 : VirtualSM(new SourceManagerForFile(FileName, Code)), 
SM(VirtualSM->get()),
   ID(VirtualSM->get().getMainFileID()), FirstStartColumn(FirstStartColumn),
-  NextStartColumn(NextStartColumn), LastStartColumn(LastStartColumn) {
-}
+  NextStartColumn(NextStartColumn), LastStartColumn(LastStartColumn) {}
 
 TokenAnalyzer::TokenAnalyzer(const Environment &Env, const FormatStyle &Style)
 : Style(Style), Env(Env),

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cp

[PATCH] D114430: [clang-format] NFC - recent changes caused clang-format to no longer be clang-formatted.

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG93fc91610f42: [clang-format] NFC - recent changes caused 
clang-format to no longer be clang… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114430

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/lib/Format/TokenAnalyzer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/WhitespaceManager.cpp

Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -913,7 +913,8 @@
   Changes[i].StartOfBlockComment->StartOfTokenColumn -
   Changes[i].StartOfTokenColumn;
 }
-if (Shift < 0) continue;
+if (Shift < 0)
+  continue;
 Changes[i].Spaces += Shift;
 if (i + 1 != Changes.size())
   Changes[i + 1].PreviousEndOfTokenColumn += Shift;
@@ -1269,7 +1270,7 @@
   for (unsigned i = 0, e = Changes.size(); i != e; ++i) {
 const Change &C = Changes[i];
 if (i > 0 && Changes[i - 1].OriginalWhitespaceRange.getBegin() ==
- C.OriginalWhitespaceRange.getBegin()) {
+ C.OriginalWhitespaceRange.getBegin()) {
   // Do not generate two replacements for the same location.
   continue;
 }
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2342,16 +2342,15 @@
 if (NextNonCommentLine && CommentLine &&
 NextNonCommentLine->First->NewlinesBefore <= 1 &&
 NextNonCommentLine->First->OriginalColumn ==
-AL->First->OriginalColumn) {
+AL->First->OriginalColumn) {
   // Align comments for preprocessor lines with the # in column 0 if
   // preprocessor lines are not indented. Otherwise, align with the next
   // line.
-  AL->Level =
-  (Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
-   (NextNonCommentLine->Type == LT_PreprocessorDirective ||
-NextNonCommentLine->Type == LT_ImportStatement))
-  ? 0
-  : NextNonCommentLine->Level;
+  AL->Level = (Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
+   (NextNonCommentLine->Type == LT_PreprocessorDirective ||
+NextNonCommentLine->Type == LT_ImportStatement))
+  ? 0
+  : NextNonCommentLine->Level;
 } else {
   NextNonCommentLine = AL->First->isNot(tok::r_brace) ? AL : nullptr;
 }
Index: clang/lib/Format/TokenAnalyzer.cpp
===
--- clang/lib/Format/TokenAnalyzer.cpp
+++ clang/lib/Format/TokenAnalyzer.cpp
@@ -37,7 +37,7 @@
 
 // FIXME: Instead of printing the diagnostic we should store it and have a
 // better way to return errors through the format APIs.
-class FatalDiagnosticConsumer: public DiagnosticConsumer {
+class FatalDiagnosticConsumer : public DiagnosticConsumer {
 public:
   void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const Diagnostic &Info) override {
@@ -71,7 +71,8 @@
   }
   // Validate that we can get the buffer data without a fatal error.
   Env->SM.getBufferData(Env->ID);
-  if (Diags.fatalError()) return nullptr;
+  if (Diags.fatalError())
+return nullptr;
   return Env;
 }
 
@@ -80,8 +81,7 @@
  unsigned LastStartColumn)
 : VirtualSM(new SourceManagerForFile(FileName, Code)), SM(VirtualSM->get()),
   ID(VirtualSM->get().getMainFileID()), FirstStartColumn(FirstStartColumn),
-  NextStartColumn(NextStartColumn), LastStartColumn(LastStartColumn) {
-}
+  NextStartColumn(NextStartColumn), LastStartColumn(LastStartColumn) {}
 
 TokenAnalyzer::TokenAnalyzer(const Environment &Env, const FormatStyle &Style)
 : Style(Style), Env(Env),
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -553,9 +553,7 @@
   auto Env = Environment::make(Code, FileName, Ranges);
   if (!Env)
 return {};
-  return JavaScriptImportSorter(*Env, Style)
-  .process()
-  .first;
+  return JavaScriptImportSorter(*Env, Style).process().first;
 }
 
 } // end namespace format
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2988,9 +2988,8 @@
   // JSON only needs the formatting passing.
   if (Style.isJson()) {
 std::vector Ranges(1, tooling::Range(0, Code.size()));
-auto Env =
-Environment::make(Code, FileName

[PATCH] D114519: [clang-format] [PR52595]

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: HazardyKnusperkeks, curdeius, owenpan.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.

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

missing space between `T (&&)` but not between `T(&` due to && being 
incorrectly thought of as `UnaryOperator`  rather than `PointerOrReference`

  int operator()(T (&)[N]) { return 0; }
  int operator()(T(&&)[N]) { return 1; }

Existing Unit tests are changed because actually I think they are originally 
incorrect, and are inconsistent with the (&) cases that are 4 or 5 lines above 
them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114519

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9659,6 +9659,11 @@
   verifyFormat("void f() { a->operator()(*a * *a); }");
 }
 
+TEST_F(FormatTest, AmpAmpOperator) {
+  verifyFormat("int operator()(T (&&)[N]) { return 1; }");
+  verifyFormat("int operator()(T (&)[N]) { return 0; }");
+}
+
 TEST_F(FormatTest, UnderstandsAttributes) {
   verifyFormat("SomeType s __attribute__((unused)) (InitValue);");
   verifyFormat("a __attribute__((unused))\n"
@@ -21871,7 +21876,7 @@
   verifyFormat("Foo::operator()(void &&);", Style);
   verifyFormat("Foo::operator&&(void &&);", Style);
   verifyFormat("Foo::operator&&();", Style);
-  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator&&(int (&&)(), class Foo);", Style);
   verifyFormat("operator const nsTArrayRight &()", Style);
   verifyFormat("[[nodiscard]] operator const nsTArrayRight &()",
Style);
@@ -21932,7 +21937,7 @@
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
-  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator&&(int (&&)(), class Foo);", Style);
   verifyFormat("operator const nsTArrayLeft&()", Style);
   verifyFormat("[[nodiscard]] operator const nsTArrayLeft&()",
Style);
@@ -21973,7 +21978,7 @@
   verifyFormat("Foo::operator()(void &&);", Style);
   verifyFormat("Foo::operator&&(void &&);", Style);
   verifyFormat("Foo::operator&&();", Style);
-  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator&&(int (&&)(), class Foo);", Style);
 }
 
 TEST_F(FormatTest, OperatorPassedAsAFunctionPtr) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -317,7 +317,7 @@
 // void (^ObjCBlock)(void);
 bool MightBeFunctionType = !Contexts[Contexts.size() - 2].IsExpression;
 bool ProbablyFunctionType =
-CurrentToken->isOneOf(tok::star, tok::amp, tok::caret);
+CurrentToken->isOneOf(tok::star, tok::amp, tok::ampamp, tok::caret);
 bool HasMultipleLines = false;
 bool HasMultipleParametersOnALine = false;
 bool MightBeObjCForRangeLoop =


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9659,6 +9659,11 @@
   verifyFormat("void f() { a->operator()(*a * *a); }");
 }
 
+TEST_F(FormatTest, AmpAmpOperator) {
+  verifyFormat("int operator()(T (&&)[N]) { return 1; }");
+  verifyFormat("int operator()(T (&)[N]) { return 0; }");
+}
+
 TEST_F(FormatTest, UnderstandsAttributes) {
   verifyFormat("SomeType s __attribute__((unused)) (InitValue);");
   verifyFormat("a __attribute__((unused))\n"
@@ -21871,7 +21876,7 @@
   verifyFormat("Foo::operator()(void &&);", Style);
   verifyFormat("Foo::operator&&(void &&);", Style);
   verifyFormat("Foo::operator&&();", Style);
-  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator&&(int (&&)(), class Foo);", Style);
   verifyFormat("operator const nsTArrayRight &()", Style);
   verifyFormat("[[nodiscard]] operator const nsTArrayRight &()",
Style);
@@ -21932,7 +21937,7 @@
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
-  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator&&(int (&&)(), class Foo);", Style);
   verifyFormat("operator const nsTArrayLeft&()", Style);
   verifyFormat("[[nodiscard]] operator const nsTArrayLeft&()",
Style);
@@ -21973,7 +21978,7 @@
   verifyFormat("Foo::operator()(void &&);", Style);
   verifyFormat("Foo::operator&&(void &&);", Style);
   verifyFormat("Foo::opera

[PATCH] D114519: [clang-format] [PR52595] clang-format does not recognize rvalue references to array

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:21879
   verifyFormat("Foo::operator&&();", Style);
-  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator&&(int (&&)(), class Foo);", Style);
   verifyFormat("operator const nsTArrayRight &()", Style);

this test should be consistent with 

```
verifyFormat("operator&(int (&)(), class Foo);", Style);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114519

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


[PATCH] D114454: [NFC][AIX]Disable unstable CSA tests failing on AIX

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

Thanks for fixing this @stevewan!

I think disabling a test is worse than actually fixing it, although I can see 
the frustration it causes.
Yet, I would propose something else.

This is just a static analyzer checker doing its own thing. What if we were 
pinning the target triple before conducting the analysis run? The platform on 
which the test runs shouldn't matter.
Or even better, setting a bunch of target triples and letting //gtest// to run 
each one to see if it still passes on **all** triples.

I haven't checked, but I think 
`clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp` does something similar by 
using the `INSTANTIATE_TEST_SUITE_P` macro.

---

If you insist, I think a conditional `GTEST_SKIP() << "my message";` should be 
prefered to simply disable a test. By doing this, you can specify the reason 
why was the test disabled.
That being said, the macro stuff would get much cleaner this way.
But I still prefer pinning the triple. See my previous comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114454

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


[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-24 Thread Mojca Miklavec via Phabricator via cfe-commits
mojca added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

tra wrote:
> mojca wrote:
> > kadircet wrote:
> > > looks like the list is getting big and hard to maintain. considering that 
> > > this is done only once per compiler invocation (and we check for 
> > > existence of directories down in the loop anyway). what about throwing in 
> > > an extra directory listing to base-directories mentioned down below and 
> > > populate `Candidates` while preserving the newest-version-first order?
> > I totally agree with the sentiment, and that was my initial thought as 
> > well, but with zero experience I was too scared to make any more 
> > significant changes.
> > 
> > I can try to come up with a new patch (that doesn't need further 
> > maintenance whenever a new CUDA version gets released) if that's what you 
> > are suggesting. I would nevertheless merge this one, and prepare a new more 
> > advanced patch separately, but that's finally your call.
> > 
> > What's your suggestion about D.SysRoot + "Program Files/..."? At the time 
> > when this function gets called it looks like D.SysRoot is empty (or at 
> > least my debugger says so) and in my case it resolves to D: while the CUDA 
> > support is installed under C:.
> > 
> > Is there any special LLVM-specific/preferrable way to iterate through 
> > directories?
> > 
> > (What I also miss a bit in the whole process in an option to simply say "I 
> > want CUDA 11.1" without the need to explicitly spell out the full path.)
> > 
> > If you provide me give some general guidelines, I'll prepare another, 
> > hopefully more future-proof patch.
> > 
> > (Side note: I'm not sure if I'm calling clang-format correctly, but if I 
> > call it, it keeps reformatting the rest of this file.)
> This whole list may no longer be particularly useful. The most common use 
> case on Linux, AFAICT, is to install only one CUDA version using 
> system-provided package manager.
> E.g. https://packages.ubuntu.com/focal/amd64/nvidia-cuda-toolkit/filelist
> 
> TBH, I'm tempted to limit autodetection to only that one system-default 
> version and require user to use --cuda-path if they need something else.
On Windows this is certainly not the case. Unless the installation is changed 
manually, one always gets the new version installed into a new directory.

I really do need multiple versions on Windows (and the ability to pick an older 
one) if I want to compile a binary that works on someone else's computer (if I 
compile against the latest CUDA, users need "the latest" drivers that may 
sometimes not even be available for their machine).

(That said, at least when using CMake, the selection needs to be done by CMake 
anyway, and maybe CMake could be forced to specify the correct flag 
automatically.)

So even if the functionality gets removed from non-Windows platforms, it would 
be really nice to keep it for Windows.

Now, there are three "conflicting" feedbacks/suggestions above. I can try to 
improve support, but it would be really helpful to reach the consensus of what 
needs to be done before coding it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114326

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


[PATCH] D114454: [NFC][AIX]Disable unstable CSA tests failing on AIX

2021-11-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added reviewers: jlebar, chandlerc.
steakhal added subscribers: jlebar, chandlerc.
steakhal added a comment.

I think D21810  (commit 
)
 was related to a triple issue in the past.
Let me summon them. @chandlerc @jlebar


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114454

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


[PATCH] D114519: [clang-format] [PR52595] clang-format does not recognize rvalue references to array

2021-11-24 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:9662
 
+TEST_F(FormatTest, AmpAmpOperator) {
+  verifyFormat("int operator()(T (&&)[N]) { return 1; }");

Nit: these are not &/&& operators but references so the test name seems 
incorrect.



Comment at: clang/unittests/Format/FormatTest.cpp:21879
   verifyFormat("Foo::operator&&();", Style);
-  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator&&(int (&&)(), class Foo);", Style);
   verifyFormat("operator const nsTArrayRight &()", Style);

MyDeveloperDay wrote:
> this test should be consistent with 
> 
> ```
> verifyFormat("operator&(int (&)(), class Foo);", Style);
> ```
Should we test
```
verifyFormat("operator&&(int (&)(), class Foo);", Style);
```
here, and
```
verifyFormat("operator&(int (&&)(), class Foo);", Style);
```
above as well?



Comment at: clang/unittests/Format/FormatTest.cpp:21940
   verifyFormat("Foo::operator&&();", Style);
-  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator&&(int (&&)(), class Foo);", Style);
   verifyFormat("operator const nsTArrayLeft&()", Style);

Ditto for combinations of &+(&&) and &&+(&).



Comment at: clang/unittests/Format/FormatTest.cpp:21981
   verifyFormat("Foo::operator&&();", Style);
-  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator&&(int (&&)(), class Foo);", Style);
 }

Ditto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114519

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


[PATCH] D114394: Compile-time computation of string attribute hashes

2021-11-24 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 389437.
serge-sans-paille marked 6 inline comments as done.
serge-sans-paille added a comment.

Use CachedHashStringRef as suggested by @MaskRay


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

https://reviews.llvm.org/D114394

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  llvm/include/llvm/Analysis/TargetLibraryInfo.h
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/IR/Assumptions.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Function.h
  llvm/include/llvm/IR/GlobalVariable.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/lib/Analysis/InlineCost.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/AttributeImpl.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp

Index: llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
===
--- llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
@@ -67,11 +67,13 @@
 }
 
 static bool runOnFunction(Function &F, bool PostInlining) {
-  StringRef EntryAttr = PostInlining ? "instrument-function-entry-inlined"
- : "instrument-function-entry";
+  AttributeKey EntryAttr =
+  PostInlining ? AttributeKey("instrument-function-entry-inlined")
+   : AttributeKey("instrument-function-entry");
 
-  StringRef ExitAttr = PostInlining ? "instrument-function-exit-inlined"
-: "instrument-function-exit";
+  AttributeKey ExitAttr = PostInlining
+  ? AttributeKey("instrument-function-exit-inlined")
+  : AttributeKey("instrument-function-exit");
 
   StringRef EntryFunc = F.getFnAttribute(EntryAttr).getValueAsString();
   StringRef ExitFunc = F.getFnAttribute(ExitAttr).getValueAsString();
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -888,7 +888,7 @@
   //   attribute can not be inherited.
   for (const auto &Attr : oldFunction->getAttributes().getFnAttrs()) {
 if (Attr.isStringAttribute()) {
-  if (Attr.getKindAsString() == "thunk")
+  if (Attr.getKindAsKey() == "thunk")
 continue;
 } else
   switch (Attr.getKindAsEnum()) {
Index: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
===
--- llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1528,7 +1528,7 @@
 } // end anonymous namespace
 
 static StringRef getDeoptLowering(CallBase *Call) {
-  const char *DeoptLowering = "deopt-lowering";
+  const char DeoptLowering[] = "deopt-lowering";
   if (Call->hasFnAttr(DeoptLowering)) {
 // FIXME: Calls have a *really* confusing interface around attributes
 // with values.
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -4194,14 +4194,9 @@
 MemorySanitizerVisitor &MSV)
   : F(F), MS(MS), MSV(MSV) {
 AMD64FpEndOffset = AMD64FpEndOffsetSSE;
-for (const auto &Attr : F.getAttributes().getFnAttrs()) {
-  if (Attr.isStringAttribute() &&
-  (Attr.getKindAsString() == "target-features")) {
-if (Attr.getValueAsString().contains("-sse"))
-  AMD64FpEndOffset = AMD64FpEndOffsetNoSSE;
-break;
-  }
-}
+if (F.hasFnAttribute("target-features") &&
+F.getFnAttribute("target-features").getValueAsString().contains("-sse"))
+  AMD64FpEndOffset = AMD64FpEndOffsetNoSSE;
   }
 
   ArgKind classifyArgument(Value* arg) {
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -4319,7 +4319,7 @@
 : ChangeStatus::CHANGED;
   }
 

[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

mojca wrote:
> tra wrote:
> > mojca wrote:
> > > kadircet wrote:
> > > > looks like the list is getting big and hard to maintain. considering 
> > > > that this is done only once per compiler invocation (and we check for 
> > > > existence of directories down in the loop anyway). what about throwing 
> > > > in an extra directory listing to base-directories mentioned down below 
> > > > and populate `Candidates` while preserving the newest-version-first 
> > > > order?
> > > I totally agree with the sentiment, and that was my initial thought as 
> > > well, but with zero experience I was too scared to make any more 
> > > significant changes.
> > > 
> > > I can try to come up with a new patch (that doesn't need further 
> > > maintenance whenever a new CUDA version gets released) if that's what you 
> > > are suggesting. I would nevertheless merge this one, and prepare a new 
> > > more advanced patch separately, but that's finally your call.
> > > 
> > > What's your suggestion about D.SysRoot + "Program Files/..."? At the time 
> > > when this function gets called it looks like D.SysRoot is empty (or at 
> > > least my debugger says so) and in my case it resolves to D: while the 
> > > CUDA support is installed under C:.
> > > 
> > > Is there any special LLVM-specific/preferrable way to iterate through 
> > > directories?
> > > 
> > > (What I also miss a bit in the whole process in an option to simply say 
> > > "I want CUDA 11.1" without the need to explicitly spell out the full 
> > > path.)
> > > 
> > > If you provide me give some general guidelines, I'll prepare another, 
> > > hopefully more future-proof patch.
> > > 
> > > (Side note: I'm not sure if I'm calling clang-format correctly, but if I 
> > > call it, it keeps reformatting the rest of this file.)
> > This whole list may no longer be particularly useful. The most common use 
> > case on Linux, AFAICT, is to install only one CUDA version using 
> > system-provided package manager.
> > E.g. https://packages.ubuntu.com/focal/amd64/nvidia-cuda-toolkit/filelist
> > 
> > TBH, I'm tempted to limit autodetection to only that one system-default 
> > version and require user to use --cuda-path if they need something else.
> On Windows this is certainly not the case. Unless the installation is changed 
> manually, one always gets the new version installed into a new directory.
> 
> I really do need multiple versions on Windows (and the ability to pick an 
> older one) if I want to compile a binary that works on someone else's 
> computer (if I compile against the latest CUDA, users need "the latest" 
> drivers that may sometimes not even be available for their machine).
> 
> (That said, at least when using CMake, the selection needs to be done by 
> CMake anyway, and maybe CMake could be forced to specify the correct flag 
> automatically.)
> 
> So even if the functionality gets removed from non-Windows platforms, it 
> would be really nice to keep it for Windows.
> 
> Now, there are three "conflicting" feedbacks/suggestions above. I can try to 
> improve support, but it would be really helpful to reach the consensus of 
> what needs to be done before coding it.
> one always gets the new version installed into a new directory.
A similar thing happens on Linux.

> users need "the latest" drivers
Since CUDA 10.2, there's some "[[ 
https://docs.nvidia.com/deploy/cuda-compatibility/ | compatibility mode ]]" 
that allows to run newer CUDA on older drivers. As long as you are not using 
the latest features, of course.

I'm personally all up for removing redundancy and duplication. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114326

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


[PATCH] D114519: [clang-format] [PR52595] clang-format does not recognize rvalue references to array

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:9662
 
+TEST_F(FormatTest, AmpAmpOperator) {
+  verifyFormat("int operator()(T (&&)[N]) { return 1; }");

curdeius wrote:
> Nit: these are not &/&& operators but references so the test name seems 
> incorrect.
oh yes sorry that was my bad so I could just run this one test through the 
debugger, I just needed a unique name, I should change that.



Comment at: clang/unittests/Format/FormatTest.cpp:21879
   verifyFormat("Foo::operator&&();", Style);
-  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator&&(int (&&)(), class Foo);", Style);
   verifyFormat("operator const nsTArrayRight &()", Style);

curdeius wrote:
> MyDeveloperDay wrote:
> > this test should be consistent with 
> > 
> > ```
> > verifyFormat("operator&(int (&)(), class Foo);", Style);
> > ```
> Should we test
> ```
> verifyFormat("operator&&(int (&)(), class Foo);", Style);
> ```
> here, and
> ```
> verifyFormat("operator&(int (&&)(), class Foo);", Style);
> ```
> above as well?
yes I'll add those, nice suggestion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114519

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: HazardyKnusperkeks, owenpan, curdeius, jaafar, 
KyrBoh.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.

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

Using the MultiLine setting for BraceWrapping.AfterControlStatement appears to 
disable AllowShortFunctionsOnASingleLine, even in cases without any control 
statements


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114521

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2860,6 +2860,19 @@
 "  baz();\n"
 "}",
 format("try{foo();}catch(...){baz();}", Style));
+
+  Style.BraceWrapping.AfterFunction = true;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  Style.ColumnLimit = 80;
+  verifyFormat("void shortfunction() { bar(); }", Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+  verifyFormat("void shortfunction()\n"
+   "{\n"
+   "  bar();\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, BeforeWhile) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -676,7 +676,7 @@
 // { <-- current Line
 //   baz();
 // }
-if (Line.First == Line.Last &&
+if (Line.First == Line.Last && Line.First->isNot(TT_FunctionLBrace) &&
 Style.BraceWrapping.AfterControlStatement ==
 FormatStyle::BWACS_MultiLine)
   return 0;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2860,6 +2860,19 @@
 "  baz();\n"
 "}",
 format("try{foo();}catch(...){baz();}", Style));
+
+  Style.BraceWrapping.AfterFunction = true;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  Style.ColumnLimit = 80;
+  verifyFormat("void shortfunction() { bar(); }", Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+  verifyFormat("void shortfunction()\n"
+   "{\n"
+   "  bar();\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, BeforeWhile) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -676,7 +676,7 @@
 // { <-- current Line
 //   baz();
 // }
-if (Line.First == Line.Last &&
+if (Line.First == Line.Last && Line.First->isNot(TT_FunctionLBrace) &&
 Style.BraceWrapping.AfterControlStatement ==
 FormatStyle::BWACS_MultiLine)
   return 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114522: [clangd] Add canonical type to hover

2021-11-24 Thread liu hui via Phabricator via cfe-commits
lh123 created this revision.
lh123 added reviewers: kadircet, sammccall.
lh123 added a project: clang-tools-extra.
Herald added subscribers: usaxena95, arphaman.
lh123 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.

Add canonical type to hover when the canonical type and the pretty-printed type 
are not the same.

  c++
  template
  struct TestHover {
using Type = T;
  };
  
  int main() {
TestHover::Type a;
  }

---

**variable a**

Type: TestHover::Type (aka 'int')


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114522

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -46,7 +46,9 @@
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
+ HI.CanonicalReturnType = "void";
  HI.Type = "void ()";
+ HI.CanonicalType = "void ()";
  HI.Parameters.emplace();
}},
   // Inside namespace
@@ -63,7 +65,9 @@
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
+ HI.CanonicalReturnType = "void";
  HI.Type = "void ()";
+ HI.CanonicalType = "void ()";
  HI.Parameters.emplace();
}},
   // Field
@@ -82,6 +86,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "char bar";
  HI.Type = "char";
+ HI.CanonicalType = "char";
  HI.Offset = 0;
  HI.Size = 1;
  HI.Padding = 7;
@@ -101,6 +106,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "char bar";
  HI.Type = "char";
+ HI.CanonicalType = "char";
  HI.Size = 1;
  HI.Padding = 15;
  HI.AccessSpecifier = "public";
@@ -119,6 +125,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "int x : 1";
  HI.Type = "int";
+ HI.CanonicalType = "int";
  HI.AccessSpecifier = "public";
}},
   // Local to class method.
@@ -138,6 +145,7 @@
  HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "int bar";
  HI.Type = "int";
+ HI.CanonicalType = "int";
}},
   // Anon namespace and local scope.
   {R"cpp(
@@ -154,6 +162,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "char bar";
  HI.Type = "char";
+ HI.CanonicalType = "char";
  HI.Offset = 0;
  HI.Size = 1;
  HI.AccessSpecifier = "public";
@@ -180,6 +189,7 @@
  HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "Foo foo = Foo(5)";
  HI.Type = "Foo";
+ HI.CanonicalType = "Foo";
}},
   // Implicit template instantiation
   {R"cpp(
@@ -212,11 +222,16 @@
 class Foo {})cpp";
  HI.TemplateParameters = {
  {std::string("template  class"),
+  std::string("template  class"),
   std::string("C"), llvm::None},
- {std::string("typename"), llvm::None, std::string("char")},
- {std::string("int"), llvm::None, std::string("0")},
- {std::string("bool"), std::string("Q"), std::string("false")},
- {std::string("class..."), std::string("Ts"), llvm::None},
+ {std::string("typename"), std::string("typename"), llvm::None,
+  std::string("char")},
+ {std::string("int"), std::string("int"), llvm::None,
+  std::string("0")},
+ {std::string("bool"), std::string("bool"), std::string("Q"),
+  std::string("false")},
+ {std::string("class..."), std::string("class..."),
+  std::string("Ts"), llvm::None},
  };
}},
   // Function template
@@ -238,7 +253,9 @@
  HI.Kind = index::SymbolKind::Function;
  HI.Definition = "template <> void foo>()";
  HI.ReturnType = "void";
+ HI.CanonicalReturnType = "void";
  HI.Type = "void ()";
+ HI.CanonicalType = "void ()";
  HI.Parameters.emplace();
}},
   // Function decl
@@ -256,10 +273,13 @@
  HI.Kind = index::SymbolKind::Function;
  HI.Definition = "Foo foo(int, bool T = false)";
  HI.ReturnType = "Foo";
+ HI.CanonicalReturnType = "Foo";
  HI.Type = "Foo (int, bool)";
+ HI.CanonicalType = "Foo (int, bool)";
  HI.Parameters = {
- {std::string("int"), llvm::None, llvm::None},
- {std::string("bool"), std::string("T"), std::string("false")},
+ {std::string("int"), std::string("int"), llvm::None, llvm::None},
+ 

[PATCH] D114430: [clang-format] NFC - recent changes caused clang-format to no longer be clang-formatted.

2021-11-24 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Thanks for cleaning up after me, and sorry for the mess - do y'all have 
clang-format set up as a presubmit or do you just remember to format manually?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114430

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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@tnorth Are you planning on working on this or do you mind if one of us fixes 
the issues enough to get it over the line. (this was previously accepted and 
landed but the unit tests fail, for what looks like a fairly minor issue)


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326

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


[PATCH] D114522: [clangd] Add canonical type to hover

2021-11-24 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 389452.
lh123 added a comment.

add testcase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114522

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -46,7 +46,9 @@
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
+ HI.CanonicalReturnType = "void";
  HI.Type = "void ()";
+ HI.CanonicalType = "void ()";
  HI.Parameters.emplace();
}},
   // Inside namespace
@@ -63,7 +65,9 @@
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
+ HI.CanonicalReturnType = "void";
  HI.Type = "void ()";
+ HI.CanonicalType = "void ()";
  HI.Parameters.emplace();
}},
   // Field
@@ -82,6 +86,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "char bar";
  HI.Type = "char";
+ HI.CanonicalType = "char";
  HI.Offset = 0;
  HI.Size = 1;
  HI.Padding = 7;
@@ -101,6 +106,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "char bar";
  HI.Type = "char";
+ HI.CanonicalType = "char";
  HI.Size = 1;
  HI.Padding = 15;
  HI.AccessSpecifier = "public";
@@ -119,6 +125,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "int x : 1";
  HI.Type = "int";
+ HI.CanonicalType = "int";
  HI.AccessSpecifier = "public";
}},
   // Local to class method.
@@ -138,6 +145,7 @@
  HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "int bar";
  HI.Type = "int";
+ HI.CanonicalType = "int";
}},
   // Anon namespace and local scope.
   {R"cpp(
@@ -154,6 +162,7 @@
  HI.Kind = index::SymbolKind::Field;
  HI.Definition = "char bar";
  HI.Type = "char";
+ HI.CanonicalType = "char";
  HI.Offset = 0;
  HI.Size = 1;
  HI.AccessSpecifier = "public";
@@ -180,6 +189,7 @@
  HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "Foo foo = Foo(5)";
  HI.Type = "Foo";
+ HI.CanonicalType = "Foo";
}},
   // Implicit template instantiation
   {R"cpp(
@@ -212,11 +222,16 @@
 class Foo {})cpp";
  HI.TemplateParameters = {
  {std::string("template  class"),
+  std::string("template  class"),
   std::string("C"), llvm::None},
- {std::string("typename"), llvm::None, std::string("char")},
- {std::string("int"), llvm::None, std::string("0")},
- {std::string("bool"), std::string("Q"), std::string("false")},
- {std::string("class..."), std::string("Ts"), llvm::None},
+ {std::string("typename"), std::string("typename"), llvm::None,
+  std::string("char")},
+ {std::string("int"), std::string("int"), llvm::None,
+  std::string("0")},
+ {std::string("bool"), std::string("bool"), std::string("Q"),
+  std::string("false")},
+ {std::string("class..."), std::string("class..."),
+  std::string("Ts"), llvm::None},
  };
}},
   // Function template
@@ -238,7 +253,9 @@
  HI.Kind = index::SymbolKind::Function;
  HI.Definition = "template <> void foo>()";
  HI.ReturnType = "void";
+ HI.CanonicalReturnType = "void";
  HI.Type = "void ()";
+ HI.CanonicalType = "void ()";
  HI.Parameters.emplace();
}},
   // Function decl
@@ -256,10 +273,13 @@
  HI.Kind = index::SymbolKind::Function;
  HI.Definition = "Foo foo(int, bool T = false)";
  HI.ReturnType = "Foo";
+ HI.CanonicalReturnType = "Foo";
  HI.Type = "Foo (int, bool)";
+ HI.CanonicalType = "Foo (int, bool)";
  HI.Parameters = {
- {std::string("int"), llvm::None, llvm::None},
- {std::string("bool"), std::string("T"), std::string("false")},
+ {std::string("int"), std::string("int"), llvm::None, llvm::None},
+ {std::string("bool"), std::string("bool"), std::string("T"),
+  std::string("false")},
  };
}},
   // Pointers to lambdas
@@ -277,10 +297,14 @@
  HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "auto *c = &b";
  HI.Type = "(lambda) **";
+ HI.CanonicalType = "(lambda) **";
  HI.ReturnType = "bool";

[PATCH] D114430: [clang-format] NFC - recent changes caused clang-format to no longer be clang-formatted.

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D114430#3151082 , @klimek wrote:

> Thanks for cleaning up after me, and sorry for the mess - do y'all have 
> clang-format set up as a presubmit or do you just remember to format manually?

Its never a problem to clean up after you of all people, happy to do so.

I personally "Format on Save", but my "phabricator patch creation" does a "git 
clang-format" too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114430

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


[PATCH] D114370: [clangd] IncludeCleaner: Attribute symbols from non self-contained headers to their parents

2021-11-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 389454.
kbobyrev marked 6 inline comments as done.
kbobyrev added a comment.
Herald added a project: clang.

Resolve review comments. This turned into a rather large refactoring change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114370

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp

Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -412,9 +412,9 @@
   std::unique_ptr Act;
   Act.reset(new PrecompilePreambleAction(
   StoreInMemory ? &Storage.asMemory().Data : nullptr, Callbacks));
-  Callbacks.BeforeExecute(*Clang);
   if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
 return BuildPreambleError::BeginSourceFileFailed;
+  Callbacks.BeforeExecute(*Clang);
 
   std::unique_ptr DelegatedPPCallbacks =
   Callbacks.createPPCallbacks();
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -83,7 +83,8 @@
   }
   IncludeStructure Includes;
   Clang->getPreprocessor().addPPCallbacks(
-  Includes.collect(Clang->getSourceManager()));
+  Includes.collect(Clang->getSourceManager(),
+   Clang->getPreprocessor().getHeaderSearchInfo()));
   if (llvm::Error Err = Action.Execute()) {
 ADD_FAILURE() << "failed to execute action: " << std::move(Err);
 return {};
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -281,7 +281,9 @@
   auto &SM = AST.getSourceManager();
   auto &Includes = AST.getIncludeStructure();
 
-  auto ReferencedFiles = findReferencedFiles(findReferencedLocations(AST), SM);
+  auto ReferencedFiles =
+  findReferencedFiles(findReferencedLocations(AST),
+  AST.getIncludeStructure(), AST.getSourceManager());
   llvm::StringSet<> ReferencedFileNames;
   for (FileID FID : ReferencedFiles)
 ReferencedFileNames.insert(
@@ -303,6 +305,52 @@
   EXPECT_THAT(getUnused(AST, ReferencedHeaders), ::testing::IsEmpty());
 }
 
+TEST(IncludeCleaner, NonSelfContainedHeaders) {
+  TestTU TU;
+  TU.Code = R"cpp(
+#include "bar.h"
+#include "foo.h"
+
+int LocalFoo = foo::Variable,
+LocalBar = bar::Variable;
+)cpp";
+  TU.AdditionalFiles["bar.h"] = R"cpp(
+#pragma once
+namespace bar {
+#include "indirection.h"
+}
+)cpp";
+  TU.AdditionalFiles["foo.h"] = R"cpp(
+#ifndef FOO_H
+#define FOO_H
+namespace foo {
+#include "unguarded.h"
+}
+#endif // FOO_H
+)cpp";
+  TU.AdditionalFiles["indirection.h"] = R"cpp(
+#include "unguarded.h"
+)cpp";
+  TU.AdditionalFiles["unguarded.h"] = R"cpp(
+constexpr int Variable = 42;
+)cpp";
+
+  ParsedAST AST = TU.build();
+
+  auto ReferencedFiles =
+  findReferencedFiles(findReferencedLocations(AST),
+  AST.getIncludeStructure(), AST.getSourceManager());
+  llvm::StringSet<> ReferencedFileNames;
+  auto &SM = AST.getSourceManager();
+  for (FileID FID : ReferencedFiles)
+ReferencedFileNames.insert(
+SM.getPresumedLoc(SM.getLocForStartOfFile(FID)).getFilename());
+  // Note that we have uplifted the referenced files from non self-contained
+  // headers to header-guarded ones.
+  EXPECT_THAT(ReferencedFileNames.keys(),
+  UnorderedElementsAre(testPath("bar.h"), testPath("foo.h")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -81,7 +81,8 @@
 Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
 IncludeStructure Includes;
 Clang->getPreprocessor().addPPCallbacks(
-Includes.collect(Clang-

[clang] 1b5a43a - Clean up clang-format tech debt.

2021-11-24 Thread Manuel Klimek via cfe-commits

Author: Manuel Klimek
Date: 2021-11-24T12:58:35+01:00
New Revision: 1b5a43ac3f1113cd0512752e021fc70740726698

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

LOG: Clean up clang-format tech debt.

Make all code go through FormatTokenSource instead of going around it, which
makes changes to TokenSource brittle.

Add LLVM_DEBUG in FormatTokenSource to be able to follow the token stream.

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index c12c7c6ecfa69..12f912305f590 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -28,9 +28,28 @@ namespace format {
 class FormatTokenSource {
 public:
   virtual ~FormatTokenSource() {}
+
+  // Returns the next token in the token stream.
   virtual FormatToken *getNextToken() = 0;
 
+  // Returns the token precedint the token returned by the last call to
+  // getNextToken() in the token stream, or nullptr if no such token exists.
+  virtual FormatToken *getPreviousToken() = 0;
+
+  // Returns the token that would be returned by the next call to
+  // getNextToken().
+  virtual FormatToken *peekNextToken() = 0;
+
+  // Returns whether we are at the end of the file.
+  // This can be 
diff erent from whether getNextToken() returned an eof token
+  // when the FormatTokenSource is a view on a part of the token stream.
+  virtual bool isEOF() = 0;
+
+  // Gets the current position in the token stream, to be used by 
setPosition().
   virtual unsigned getPosition() = 0;
+
+  // Resets the token stream to the state it was in when getPosition() returned
+  // Position, and return the token at that position in the stream.
   virtual FormatToken *setPosition(unsigned Position) = 0;
 };
 
@@ -108,6 +127,18 @@ class ScopedMacroState : public FormatTokenSource {
 return Token;
   }
 
+  FormatToken *getPreviousToken() override {
+return PreviousTokenSource->getPreviousToken();
+  }
+
+  FormatToken *peekNextToken() override {
+if (eof())
+  return &FakeEOF;
+return PreviousTokenSource->peekNextToken();
+  }
+
+  bool isEOF() override { return PreviousTokenSource->isEOF(); }
+
   unsigned getPosition() override { return PreviousTokenSource->getPosition(); 
}
 
   FormatToken *setPosition(unsigned Position) override {
@@ -199,18 +230,45 @@ class IndexedTokenSource : public FormatTokenSource {
   : Tokens(Tokens), Position(-1) {}
 
   FormatToken *getNextToken() override {
-if (Position >= 0 && Tokens[Position]->is(tok::eof))
+if (Position >= 0 && Tokens[Position]->is(tok::eof)) {
+  LLVM_DEBUG({
+llvm::dbgs() << "Next ";
+dbgToken(Position);
+  });
   return Tokens[Position];
+}
 ++Position;
+LLVM_DEBUG({
+  llvm::dbgs() << "Next ";
+  dbgToken(Position);
+});
 return Tokens[Position];
   }
 
+  FormatToken *getPreviousToken() override {
+assert(Position > 0);
+return Tokens[Position - 1];
+  }
+
+  FormatToken *peekNextToken() override {
+int Next = Position + 1;
+LLVM_DEBUG({
+  llvm::dbgs() << "Peeking ";
+  dbgToken(Next);
+});
+return Tokens[Next];
+  }
+
+  bool isEOF() override { return Tokens[Position]->is(tok::eof); }
+
   unsigned getPosition() override {
+LLVM_DEBUG(llvm::dbgs() << "Getting Position: " << Position << "\n");
 assert(Position >= 0);
 return Position;
   }
 
   FormatToken *setPosition(unsigned P) override {
+LLVM_DEBUG(llvm::dbgs() << "Setting Position: " << P << "\n");
 Position = P;
 return Tokens[Position];
   }
@@ -218,6 +276,13 @@ class IndexedTokenSource : public FormatTokenSource {
   void reset() { Position = -1; }
 
 private:
+  void dbgToken(int Position, llvm::StringRef Indent = "") {
+FormatToken *Tok = Tokens[Position];
+llvm::dbgs() << Indent << "[" << Position
+ << "] Token: " << Tok->Tok.getName() << " / " << 
Tok->TokenText
+ << ", Macro: " << !!Tok->MacroCtx << "\n";
+  }
+
   ArrayRef Tokens;
   int Position;
 };
@@ -877,10 +942,7 @@ void UnwrappedLineParser::parsePPEndIf() {
   parsePPUnknown();
   // If the #endif of a potential include guard is the last thing in the file,
   // then we found an include guard.
-  unsigned TokenPosition = Tokens->getPosition();
-  FormatToken *PeekNext = AllTokens[TokenPosition];
-  if (IncludeGuard == IG_Defined && PPBranchLevel == -1 &&
-  PeekNext->is(tok::eof) &&
+  if (IncludeGuard == IG_Defined && PPBranchLevel == -1 && Tokens->isEOF() &&
   Style.IndentPPDirectives != FormatStyle::PPDIS_None)
 IncludeGuard = IG_Found;
 }
@@ -1403,9 +1465,7 @@ void UnwrappedLineParser::parseStructuralElement(bool 
IsT

[PATCH] D112913: Misleading bidirectional detection

2021-11-24 Thread Xidorn Quan via Phabricator via cfe-commits
upsuper added a comment.

I'm not familiar with LLVM / Clang codebase. I was asked by @MaskRay to help 
review the bidi-related part of this patch.

Generally I believe the algorithm here is too naive that it produces both false 
positives and false negatives. I'm not sure how important those edge cases are 
considered, but anyway... details comments below:




Comment at: clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp:48-49
+  // Line break: https://www.unicode.org/reports/tr14/tr14-32.html
+  if (C == '\n' || C == '\r' || C == '\f' || C == '\v' ||
+  C == 0x85 /*next line*/)
+EmbeddingOverride = Isolate = 0;

UAX 14 is probably not the right document to look here.

According to UAX 9 step [[ https://www.unicode.org/reports/tr9/#L1 | L1 ]], the 
embedding level is reset to the paragraph embedding level when hitting segment 
separator and paragraph separator, which are defined in [[ 
https://www.unicode.org/reports/tr9/#Table_Bidirectional_Character_Types | 
table 4 ]] as type B and S, and in UCD [[ 
https://www.unicode.org/Public/UCD/latest/ucd/extracted/DerivedBidiClass.txt | 
DerivedBidiClass.txt ]] you can see type B includes U+000A, U+000D, 
U+001C..001E, U+0085, U+2029, and type S includes U+0009, U+000B, and U+001F.

You have U+000C and U+2028 here which are counted as type WS which doesn't 
affect embedding level, so you may be resetting the counter prematurely. And 
you may want to reset the counter for all other characters above.



Comment at: clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp:64-72
+if (CodePoint == RLO || CodePoint == RLE || CodePoint == LRO ||
+CodePoint == LRE)
+  EmbeddingOverride += 1;
+else if (CodePoint == PDF)
+  EmbeddingOverride = std::min(EmbeddingOverride - 1, EmbeddingOverride);
+else if (CodePoint == RLI || CodePoint == LRI || CodePoint == FSI)
+  Isolate += 1;

The bidi algorithm is more complicated than having two simple counters. 
Basically, a `PDF` cancels a override / embedding character only when they 
match, and `PDI` cancels all override / embedding between it and its matching 
isolate character.

I was thinking whether the counters would be enough in the sense that we may 
accept some false positive for edge cases but definitely no false negative. But 
I'm convinced it's not the case. As an example, a sequence of `RLO LRI PDF PDI` 
will yield no embedding and no isolate in this counting model, but the `PDF` 
here actually has no effect, as shown in step [[ 
https://www.unicode.org/reports/tr9/#X7 | X7 ]], if it does not match an 
embedding initiator, it is ignored, so this is effectively leaving a dangling 
`RLO`.


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

https://reviews.llvm.org/D112913

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


[PATCH] D114370: [clangd] IncludeCleaner: Attribute symbols from non self-contained headers to their parents

2021-11-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 389457.
kbobyrev added a comment.

Untangle BeforeExecute call ordering change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114370

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp

Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -83,7 +83,8 @@
   }
   IncludeStructure Includes;
   Clang->getPreprocessor().addPPCallbacks(
-  Includes.collect(Clang->getSourceManager()));
+  Includes.collect(Clang->getSourceManager(),
+   Clang->getPreprocessor().getHeaderSearchInfo()));
   if (llvm::Error Err = Action.Execute()) {
 ADD_FAILURE() << "failed to execute action: " << std::move(Err);
 return {};
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -281,7 +281,9 @@
   auto &SM = AST.getSourceManager();
   auto &Includes = AST.getIncludeStructure();
 
-  auto ReferencedFiles = findReferencedFiles(findReferencedLocations(AST), SM);
+  auto ReferencedFiles =
+  findReferencedFiles(findReferencedLocations(AST),
+  AST.getIncludeStructure(), AST.getSourceManager());
   llvm::StringSet<> ReferencedFileNames;
   for (FileID FID : ReferencedFiles)
 ReferencedFileNames.insert(
@@ -303,6 +305,52 @@
   EXPECT_THAT(getUnused(AST, ReferencedHeaders), ::testing::IsEmpty());
 }
 
+TEST(IncludeCleaner, NonSelfContainedHeaders) {
+  TestTU TU;
+  TU.Code = R"cpp(
+#include "bar.h"
+#include "foo.h"
+
+int LocalFoo = foo::Variable,
+LocalBar = bar::Variable;
+)cpp";
+  TU.AdditionalFiles["bar.h"] = R"cpp(
+#pragma once
+namespace bar {
+#include "indirection.h"
+}
+)cpp";
+  TU.AdditionalFiles["foo.h"] = R"cpp(
+#ifndef FOO_H
+#define FOO_H
+namespace foo {
+#include "unguarded.h"
+}
+#endif // FOO_H
+)cpp";
+  TU.AdditionalFiles["indirection.h"] = R"cpp(
+#include "unguarded.h"
+)cpp";
+  TU.AdditionalFiles["unguarded.h"] = R"cpp(
+constexpr int Variable = 42;
+)cpp";
+
+  ParsedAST AST = TU.build();
+
+  auto ReferencedFiles =
+  findReferencedFiles(findReferencedLocations(AST),
+  AST.getIncludeStructure(), AST.getSourceManager());
+  llvm::StringSet<> ReferencedFileNames;
+  auto &SM = AST.getSourceManager();
+  for (FileID FID : ReferencedFiles)
+ReferencedFileNames.insert(
+SM.getPresumedLoc(SM.getLocForStartOfFile(FID)).getFilename());
+  // Note that we have uplifted the referenced files from non self-contained
+  // headers to header-guarded ones.
+  EXPECT_THAT(ReferencedFileNames.keys(),
+  UnorderedElementsAre(testPath("bar.h"), testPath("foo.h")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -81,7 +81,8 @@
 Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
 IncludeStructure Includes;
 Clang->getPreprocessor().addPPCallbacks(
-Includes.collect(Clang->getSourceManager()));
+Includes.collect(Clang->getSourceManager(),
+ Clang->getPreprocessor().getHeaderSearchInfo()));
 EXPECT_FALSE(Action.Execute());
 Action.EndSourceFile();
 return Includes;
@@ -363,6 +364,38 @@
   EXPECT_THAT(collectIncludes().MainFileIncludes,
   Contains(AllOf(IncludeLine(2), Written("";
 }
+
+TEST_F(HeadersTest, SelfContainedHeaders) {
+  // Including through non-builtin file has no effects.
+  FS.Files[MainFile] = R"cpp(
+#include "includeguarded.h"
+#include "nonguarded.h"
+#include "pp_depend.h"
+#include "pragmaguarded.h"
+)cpp";
+  FS.Files["pragmaguarded.h"] = R"cpp(
+#pragma once
+)cpp";
+  FS.Files["includeguarded.h"] = R"cpp(
+#ifndef INCLUDE_GUARDED_H
+#define INCLUDE_GUARDED_H
+void foo();
+#endif // INCL

[PATCH] D114525: [clang] Change ordering of PreableCallbacks to make sure PP can be referenced in them

2021-11-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added reviewers: kadircet, sammccall.
kbobyrev requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently, BeforeExecute is called before BeginSourceFile which does not allow
using PP in the callbacks. Change the ordering to ensure it is possible.
This is a prerequisite for D114370 .

Originated from a discussion with @kadircet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114525

Files:
  clang/include/clang/Frontend/PrecompiledPreamble.h
  clang/lib/Frontend/PrecompiledPreamble.cpp


Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -412,10 +412,13 @@
   std::unique_ptr Act;
   Act.reset(new PrecompilePreambleAction(
   StoreInMemory ? &Storage.asMemory().Data : nullptr, Callbacks));
-  Callbacks.BeforeExecute(*Clang);
   if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
 return BuildPreambleError::BeginSourceFileFailed;
 
+  // Performed after BeginSourceFile to ensure Clang->Preprocessor can be
+  // referenced in the callback.
+  Callbacks.BeforeExecute(*Clang);
+
   std::unique_ptr DelegatedPPCallbacks =
   Callbacks.createPPCallbacks();
   if (DelegatedPPCallbacks)
Index: clang/include/clang/Frontend/PrecompiledPreamble.h
===
--- clang/include/clang/Frontend/PrecompiledPreamble.h
+++ clang/include/clang/Frontend/PrecompiledPreamble.h
@@ -274,7 +274,7 @@
 public:
   virtual ~PreambleCallbacks() = default;
 
-  /// Called before FrontendAction::BeginSourceFile.
+  /// Called before FrontendAction::Execute.
   /// Can be used to store references to various CompilerInstance fields
   /// (e.g. SourceManager) that may be interesting to the consumers of other
   /// callbacks.
@@ -291,7 +291,7 @@
   /// used instead, but having only this method allows a simpler API.
   virtual void HandleTopLevelDecl(DeclGroupRef DG);
   /// Creates wrapper class for PPCallbacks so we can also process information
-  /// about includes that are inside of a preamble
+  /// about includes that are inside of a preamble. Called after BeforeExecute.
   virtual std::unique_ptr createPPCallbacks();
   /// The returned CommentHandler will be added to the preprocessor if not 
null.
   virtual CommentHandler *getCommentHandler();


Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -412,10 +412,13 @@
   std::unique_ptr Act;
   Act.reset(new PrecompilePreambleAction(
   StoreInMemory ? &Storage.asMemory().Data : nullptr, Callbacks));
-  Callbacks.BeforeExecute(*Clang);
   if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
 return BuildPreambleError::BeginSourceFileFailed;
 
+  // Performed after BeginSourceFile to ensure Clang->Preprocessor can be
+  // referenced in the callback.
+  Callbacks.BeforeExecute(*Clang);
+
   std::unique_ptr DelegatedPPCallbacks =
   Callbacks.createPPCallbacks();
   if (DelegatedPPCallbacks)
Index: clang/include/clang/Frontend/PrecompiledPreamble.h
===
--- clang/include/clang/Frontend/PrecompiledPreamble.h
+++ clang/include/clang/Frontend/PrecompiledPreamble.h
@@ -274,7 +274,7 @@
 public:
   virtual ~PreambleCallbacks() = default;
 
-  /// Called before FrontendAction::BeginSourceFile.
+  /// Called before FrontendAction::Execute.
   /// Can be used to store references to various CompilerInstance fields
   /// (e.g. SourceManager) that may be interesting to the consumers of other
   /// callbacks.
@@ -291,7 +291,7 @@
   /// used instead, but having only this method allows a simpler API.
   virtual void HandleTopLevelDecl(DeclGroupRef DG);
   /// Creates wrapper class for PPCallbacks so we can also process information
-  /// about includes that are inside of a preamble
+  /// about includes that are inside of a preamble. Called after BeforeExecute.
   virtual std::unique_ptr createPPCallbacks();
   /// The returned CommentHandler will be added to the preprocessor if not null.
   virtual CommentHandler *getCommentHandler();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114394: Compile-time computation of string attribute hashes

2021-11-24 Thread Yilong Guo via Phabricator via cfe-commits
Nuu added inline comments.



Comment at: llvm/include/llvm/IR/Attributes.h:54
+size_(HashedS.size()) {
+assert(hash_ == hasher(s.data(), s.size()) && "consistent hashing");
+  }




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

https://reviews.llvm.org/D114394

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


[PATCH] D112430: [ARM][libunwind] add PACBTI-M support for libunwind

2021-11-24 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Looks overall ok, without diving in very deep, except for this one change that 
seemed unrelated.




Comment at: libunwind/src/Unwind-EHABI.cpp:312
   uint8_t registers = getByte(data, offset++);
-  if (registers & 0xf0 || !registers)
+  if (registers & 0xf0)
 return _URC_FAILURE;

This particular change looks unrelated to the rest, on a quick glance


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112430

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


[clang] b7bf937 - [PowerPC] Provide XL-compatible vec_round implementation

2021-11-24 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-11-24T06:43:56-06:00
New Revision: b7bf937bbee38c2db0c0640176ef618d9c746538

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

LOG: [PowerPC] Provide XL-compatible vec_round implementation

The XL implementation of vec_round for vector double uses
"round-to-nearest, ties to even" just as the vector float
`version does. However clang and gcc use "round-to-nearest-away"
for vector double and "round-to-nearest, ties to even"
for vector float.

The XL behaviour is implemented under the __XL_COMPAT_ALTIVEC__
macro similarly to other instances of incompatibility.

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

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c
clang/test/CodeGen/builtins-ppc-xlcompat.c
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/read-set-flm.ll

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index fb808d7b0a4f..3366e1fc94b1 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -8413,9 +8413,20 @@ static __inline__ vector float __ATTRS_o_ai 
vec_round(vector float __a) {
 }
 
 #ifdef __VSX__
+#ifdef __XL_COMPAT_ALTIVEC__
+static __inline__ vector double __ATTRS_o_ai vec_rint(vector double __a);
+static __inline__ vector double __ATTRS_o_ai vec_round(vector double __a) {
+  double __fpscr = __builtin_readflm();
+  __builtin_setrnd(0);
+  vector double __rounded = vec_rint(__a);
+  __builtin_setflm(__fpscr);
+  return __rounded;
+}
+#else
 static __inline__ vector double __ATTRS_o_ai vec_round(vector double __a) {
   return __builtin_vsx_xvrdpi(__a);
 }
+#endif
 
 /* vec_rint */
 

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index da16124b0cd5..b0028e973773 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -409,10 +409,6 @@ void test1() {
 // CHECK: call <4 x float> @llvm.ppc.altivec.vrfin(<4 x float>
 // CHECK-LE: call <4 x float> @llvm.ppc.altivec.vrfin(<4 x float>
 
-  res_vd = vec_round(vd);
-// CHECK: call <2 x double> @llvm.round.v2f64(<2 x double>
-// CHECK-LE: call <2 x double> @llvm.round.v2f64(<2 x double>
-
   res_vd = vec_perm(vd, vd, vuc);
 // CHECK: @llvm.ppc.altivec.vperm
 // CHECK-LE: @llvm.ppc.altivec.vperm

diff  --git a/clang/test/CodeGen/builtins-ppc-xlcompat.c 
b/clang/test/CodeGen/builtins-ppc-xlcompat.c
index 7d350fb5cb1b..5c27b9d36db4 100644
--- a/clang/test/CodeGen/builtins-ppc-xlcompat.c
+++ b/clang/test/CodeGen/builtins-ppc-xlcompat.c
@@ -5,11 +5,16 @@
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
 // RUN:   -triple powerpc64le-unknown-linux-gnu -emit-llvm %s -o - \
 // RUN:   -D__XL_COMPAT_ALTIVEC__ -target-cpu pwr8 | FileCheck %s
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -triple powerpc64le-unknown-linux-gnu -emit-llvm %s -o - \
+// RUN:   -U__XL_COMPAT_ALTIVEC__ -target-cpu pwr8 | FileCheck \
+// RUN:   --check-prefix=NOCOMPAT %s
 #include 
 vector double vd = { 3.4e22, 1.8e-3 };
 vector signed long long vsll = { -12345678999ll, 12345678999 };
 vector unsigned long long vull = { 11547229456923630743llu, 
18014402265226391llu };
 vector float res_vf;
+vector double res_vd;
 vector signed int res_vsi;
 vector unsigned int res_vui;
 
@@ -38,4 +43,11 @@ void test() {
 // CHECK: [[TMP8:%.*]] = load <2 x double>, <2 x double>* @vd, align 16
 // CHECK-NEXT:fmul <2 x double> [[TMP8]], 
 // CHECK: call <4 x i32> @llvm.ppc.vsx.xvcvdpuxws(<2 x double>
+
+  res_vd = vec_round(vd);
+// CHECK: call double @llvm.ppc.readflm()
+// CHECK: call double @llvm.ppc.setrnd(i32 0)
+// CHECK: call <2 x double> @llvm.rint.v2f64(<2 x double>
+// CHECK: call double @llvm.ppc.setflm(double
+// NOCOMPAT:  call <2 x double> @llvm.round.v2f64(<2 x double>
 }

diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 541e50d8dcce..ec7e30d7e362 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -12116,6 +12116,7 @@ 
PPCTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
   MachineFunction::iterator It = ++BB->getIterator();
 
   MachineFunction *F = BB->getParent();
+  MachineRegisterInfo &MRI = F->getRegInfo();
 
   if (MI.getOpcode() == PPC::SELECT_CC_I4 ||
   MI.getOpcode() == PPC::SELECT_CC_I8 || MI.getOpcode() == PPC::SELECT_I4 
||
@@ -12721,7 +12722,10 @@ 
PPCTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
 Register OldFPSCRReg = MI.getOperand(0).getReg();
 
 // Save FPSCR value.
-BuildMI(*BB, MI, dl, TII->get(PPC::MFFS), OldFPS

[PATCH] D113642: [PowerPC] Provide XL-compatible vec_round implementation

2021-11-24 Thread Nemanja Ivanovic 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 rGb7bf937bbee3: [PowerPC] Provide XL-compatible vec_round 
implementation (authored by nemanjai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113642

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-vsx.c
  clang/test/CodeGen/builtins-ppc-xlcompat.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/read-set-flm.ll

Index: llvm/test/CodeGen/PowerPC/read-set-flm.ll
===
--- llvm/test/CodeGen/PowerPC/read-set-flm.ll
+++ llvm/test/CodeGen/PowerPC/read-set-flm.ll
@@ -11,7 +11,6 @@
 ; CHECK-NEXT:xsdivdp 1, 1, 2
 ; CHECK-NEXT:xsadddp 1, 1, 3
 ; CHECK-NEXT:xsadddp 0, 1, 0
-; CHECK-NEXT:mffs 1
 ; CHECK-NEXT:mtfsf 255, 4
 ; CHECK-NEXT:xsdivdp 1, 3, 4
 ; CHECK-NEXT:xsadddp 1, 1, 2
@@ -47,7 +46,6 @@
 ; CHECK-NEXT:xsdivdp 1, 1, 2
 ; CHECK-NEXT:xsadddp 1, 1, 3
 ; CHECK-NEXT:xsadddp 0, 1, 0
-; CHECK-NEXT:mffs 1
 ; CHECK-NEXT:mtfsf 255, 4
 ; CHECK-NEXT:xsdivdp 1, 3, 4
 ; CHECK-NEXT:xsadddp 1, 1, 2
@@ -96,7 +94,6 @@
 ; CHECK-NEXT:nop
 ; CHECK-NEXT:mffs 0
 ; CHECK-NEXT:stfd 0, 0(30)
-; CHECK-NEXT:mffs 0
 ; CHECK-NEXT:mtfsf 255, 31
 ; CHECK-NEXT:addi 1, 1, 64
 ; CHECK-NEXT:ld 0, 16(1)
@@ -134,7 +131,6 @@
 ; CHECK-NEXT:nop
 ; CHECK-NEXT:mffs 0
 ; CHECK-NEXT:stfd 0, 0(30)
-; CHECK-NEXT:mffs 0
 ; CHECK-NEXT:mtfsf 255, 31
 ; CHECK-NEXT:addi 1, 1, 64
 ; CHECK-NEXT:ld 0, 16(1)
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -12116,6 +12116,7 @@
   MachineFunction::iterator It = ++BB->getIterator();
 
   MachineFunction *F = BB->getParent();
+  MachineRegisterInfo &MRI = F->getRegInfo();
 
   if (MI.getOpcode() == PPC::SELECT_CC_I4 ||
   MI.getOpcode() == PPC::SELECT_CC_I8 || MI.getOpcode() == PPC::SELECT_I4 ||
@@ -12721,7 +12722,10 @@
 Register OldFPSCRReg = MI.getOperand(0).getReg();
 
 // Save FPSCR value.
-BuildMI(*BB, MI, dl, TII->get(PPC::MFFS), OldFPSCRReg);
+if (MRI.use_empty(OldFPSCRReg))
+  BuildMI(*BB, MI, dl, TII->get(TargetOpcode::IMPLICIT_DEF), OldFPSCRReg);
+else
+  BuildMI(*BB, MI, dl, TII->get(PPC::MFFS), OldFPSCRReg);
 
 // The floating point rounding mode is in the bits 62:63 of FPCSR, and has
 // the following settings:
@@ -12854,7 +12858,10 @@
 
 // Result of setflm is previous FPSCR content, so we need to save it first.
 Register OldFPSCRReg = MI.getOperand(0).getReg();
-BuildMI(*BB, MI, Dl, TII->get(PPC::MFFS), OldFPSCRReg);
+if (MRI.use_empty(OldFPSCRReg))
+  BuildMI(*BB, MI, Dl, TII->get(TargetOpcode::IMPLICIT_DEF), OldFPSCRReg);
+else
+  BuildMI(*BB, MI, Dl, TII->get(PPC::MFFS), OldFPSCRReg);
 
 // Put bits in 32:63 to FPSCR.
 Register NewFPSCRReg = MI.getOperand(1).getReg();
Index: clang/test/CodeGen/builtins-ppc-xlcompat.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat.c
@@ -5,11 +5,16 @@
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
 // RUN:   -triple powerpc64le-unknown-linux-gnu -emit-llvm %s -o - \
 // RUN:   -D__XL_COMPAT_ALTIVEC__ -target-cpu pwr8 | FileCheck %s
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -triple powerpc64le-unknown-linux-gnu -emit-llvm %s -o - \
+// RUN:   -U__XL_COMPAT_ALTIVEC__ -target-cpu pwr8 | FileCheck \
+// RUN:   --check-prefix=NOCOMPAT %s
 #include 
 vector double vd = { 3.4e22, 1.8e-3 };
 vector signed long long vsll = { -12345678999ll, 12345678999 };
 vector unsigned long long vull = { 11547229456923630743llu, 18014402265226391llu };
 vector float res_vf;
+vector double res_vd;
 vector signed int res_vsi;
 vector unsigned int res_vui;
 
@@ -38,4 +43,11 @@
 // CHECK: [[TMP8:%.*]] = load <2 x double>, <2 x double>* @vd, align 16
 // CHECK-NEXT:fmul <2 x double> [[TMP8]], 
 // CHECK: call <4 x i32> @llvm.ppc.vsx.xvcvdpuxws(<2 x double>
+
+  res_vd = vec_round(vd);
+// CHECK: call double @llvm.ppc.readflm()
+// CHECK: call double @llvm.ppc.setrnd(i32 0)
+// CHECK: call <2 x double> @llvm.rint.v2f64(<2 x double>
+// CHECK: call double @llvm.ppc.setflm(double
+// NOCOMPAT:  call <2 x double> @llvm.round.v2f64(<2 x double>
 }
Index: clang/test/CodeGen/builtins-ppc-vsx.c
===
--- clang/test/CodeGen/builtins-ppc-vsx.c
+++ clang/test/CodeGen/builtins-ppc-vsx.c
@@ -409,10 +409,6 @@
 // CHECK: call <4 x float

[PATCH] D112430: [ARM][libunwind] add PACBTI-M support for libunwind

2021-11-24 Thread Momchil Velikov via Phabricator via cfe-commits
chill added inline comments.



Comment at: libunwind/src/Unwind-EHABI.cpp:312
   uint8_t registers = getByte(data, offset++);
-  if (registers & 0xf0 || !registers)
+  if (registers & 0xf0)
 return _URC_FAILURE;

mstorsjo wrote:
> This particular change looks unrelated to the rest, on a quick glance
Indeed, that change is a leftover from when the encoding of the instruction to 
pop return address authentication code was `<0xb1,0x00>`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112430

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


[PATCH] D114394: Compile-time computation of string attribute hashes

2021-11-24 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 389463.

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

https://reviews.llvm.org/D114394

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  llvm/include/llvm/Analysis/TargetLibraryInfo.h
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/IR/Assumptions.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Function.h
  llvm/include/llvm/IR/GlobalVariable.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/lib/Analysis/InlineCost.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/AttributeImpl.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp

Index: llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
===
--- llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
@@ -67,11 +67,13 @@
 }
 
 static bool runOnFunction(Function &F, bool PostInlining) {
-  StringRef EntryAttr = PostInlining ? "instrument-function-entry-inlined"
- : "instrument-function-entry";
+  AttributeKey EntryAttr =
+  PostInlining ? AttributeKey("instrument-function-entry-inlined")
+   : AttributeKey("instrument-function-entry");
 
-  StringRef ExitAttr = PostInlining ? "instrument-function-exit-inlined"
-: "instrument-function-exit";
+  AttributeKey ExitAttr = PostInlining
+  ? AttributeKey("instrument-function-exit-inlined")
+  : AttributeKey("instrument-function-exit");
 
   StringRef EntryFunc = F.getFnAttribute(EntryAttr).getValueAsString();
   StringRef ExitFunc = F.getFnAttribute(ExitAttr).getValueAsString();
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -888,7 +888,7 @@
   //   attribute can not be inherited.
   for (const auto &Attr : oldFunction->getAttributes().getFnAttrs()) {
 if (Attr.isStringAttribute()) {
-  if (Attr.getKindAsString() == "thunk")
+  if (Attr.getKindAsKey() == "thunk")
 continue;
 } else
   switch (Attr.getKindAsEnum()) {
Index: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
===
--- llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1528,7 +1528,7 @@
 } // end anonymous namespace
 
 static StringRef getDeoptLowering(CallBase *Call) {
-  const char *DeoptLowering = "deopt-lowering";
+  const char DeoptLowering[] = "deopt-lowering";
   if (Call->hasFnAttr(DeoptLowering)) {
 // FIXME: Calls have a *really* confusing interface around attributes
 // with values.
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -4194,14 +4194,9 @@
 MemorySanitizerVisitor &MSV)
   : F(F), MS(MS), MSV(MSV) {
 AMD64FpEndOffset = AMD64FpEndOffsetSSE;
-for (const auto &Attr : F.getAttributes().getFnAttrs()) {
-  if (Attr.isStringAttribute() &&
-  (Attr.getKindAsString() == "target-features")) {
-if (Attr.getValueAsString().contains("-sse"))
-  AMD64FpEndOffset = AMD64FpEndOffsetNoSSE;
-break;
-  }
-}
+if (F.hasFnAttribute("target-features") &&
+F.getFnAttribute("target-features").getValueAsString().contains("-sse"))
+  AMD64FpEndOffset = AMD64FpEndOffsetNoSSE;
   }
 
   ArgKind classifyArgument(Value* arg) {
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -4319,7 +4319,7 @@
 : ChangeStatus::CHANGED;
   }
 
-  ChangeStatus foldKernelFnAttribute(Attributor &A, llvm::StringRef Attr) {
+  ChangeStatus foldKernelFnAttribute(Attributor &A, Attribut

[PATCH] D114394: Compile-time computation of string attribute hashes

2021-11-24 Thread serge via Phabricator via cfe-commits
serge-sans-paille marked an inline comment as done.
serge-sans-paille added inline comments.



Comment at: llvm/include/llvm/IR/Attributes.h:79
+  bool operator<(AttributeKey const &other) const {
+return strcmp(value_, other.value_) < 0;
+  }

JonChesterfield wrote:
> Could order by size first here, then strncmp on equal sizes
I tend to agree, but that would change how attributes are pretty-printed, so 
I'd rather keep that for another review.



Comment at: llvm/lib/IR/AttributeImpl.h:214
 
-  DenseMap StringAttrs;
+  std::unordered_map StringAttrs;
 

MaskRay wrote:
> std::unordered_map is inefficient. Why is this change?
Because in the specific case of `AttrBuilder`, `std::unordered_map` is actually 
more efficient. `AttrBuilder` usually only handles a few elements, I even tried 
an implementation based on a sorted array and it was better than other 
alternatives in my benchmarks. But that's for another PR.



Comment at: llvm/lib/IR/Attributes.cpp:125
   FoldingSetNodeID ID;
-  ID.AddString(Kind);
+  ID.AddString(Kind.value());
   if (!Val.empty()) ID.AddString(Val);

mehdi_amini wrote:
> Carrying over my comment from the original revision: it seem that you're ever 
> only using the StringRef from the Kind in this function.
> If so changing the API to use an AttributeKey seems pessimizing to me?
`Kind` is actually also used as a parameter of `StringAttributeImpl` which has 
been updated to store an AttributeKey, so that would just move the AttributeKey 
creation from the caller to the internal implementation.
And I'd rather have an homogeneous API alongside all string Attribute creation.



Comment at: llvm/lib/IR/Attributes.cpp:862
+  auto Where = StringAttrs.find(Kind);
+  return Where != StringAttrs.end() ? Where->second : Attribute();
 }

MaskRay wrote:
> `lookup`
Not for `std::unordered_map` :-/



Comment at: llvm/lib/IR/Attributes.cpp:2054
+  auto &AttributeKeys = pImpl->AttributeKeys;
+  auto Where = AttributeKeys.find(s);
+  if (Where == AttributeKeys.end()) {

MaskRay wrote:
> If you change `AttributeKeys` to `DenseMap`, you 
> can construct a `CachedHashStringRef` and avoid a hash computation in 
> `AttributeKey Key(s);`
I was looking for something along these lines, thanks!



Comment at: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp:1531
 static StringRef getDeoptLowering(CallBase *Call) {
-  const char *DeoptLowering = "deopt-lowering";
+  const char DeoptLowering[] = "deopt-lowering";
   if (Call->hasFnAttr(DeoptLowering)) {

MaskRay wrote:
> This can be committed separately.
Actually it cannot, because the `AttributeKey` constructor accepts a `char 
const (&) [N]` in order to get a compile-time size, and `const char*` doesn 
match this signature.


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

https://reviews.llvm.org/D114394

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


[PATCH] D114527: [VE] Support multiple architectures installation

2021-11-24 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 created this revision.
kaz7 added reviewers: simoll, k-ishizaka.
kaz7 added projects: LLVM, VE.
kaz7 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Change C++ header files placement to support multiple LLVM_RUNTIME_TARGETS
build.  Also modifies regression test for it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114527

Files:
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/test/Driver/ve-toolchain.cpp

Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -13,54 +13,69 @@
 // RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
 // RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
 // RUN: 2>&1 | FileCheck -check-prefix=DEFINC %s
-// DEFINC: clang{{.*}} "-cc1"
+// DEFINC: [[BIN_DIR:/.+]]/clang{{.*}} "-cc1"
 // DEFINC-SAME: "-nostdsysteminc"
 // DEFINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // DEFINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// DEFINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+
+// Following directory is created iff LLVM_ENABLE_RUNTIMES is used.  We use
+// standalone build often, and it breaks this.  So, commenting out it for a
+// while
+// IGNORE-DEFINC-SAME: "-internal-isystem" "[[BIN_DIR]]/../include/ve-unknown-linux-gnu/c++/v1"
+
+// DEFINC-SAME: "-internal-isystem" "[[BIN_DIR]]/../include/c++/v1"
 // DEFINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // DEFINC-SAME: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
 // RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
 // RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
 // RUN: -nostdlibinc 2>&1 | FileCheck -check-prefix=NOSTDLIBINC %s
-// NOSTDLIBINC: clang{{.*}} "-cc1"
+// NOSTDLIBINC: [[BIN_DIR:/.+]]/clang{{.*}} "-cc1"
 // NOSTDLIBINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOSTDLIBINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOSTDLIBINC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "[[BIN_DIR]]/../include/ve-unknown-linux-gnu/c++/v1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "[[BIN_DIR]]/../include/c++/v1"
 // NOSTDLIBINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
 // RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
 // RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
 // RUN: -nobuiltininc 2>&1 | FileCheck -check-prefix=NOBUILTININC %s
-// NOBUILTININC: clang{{.*}} "-cc1"
+// NOBUILTININC: [[BIN_DIR:/.+]]/clang{{.*}} "-cc1"
 // NOBUILTININC-SAME: "-nobuiltininc"
 // NOBUILTININC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOBUILTININC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOBUILTININC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+
+// Following directory is created iff LLVM_ENABLE_RUNTIMES is used.  We use
+// standalone build often, and it breaks this.  So, commenting out it for a
+// while
+// IGNORE-NOBUILTININC-SAME: "-internal-isystem" "[[BIN_DIR]]/../include/ve-unknown-linux-gnu/c++/v1"
+
+// NOBUILTININC-SAME: "-internal-isystem" "[[BIN_DIR]]/../include/c++/v1"
 // NOBUILTININC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // NOBUILTININC-SAME: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
 // RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
 // RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
 // RUN: -nostdinc 2>&1 | FileCheck -check-prefix=NOSTDINC %s
-// NOSTDINC: clang{{.*}} "-cc1"
+// NOSTDINC: [[BIN_DIR:/.+]]/clang{{.*}} "-cc1"
 // NOSTDINC-SAME: "-nobuiltininc"
 // NOSTDINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOSTDINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOSTDINC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOSTDINC-NOT: "-internal-isystem" "[[BIN_DIR]]/../include/ve-unknown-linux-gnu/c++/v1"
+// NOSTDINC-NOT: "-internal-isystem" "[[BIN_DIR]]/../include/c++/v1"
 // NOSTDINC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // NOSTDINC-NOT: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
 // RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
 // RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
 // RUN: -nostdinc++ 2>&1 | FileCheck -check-prefix=NOSTDINCXX %s
-// NOSTDINCXX: clang{{.*}} "-cc1"
+// NOSTDINCXX: [[BIN_DIR:/.+]]/clang{{.*}} "-cc1"
 // NOSTDINCXX-SAME: "-nostdinc++"
 // NOSTDINCXX-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOSTDINCXX-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOSTDINCXX-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOSTDINCXX-NOT: "-internal-isystem" "[[BIN_DIR]]/../include/ve-unknown-linux-gnu/c++/v1"
+// NOSTDINCXX-NOT: "-internal-isystem" "[[BIN_DIR]]/../include/c++/v1"
 // NOSTDINCXX-SAME:

[PATCH] D114525: [clang] Change ordering of PreableCallbacks to make sure PP can be referenced in them

2021-11-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

As discussed offline this definitely LGTM, let me summarize the reasoning here.

The original review was in https://reviews.llvm.org/D41365. It's unclear why 
they went with before `BeginSourceFile`. In theory having the callback issued 
before `BeginSourceFile` allows setting various options that'll effect parsing, 
but today there's only one user (at least in the upstream) of this callback, 
clangd, which uses the callack to stash some state from CompilerIntance rather 
than mutating it.
If we ever have users that'll need to mutate the CompilerIntance before 
`BeginSourceFile`, I think we should have a particular callback for that use 
case then.

Will still wait for feedback from @sammccall as he might have some historical 
context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114525

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


[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-24 Thread Mojca Miklavec via Phabricator via cfe-commits
mojca added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

carlosgalvezp wrote:
> mojca wrote:
> > tra wrote:
> > > mojca wrote:
> > > > kadircet wrote:
> > > > > looks like the list is getting big and hard to maintain. considering 
> > > > > that this is done only once per compiler invocation (and we check for 
> > > > > existence of directories down in the loop anyway). what about 
> > > > > throwing in an extra directory listing to base-directories mentioned 
> > > > > down below and populate `Candidates` while preserving the 
> > > > > newest-version-first order?
> > > > I totally agree with the sentiment, and that was my initial thought as 
> > > > well, but with zero experience I was too scared to make any more 
> > > > significant changes.
> > > > 
> > > > I can try to come up with a new patch (that doesn't need further 
> > > > maintenance whenever a new CUDA version gets released) if that's what 
> > > > you are suggesting. I would nevertheless merge this one, and prepare a 
> > > > new more advanced patch separately, but that's finally your call.
> > > > 
> > > > What's your suggestion about D.SysRoot + "Program Files/..."? At the 
> > > > time when this function gets called it looks like D.SysRoot is empty 
> > > > (or at least my debugger says so) and in my case it resolves to D: 
> > > > while the CUDA support is installed under C:.
> > > > 
> > > > Is there any special LLVM-specific/preferrable way to iterate through 
> > > > directories?
> > > > 
> > > > (What I also miss a bit in the whole process in an option to simply say 
> > > > "I want CUDA 11.1" without the need to explicitly spell out the full 
> > > > path.)
> > > > 
> > > > If you provide me give some general guidelines, I'll prepare another, 
> > > > hopefully more future-proof patch.
> > > > 
> > > > (Side note: I'm not sure if I'm calling clang-format correctly, but if 
> > > > I call it, it keeps reformatting the rest of this file.)
> > > This whole list may no longer be particularly useful. The most common use 
> > > case on Linux, AFAICT, is to install only one CUDA version using 
> > > system-provided package manager.
> > > E.g. https://packages.ubuntu.com/focal/amd64/nvidia-cuda-toolkit/filelist
> > > 
> > > TBH, I'm tempted to limit autodetection to only that one system-default 
> > > version and require user to use --cuda-path if they need something else.
> > On Windows this is certainly not the case. Unless the installation is 
> > changed manually, one always gets the new version installed into a new 
> > directory.
> > 
> > I really do need multiple versions on Windows (and the ability to pick an 
> > older one) if I want to compile a binary that works on someone else's 
> > computer (if I compile against the latest CUDA, users need "the latest" 
> > drivers that may sometimes not even be available for their machine).
> > 
> > (That said, at least when using CMake, the selection needs to be done by 
> > CMake anyway, and maybe CMake could be forced to specify the correct flag 
> > automatically.)
> > 
> > So even if the functionality gets removed from non-Windows platforms, it 
> > would be really nice to keep it for Windows.
> > 
> > Now, there are three "conflicting" feedbacks/suggestions above. I can try 
> > to improve support, but it would be really helpful to reach the consensus 
> > of what needs to be done before coding it.
> > one always gets the new version installed into a new directory.
> A similar thing happens on Linux.
> 
> > users need "the latest" drivers
> Since CUDA 10.2, there's some "[[ 
> https://docs.nvidia.com/deploy/cuda-compatibility/ | compatibility mode ]]" 
> that allows to run newer CUDA on older drivers. As long as you are not using 
> the latest features, of course.
> 
> I'm personally all up for removing redundancy and duplication. 
I'm following https://docs.nvidia.com/cuda/wsl-user-guide/index.html right now 
and the NVIDIA's "official packages" for Ubuntu get installed under 
`/usr/local/cuda-11.x`.

That sounds significant enough to me to argue against the removal of versioned 
folders from search.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114326

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


[PATCH] D114530: [clang][scan-build] Use cc/c++ instead of gcc/g++ on FreeBSD.

2021-11-24 Thread Frederic Cambus via Phabricator via cfe-commits
fcambus created this revision.
fcambus added reviewers: emaste, mgorny.
Herald added subscribers: krytarowski, arichardson.
fcambus requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

All supported FreeBSD platforms do not have GCC in base anymore.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114530

Files:
  clang/tools/scan-build/libexec/ccc-analyzer


Index: clang/tools/scan-build/libexec/ccc-analyzer
===
--- clang/tools/scan-build/libexec/ccc-analyzer
+++ clang/tools/scan-build/libexec/ccc-analyzer
@@ -80,7 +80,7 @@
   if (-x "/usr/bin/xcrun") {
 $UseXCRUN = 1;
   }
-} elsif (`uname -s` =~ m/OpenBSD/) {
+} elsif (`uname -s` =~ m/(FreeBSD|OpenBSD)/) {
   $DefaultCCompiler = 'cc';
   $DefaultCXXCompiler = 'c++';
 } else {


Index: clang/tools/scan-build/libexec/ccc-analyzer
===
--- clang/tools/scan-build/libexec/ccc-analyzer
+++ clang/tools/scan-build/libexec/ccc-analyzer
@@ -80,7 +80,7 @@
   if (-x "/usr/bin/xcrun") {
 $UseXCRUN = 1;
   }
-} elsif (`uname -s` =~ m/OpenBSD/) {
+} elsif (`uname -s` =~ m/(FreeBSD|OpenBSD)/) {
   $DefaultCCompiler = 'cc';
   $DefaultCXXCompiler = 'c++';
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114504: [clang][DebugInfo] Debug support for private variables inside an OpenMP task construct

2021-11-24 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Thanks for doing this! Can you please update the summary, since it hard to read 
with the format like this (at least, just try to reformat the debugger output 
properly with the Phabricator formatters)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114504

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


[PATCH] D114527: [VE] Support multiple architectures installation

2021-11-24 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 updated this revision to Diff 389479.
kaz7 added a comment.

Update ve-toolchain.c and ve-toolchain.cpp using -ccc-install-dir
option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114527

Files:
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/test/Driver/Inputs/basic_ve_tree/bin/.keep
  clang/test/Driver/Inputs/basic_ve_tree/include/c++/v1/.keep
  
clang/test/Driver/Inputs/basic_ve_tree/include/ve-unknown-linux-gnu/c++/v1/.keep
  clang/test/Driver/ve-toolchain.c
  clang/test/Driver/ve-toolchain.cpp

Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -4,72 +4,89 @@
 ///-
 /// Checking dwarf-version
 
-// RUN: %clangxx -### -g -target ve %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
+// RUN: %clangxx -### -g -target ve-unknown-linux-gnu \
+// RUN: %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
 // DWARF_VER: "-dwarf-version=4"
 
 ///-
 /// Checking include-path
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: 2>&1 | FileCheck -check-prefix=DEFINC %s
 // DEFINC: clang{{.*}} "-cc1"
 // DEFINC-SAME: "-nostdsysteminc"
 // DEFINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // DEFINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// DEFINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// DEFINC-SAME: "-internal-isystem" "{{.*}}/bin/../include/ve-unknown-linux-gnu/c++/v1"
+// DEFINC-SAME: "-internal-isystem" "{{.*}}/bin/../include/c++/v1"
 // DEFINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // DEFINC-SAME: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: -nostdlibinc 2>&1 | FileCheck -check-prefix=NOSTDLIBINC %s
 // NOSTDLIBINC: clang{{.*}} "-cc1"
 // NOSTDLIBINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOSTDLIBINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOSTDLIBINC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "{{.*}}/bin/../include/ve-unknown-linux-gnu/c++/v1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "{{.*}}/bin/../include/c++/v1"
 // NOSTDLIBINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: -nobuiltininc 2>&1 | FileCheck -check-prefix=NOBUILTININC %s
 // NOBUILTININC: clang{{.*}} "-cc1"
 // NOBUILTININC-SAME: "-nobuiltininc"
 // NOBUILTININC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOBUILTININC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOBUILTININC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOBUILTININC-SAME: "-internal-isystem" "{{.*}}/bin/../include/ve-unknown-linux-gnu/c++/v1"
+// NOBUILTININC-SAME: "-internal-isystem" "{{.*}}/bin/../include/c++/v1"
 // NOBUILTININC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // NOBUILTININC-SAME: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: -nostdinc 2>&1 | FileCheck -check-prefix=NOSTDINC %s
 // NOSTDINC: clang{{.*}} "-cc1"
 // NOSTDINC-SAME: "-nobuiltininc"
 // NOSTDINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOSTDINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOSTDINC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/bin/../include/ve-unkn

[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

2021-11-24 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 created this revision.
skc7 added reviewers: sameerds, arsenm.
Herald added subscribers: dexonsmith, lxfind, jdoerfert, zzheng, hiraditya.
skc7 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng.
Herald added projects: clang, LLVM.

When the addrspacecast instruction was added, the ability to bitcast between 
pointers from different address spaces was removed.
There are cases, where after analysis, cast between pointers from different 
address spaces can be concluded to be a no-op cast.
If bitcast can be allowed in these scenarios, it would help further optimise 
the IR in Transform passes since its a no-op cast.
This enhancement to bitcast will require that pointers to the two address 
spaces have the same bit widths(can be queried from DataLayout).
Frontend should never misuse the bitcast wherever addrspace cast would have 
been more appropriate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114533

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/IRBuilderFolder.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/NoFolder.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/LoopUnrollAnalyzer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Coroutines/Coroutines.cpp
  llvm/lib/Transforms/Utils/VNCoercion.cpp
  llvm/test/Transforms/GVN/gvn-eliminate-inttoptr-ptrtoint-for-load.ll
  llvm/test/Transforms/GVN/gvn-eliminate-inttoptr-ptrtoint-for-vector-load.ll
  
llvm/test/Transforms/GVN/gvn-eliminate-inttoptr-ptrtoint-for-vector-ptr-load.ll
  llvm/test/Verifier/bitcast-vector-pointer-as-neg.ll
  llvm/test/Verifier/bitcast-vector-pointer-different-addrspace-illegal.ll
  llvm/test/Verifier/bitcast-vector-pointer-neg.ll
  llvm/test/Verifier/bitcast-vector-pointer-pos.ll
  llvm/test/Verifier/bitcast-vector-pointer-same-addrspace.ll
  llvm/unittests/IR/InstructionsTest.cpp

Index: llvm/unittests/IR/InstructionsTest.cpp
===
--- llvm/unittests/IR/InstructionsTest.cpp
+++ llvm/unittests/IR/InstructionsTest.cpp
@@ -189,6 +189,10 @@
 TEST(InstructionsTest, CastInst) {
   LLVMContext C;
 
+  DataLayout DL("e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-"
+"p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
+"v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7");
+
   Type *Int8Ty = Type::getInt8Ty(C);
   Type *Int16Ty = Type::getInt16Ty(C);
   Type *Int32Ty = Type::getInt32Ty(C);
@@ -217,7 +221,11 @@
   Type *Int32PtrAS1Ty = PointerType::get(Int32Ty, 1);
   Type *Int64PtrAS1Ty = PointerType::get(Int64Ty, 1);
 
+  Type *Int32PtrAS2Ty = PointerType::get(Int32Ty, 2);
+  Type *Int32PtrAS3Ty = PointerType::get(Int32Ty, 3);
+
   Type *V2Int32PtrAS1Ty = FixedVectorType::get(Int32PtrAS1Ty, 2);
+  Type *V2Int32PtrAS2Ty = FixedVectorType::get(Int32PtrAS2Ty, 2);
   Type *V2Int64PtrAS1Ty = FixedVectorType::get(Int64PtrAS1Ty, 2);
   Type *V4Int32PtrAS1Ty = FixedVectorType::get(Int32PtrAS1Ty, 4);
   Type *VScaleV4Int32PtrAS1Ty = ScalableVectorType::get(Int32PtrAS1Ty, 4);
@@ -238,50 +246,52 @@
   EXPECT_EQ(CastInst::Trunc, CastInst::getCastOpcode(c64, true, V8x8Ty, true));
   EXPECT_EQ(CastInst::SExt, CastInst::getCastOpcode(c8, true, V8x64Ty, true));
 
-  EXPECT_FALSE(CastInst::isBitCastable(V8x8Ty, X86MMXTy));
-  EXPECT_FALSE(CastInst::isBitCastable(X86MMXTy, V8x8Ty));
-  EXPECT_FALSE(CastInst::isBitCastable(Int64Ty, X86MMXTy));
-  EXPECT_FALSE(CastInst::isBitCastable(V8x64Ty, V8x8Ty));
-  EXPECT_FALSE(CastInst::isBitCastable(V8x8Ty, V8x64Ty));
-
-  // Check address space casts are rejected since we don't know the sizes here
-  EXPECT_FALSE(CastInst::isBitCastable(Int32PtrTy, Int32PtrAS1Ty));
-  EXPECT_FALSE(CastInst::isBitCastable(Int32PtrAS1Ty, Int32PtrTy));
-  EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrTy, V2Int32PtrAS1Ty));
-  EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrAS1Ty, V2Int32PtrTy));
-  EXPECT_TRUE(CastInst::isBitCastable(V2Int32PtrAS1Ty, V2Int64PtrAS1Ty));
+  EXPECT_FALSE(CastInst::isBitCastable(V8x8Ty, X86MMXTy, DL));
+  EXPECT_FALSE(CastInst::isBitCastable(X86MMXTy, V8x8Ty, DL));
+  EXPECT_FALSE(CastInst::isBitCastable(Int64Ty, X86MMXTy, DL));
+  EXPECT_FALSE(CastInst::isBitCastable(V8x64Ty, V8x8Ty, DL));
+  EXPECT_FALSE(CastInst::isBitCastable(V8x8Ty, V8x64Ty, DL));
+
+  // Check validity of casts here
+  EXPECT_TRUE(CastInst::isBitCastable(Int32PtrAS2Ty, Int32PtrAS3Ty, DL));
+  EXPECT_FALSE(CastInst::isBitCastable(Int32PtrAS1Ty, Int32PtrAS2Ty, DL));
+  EXPECT_TRUE(CastInst::isBitCastable(Int32PtrTy, Int32PtrAS1Ty, DL));
+  EXPECT_TRUE(CastInst::isBitCa

[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

2021-11-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Is there an RFC? This quite seems like asking for problems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114533

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2021-11-24 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 389298.
mizvekov edited the summary of this revision.
mizvekov added a comment.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.

- Avoid using any storage for an empty ElaboratedTYpeLoc.
  - But we still require pointer alignment for it, due to pre-existing bugs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-copy-constructor-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance-nesting-threshold.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang/bindings/python/tests/cindex/test_type.py
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/TypeLocBuilder.cpp
  clang/lib/Sema/TypeLocBuilder.h
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/float16.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
  clang/test/Analysis/analyzer-display-progress.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/bug_hash_test.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
  clang/test/Analysis/dump_egra

[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2021-11-24 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 389352.
mizvekov added a comment.

- fix IntrospectionTests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-copy-constructor-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance-nesting-threshold.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang/bindings/python/tests/cindex/test_type.py
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/TypeLocBuilder.cpp
  clang/lib/Sema/TypeLocBuilder.h
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/float16.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
  clang/test/Analysis/analyzer-display-progress.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/bug_hash_test.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
  clang/test/Analysis/initializers-cfg-output.cpp
  clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
  clang/test/Analysis/lambdas.cpp
  clang

[PATCH] D114502: File Reorganization changes

2021-11-24 Thread Ranjith Ramakrishnan via Phabricator via cfe-commits
raramakr created this revision.
raramakr added reviewers: yaxunl, msearles.
Herald added subscribers: sdasgup3, wenzhicui, wrengr, Chia-hungDuan, dcaballe, 
cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, 
Joonsoo, kerbowa, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, csigg, 
antiagainst, shauheen, rriddle, mehdi_amini, mgorny, nhaehnle, jvesely.
raramakr requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, cfe-commits, sstefan1, 
stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, OpenMP, MLIR.

ROCM file reorganization feature(SWDEV-29145 )

- Device library path moved to /opt/rocm/share
- External module header file access using 
- Hip is installed in /opt/rocm
- Hsa header files moved to /opt/rocm/include/hsa/
- Hip cmake file moved to /opt/rocm/lib/cmake/hip




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114502

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_daz_opt_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_finite_only_off.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_finite_only_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_1010.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_1011.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_1012.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_803.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_900.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_908.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_unsafe_math_off.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/opencl.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_daz_opt_on.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_finite_only_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_finite_only_on.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_1010.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_1011.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_1012.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_803.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_900.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_isa_version_908.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_unsafe_math_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm-invalid/share/amdgcn/bitcode/opencl.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/asanrtl.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/oclc_daz_opt_off.bc
  
clang/test/Driver/Inputs/

[PATCH] D114502: File Reorganization changes

2021-11-24 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: mlir/lib/ExecutionEngine/CMakeLists.txt:153
+  set(CMAKE_MODULE_PATH "${HIP_PATH}/lib/cmake/hip" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)

Is MLIR really coupled to Clang here? That seems suspicious to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114502

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


[PATCH] D114502: File Reorganization changes

2021-11-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

could you please include a complete diff context in the patch? You can do that 
by using git diff -U




Comment at: mlir/lib/ExecutionEngine/CMakeLists.txt:153
+  set(CMAKE_MODULE_PATH "${HIP_PATH}/lib/cmake/hip" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)

mehdi_amini wrote:
> mehdi_amini wrote:
> > Is MLIR really coupled to Clang here? That seems suspicious to me.
> In particular, this makes MLIR sensitive to the version actually installed on 
> the machine, which is independent from whatever clang is in the repo. This 
> seems undesirable, what am I missing here?
Probably it is not depending on clang, but depending on HIP cmake file to get 
HIP package to be able to use HIP header and library files for kernel launching 
API.

To be compatible with all ROCm releases, probably CMAKE_MODULE_PATH should also 
include the HIP cmake path for both old and new ROCm releases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114502

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


[PATCH] D114502: File Reorganization changes

2021-11-24 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: mlir/lib/ExecutionEngine/CMakeLists.txt:153
+  set(CMAKE_MODULE_PATH "${HIP_PATH}/lib/cmake/hip" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)

mehdi_amini wrote:
> Is MLIR really coupled to Clang here? That seems suspicious to me.
In particular, this makes MLIR sensitive to the version actually installed on 
the machine, which is independent from whatever clang is in the repo. This 
seems undesirable, what am I missing here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114502

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


[PATCH] D112430: [ARM][libunwind] add PACBTI-M support for libunwind

2021-11-24 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 389481.
stuij added a comment.

address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112430

Files:
  clang/lib/Headers/unwind.h
  libunwind/include/libunwind.h
  libunwind/include/unwind_arm_ehabi.h
  libunwind/src/DwarfInstructions.hpp
  libunwind/src/Registers.hpp
  libunwind/src/Unwind-EHABI.cpp
  libunwind/src/UnwindCursor.hpp
  libunwind/src/UnwindRegistersRestore.S
  libunwind/src/assembly.h

Index: libunwind/src/assembly.h
===
--- libunwind/src/assembly.h
+++ libunwind/src/assembly.h
@@ -81,7 +81,7 @@
 #define PPC64_OPD2
 #endif
 
-#if defined(__ARM_FEATURE_BTI_DEFAULT)
+#if defined(__aarch64__) && defined(__ARM_FEATURE_BTI_DEFAULT)
   .pushsection ".note.gnu.property", "a" SEPARATOR \
   .balign 8 SEPARATOR  \
   .long 4 SEPARATOR\
@@ -99,6 +99,17 @@
 #define AARCH64_BTI
 #endif
 
+#if !defined(__aarch64__)
+#ifdef __ARM_FEATURE_PAC_DEFAULT
+  .eabi_attribute Tag_PAC_extension, 2
+  .eabi_attribute Tag_PACRET_use, 1
+#endif
+#ifdef __ARM_FEATURE_BTI_DEFAULT
+  .eabi_attribute Tag_BTI_extension, 1
+  .eabi_attribute Tag_BTI_use, 1
+#endif
+#endif
+
 #define GLUE2(a, b) a ## b
 #define GLUE(a, b) GLUE2(a, b)
 #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
Index: libunwind/src/UnwindRegistersRestore.S
===
--- libunwind/src/UnwindRegistersRestore.S
+++ libunwind/src/UnwindRegistersRestore.S
@@ -660,7 +660,13 @@
   ldr sp, [lr, #52]
   ldr lr, [lr, #60]  @ restore pc into lr
 #endif
+#if defined(__ARM_FEATURE_BTI_DEFAULT) && !defined(__ARM_ARCH_ISA_ARM)
+  // 'bx' is not BTI setting when used with lr, therefore r12 is used instead
+  mov r12, lr
+  JMP(r12)
+#else
   JMP(lr)
+#endif
 
 @
 @ static void libunwind::Registers_arm::restoreVFPWithFLDMD(unw_fpreg_t* values)
Index: libunwind/src/UnwindCursor.hpp
===
--- libunwind/src/UnwindCursor.hpp
+++ libunwind/src/UnwindCursor.hpp
@@ -655,7 +655,9 @@
 #if defined(_LIBUNWIND_TARGET_X86_64)
   if (regNum >= UNW_X86_64_RAX && regNum <= UNW_X86_64_R15) return true;
 #elif defined(_LIBUNWIND_TARGET_ARM)
-  if (regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R15) return true;
+  if ((regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R15) ||
+  regNum == UNW_ARM_RA_AUTH_CODE)
+return true;
 #elif defined(_LIBUNWIND_TARGET_AARCH64)
   if (regNum >= UNW_AARCH64_X0 && regNum <= UNW_ARM64_X30) return true;
 #endif
Index: libunwind/src/Unwind-EHABI.cpp
===
--- libunwind/src/Unwind-EHABI.cpp
+++ libunwind/src/Unwind-EHABI.cpp
@@ -256,6 +256,7 @@
   size_t offset, size_t len) {
   bool wrotePC = false;
   bool finish = false;
+  bool hasReturnAddrAuthCode = false;
   while (offset < len && !finish) {
 uint8_t byte = getByte(data, offset++);
 if ((byte & 0x80) == 0) {
@@ -342,6 +343,10 @@
   break;
 }
 case 0xb4:
+  hasReturnAddrAuthCode = true;
+  _Unwind_VRS_Pop(context, _UVRSC_PSEUDO,
+  0 /* Return Address Auth Code */, _UVRSD_UINT32);
+  break;
 case 0xb5:
 case 0xb6:
 case 0xb7:
@@ -417,6 +422,16 @@
   if (!wrotePC) {
 uint32_t lr;
 _Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_LR, _UVRSD_UINT32, &lr);
+#ifdef __ARM_FEATURE_PAUTH
+if (hasReturnAddrAuthCode) {
+  uint32_t sp;
+  uint32_t pac;
+  _Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, &sp);
+  _Unwind_VRS_Get(context, _UVRSC_PSEUDO, UNW_ARM_RA_AUTH_CODE, _UVRSD_UINT32,
+  &pac);
+  __asm__ __volatile__("autg %0, %1, %2" : : "r"(pac), "r"(lr), "r"(sp) :);
+}
+#endif
 _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_IP, _UVRSD_UINT32, &lr);
   }
   return _URC_CONTINUE_UNWIND;
@@ -927,6 +942,15 @@
 case _UVRSC_WMMXD:
   break;
 #endif
+case _UVRSC_PSEUDO:
+  // There's only one pseudo-register, PAC, with regno == 0.
+  if (representation != _UVRSD_UINT32 || regno != 0)
+return _UVRSR_FAILED;
+  return __unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_RA_AUTH_CODE),
+   *(unw_word_t *)valuep) == UNW_ESUCCESS
+ ? _UVRSR_OK
+ : _UVRSR_FAILED;
+  break;
   }
   _LIBUNWIND_ABORT("unsupported register class");
 }
@@ -981,6 +1005,15 @@
 case _UVRSC_WMMXD:
   break;
 #endif
+case _UVRSC_PSEUDO:
+  // There's only one pseudo-register, PAC, with regno == 0.
+  if (representation != _UVRSD_UINT32 || regno != 0)
+return _UVRSR_FAILED;
+ 

[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

After rebasing these tests seem to work (on Windows)

  -- Testing: 24 tests, 16 workers --
  PASS: Clang :: Format/dry-run-alias.cpp (1 of 24)
  PASS: Clang :: Format/remove-duplicate-includes.cpp (2 of 24)
  PASS: Clang :: Format/disable-format.cpp (3 of 24)
  PASS: Clang :: Format/cursor.cpp (4 of 24)
  PASS: Clang :: Format/multiple-inputs.cpp (5 of 24)
  PASS: Clang :: Format/basic.cpp (6 of 24)
  PASS: Clang :: Format/incomplete.cpp (7 of 24)
  PASS: Clang :: Format/line-ranges.cpp (8 of 24)
  PASS: Clang :: Format/adjust-indent.cpp (9 of 24)
  UNSUPPORTED: Clang :: Format/style-on-command-line.cpp (10 of 24)
  PASS: Clang :: Format/ranges.cpp (11 of 24)
  PASS: Clang :: Format/access-modifiers.cpp (12 of 24)
  PASS: Clang :: Format/multiple-inputs-error.cpp (13 of 24)
  PASS: Clang :: Format/dump-config-objc.h (14 of 24)
  PASS: Clang :: Format/xmloutput.cpp (15 of 24)
  PASS: Clang :: Format/dump-config-cxx.h (16 of 24)
  PASS: Clang :: Format/multiple-inputs-inplace.cpp (17 of 24)
  PASS: Clang :: Format/error-config.cpp (18 of 24)
  PASS: Clang :: Format/dry-run.cpp (19 of 24)
  PASS: Clang :: Format/inplace.cpp (20 of 24)
  PASS: Clang :: Format/dump-config-list-override.cpp (21 of 24)
  PASS: Clang :: Format/disable-include-sorting.cpp (22 of 24)
  PASS: Clang :: Format/language-detection.cpp (23 of 24)
  PASS: Clang :: Format/verbose.cpp (24 of 24)

I'm going to Commandeer this revision and see if we can't get this relanded.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326

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


[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

2021-11-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Patch description should include this avoids a need to introduce 
ptrtoint/inttoptr pairs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114533

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


[PATCH] D114088: [PowerPC] Add BCD add/sub/cmp builtins

2021-11-24 Thread Bardia Mahjour via Phabricator via cfe-commits
bmahjour added a comment.

@nemanjai how come the changes in `altivec.h` and 
`clang/test/CodeGen/builtins-ppc-p8vector.c` have been removed in the latest 
diff and the commit above?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114088

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

LGTM, but I have one question. You mentioned in the bug ticket comment that 
"this exposes a greater issue in AllowShortXXX". Have you found other cases 
that misbehave? If so, then it would probably be good to add them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114504: [clang][DebugInfo] Debug support for private variables inside an OpenMP task construct

2021-11-24 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok added a comment.

In D114504#3151332 , @djtodoro wrote:

> Thanks for doing this! Can you please update the summary, since it hard to 
> read with the format like this (at least, just try to reformat the debugger 
> output properly with the Phabricator formatters)?

Sorry for the bad formatting. I have corrected it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114504

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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 389488.
MyDeveloperDay added a comment.

Rebasing previously landed but reverted commit


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

https://reviews.llvm.org/D72326

Files:
  clang/docs/ClangFormat.rst
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  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
@@ -21343,6 +21343,64 @@
   }());
 }
 
+TEST(FormatStyle, GetStyleFromExteranlFile) {
+  llvm::vfs::InMemoryFileSystem FS;
+  // Explicit format file in parent directory.
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+  FS.addFile("/e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/sub/test.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style = getStyle("file:/e/explicit.clang-format",
+"/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style);
+  ASSERT_EQ(*Style, getGoogleStyle());
+
+  // Relative pah to a format file
+  ASSERT_TRUE(
+  FS.addFile("../../e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  Style = getStyle("file:../../e/explicit.clang-format",
+   "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style);
+  ASSERT_EQ(*Style, getGoogleStyle());
+
+  // Missing explicit format file
+  Style = getStyle("file:/e/missing.clang-format", "/e/sub/sub/sub/test.cpp",
+   "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style);
+  llvm::consumeError(Style.takeError());
+
+  // Format file from the filesystem
+  SmallString<128> FormatFilePath;
+  std::error_code ECF = llvm::sys::fs::createTemporaryFile(
+  "FormatFileTest", "tpl", FormatFilePath);
+  EXPECT_FALSE((bool)ECF);
+  llvm::raw_fd_ostream FormatFileTest(FormatFilePath, ECF);
+  EXPECT_FALSE((bool)ECF);
+  FormatFileTest << "BasedOnStyle: Google\n";
+  FormatFileTest.close();
+
+  SmallString<128> TestFilePath;
+  std::error_code ECT =
+  llvm::sys::fs::createTemporaryFile("CodeFileTest", "cc", TestFilePath);
+  EXPECT_FALSE((bool)ECT);
+  llvm::raw_fd_ostream CodeFileTest(TestFilePath, ECT);
+  CodeFileTest << "int i;\n";
+  CodeFileTest.close();
+
+  std::string format_file_arg = std::string("file:") + FormatFilePath.c_str();
+  Style = getStyle(format_file_arg, TestFilePath, "LLVM", "", nullptr);
+
+  llvm::sys::fs::remove(FormatFilePath.c_str());
+  llvm::sys::fs::remove(TestFilePath.c_str());
+  ASSERT_TRUE((bool)Style);
+  ASSERT_EQ(*Style, getGoogleStyle());
+}
+
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
   // Column limit is 20.
   std::string Code = "Type *a =\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3163,6 +3163,8 @@
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
+"Use -style=file: to explicitly specify"
+"the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"
 "  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
@@ -3211,6 +3213,29 @@
   return GuessedLanguage;
 }
 
+/// Attempts to load a format file
+llvm::Expected LoadConfigFile(StringRef ConfigFile,
+   llvm::vfs::FileSystem *FS,
+   bool *IsSuitable) {
+  FormatStyle Style = getLLVMStyle();
+  *IsSuitable = false;
+
+  llvm::ErrorOr> Text =
+  FS->getBufferForFile(ConfigFile.str());
+  if (std::error_code EC = Text.getError())
+return make_string_error(EC.message());
+  std::error_code ParserErrorCode =
+  parseConfiguration(Text.get()->getBuffer(), &Style);
+  if (ParserErrorCode == ParseError::Unsuitable) {
+return Style;
+  } else if (ParserErrorCode != ParseError::Success) {
+return make_string_error("Error reading " + ConfigFile + ": " +
+ ParserErrorCode.message());
+  }
+  *IsSuitable = true;
+  return Style;
+}
+
 const char *DefaultFormatStyle = "file";
 
 const char *DefaultFallbackStyle = "LLVM";
@@ -3245,6 +3270,23 @@
   return Style;
   }
 
+  llvm::SmallVector FilesToLookFor;
+  // User provided clang-format file using -style=file:/path/to/format/file
+  // Check for explicit config filename
+  if (StyleName.startswith_insensitive("file:")) {
+auto StyleNameFile = StyleName.substr(5);
+bool IsSuitable

[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

2021-11-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D114533#3151423 , @arsenm wrote:

> Patch description should include this avoids a need to introduce 
> ptrtoint/inttoptr pairs

That is a good point, but all the motivational cases seem to be about chaining 
the address space of the pointee pointer.
Does this come up for changing the address space of the pointer itself? I'm 
just wondering if this is still relevant with opaque pointers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114533

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread Kyrylo Bohdanenko via Phabricator via cfe-commits
KyrBoh added a comment.

In D114521#3151431 , @curdeius wrote:

> LGTM, but I have one question. You mentioned in the bug ticket comment that 
> "this exposes a greater issue in AllowShortXXX". Have you found other cases 
> that misbehave? If so, then it would probably be good to add them.

There also seems to be a behavior caused by AfterControlStatement = Multiline. 
This code:

if (condition) { contrinue; }

Is broken up into lines:

if (condition)
{

  continue;

}

I am not sure if this is intended behavior or not.

Because when having this configuration:

BreakBeforeBraces: Custom
BraceWrapping:

  AfterControlStatement: Never

AllowShortBlocksOnASingleLine: Always
AllowShortIfStatementsOnASingleLine: WithoutElse # any value except Never

clang-format would leave that code unchanged.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

2021-11-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D114533#3151482 , @lebedev.ri 
wrote:

> In D114533#3151423 , @arsenm wrote:
>
>> Patch description should include this avoids a need to introduce 
>> ptrtoint/inttoptr pairs
>
> That is a good point, but all the motivational cases seem to be about 
> chaining the address space of the pointee pointer.
> Does this come up for changing the address space of the pointer itself? I'm 
> just wondering if this is still relevant with opaque pointers.

Nothing about address spaces changes with opaque pointers. The address space is 
a property of the pointer itself, not the memory it points to. This is for 
dealing with cases where we end up with a bit reinterpret of a pointer in 
another address space, and need to do a true no-op cast to convert them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114533

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


[PATCH] D112230: [OpenCL] Add support of __opencl_c_device_enqueue feature macro.

2021-11-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:9554
+
+const auto &OpenCLFeaturesMap =
+Info.Ctx.getTargetInfo().getSupportedOpenCLOpts();

azabaznov wrote:
> azabaznov wrote:
> > Anastasia wrote:
> > > What test case covers this change? It feels like something we should try 
> > > to diagnose earlier...
> > The test case which exactly was added. Since blocks in constant address 
> > space are disallowed at this point, we can treat all other blocks with no 
> > captures not as constant expressions - it will make CodeGen generate block  
> > literal in local scope for blocks with no captures. See `buildGlobalBlock 
> > `and `CodeGenModule::GetAddrOfGlobalBlock` for details.
> I mean - //blocks_no_global_literal.cl// - that's exactly the case which 
> covers it.
Ok I see, it doesn't seem to have any constant but my guess is that it becomes 
constant implicitly?

Does the case with program scope variable supported need testing too or is it 
covered elsewhere?



Comment at: clang/lib/Sema/Sema.cpp:328
+auto OCLCompatibleVersion = getLangOpts().getOpenCLCompatibleVersion();
+if (OCLCompatibleVersion >= 200) {
+  if ((OCLCompatibleVersion == 200) ||

I wonder if we should simplify this condition by only checking 
`getLangOpts().Blocks` but then we make sure to set it correctly based on the 
language version and the target just like we do now for generic address space 
or pipes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112230

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


[PATCH] D114539: [clang-tidy] performance-unnecessary-copy-initialization: handle pointer containers.

2021-11-24 Thread Clement Courbet via Phabricator via cfe-commits
courbet created this revision.
courbet added reviewers: flx, aaron.ballman.
Herald added subscribers: carlosgalvezp, xazax.hun, mgorny.
courbet requested review of this revision.
Herald added a project: clang-tools-extra.

This includes modifying `DeclRefExprUtils` to handle more cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114539

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
@@ -0,0 +1,315 @@
+#include "../clang-tidy/utils/DeclRefExprUtils.h"
+#include "ClangTidyDiagnosticConsumer.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+
+namespace {
+using namespace clang::ast_matchers;
+
+class ConstReferenceDeclRefExprsTransform : public ClangTidyCheck {
+public:
+  ConstReferenceDeclRefExprsTransform(StringRef CheckName,
+  ClangTidyContext *Context)
+  : ClangTidyCheck(CheckName, Context) {}
+
+  void registerMatchers(MatchFinder *Finder) override {
+Finder->addMatcher(varDecl(hasName("target")).bind("var"), this);
+  }
+
+  void check(const MatchFinder::MatchResult &Result) override {
+const auto *D = Result.Nodes.getNodeAs("var");
+using utils::decl_ref_expr::constReferenceDeclRefExprs;
+const auto const_decrefexprs = constReferenceDeclRefExprs(
+*D, *cast(D->getDeclContext())->getBody(),
+*Result.Context);
+
+for (const DeclRefExpr *const Expr : const_decrefexprs) {
+  assert(Expr);
+  diag(Expr->getBeginLoc(), "const usage")
+  << FixItHint::CreateInsertion(Expr->getBeginLoc(), "/*const*/");
+}
+  }
+};
+} // namespace
+
+namespace test {
+
+void RunTest(StringRef Snippet) {
+
+  StringRef CommonCode = R"(
+struct ConstTag{};
+struct NonConstTag{};
+
+struct S {
+  void constMethod() const;
+  void nonConstMethod();
+
+  void operator()(ConstTag) const;
+  void operator()(NonConstTag);
+
+  void operator[](int);
+  void operator[](int) const;
+
+  bool operator==(const S&) const;
+
+  int int_member;
+  int* ptr_member;
+
+};
+
+struct Derived : public S {
+
+};
+
+void useVal(S);
+void useRef(S&);
+void usePtr(S*);
+void usePtrPtr(S**);
+void usePtrConstPtr(S* const*);
+void useConstRef(const S&);
+void useConstPtr(const S*);
+void useConstPtrRef(const S*&);
+void useConstPtrPtr(const S**);
+void useConstPtrConstRef(const S* const&);
+void useConstPtrConstPtr(const S* const*);
+
+void useInt(int);
+void useIntRef(int&);
+void useIntConstRef(const int&);
+void useIntPtr(int*);
+void useIntConstPtr(const int*);
+
+)";
+
+  std::string Code = (CommonCode + Snippet).str();
+
+  llvm::SmallVector Parts;
+  StringRef(Code).split(Parts, "/*const*/");
+
+  EXPECT_EQ(Code, runCheckOnCode(
+  join(Parts, "")));
+}
+
+TEST(ConstReferenceDeclRefExprsTest, ConstValueVar) {
+  RunTest(R"(
+void f(const S target) {
+  useVal(/*const*/target);
+  useConstRef(/*const*/target);
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
+  /*const*/target.constMethod();
+  /*const*/target(ConstTag{});
+  /*const*/target[42];
+  useConstRef((/*const*/target));
+  (/*const*/target).constMethod();
+  (void)(/*const*/target == /*const*/target);
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
+  S copy1 = /*const*/target;
+  S copy2(/*const*/target);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
+  useIntPtr(target.ptr_member);
+  useIntConstPtr(&/*const*/target.int_member);
+}
+)");
+}
+
+TEST(ConstReferenceDeclRefExprsTest, ConstRefVar) {
+  RunTest(R"(
+void f(const S& target) {
+  useVal(/*const*/target);
+  useConstRef(/*const*/target);
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
+  /*const*/target.constMethod();
+  /*const*/target(ConstTag{});
+  /*const*/target[42];
+  useConstRef((/*const*/target));
+  (/*const*/target).constMethod();
+  (void)(/*const*/target == /*const*/target);
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
+  S copy1 = /*const*/target;
+   

[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D114521#3151431 , @curdeius wrote:

> LGTM, but I have one question. You mentioned in the bug ticket comment that 
> "this exposes a greater issue in AllowShortXXX". Have you found other cases 
> that misbehave? If so, then it would probably be good to add them.

So when I took a look I think I stumbled on what @KyrBoh said below, but I'm 
not convinced its related. (so really want to deal with this separately)

What it seems is "AllowShortIfStatementsOnASingleLine" ONLY seems to work when 
there are no `{}`  (this seems to be by design 
https://clang.llvm.org/docs/ClangFormatStyleOptions.html)

i.e. for

  BasedOnStyle: LLVM
  AllowShortIfStatementsOnASingleLine: AllIfsAndElse
  ColumnLimit: 80

I get

  class Foo {
foo() {
  if (x) bar();
  if (x) {
bar();
  }
}
  };

So I think that was just me not understanding that limitation, (although I 
agree it doesn't seem to follow other options of a similar name)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM.
@KyrBoh, could you create a bug report for the problem you described, please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114105: [clang-tidy] Ignore narrowing conversions in case of bitfields

2021-11-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 389496.
steakhal edited the summary of this revision.
steakhal added a comment.

Bitshifts have nothing to do with this issue, thus I'm simply matching for 
bitfield -> `int` implicit casts due to promotions.


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

https://reviews.llvm.org/D114105

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-bitfields.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-bitfields.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-bitfields.cpp
@@ -0,0 +1,154 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-narrowing-conversions %t \
+// RUN:   -std=c++17 -- -target x86_64-unknown-linux
+
+#define CHAR_BITS 8
+static_assert(sizeof(unsigned int) == 32 / CHAR_BITS);
+
+template 
+struct is_same {
+  static constexpr bool value = false;
+};
+template 
+struct is_same {
+  static constexpr bool value = true;
+};
+
+template 
+static constexpr bool is_same_v = is_same::value;
+
+struct NoBitfield {
+  unsigned int id;
+};
+struct SmallBitfield {
+  unsigned int id : 4;
+};
+
+struct BigBitfield {
+  unsigned int id : 31;
+};
+struct CompleteBitfield {
+  unsigned int id : 32;
+};
+
+int example_warning(unsigned x) {
+  // CHECK-MESSAGES: :[[@LINE+1]]:10: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  return x;
+}
+
+void test_binary_and(SmallBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id & 1;
+  x.id & 1u;
+
+  1 & x.id;
+  1u & x.id;
+}
+
+void test_binary_or(SmallBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id | 1;
+  x.id | 1u;
+
+  1 | x.id;
+  1u | x.id;
+}
+
+void test(NoBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id << 1;
+  x.id << 1u;
+  x.id >> 1;
+  x.id >> 1u;
+  x.id + 1;
+  x.id + 1u;
+
+  1 << x.id;
+  1u << x.id;
+  1 >> x.id;
+  1u >> x.id;
+  1 + x.id;
+  1u + x.id;
+}
+
+void test(SmallBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id << 1;
+  x.id << 1u;
+  x.id >> 1;
+  x.id >> 1u;
+
+  x.id + 1;
+  x.id + 1u;
+
+  1 << x.id;
+  1u << x.id;
+  1 >> x.id;
+  1u >> x.id;
+
+  1 + x.id;
+  1u + x.id;
+}
+
+void test(BigBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id << 1;
+  x.id << 1u;
+  x.id >> 1;
+  x.id >> 1u;
+
+  x.id + 1;
+  x.id + 1u;
+
+  1 << x.id;
+  1u << x.id;
+  1 >> x.id;
+  1u >> x.id;
+
+  1 + x.id;
+  1u + x.id;
+}
+
+void test(CompleteBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+
+  x.id << 1;
+  x.id << 1u;
+  x.id >> 1;
+  x.id >> 1u;
+
+  x.id + 1;
+  x.id + 1u;
+
+  1 << x.id;
+  1u << x.id;
+  1 >> x.id;
+  1u >> x.id;
+
+  1 + x.id;
+  1u + x.id;
+}
+
+void test_parens(SmallBitfield x) {
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+  x.id << (2);
+  ((x.id)) << (2);
+
+  static_assert(is_same_v);
+  static_assert(is_same_v);
+  (2) << x.id;
+  (2) << ((x.id));
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
@@ -83,6 +83,46 @@
 binaryOperator(hasOperands(IsConversionFromIgnoredType,
hasType(isInteger();
 
+  // Bitfields are special. Due to integral promotion [conv.prom/5] bitfield
+  // member access expressions are frequently wrapped by an implicit cast to
+  // `int` if that type can represent all the values of the bitfield.
+  //
+  // Consider these examples:
+  //   struct SmallBitfield { unsigned int id : 4; };
+  //   x.id & 1; (case-1)
+  //   x.id & 1u;(case-2)
+  //   x.id << 1u;   (case-3)
+  //   (unsigned)x.id << 1;  (case-4)
+  //
+  // Due to the promotion rules, we would get a warning for case-1. It's
+  // debatable how useful this is, but the user at least has a convenient way of
+  // //fixing// it by adding the `u` unsigned-suffix to the literal as
+  // demonstrated by case-2. However, this won't work for shift operators like
+  // the one in case-3. In case of a normal binary operator, both operands
+  // contribute to the result type. However, the type of the shift expression is
+  // the promoted type of the left operand. One could still suppress this
+  // superfluous warning by explicitly casting the bitfield member access as
+  // case-4 demonstrates, but why? Th

[PATCH] D114105: [clang-tidy] Ignore narrowing conversions in case of bitfields

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

I think it's in pretty good shape, please have a look to help me move this 
forward.


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

https://reviews.llvm.org/D114105

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

However if we add

  AllowShortBlocksOnASingleLine : Always

then it will be

  class Foo {
foo() {
  if (x) bar();
  if (x) { bar(); }
}
  };

but if we set

  BasedOnStyle: LLVM
  AllowShortIfStatementsOnASingleLine: Never
  ColumnLimit: 80
  AllowShortBlocksOnASingleLine : Always

we get

  class Foo {
foo() {
  if (x)
bar();
  if (x) {
bar();
  }
}
  };

which feels like `if(x){ bar(); }` is primarily controlled by  
`AllowShortBlocksOnASingleLine`  i.e. setting it to `Never` will override the 
`AllowShortIfStatementsOnASingleLine` setting for if statements with braces.

However if `AllowShortBlocksOnASingleLine` is `Always` then if 
`AllowShortIfStatementsOnASingleLine` is set to `Never` then it wins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread Kyrylo Bohdanenko via Phabricator via cfe-commits
KyrBoh added a comment.

@MyDeveloperDay

> What it seems is "AllowShortIfStatementsOnASingleLine" ONLY seems to work 
> when there are no {}

AFAIR, there are 2 settings (in case of control statements):

- AllowShortBlocksOnASingleLine --> whether to treat (curly-)braced blocks as a 
single statement (i.e. allow them be one-liners)
- AllowShortIfStatementsOnASingleLine --> this actually tells whether control 
statements *can* be one-liners

So these two should be considered in pair. BTW, the documentation for 
AllowShortIfStatementsOnASingleLine seems to be a bit misleading

@curdeius 
Alright, I'll create a report


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[clang-tools-extra] 3b72448 - [clang-tidy] Add unit tests for `DeclRefExprUtils`.

2021-11-24 Thread Clement Courbet via cfe-commits

Author: Clement Courbet
Date: 2021-11-24T16:47:55+01:00
New Revision: 3b72448084052785b79566fa5bd374feb8ae3907

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

LOG: [clang-tidy] Add unit tests for `DeclRefExprUtils`.

In preparation for D114539.

Added: 
clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp

Modified: 
clang-tools-extra/unittests/clang-tidy/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt 
b/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
index 4a8d50f01473..6c9fa61cf92e 100644
--- a/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -20,6 +20,7 @@ add_extra_unittest(ClangTidyTests
   AddConstTest.cpp
   ClangTidyDiagnosticConsumerTest.cpp
   ClangTidyOptionsTest.cpp
+  DeclRefExprUtilsTest.cpp
   IncludeInserterTest.cpp
   GlobListTest.cpp
   GoogleModuleTest.cpp

diff  --git a/clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
new file mode 100644
index ..d47add410b2c
--- /dev/null
+++ b/clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
@@ -0,0 +1,315 @@
+#include "../clang-tidy/utils/DeclRefExprUtils.h"
+#include "ClangTidyDiagnosticConsumer.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+
+namespace {
+using namespace clang::ast_matchers;
+
+class ConstReferenceDeclRefExprsTransform : public ClangTidyCheck {
+public:
+  ConstReferenceDeclRefExprsTransform(StringRef CheckName,
+  ClangTidyContext *Context)
+  : ClangTidyCheck(CheckName, Context) {}
+
+  void registerMatchers(MatchFinder *Finder) override {
+Finder->addMatcher(varDecl(hasName("target")).bind("var"), this);
+  }
+
+  void check(const MatchFinder::MatchResult &Result) override {
+const auto *D = Result.Nodes.getNodeAs("var");
+using utils::decl_ref_expr::constReferenceDeclRefExprs;
+const auto const_decrefexprs = constReferenceDeclRefExprs(
+*D, *cast(D->getDeclContext())->getBody(),
+*Result.Context);
+
+for (const DeclRefExpr *const Expr : const_decrefexprs) {
+  assert(Expr);
+  diag(Expr->getBeginLoc(), "const usage")
+  << FixItHint::CreateInsertion(Expr->getBeginLoc(), "/*const*/");
+}
+  }
+};
+} // namespace
+
+namespace test {
+
+void RunTest(StringRef Snippet) {
+
+  StringRef CommonCode = R"(
+struct ConstTag{};
+struct NonConstTag{};
+
+struct S {
+  void constMethod() const;
+  void nonConstMethod();
+
+  void operator()(ConstTag) const;
+  void operator()(NonConstTag);
+
+  void operator[](int);
+  void operator[](int) const;
+
+  bool operator==(const S&) const;
+
+  int int_member;
+  int* ptr_member;
+
+};
+
+struct Derived : public S {
+
+};
+
+void useVal(S);
+void useRef(S&);
+void usePtr(S*);
+void usePtrPtr(S**);
+void usePtrConstPtr(S* const*);
+void useConstRef(const S&);
+void useConstPtr(const S*);
+void useConstPtrRef(const S*&);
+void useConstPtrPtr(const S**);
+void useConstPtrConstRef(const S* const&);
+void useConstPtrConstPtr(const S* const*);
+
+void useInt(int);
+void useIntRef(int&);
+void useIntConstRef(const int&);
+void useIntPtr(int*);
+void useIntConstPtr(const int*);
+
+)";
+
+  std::string Code = (CommonCode + Snippet).str();
+
+  llvm::SmallVector Parts;
+  StringRef(Code).split(Parts, "/*const*/");
+
+  EXPECT_EQ(Code, runCheckOnCode(
+  join(Parts, "")));
+}
+
+TEST(ConstReferenceDeclRefExprsTest, ConstValueVar) {
+  RunTest(R"(
+void f(const S target) {
+  useVal(/*const*/target);
+  useConstRef(/*const*/target);
+  useConstPtr(&target);
+  useConstPtrConstRef(&target);
+  /*const*/target.constMethod();
+  /*const*/target(ConstTag{});
+  /*const*/target[42];
+  useConstRef((/*const*/target));
+  (/*const*/target).constMethod();
+  (void)(/*const*/target == /*const*/target);
+  (void)target;
+  (void)⌖
+  (void)*⌖
+  S copy1 = /*const*/target;
+  S copy2(/*const*/target);
+  useInt(target.int_member);
+  useIntConstRef(target.int_member);
+  useIntPtr(target.ptr_member);
+  useIntConstPtr(&target.int_member);
+}
+)");
+}
+
+TEST(ConstReferenceDeclRefExprsTest, ConstRefVar) {
+  RunTest(R"(
+void f(const S& target) {
+  useVal(/*const*/target);
+  useConstRef(/*const*/target);
+  useConstPtr(&target);
+ 

[PATCH] D114540: Big-endian version of vpermxor

2021-11-24 Thread Tarique Islam via Phabricator via cfe-commits
tislam created this revision.
tislam added a reviewer: nemanjai.
Herald added subscribers: kbarton, hiraditya.
tislam requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

A big-endian version of `vpermxor`, named `vpermxor_be`, is added to LLVM and 
Clang. `vpermxor_be` can be called directly on a little-endian platform.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114540

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/crypto_bifs_be.ll

Index: llvm/test/CodeGen/PowerPC/crypto_bifs_be.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/crypto_bifs_be.ll
@@ -0,0 +1,94 @@
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+
+; Function Attrs: nounwind
+define <16 x i8> @test_vpermxorb() #0 {
+entry:
+  %a = alloca <16 x i8>, align 16
+  %b = alloca <16 x i8>, align 16
+  %c = alloca <16 x i8>, align 16
+  store <16 x i8> , <16 x i8>* %a, align 16
+  store <16 x i8> , <16 x i8>* %b, align 16
+  store <16 x i8> , <16 x i8>* %c, align 16
+  %0 = load <16 x i8>,  <16 x i8>* %a, align 16
+  %1 = load <16 x i8>,  <16 x i8>* %b, align 16
+  %2 = load <16 x i8>,  <16 x i8>* %c, align 16
+  %3 = call <16 x i8> @llvm.ppc.altivec.crypto.vpermxor.be(<16 x i8> %0, <16 x i8> %1, <16 x i8> %2)
+  ret <16 x i8> %3
+; CHECK-NOT: xxlnor
+; CHECK: vpermxor 2,
+}
+
+; Function Attrs: nounwind readnone
+declare <16 x i8> @llvm.ppc.altivec.crypto.vpermxor.be(<16 x i8>, <16 x i8>, <16 x i8>) #1
+
+; Function Attrs: nounwind
+define <8 x i16> @test_vpermxorh() #0 {
+entry:
+  %a = alloca <8 x i16>, align 16
+  %b = alloca <8 x i16>, align 16
+  %c = alloca <8 x i16>, align 16
+  store <8 x i16> , <8 x i16>* %a, align 16
+  store <8 x i16> , <8 x i16>* %b, align 16
+  store <8 x i16> , <8 x i16>* %c, align 16
+  %0 = load <8 x i16>,  <8 x i16>* %a, align 16
+  %1 = bitcast <8 x i16> %0 to <16 x i8>
+  %2 = load <8 x i16>,  <8 x i16>* %b, align 16
+  %3 = bitcast <8 x i16> %2 to <16 x i8>
+  %4 = load <8 x i16>,  <8 x i16>* %c, align 16
+  %5 = bitcast <8 x i16> %4 to <16 x i8>
+  %6 = call <16 x i8> @llvm.ppc.altivec.crypto.vpermxor.be(<16 x i8> %1, <16 x i8> %3, <16 x i8> %5)
+  %7 = bitcast <16 x i8> %6 to <8 x i16>
+  ret <8 x i16> %7
+; CHECK-NOT: xxlnor
+; CHECK: vpermxor 2,
+}
+
+; Function Attrs: nounwind
+define <4 x i32> @test_vpermxorw() #0 {
+entry:
+  %a = alloca <4 x i32>, align 16
+  %b = alloca <4 x i32>, align 16
+  %c = alloca <4 x i32>, align 16
+  store <4 x i32> , <4 x i32>* %a, align 16
+  store <4 x i32> , <4 x i32>* %b, align 16
+  store <4 x i32> , <4 x i32>* %c, align 16
+  %0 = load <4 x i32>,  <4 x i32>* %a, align 16
+  %1 = bitcast <4 x i32> %0 to <16 x i8>
+  %2 = load <4 x i32>,  <4 x i32>* %b, align 16
+  %3 = bitcast <4 x i32> %2 to <16 x i8>
+  %4 = load <4 x i32>,  <4 x i32>* %c, align 16
+  %5 = bitcast <4 x i32> %4 to <16 x i8>
+  %6 = call <16 x i8> @llvm.ppc.altivec.crypto.vpermxor.be(<16 x i8> %1, <16 x i8> %3, <16 x i8> %5)
+  %7 = bitcast <16 x i8> %6 to <4 x i32>
+  ret <4 x i32> %7
+; CHECK-NOT: xxlnor
+; CHECK: vpermxor 2,
+}
+
+; Function Attrs: nounwind
+define <2 x i64> @test_vpermxord() #0 {
+entry:
+  %a = alloca <2 x i64>, align 16
+  %b = alloca <2 x i64>, align 16
+  %c = alloca <2 x i64>, align 16
+  store <2 x i64> , <2 x i64>* %a, align 16
+  store <2 x i64> , <2 x i64>* %b, align 16
+  store <2 x i64> , <2 x i64>* %c, align 16
+  %0 = load <2 x i64>,  <2 x i64>* %a, align 16
+  %1 = bitcast <2 x i64> %0 to <16 x i8>
+  %2 = load <2 x i64>,  <2 x i64>* %b, align 16
+  %3 = bitcast <2 x i64> %2 to <16 x i8>
+  %4 = load <2 x i64>,  <2 x i64>* %c, align 16
+  %5 = bitcast <2 x i64> %4 to <16 x i8>
+  %6 = call <16 x i8> @llvm.ppc.altivec.crypto.vpermxor.be(<16 x i8> %1, <16 x i8> %3, <16 x i8> %5)
+  %7 = bitcast <16 x i8> %6 to <2 x i64>
+  ret <2 x i64> %7
+; CHECK-NOT: xxlnor
+; CHECK: vpermxor 2,
+}
+
+attributes #0 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { nounwind readnone }
Index: llvm/lib/Target/PowerPC/PPCInstrVSX.td
===
--- llvm/lib/Target/PowerPC/PPCInstrVSX.td
+++ llvm/lib/Target/PowerPC/PPCInstrVSX.td
@@ -2491,11 +2491,16 @@
 
 // These Altivec patterns are here because we need a VSX instruction to match
 // the intrinsic (but only for little endian system).
-let Predicates = [HasVSX, IsLittleEndian, HasP8Altivec] in
+let Predicates = [HasVSX, IsLittleEndian, HasP

[PATCH] D114481: [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-24 Thread David Tenty via Phabricator via cfe-commits
daltenty accepted this revision.
daltenty added a comment.
This revision is now accepted and ready to land.

LGTM, with minor nit.




Comment at: clang/test/ClangScanDeps/modules-pch-common-submodule.c:1
+// UNSUPPORTED: aix
+

Let's add a comment, to let folks know what's going on with these. Something 
like:

// Unsupported on AIX because we don't support the requisite __clangast section 
in XCOFF yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114481

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


[PATCH] D114539: [clang-tidy] performance-unnecessary-copy-initialization: handle pointer containers.

2021-11-24 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 389504.
courbet added a comment.

Rebase on submitted unit tests so that we can see the changes better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114539

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
  clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
@@ -101,23 +101,23 @@
 void f(const S target) {
   useVal(/*const*/target);
   useConstRef(/*const*/target);
-  useConstPtr(&target);
-  useConstPtrConstRef(&target);
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
   /*const*/target.constMethod();
   /*const*/target(ConstTag{});
   /*const*/target[42];
   useConstRef((/*const*/target));
   (/*const*/target).constMethod();
   (void)(/*const*/target == /*const*/target);
-  (void)target;
-  (void)⌖
-  (void)*⌖
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
-  useIntConstPtr(&target.int_member);
+  useIntConstPtr(&/*const*/target.int_member);
 }
 )");
 }
@@ -127,23 +127,23 @@
 void f(const S& target) {
   useVal(/*const*/target);
   useConstRef(/*const*/target);
-  useConstPtr(&target);
-  useConstPtrConstRef(&target);
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
   /*const*/target.constMethod();
   /*const*/target(ConstTag{});
   /*const*/target[42];
   useConstRef((/*const*/target));
   (/*const*/target).constMethod();
   (void)(/*const*/target == /*const*/target);
-  (void)target;
-  (void)⌖
-  (void)*⌖
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
-  useIntConstPtr(&target.int_member);
+  useIntConstPtr(&/*const*/target.int_member);
 }
 )");
 }
@@ -153,8 +153,8 @@
 void f(S target, const S& other) {
   useConstRef(/*const*/target);
   useVal(/*const*/target);
-  useConstPtr(&target);
-  useConstPtrConstRef(&target);
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
   /*const*/target.constMethod();
   target.nonConstMethod();
   /*const*/target(ConstTag{});
@@ -167,15 +167,15 @@
   (/*const*/target).constMethod();
   (void)(/*const*/target == /*const*/target);
   (void)(/*const*/target == other);
-  (void)target;
-  (void)⌖
-  (void)*⌖
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
-  useIntConstPtr(&target.int_member);
+  useIntConstPtr(&/*const*/target.int_member);
 }
 )");
 }
@@ -185,8 +185,8 @@
 void f(S& target) {
   useVal(/*const*/target);
   useConstRef(/*const*/target);
-  useConstPtr(&target);
-  useConstPtrConstRef(&target);
+  useConstPtr(&/*const*/target);
+  useConstPtrConstRef(&/*const*/target);
   /*const*/target.constMethod();
   target.nonConstMethod();
   /*const*/target(ConstTag{});
@@ -194,15 +194,15 @@
   useConstRef((/*const*/target));
   (/*const*/target).constMethod();
   (void)(/*const*/target == /*const*/target);
-  (void)target;
-  (void)⌖
-  (void)*⌖
+  (void)/*const*/target;
+  (void)&/*const*/target;
+  (void)*&/*const*/target;
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
-  useIntConstPtr(&target.int_member);
+  useIntCons

[PATCH] D114539: [clang-tidy] performance-unnecessary-copy-initialization: handle pointer containers.

2021-11-24 Thread Felix Berger via Phabricator via cfe-commits
flx added a comment.

This looks great, but goes past my knowledge of the AST API :) While the 
existing and new test coverage provides good confidence, one other reviewer 
taking look would be good.




Comment at: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp:112
+  switch (
+  E->ClassifyModifiable(Finder->getASTContext(), Loc).getModifiable()) 
{
+  case Expr::Classification::CM_Untested:

Reuse Ctx here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114539

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


[clang] 6b96b2a - [clang][AST] Check context of record in structural equivalence.

2021-11-24 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-11-24T17:36:15+01:00
New Revision: 6b96b2a0bf65ff838d4dbf909a5120d4d1083e29

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

LOG: [clang][AST] Check context of record in structural equivalence.

The AST structural equivalence check did not differentiate between
a struct and a struct with same name in different namespace. When
type of a member is checked it is possible to encounter such a case
and wrongly decide that the types are similar. This problem is fixed
by check for the namespaces of a record declaration.

Reviewed By: martong

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

Added: 


Modified: 
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/unittests/AST/StructuralEquivalenceTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTStructuralEquivalence.cpp 
b/clang/lib/AST/ASTStructuralEquivalence.cpp
index e85feb779190f..7fd24e2aa9ad2 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1347,6 +1347,42 @@ 
IsStructurallyEquivalentLambdas(StructuralEquivalenceContext &Context,
   return true;
 }
 
+/// Determine if context of a class is equivalent.
+static bool IsRecordContextStructurallyEquivalent(RecordDecl *D1,
+  RecordDecl *D2) {
+  // The context should be completely equal, including anonymous and inline
+  // namespaces.
+  // We compare objects as part of full translation units, not subtrees of
+  // translation units.
+  DeclContext *DC1 = D1->getDeclContext()->getNonTransparentContext();
+  DeclContext *DC2 = D2->getDeclContext()->getNonTransparentContext();
+  while (true) {
+// Special case: We allow a struct defined in a function to be equivalent
+// with a similar struct defined outside of a function.
+if ((DC1->isFunctionOrMethod() && DC2->isTranslationUnit()) ||
+(DC2->isFunctionOrMethod() && DC1->isTranslationUnit()))
+  return true;
+
+if (DC1->getDeclKind() != DC2->getDeclKind())
+  return false;
+if (DC1->isTranslationUnit())
+  break;
+if (DC1->isInlineNamespace() != DC2->isInlineNamespace())
+  return false;
+if (const auto *ND1 = dyn_cast(DC1)) {
+  const auto *ND2 = cast(DC2);
+  if (!DC1->isInlineNamespace() &&
+  !IsStructurallyEquivalent(ND1->getIdentifier(), 
ND2->getIdentifier()))
+return false;
+}
+
+DC1 = DC1->getParent()->getNonTransparentContext();
+DC2 = DC2->getParent()->getNonTransparentContext();
+  }
+
+  return true;
+}
+
 /// Determine structural equivalence of two records.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
  RecordDecl *D1, RecordDecl *D2) {
@@ -1386,6 +1422,12 @@ static bool 
IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
 }
   }
 
+  // If the records occur in 
diff erent context (namespace), these should be
+  // 
diff erent. This is specially important if the definition of one or both
+  // records is missing.
+  if (!IsRecordContextStructurallyEquivalent(D1, D2))
+return false;
+
   // If both declarations are class template specializations, we know
   // the ODR applies, so check the template and template arguments.
   const auto *Spec1 = dyn_cast(D1);

diff  --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp 
b/clang/unittests/AST/StructuralEquivalenceTest.cpp
index 9ae0da8b9dd2c..2f5b5c1460950 100644
--- a/clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -929,6 +929,136 @@ TEST_F(StructuralEquivalenceTest, ExplicitBoolSame) {
   EXPECT_TRUE(testStructuralMatch(First, Second));
 }
 
+struct StructuralEquivalenceRecordContextTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNoVsNamed) {
+  auto Decls = makeDecls("class X;", "namespace N { class X; }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNamedVsNamed) {
+  auto Decls = makeDecls("namespace A { class X; }",
+"namespace B { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsNamed) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace N { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNoVsAnon) {
+  auto Decls = makeDe

[PATCH] D113118: [clang][AST] Check context of record in structural equivalence.

2021-11-24 Thread Balázs Kéri 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 rG6b96b2a0bf65: [clang][AST] Check context of record in 
structural equivalence. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113118

Files:
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -929,6 +929,136 @@
   EXPECT_TRUE(testStructuralMatch(First, Second));
 }
 
+struct StructuralEquivalenceRecordContextTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNoVsNamed) {
+  auto Decls = makeDecls("class X;", "namespace N { class X; }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNamedVsNamed) {
+  auto Decls = makeDecls("namespace A { class X; }",
+"namespace B { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsNamed) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace N { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNoVsAnon) {
+  auto Decls = makeDecls("class X;", "namespace { class X; }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsAnon) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsAnonAnon) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace { namespace { class X; } }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest,
+   NamespaceNamedNamedVsNamedNamed) {
+  auto Decls = makeDecls(
+  "namespace A { namespace N { class X; } }",
+  "namespace B { namespace N { class X; } }", Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNamedVsInline) {
+  auto Decls = makeDecls(
+  "namespace A { namespace A { class X; } }",
+  "namespace A { inline namespace A { class X; } }", Lang_CXX17,
+  cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceInlineVsInline) {
+  auto Decls = makeDecls(
+  "namespace A { inline namespace A { class X; } }",
+  "namespace A { inline namespace B { class X; } }", Lang_CXX17,
+  cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceInlineTopLevel) {
+  auto Decls = makeDecls("inline namespace A { class X; } }",
+"inline namespace B { class X; } }",
+Lang_CXX17, cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, TransparentContext) {
+  auto Decls = makeDecls("extern \"C\" { class X; }", "class X;",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, TransparentContextNE) {
+  auto Decls = makeDecls("extern \"C\" { class X; }",
+"namespace { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, TransparentContextInNamespace) {
+  auto Decls = makeDecls(
+  "extern \"C\" { namespace N { class X; } }",
+  "namespace N { extern \"C\" { class X; } }", Lang_CXX03, cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceTest, NamespaceOfRecordMember) {
+  auto Decls = makeDecls(
+  R"(
+  class X;
+  class Y { X* x; };
+  )",
+  R"(
+  namespace N { class X; }
+  class Y { N::X* x; };
+ 

[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.



> @curdeius 
> Alright, I'll create a report https://bugs.llvm.org/show_bug.cgi?id=52598

That is related. But I'd rather handle it separately because the fix for the 
function and the fix for a while or if will need to be different.

It really comes down to this line..

  if (Line.First == Line.Last && Line.First->isNot(TT_FunctionLBrace)

in the if case and in the while case the `{` isn't labeled like it is for the 
function

  M=0 C=0 T=Unknown S=1 F=0 B=0 BK=1 P=0 Name=l_brace L=1 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='{'

To be honest this is something we should think about, if every `{` and `}` 
every `(`,`)` and `[`,`]` got given a Type labels this would be super good at 
disambiguating them

This is not something new, we've been doing it with the ')' of a cstyle cast 
for years `CastRParen`

  M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=int L=3 PPK=2 FakeLParens=2/ 
FakeRParens=0 II=0x25a969b1660 Text='int'
  M=0 C=1 T=StartOfName S=1 F=0 B=0 BK=0 P=220 Name=identifier L=5 PPK=2 
FakeLParens= FakeRParens=0 II=0x25a969b8768 Text='a'
  M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=22 Name=equal L=7 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='='
  M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=22 Name=l_paren L=9 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='('
  M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=59 Name=int L=12 PPK=2 FakeLParens= 
FakeRParens=0 II=0x25a969b1660 Text='int'
  M=0 C=0 T=CastRParen S=0 F=0 B=0 BK=0 P=43 Name=r_paren L=13 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text=')'

but in this case, the real problem here is that `Multiline`  just too lax, 
basically Multiline doesn't in my view seem to be doing what it expects

F20680737: image.png 

From this is seems it should ONLY be returning 0 (meaning don't join the line), 
if the "clause" in the (if,for,while) contains multiple conditions that have 
been broken over several lines.

I just don't think this is sufficiently constrained.

  // Don't merge a trailing multi-line control statement block like:
  // } else if (foo &&
  //bar)
  // { <-- current Line
  //   baz();
  // }
  if (Line.First == Line.Last  &&
  Style.BraceWrapping.AfterControlStatement ==
  FormatStyle::BWACS_MultiLine)
return 0;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114540: Big-endian version of vpermxor

2021-11-24 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

Please also add a test for this builtin to the front end test 
`clang/test/CodeGen/builtins-ppc-crypto.c`




Comment at: llvm/lib/Target/PowerPC/PPCInstrVSX.td:2499
  (COPY_TO_REGCLASS $c, VSRC>;
+  def : Pat<(v16i8 (int_ppc_altivec_crypto_vpermxor_be v16i8:$a,
+v16i8:$b, v16i8:$c)),

Although it would be redundant, it is not invalid to use this builtin/intrinsic 
in BE compilations. As such, please move this to a block that has only the
`[HasVSX, HasP8Altivec]` predicates as the desired code is the same for LE/BE.



Comment at: llvm/test/CodeGen/PowerPC/crypto_bifs_be.ll:9
+entry:
+  %a = alloca <16 x i8>, align 16
+  %b = alloca <16 x i8>, align 16

Please clean up this test case a bit:
- Run `opt --passes="default"` on it to clean up the unnecessary code
- Remove the attributes
- The 755 permissions on the test case are unusual
- Produce the CHECK's automatically using 
`$LLVM_SRC/utils/update_llc_test_checks.py`
- Add a BE invocation (either the P8 or the P9 can just use the 
`powerpc64-unknown-linux-gnu` triple)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114540

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


[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think the problem here is encapsulated by adding the following tests

   Style.BraceWrapping.AfterFunction = true;
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_AllIfsAndElse;
   Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Always;
   Style.AllowShortLoopsOnASingleLine = true;
   Style.ColumnLimit = 80;
  
   Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
   verifyFormat("void shortfunction() { bar(); }", Style);
   verifyFormat("if (x) { bar(); }", Style);
   verifyFormat("for (;;) { bar(); }", Style);
   verifyFormat("while (true) { bar(); }", Style);
   Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
   verifyFormat("void shortfunction() { bar(); }", Style);
   verifyFormat("if (x) { bar(); }", Style);
  >>> FAILS  ^^^
  
   verifyFormat("for (;;) { bar(); }", Style);
  >>> FAILS  ^^^
  
   verifyFormat("while (true) { bar(); }", Style);
  >>> FAILS  ^^^
  
   Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
   Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   Style.AllowShortLoopsOnASingleLine = false;
   verifyFormat("void shortfunction()\n"
"{\n"
"  foo();\n"
"}",
Style);
   verifyFormat("if (x) {\n"
"  foo();\n"
"}",
Style);
   verifyFormat("for (;;) {\n"
"  foo();\n"
"}",
Style);
   verifyFormat("while (true) {\n"
"  foo();\n"
"}",
Style);
  
   Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
   verifyFormat("void shortfunction()\n"
"{\n"
"  foo();\n"
"}",
Style);
   verifyFormat("if (x) {\n"
"  foo();\n"
"}",
Style);
   verifyFormat("for (;;) {\n"
"  foo();\n"
"}",
Style);
   verifyFormat("while (true) {\n"
"  foo();\n"
"}",
Style);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521

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


[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-24 Thread Jesses Gott via Phabricator via cfe-commits
jessesna added a comment.

In D114320#3148046 , @MyDeveloperDay 
wrote:

> Ok now I'm a little puzzled, shouldn't this be covered by 
> `AllowShortIfStatementsOnASingleLine`?

That's exactly what i thought when i first stumbled over the behavior :D But I 
think the majority of users might not even consider adding empty else blocks. 
Only a few either just do it or have to comply with some standards, f.e. MISRA 
 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-11-24 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 389520.

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

https://reviews.llvm.org/D109372

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/riscv-overlay.c
  clang/test/Driver/riscv-overlay.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/riscv-overlay-attr.c
  clang/test/Sema/riscv-overlay-namespace.cpp

Index: clang/test/Sema/riscv-overlay-namespace.cpp
===
--- /dev/null
+++ clang/test/Sema/riscv-overlay-namespace.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only -moverlay
+// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only -moverlay
+
+namespace {
+class foo {
+public:
+  static int X() __attribute__((overlay_call)) { return 0; } // expected-error {{functions marked with 'overlay_call' attribute must have external linkage}}
+};
+} // end of anonymous namespace
+
+namespace X {
+class bar {
+public:
+  static int X() __attribute__((overlay_call)) { return 1; }
+};
+} // end of namespace X
+
+extern "C" {
+int main(void) { return foo::X() + X::bar::X(); }
+}
Index: clang/test/Sema/riscv-overlay-attr.c
===
--- /dev/null
+++ clang/test/Sema/riscv-overlay-attr.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple riscv32 -moverlay -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64 -moverlay -fsyntax-only -verify %s
+
+int notAFunction __attribute__((overlay_call));
+// expected-warning@-1 {{'overlay_call' attribute only applies to functions}}
+
+void incompatForwardDecl(int x);
+void __attribute__((overlay_call)) incompatForwardDecl(int x) {}
+// expected-error@-1 {{redeclaration of 'incompatForwardDecl' must not have the 'overlay_call' attribute}}
+// expected-note@-3 {{previous definition is here}}
+
+static void staticcall() __attribute__((overlay_call)) {}
+// expected-error@-1 {{functions marked with 'overlay_call' attribute must have external linkage}}
+
+static void __attribute__((overlay_call)) staticcall2() {}
+// expected-error@-1 {{functions marked with 'overlay_call' attribute must have external linkage}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -147,6 +147,7 @@
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PatchableFunctionEntry (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: RISCVOverlayCall (SubjectMatchRule_function)
 // CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
Index: clang/test/Driver/riscv-overlay.c
===
--- /dev/null
+++ clang/test/Driver/riscv-overlay.c
@@ -0,0 +1,5 @@
+// Check that ComRV Driver Arguments
+
+// RUN: not %clang -target riscv32 -moverlay %s -o %t.o -mabi=ilp32f 2>&1 \
+// RUN:   | FileCheck -check-prefix=INVALID-ABI %s
+// INVALID-ABI: invalid ABI 'ilp32f' when using '-moverlay'
Index: clang/test/CodeGen/riscv-overlay.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-overlay.c
@@ -0,0 +1,11 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes
+// RUN: %clang_cc1 -triple riscv32 -moverlay -emit-llvm %s -o - \
+// RUN:| FileCheck %s
+
+// CHECK-LABEL: @test_overlay_func(
+// CHECK-SAME: #0
+// CHECK: attributes #0 = {
+// CHECK-SAME: "overlay"
+int __attribute__((overlay_call)) test_overlay_func(void) {
+  return 5;
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2039,6 +2039,33 @@
   D->addAttr(::new (S.Context) CmseNSEntryAttr(S.Context, AL));
 }
 
+static void handleRISCVOverlayAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!S.getLangOpts().Overlay) {
+S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored_overlay)
+<< AL;
+return;
+  }
+
+  if (isFunctionOrMethod(D)) {
+ 

[PATCH] D114234: [clang][dataflow] Add base types for building dataflow analyses

2021-11-24 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 389522.
sgatev marked an inline comment as done.
sgatev added a comment.

Document the role of the "Dynamic" suffix in the name of 
DataflowAnalysisDynamic and its members.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114234

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/Environment.h
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysis.cpp

Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysis.cpp
===
--- /dev/null
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysis.cpp
@@ -0,0 +1,34 @@
+//===- DataflowAnalysis.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines base types for building dataflow analyses that run over
+//  Control-Flow Graphs (CFGs).
+//
+//===--===//
+
+#include 
+
+#include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
+#include "clang/Analysis/FlowSensitive/Environment.h"
+#include "llvm/ADT/Optional.h"
+
+using namespace clang;
+using namespace dataflow;
+
+std::vector>
+runDataflowAnalysis(const CFG &Cfg, DataflowAnalysisDynamic &Analysis,
+const Environment &InitEnv) {
+  // FIXME: Consider enforcing that `Cfg` meets the requirements that
+  // are specified in the header. This could be done by remembering
+  // what options were used to build `Cfg` and asserting on them here.
+
+  // FIXME: Implement work list-based algorithm to compute the fixed
+  // point of `Analysis::transform` for every basic block in `Cfg`.
+  return {};
+}
Index: clang/lib/Analysis/FlowSensitive/CMakeLists.txt
===
--- /dev/null
+++ clang/lib/Analysis/FlowSensitive/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_clang_library(clangAnalysisFlowSensitive
+  DataflowAnalysis.cpp
+
+  LINK_LIBS
+  clangAnalysis
+  clangAST
+  )
Index: clang/lib/Analysis/CMakeLists.txt
===
--- clang/lib/Analysis/CMakeLists.txt
+++ clang/lib/Analysis/CMakeLists.txt
@@ -44,3 +44,4 @@
   )
 
 add_subdirectory(plugins)
+add_subdirectory(FlowSensitive)
Index: clang/include/clang/Analysis/FlowSensitive/Environment.h
===
--- /dev/null
+++ clang/include/clang/Analysis/FlowSensitive/Environment.h
@@ -0,0 +1,27 @@
+//===-- Environment.h ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines an Environment class that is used by dataflow analyses
+//  that run over Control-Flow Graphs (CFGs) to keep track of the state of the
+//  program at given program points.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ENVIRONMENT_H
+#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ENVIRONMENT_H
+
+namespace clang {
+namespace dataflow {
+
+/// Holds the state of the program (store and heap) at a given program point.
+class Environment {};
+
+} // namespace dataflow
+} // namespace clang
+
+#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ENVIRONMENT_H
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
===
--- /dev/null
+++ clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
@@ -0,0 +1,167 @@
+//===- DataflowAnalysis.h ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines base types for building dataflow analyses that run over
+//  Control-Flow Graphs (CFGs).
+//
+//===--===//
+
+#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWANALYSIS_H
+#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWANALYSIS_H
+
+#include 
+#include 
+
+#i

[PATCH] D114454: [NFC][AIX]Disable unstable CSA tests failing on AIX

2021-11-24 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

> Let me summon them.

*I have no memory of this place.*

Sorry to disappoint.  That blame was four years ago, not counting covid-related 
time dilation.

I do agree that disabling a test just to please a static analyzer is probably 
not the best way to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114454

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


[PATCH] D108479: [Clang] Add __builtin_addressof_nocfi

2021-11-24 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen planned changes to this revision.
samitolvanen added a comment.

In D108479#3150298 , @rjmccall wrote:

> Your builtin is using custom type-checking (`t`), which suppresses all the 
> normal conversions that happen on expressions.  Specifically, it skips 
> lvalue-to-rvalue conversion, so in this example the argument ends up being an 
> l-value reference to a variable rather than an r-value loaded from that 
> variable.

OK, that explains it. Thanks for the explanation!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108479

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


[PATCH] D114481: [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-24 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 389535.
stevewan added a comment.

Explain the rationale


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114481

Files:
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/PCH/debug-info-pch-path.c


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 06d4a76 - [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-24 Thread Steven Wan via cfe-commits

Author: Steven Wan
Date: 2021-11-24T13:22:09-05:00
New Revision: 06d4a76309cd97e25859770b3da29006ccac421a

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

LOG: [NFC][AIX]Disable precompiled module file tests on AIX

The PCH reader looks for `__clangast` section in the precompiled module file, 
which is not present in the file on AIX, and we don't support writing this 
custom section in XCOFF yet.

Reviewed By: daltenty

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

Added: 


Modified: 
clang/test/ClangScanDeps/modules-pch-common-submodule.c
clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
clang/test/ClangScanDeps/modules-pch.c
clang/test/PCH/debug-info-pch-path.c

Removed: 




diff  --git a/clang/test/ClangScanDeps/modules-pch-common-submodule.c 
b/clang/test/ClangScanDeps/modules-pch-common-submodule.c
index 0189ab346ac01..c7f3e76cf0a15 100644
--- a/clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ b/clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause

diff  --git a/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c 
b/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
index 3d35ede3b67c9..e63e310b22d09 100644
--- a/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ b/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.

diff  --git a/clang/test/ClangScanDeps/modules-pch.c 
b/clang/test/ClangScanDeps/modules-pch.c
index 755ddeea67c56..2be17743a64b9 100644
--- a/clang/test/ClangScanDeps/modules-pch.c
+++ b/clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 

diff  --git a/clang/test/PCH/debug-info-pch-path.c 
b/clang/test/PCH/debug-info-pch-path.c
index 272d9ac1ab7cf..192d5c79d4819 100644
--- a/clang/test/PCH/debug-info-pch-path.c
+++ b/clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t



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


[PATCH] D114481: [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-24 Thread Steven Wan 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 rG06d4a76309cd: [NFC][AIX]Disable precompiled module file 
tests on AIX (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114481

Files:
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/PCH/debug-info-pch-path.c


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114100: [NFC][clang-tools-extra] Inclusive language: replace master with main

2021-11-24 Thread Quinn Pham via Phabricator via cfe-commits
quinnp added a comment.

@sammccall could you take a look at the other changes when you have time? 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114100

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


[PATCH] D114546: [OPENMP]Fix PR52117: Crash caused by target region inside of task construct.

2021-11-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, mikerice.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Need to do the analysis of the captured expressions in the clauses.
Previously the compiler ignored them and it may lead to a compiler crash
trying to get the address of the mapped variables.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114546

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/Analysis/cfg-openmp.cpp
  clang/test/OpenMP/task_target_device_codegen.c
  clang/test/OpenMP/taskloop_codegen.cpp

Index: clang/test/OpenMP/taskloop_codegen.cpp
===
--- clang/test/OpenMP/taskloop_codegen.cpp
+++ clang/test/OpenMP/taskloop_codegen.cpp
@@ -238,8 +238,8 @@
 // CHECK-LABEL: taskloop_with_class
 void taskloop_with_class() {
   St s1;
-  // CHECK: [[TD:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 [[GTID:%.+]], i32 1, i64 88, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, [[TD_TYPE:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
-  // CHECK: call void @__kmpc_taskloop(%struct.ident_t* @{{.+}}, i32 [[GTID]], i8* [[TD]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, i8* bitcast (void ([[TD_TYPE]]*, [[TD_TYPE]]*, i32)* @{{.+}} to i8*))
+  // CHECK: [[TD:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 [[GTID:%.+]], i32 1, i64 80, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, [[TD_TYPE:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
+  // CHECK: call void @__kmpc_taskloop(%struct.ident_t* @{{.+}}, i32 [[GTID]], i8* [[TD]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, i8* null)
 #pragma omp taskloop
   for (St s = St(); s < s1; s += 1) {
   }
Index: clang/test/OpenMP/task_target_device_codegen.c
===
--- /dev/null
+++ clang/test/OpenMP/task_target_device_codegen.c
@@ -0,0 +1,105 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[   .].+[.|,]" --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-version=50 -x c -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fopenmp-version=50 -x c -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+void test_task_affinity() {
+  int t;
+#pragma omp task
+  {
+#pragma omp target device(t)
+;
+  }
+}
+#endif
+// CHECK-LABEL: define {{[^@]+}}@test_task_affinity
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[T:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 1
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]], i32 1, i64 48, i64 0, i32 (i32, i8*)* bitcast (i32 (i32, %struct.kmp_task_t_with_privates*)* @.omp_task_entry. to i32 (i32, i8*)*))
+// CHECK-NEXT:[[TMP2:%.*]] = bitcast i8* [[TMP1]] to %struct.kmp_task_t_with_privates*
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], %struct.kmp_task_t_with_privates* [[TMP2]], i32 0, i32 0
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T_WITH_PRIVATES]], %struct.kmp_task_t_with_privates* [[TMP2]], i32 0, i32 1
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds [[STRUCT__KMP_PRIVATES_T:%.*]], %struct..kmp_privates.t* [[TMP4]], i32 0, i32 0
+// CHECK-NEXT:[[TMP6:%.*]] = load i32, i32* [[T]], align 4
+// CHECK-NEXT:store i32 [[TMP6]], i32* [[TMP5]], align 8
+// CHECK-NEXT:[[TMP7:%.*]] = call i32 @__kmpc_omp_task(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]], i8* [[TMP1]])
+// CHECK-NEXT:ret void
+//
+//
+// CHECK-LABEL: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_test_task_affinity_l18
+// CHECK-SAME: () #[[ATTR1:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+//
+// CHECK-LABEL: define {{[^@]+}}@.omp_task

[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-24 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

tra wrote:
> mojca wrote:
> > kadircet wrote:
> > > looks like the list is getting big and hard to maintain. considering that 
> > > this is done only once per compiler invocation (and we check for 
> > > existence of directories down in the loop anyway). what about throwing in 
> > > an extra directory listing to base-directories mentioned down below and 
> > > populate `Candidates` while preserving the newest-version-first order?
> > I totally agree with the sentiment, and that was my initial thought as 
> > well, but with zero experience I was too scared to make any more 
> > significant changes.
> > 
> > I can try to come up with a new patch (that doesn't need further 
> > maintenance whenever a new CUDA version gets released) if that's what you 
> > are suggesting. I would nevertheless merge this one, and prepare a new more 
> > advanced patch separately, but that's finally your call.
> > 
> > What's your suggestion about D.SysRoot + "Program Files/..."? At the time 
> > when this function gets called it looks like D.SysRoot is empty (or at 
> > least my debugger says so) and in my case it resolves to D: while the CUDA 
> > support is installed under C:.
> > 
> > Is there any special LLVM-specific/preferrable way to iterate through 
> > directories?
> > 
> > (What I also miss a bit in the whole process in an option to simply say "I 
> > want CUDA 11.1" without the need to explicitly spell out the full path.)
> > 
> > If you provide me give some general guidelines, I'll prepare another, 
> > hopefully more future-proof patch.
> > 
> > (Side note: I'm not sure if I'm calling clang-format correctly, but if I 
> > call it, it keeps reformatting the rest of this file.)
> This whole list may no longer be particularly useful. The most common use 
> case on Linux, AFAICT, is to install only one CUDA version using 
> system-provided package manager.
> E.g. https://packages.ubuntu.com/focal/amd64/nvidia-cuda-toolkit/filelist
> 
> TBH, I'm tempted to limit autodetection to only that one system-default 
> version and require user to use --cuda-path if they need something else.
I think on windows (I mean the windows environment itself, not WSL), CUDA 
installer sets an environment variable which could be used to detect the 
default CUDA version, so it may warrant a windows-specific way to find it. 



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

mojca wrote:
> carlosgalvezp wrote:
> > mojca wrote:
> > > tra wrote:
> > > > tra wrote:
> > > > > mojca wrote:
> > > > > > kadircet wrote:
> > > > > > > looks like the list is getting big and hard to maintain. 
> > > > > > > considering that this is done only once per compiler invocation 
> > > > > > > (and we check for existence of directories down in the loop 
> > > > > > > anyway). what about throwing in an extra directory listing to 
> > > > > > > base-directories mentioned down below and populate `Candidates` 
> > > > > > > while preserving the newest-version-first order?
> > > > > > I totally agree with the sentiment, and that was my initial thought 
> > > > > > as well, but with zero experience I was too scared to make any more 
> > > > > > significant changes.
> > > > > > 
> > > > > > I can try to come up with a new patch (that doesn't need further 
> > > > > > maintenance whenever a new CUDA version gets released) if that's 
> > > > > > what you are suggesting. I would nevertheless merge this one, and 
> > > > > > prepare a new more advanced patch separately, but that's finally 
> > > > > > your call.
> > > > > > 
> > > > > > What's your suggestion about D.SysRoot + "Program Files/..."? At 
> > > > > > the time when this function gets called it looks like D.SysRoot is 
> > > > > > empty (or at least my debugger says so) and in my case it resolves 
> > > > > > to D: while the CUDA support is installed under C:.
> > > > > > 
> > > > > > Is there any special LLVM-specific/preferrable way to iterate 
> > > > > > through directories?
> > > > > > 
> > > > > > (What I also miss a bit in the whole process in an option to simply 
> > > > > > say "I want CUDA 11.1" without the need to explicitly spell out the 
> > > > > > full path.)
> > > > > > 
> > > > > > If you provide me give some general guidelines, I'll prepare 
> > > > > > another, hopefully more future-proof patch.
> > > > > > 
> > > > > > (Side note: I'm not sure if I'm calling clang-format correctly, but 
> > > > > > if I call it, it keeps reformatting the rest of this file.)
> > > > > This whole list may no longer be pa

[clang] dc1aa8e - [PowerPC] Add missed clang portion of c933c2eb3346

2021-11-24 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-11-24T12:42:58-06:00
New Revision: dc1aa8eacd1e0e554f206cc15d730f37ea90c4ea

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

LOG: [PowerPC] Add missed clang portion of c933c2eb3346

The clang portion of c933c2eb3346 was missed as I made
some kind of mistake squashing the commits with git.
This patch just adds those.

The original review: https://reviews.llvm.org/D114088

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p8vector.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index cd6b2df10e52..4ba23f8f3139 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -424,6 +424,12 @@ BUILTIN(__builtin_altivec_vctzh, "V8UsV8Us", "")
 BUILTIN(__builtin_altivec_vctzw, "V4UiV4Ui", "")
 BUILTIN(__builtin_altivec_vctzd, "V2ULLiV2ULLi", "")
 
+// P8 BCD builtins.
+BUILTIN(__builtin_ppc_bcdadd, "V16UcV16UcV16UcIi", "")
+BUILTIN(__builtin_ppc_bcdsub, "V16UcV16UcV16UcIi", "")
+BUILTIN(__builtin_ppc_bcdadd_p, "iiV16UcV16Uc", "")
+BUILTIN(__builtin_ppc_bcdsub_p, "iiV16UcV16Uc", "")
+
 BUILTIN(__builtin_altivec_vclzlsbb, "SiV16Uc", "")
 BUILTIN(__builtin_altivec_vctzlsbb, "SiV16Uc", "")
 BUILTIN(__builtin_altivec_vprtybw, "V4UiV4Ui", "")

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 3366e1fc94b1..55195b0781fb 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -19,6 +19,10 @@
 #define __CR6_EQ_REV 1
 #define __CR6_LT 2
 #define __CR6_LT_REV 3
+#define __CR6_GT 4
+#define __CR6_GT_REV 5
+#define __CR6_SO 6
+#define __CR6_SO_REV 7
 
 /* Constants for vec_test_data_class */
 #define __VEC_CLASS_FP_SUBNORMAL_N (1 << 0)
@@ -19037,6 +19041,51 @@ vec_sra(vector signed __int128 __a, vector unsigned 
__int128 __b) {
 #endif /* __SIZEOF_INT128__ */
 #endif /* __POWER10_VECTOR__ */
 
+#ifdef __POWER8_VECTOR__
+#define __bcdadd(__a, __b, __ps) __builtin_ppc_bcdadd((__a), (__b), (__ps))
+#define __bcdsub(__a, __b, __ps) __builtin_ppc_bcdsub((__a), (__b), (__ps))
+
+static __inline__ long __bcdadd_ofl(vector unsigned char __a,
+vector unsigned char __b) {
+  return __builtin_ppc_bcdadd_p(__CR6_SO, __a, __b);
+}
+
+static __inline__ long __bcdsub_ofl(vector unsigned char __a,
+vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_SO, __a, __b);
+}
+
+static __inline__ long __bcd_invalid(vector unsigned char __a) {
+  return __builtin_ppc_bcdsub_p(__CR6_SO, __a, __a);
+}
+
+static __inline__ long __bcdcmpeq(vector unsigned char __a,
+  vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_EQ, __a, __b);
+}
+
+static __inline__ long __bcdcmplt(vector unsigned char __a,
+  vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_LT, __a, __b);
+}
+
+static __inline__ long __bcdcmpgt(vector unsigned char __a,
+  vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_GT, __a, __b);
+}
+
+static __inline__ long __bcdcmple(vector unsigned char __a,
+  vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_GT_REV, __a, __b);
+}
+
+static __inline__ long __bcdcmpge(vector unsigned char __a,
+  vector unsigned char __b) {
+  return __builtin_ppc_bcdsub_p(__CR6_LT_REV, __a, __b);
+}
+
+#endif // __POWER8_VECTOR__
+
 #undef __ATTRS_o_ai
 
 #endif /* __ALTIVEC_H */

diff  --git a/clang/test/CodeGen/builtins-ppc-p8vector.c 
b/clang/test/CodeGen/builtins-ppc-p8vector.c
index 90e6de283cb1..7825d69c97ec 100644
--- a/clang/test/CodeGen/builtins-ppc-p8vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p8vector.c
@@ -1272,3 +1272,85 @@ vector unsigned int test_vec_subec_unsigned (vector 
unsigned int a, vector unsig
 // CHECK: xor <4 x i32> {{%[0-9]+}}, 
 // CHECK: ret <4 x i32>
 }
+
+int test_bcd_invalid(vector unsigned char a) {
+  // CHECK-LABEL: test_bcd_invalid
+  // CHECK: call i32 @llvm.ppc.bcdsub.p(i32 6, <16 x i8>
+  // CHECK-LE-LABEL: test_bcd_invalid
+  // CHECK-LE: call i32 @llvm.ppc.bcdsub.p(i32 6, <16 x i8>
+  return __bcd_invalid(a);
+}
+
+vector unsigned char test_bcd_add(vector unsigned char a, vector unsigned char 
b,
+  int ps) {
+  // CHECK-LABEL: test_bcd_add
+  // CHECK: call <16 x i8> @llvm.ppc.bcdadd(<16 x i8>
+  // CHECK-LE-LABEL: test_bcd_add
+  // CHECK-LE: call <16 x i8> @llvm.ppc.bcdadd(<16 x i8>
+  return __bcdadd(a, b, 1);
+}
+
+int test_bcd_add_ofl(vector unsigned char a, vector unsigned char b,

[clang] c79345f - [NFC][Clang][test] Inclusive language: Remove and rephrase uses of sanity test/check in clang/test

2021-11-24 Thread Zarko Todorovski via cfe-commits

Author: Zarko Todorovski
Date: 2021-11-24T14:03:49-05:00
New Revision: c79345fb7b149d9c952f8506c9e6c6317a5b4cd8

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

LOG: [NFC][Clang][test] Inclusive language: Remove and rephrase uses of sanity 
test/check in clang/test

Part of work to use more inclusive terms in clang/llvm.

Added: 


Modified: 
clang/test/Analysis/additive-folding.cpp
clang/test/Analysis/bitwise-ops.c
clang/test/Analysis/comparison-implicit-casts.cpp
clang/test/Analysis/ctor.mm
clang/test/Analysis/derived-to-base.cpp
clang/test/Analysis/dtor.cpp
clang/test/Analysis/expr-inspection.cpp
clang/test/Analysis/malloc-sizeof.cpp
clang/test/Analysis/plist-html-macros.c
clang/test/Analysis/reference.cpp
clang/test/Analysis/retain-release.m
clang/test/CodeGen/attr-nodebug.c
clang/test/CodeGenObjCXX/arc-attrs.mm
clang/test/CodeGenObjCXX/arc.mm
clang/test/Driver/arm-target-as-march-mcpu.s
clang/test/Driver/clang-g-opts.c
clang/test/Modules/framework-name.m
clang/test/Modules/target-features.m
clang/test/Modules/va_list.m
clang/test/PCH/cxx11-statement-attributes.cpp
clang/test/Rewriter/instancetype-test.mm
clang/test/Rewriter/rewrite-foreach-in-block.mm
clang/test/Sema/dllexport.c
clang/test/Sema/dllimport.c
clang/test/Sema/predef.c
clang/test/SemaCXX/coroutines-exp-namespace.cpp
clang/test/SemaCXX/coroutines.cpp
clang/test/SemaCXX/dllexport.cpp
clang/test/SemaCXX/dllimport.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp
clang/test/SemaObjC/arc-repeated-weak.mm
clang/test/SemaObjC/conversion.m
clang/test/SemaObjC/instancetype.m
clang/test/SemaObjC/warn-retain-cycle.m
clang/test/SemaObjCXX/instancetype.mm
clang/unittests/AST/ASTImporterFixtures.h
clang/unittests/Analysis/CFGDominatorTree.cpp
clang/unittests/Sema/ExternalSemaSourceTest.cpp
clang/unittests/Tooling/Syntax/TokensTest.cpp

Removed: 




diff  --git a/clang/test/Analysis/additive-folding.cpp 
b/clang/test/Analysis/additive-folding.cpp
index 6c84bf345e5ee..ddb32bdfa966a 100644
--- a/clang/test/Analysis/additive-folding.cpp
+++ b/clang/test/Analysis/additive-folding.cpp
@@ -141,7 +141,7 @@ void tautologiesOutside(unsigned char a) {
 
 // Wraparound with mixed types. Note that the analyzer assumes
 // -fwrapv semantics.
-void mixedWraparoundSanityCheck(int a) {
+void mixedWraparoundBasicCheck(int a) {
   int max = INT_MAX;
   int min = INT_MIN;
 
@@ -197,7 +197,7 @@ void mixedSignedness3(unsigned a) {
 }
 
 
-void multiplicativeSanityTest(int x) {
+void multiplicativeBasicTest(int x) {
   // At one point we were ignoring the *4 completely -- the constraint manager
   // would see x < 8 and then declare the assertion to be known false.
   if (x*4 < 8)

diff  --git a/clang/test/Analysis/bitwise-ops.c 
b/clang/test/Analysis/bitwise-ops.c
index fcd3d7dbc7cff..d8d2c920517d4 100644
--- a/clang/test/Analysis/bitwise-ops.c
+++ b/clang/test/Analysis/bitwise-ops.c
@@ -4,7 +4,7 @@ void clang_analyzer_eval(int);
 #define CHECK(expr) if (!(expr)) return; clang_analyzer_eval(expr)
 
 void testPersistentConstraints(int x, int y) {
-  // Sanity check
+  // Basic check
   CHECK(x); // expected-warning{{TRUE}}
   CHECK(x & 1); // expected-warning{{TRUE}}
   

diff  --git a/clang/test/Analysis/comparison-implicit-casts.cpp 
b/clang/test/Analysis/comparison-implicit-casts.cpp
index fe5254c0a53bd..dac2860110366 100644
--- a/clang/test/Analysis/comparison-implicit-casts.cpp
+++ b/clang/test/Analysis/comparison-implicit-casts.cpp
@@ -18,7 +18,7 @@ typedef typeof(sizeof(int)) size_t;
 void PR12206(int x) {
   size_t comparisonSize = sizeof(1 == 1);
 
-  // Sanity check. This test is useless if size_t isn't bigger than bool.
+  // This test is useless if size_t isn't bigger than bool.
   clang_analyzer_eval(sizeof(size_t) > comparisonSize); // 
expected-warning{{TRUE}}
 
   // Build a SymIntExpr, dependent on x.
@@ -75,7 +75,7 @@ size_t strlen(const char *s);
 void PR12206_strlen(const char *x) {
   size_t comparisonSize = sizeof(1 == 1);
 
-  // Sanity check. This test is useless if size_t isn't bigger than bool.
+  // This test is useless if size_t isn't bigger than bool.
   clang_analyzer_eval(sizeof(size_t) > comparisonSize); // 
expected-warning{{TRUE}}
 
   // Create a value that requires more bits to store than a comparison result.

diff  --git a/clang/test/Analysis/ctor.mm b/clang/test/Analysis/ctor.mm
index 08f06e75aebfe..1eafabb443de6 100644
--- a/clang/test/Analysis/ctor.mm
+++ b/clang/test/Analysis/ctor.mm
@@ -93,7 +93,7 @@ void test() {
 
 clang_analyzer_eval(obj.get() == 3); // expected-warning{{TRUE}}
 
-// Sanity check for devirtualization.
+// Correctness c

[PATCH] D114553: [HIP] Add atomic load, atomic store and atomic cmpxchng_weak builtin support in HIP-clang

2021-11-24 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 created this revision.
gandhi21299 added reviewers: yaxunl, b-sumner, t-tye, tra, rjmccall.
gandhi21299 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Introduce __hip_atomic_load, __hip_atomic_store and 
__hip_atomic_compare_exchange_weak
builtins in HIP.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114553

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCUDA/atomic-ops.cu
  clang/test/CodeGenOpenCL/atomic-ops.cl

Index: clang/test/CodeGenOpenCL/atomic-ops.cl
===
--- clang/test/CodeGenOpenCL/atomic-ops.cl
+++ clang/test/CodeGenOpenCL/atomic-ops.cl
@@ -35,7 +35,7 @@
 
 atomic_int j;
 
-void fi1(atomic_int *i) {
+void fi1(atomic_int *i, int* z) {
   // CHECK-LABEL: @fi1
   // CHECK: load atomic i32, i32* %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst, align 4
   int x = __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
@@ -48,6 +48,9 @@
 
   // CHECK: load atomic i32, i32* %{{[.0-9A-Z_a-z]+}} syncscope("wavefront") seq_cst, align 4
   x = __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_sub_group);
+
+  // CHECK: load i32, i32 addrspace(5)* %atomic-temp3, align 4
+  x = __hip_atomic_load(z, memory_scope_device);
 }
 
 void fi2(atomic_int *i) {
Index: clang/test/CodeGenCUDA/atomic-ops.cu
===
--- clang/test/CodeGenCUDA/atomic-ops.cu
+++ clang/test/CodeGenCUDA/atomic-ops.cu
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -x hip -std=c++11 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s
 #include "Inputs/cuda.h"
 
-// CHECK-LABEL: @_Z24atomic32_op_singlethreadPiii
+// CHECK-LABEL: @_Z24atomic32_op_singlethreadPiS_ii
 // CHECK: cmpxchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw xchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw add i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
@@ -10,7 +10,15 @@
 // CHECK: atomicrmw xor i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw min i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw max i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
-__device__ int atomic32_op_singlethread(int *ptr, int val, int desired) {
+// CHECK: load atomic i32, i32* {{%[0-9]+}} syncscope("singlethread-one-as") acquire, align 4
+// CHECK: store atomic i32 {{%[0-9]+}}, i32* {{%[0-9]+}} seq_cst, align 4
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 {{%[0-9]+}}, i8* align 8 {{%[0-9]+}}, i64 4, i1 false)
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") monotonic monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") acquire monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") release monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") acq_rel monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup") seq_cst monotonic, align 4
+__device__ int atomic32_op_singlethread(int *ptr, int *ptr2, int val, int desired) {
   bool flag = __hip_atomic_compare_exchange_strong(ptr, &val, desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
@@ -19,6 +27,9 @@
   val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_min(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_max(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_load(ptr, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  __hip_atomic_store(ptr, ptr2, 5);
+  flag = __hip_atomic_compare_exchange_weak(ptr, ptr2, &val, desired, __HIP_MEMORY_SCOPE_WORKGROUP);
   return flag ? val : desired;
 }
 
@@ -31,7 +42,7 @@
   return val;
 }
 
-// CHECK-LABEL: @_Z21atomic32_op_wavefrontPiii
+// CHECK-LABEL: @_Z21atomic32_op_wavefrontPiS_ii
 // CHECK: cmpxchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw xchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw add i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
@@ -40,7 +51,9 @@
 // CHECK: atomicrmw xor i32* {{%[

[clang] d42a643 - [NFC][clang]Inclusive language: remove remaining uses of sanity

2021-11-24 Thread Zarko Todorovski via cfe-commits

Author: Zarko Todorovski
Date: 2021-11-24T14:20:13-05:00
New Revision: d42a6432aa37a6b9aa7e4f5209e9679c8a4c2fbb

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

LOG: [NFC][clang]Inclusive language: remove remaining uses of sanity

Missed some uses of sanity check in previous commits.

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
clang/utils/TableGen/ASTTableGen.cpp
clang/utils/check_cfc/check_cfc.py

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index fe96db9ca918e..99babd58b0276 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -7483,7 +7483,7 @@ class ExprEvaluatorBase
 const Expr *Source = E->getSourceExpr();
 if (!Source)
   return Error(E);
-if (Source == E) { // sanity checking.
+if (Source == E) {
   assert(0 && "OpaqueValueExpr recursively refers to itself");
   return Error(E);
 }

diff  --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
index bc939d2528002..d57bab154b617 100644
--- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -686,8 +686,8 @@ SwitchNodeBuilder::generateDefaultCaseNode(ProgramStateRef 
St,
   assert(Src->succ_rbegin() != Src->succ_rend());
   CFGBlock *DefaultBlock = *Src->succ_rbegin();
 
-  // Sanity check for default blocks that are unreachable and not caught
-  // by earlier stages.
+  // Basic correctness check for default blocks that are unreachable and not
+  // caught by earlier stages.
   if (!DefaultBlock)
 return nullptr;
 

diff  --git a/clang/utils/TableGen/ASTTableGen.cpp 
b/clang/utils/TableGen/ASTTableGen.cpp
index 3f6da40964e0b..6aa8b28a942f3 100644
--- a/clang/utils/TableGen/ASTTableGen.cpp
+++ b/clang/utils/TableGen/ASTTableGen.cpp
@@ -107,7 +107,7 @@ static void visitASTNodeRecursive(ASTNode node, ASTNode 
base,
 static void visitHierarchy(RecordKeeper &records,
StringRef nodeClassName,
ASTNodeHierarchyVisitor visit) {
-  // Check for the node class, just as a sanity check.
+  // Check for the node class, just as a basic correctness check.
   if (!records.getClass(nodeClassName)) {
 PrintFatalError(Twine("cannot find definition for node class ")
   + nodeClassName);

diff  --git a/clang/utils/check_cfc/check_cfc.py 
b/clang/utils/check_cfc/check_cfc.py
index 311f502f800b3..cab33b41c1ca0 100755
--- a/clang/utils/check_cfc/check_cfc.py
+++ b/clang/utils/check_cfc/check_cfc.py
@@ -339,7 +339,7 @@ def perform_check(self, arguments, my_env):
 # Prevent infinite loop if called with absolute path.
 arguments_a[0] = os.path.basename(arguments_a[0])
 
-# Sanity check
+# Basic correctness check
 enabled_checks = [check_name
   for check_name in checks
   if config.getboolean('Checks', check_name)]



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


[PATCH] D114553: [HIP] Add atomic load, atomic store and atomic cmpxchng_weak builtin support in HIP-clang

2021-11-24 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 389577.
gandhi21299 added a comment.

removed changes in atomic-ops.cl, CUDA test may be sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114553

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCUDA/atomic-ops.cu

Index: clang/test/CodeGenCUDA/atomic-ops.cu
===
--- clang/test/CodeGenCUDA/atomic-ops.cu
+++ clang/test/CodeGenCUDA/atomic-ops.cu
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -x hip -std=c++11 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s
 #include "Inputs/cuda.h"
 
-// CHECK-LABEL: @_Z24atomic32_op_singlethreadPiii
+// CHECK-LABEL: @_Z24atomic32_op_singlethreadPiS_ii
 // CHECK: cmpxchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw xchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw add i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
@@ -10,7 +10,15 @@
 // CHECK: atomicrmw xor i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw min i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw max i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
-__device__ int atomic32_op_singlethread(int *ptr, int val, int desired) {
+// CHECK: load atomic i32, i32* {{%[0-9]+}} syncscope("singlethread-one-as") acquire, align 4
+// CHECK: store atomic i32 {{%[0-9]+}}, i32* {{%[0-9]+}} seq_cst, align 4
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 {{%[0-9]+}}, i8* align 8 {{%[0-9]+}}, i64 4, i1 false)
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") monotonic monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") acquire monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") release monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") acq_rel monotonic, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup") seq_cst monotonic, align 4
+__device__ int atomic32_op_singlethread(int *ptr, int *ptr2, int val, int desired) {
   bool flag = __hip_atomic_compare_exchange_strong(ptr, &val, desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
@@ -19,6 +27,9 @@
   val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_min(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_max(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_load(ptr, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  __hip_atomic_store(ptr, ptr2, 5);
+  flag = __hip_atomic_compare_exchange_weak(ptr, ptr2, &val, desired, __HIP_MEMORY_SCOPE_WORKGROUP);
   return flag ? val : desired;
 }
 
@@ -31,7 +42,7 @@
   return val;
 }
 
-// CHECK-LABEL: @_Z21atomic32_op_wavefrontPiii
+// CHECK-LABEL: @_Z21atomic32_op_wavefrontPiS_ii
 // CHECK: cmpxchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw xchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw add i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
@@ -40,7 +51,9 @@
 // CHECK: atomicrmw xor i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw min i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw max i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
-__device__ int atomic32_op_wavefront(int *ptr, int val, int desired) {
+// CHECK: load atomic i32, i32* {{%[0-9]+}} syncscope("wavefront-one-as") acquire, align 4
+// CHECK: store atomic i32 {{%[0-9]+}}, i32* {{%[0-9]+}} seq_cst, align 4
+__device__ int atomic32_op_wavefront(int *ptr, int *ptr2, int val, int desired) {
   bool flag = __hip_atomic_compare_exchange_strong(ptr, &val, desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
@@ -49,6 +62,8 @@
   val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = __hip_at

[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

In D114320#3151741 , @jessesna wrote:

> In D114320#3148046 , 
> @MyDeveloperDay wrote:
>
>> Ok now I'm a little puzzled, shouldn't this be covered by 
>> `AllowShortIfStatementsOnASingleLine`?
>
> That's exactly what i thought when i first stumbled over the behavior :D But 
> I think the majority of users might not even consider adding empty else 
> blocks. Only a few either just do it or have to comply with some standards, 
> f.e. MISRA  .

I tend to agree with you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


[PATCH] D113118: [clang][AST] Check context of record in structural equivalence.

2021-11-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on windows: http://45.33.8.238/win/49558/step_7.txt

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113118

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


[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-24 Thread Mojca Miklavec via Phabricator via cfe-commits
mojca added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

tra wrote:
> tra wrote:
> > mojca wrote:
> > > carlosgalvezp wrote:
> > > > mojca wrote:
> > > > > tra wrote:
> > > > > > tra wrote:
> > > > > > > mojca wrote:
> > > > > > > > kadircet wrote:
> > > > > > > > > looks like the list is getting big and hard to maintain. 
> > > > > > > > > considering that this is done only once per compiler 
> > > > > > > > > invocation (and we check for existence of directories down in 
> > > > > > > > > the loop anyway). what about throwing in an extra directory 
> > > > > > > > > listing to base-directories mentioned down below and populate 
> > > > > > > > > `Candidates` while preserving the newest-version-first order?
> > > > > > > > I totally agree with the sentiment, and that was my initial 
> > > > > > > > thought as well, but with zero experience I was too scared to 
> > > > > > > > make any more significant changes.
> > > > > > > > 
> > > > > > > > I can try to come up with a new patch (that doesn't need 
> > > > > > > > further maintenance whenever a new CUDA version gets released) 
> > > > > > > > if that's what you are suggesting. I would nevertheless merge 
> > > > > > > > this one, and prepare a new more advanced patch separately, but 
> > > > > > > > that's finally your call.
> > > > > > > > 
> > > > > > > > What's your suggestion about D.SysRoot + "Program Files/..."? 
> > > > > > > > At the time when this function gets called it looks like 
> > > > > > > > D.SysRoot is empty (or at least my debugger says so) and in my 
> > > > > > > > case it resolves to D: while the CUDA support is installed 
> > > > > > > > under C:.
> > > > > > > > 
> > > > > > > > Is there any special LLVM-specific/preferrable way to iterate 
> > > > > > > > through directories?
> > > > > > > > 
> > > > > > > > (What I also miss a bit in the whole process in an option to 
> > > > > > > > simply say "I want CUDA 11.1" without the need to explicitly 
> > > > > > > > spell out the full path.)
> > > > > > > > 
> > > > > > > > If you provide me give some general guidelines, I'll prepare 
> > > > > > > > another, hopefully more future-proof patch.
> > > > > > > > 
> > > > > > > > (Side note: I'm not sure if I'm calling clang-format correctly, 
> > > > > > > > but if I call it, it keeps reformatting the rest of this file.)
> > > > > > > This whole list may no longer be particularly useful. The most 
> > > > > > > common use case on Linux, AFAICT, is to install only one CUDA 
> > > > > > > version using system-provided package manager.
> > > > > > > E.g. 
> > > > > > > https://packages.ubuntu.com/focal/amd64/nvidia-cuda-toolkit/filelist
> > > > > > > 
> > > > > > > TBH, I'm tempted to limit autodetection to only that one 
> > > > > > > system-default version and require user to use --cuda-path if 
> > > > > > > they need something else.
> > > > > > I think on windows (I mean the windows environment itself, not 
> > > > > > WSL), CUDA installer sets an environment variable which could be 
> > > > > > used to detect the default CUDA version, so it may warrant a 
> > > > > > windows-specific way to find it. 
> > > > > On Windows this is certainly not the case. Unless the installation is 
> > > > > changed manually, one always gets the new version installed into a 
> > > > > new directory.
> > > > > 
> > > > > I really do need multiple versions on Windows (and the ability to 
> > > > > pick an older one) if I want to compile a binary that works on 
> > > > > someone else's computer (if I compile against the latest CUDA, users 
> > > > > need "the latest" drivers that may sometimes not even be available 
> > > > > for their machine).
> > > > > 
> > > > > (That said, at least when using CMake, the selection needs to be done 
> > > > > by CMake anyway, and maybe CMake could be forced to specify the 
> > > > > correct flag automatically.)
> > > > > 
> > > > > So even if the functionality gets removed from non-Windows platforms, 
> > > > > it would be really nice to keep it for Windows.
> > > > > 
> > > > > Now, there are three "conflicting" feedbacks/suggestions above. I can 
> > > > > try to improve support, but it would be really helpful to reach the 
> > > > > consensus of what needs to be done before coding it.
> > > > > one always gets the new version installed into a new directory.
> > > > A similar thing happens on Linux.
> > > > 
> > > > > users need "the latest" drivers
> > > > Since CUDA 10.2, there's some "[[ 
> > > > https://docs.nvidia.com/deploy/cuda-compatibility/ | compatibility mode 
> > > > ]]" that allows to run newer CUDA on older drivers. As long as you are 
> > > > not using the latest features, of course.
> > > > 
> > > > I'm personally all up for removing redundancy and duplication. 
> > > I'm fo

[PATCH] D114559: [clang] ASTMatchers: Fix out-of-bounds access in foreachArgumentWithParamType.

2021-11-24 Thread Felix Berger via Phabricator via cfe-commits
flx created this revision.
flx requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The matcher crashes when a variadic function pointer is invoked because the
FunctionProtoType has fewer parameters than arguments.

Matching of non-variadic arguments now works.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114559

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1094,6 +1094,31 @@
   S, CallExpr, std::make_unique>("arg")));
 }
 
+TEST(ForEachArgumentWithParamType, MatchesVariadicFunctionPtrCalls) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(builtinType()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  StringRef S = R"cpp(
+void fcntl(int fd, int cmd, ...) {}
+
+template 
+void f(Func F) {
+  int y = 42;
+  F(y, 1, 3);
+}
+
+void g() { f(fcntl); }
+  )cpp";
+
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  S, CallExpr, std::make_unique>("type")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  S, CallExpr, std::make_unique>("arg")));
+}
+
 TEST(QualType, hasCanonicalType) {
   EXPECT_TRUE(notMatches("typedef int &int_ref;"
"int a;"
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4885,7 +4885,7 @@
 
   // This test is cheaper compared to the big matcher in the next if.
   // Therefore, please keep this order.
-  if (FProto) {
+  if (FProto && FProto->getNumParams() > ParamIndex) {
 QualType ParamType = FProto->getParamType(ParamIndex);
 if (ParamMatcher.matches(ParamType, Finder, &ParamMatches)) {
   Result.addMatch(ParamMatches);


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1094,6 +1094,31 @@
   S, CallExpr, std::make_unique>("arg")));
 }
 
+TEST(ForEachArgumentWithParamType, MatchesVariadicFunctionPtrCalls) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(builtinType()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  StringRef S = R"cpp(
+void fcntl(int fd, int cmd, ...) {}
+
+template 
+void f(Func F) {
+  int y = 42;
+  F(y, 1, 3);
+}
+
+void g() { f(fcntl); }
+  )cpp";
+
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  S, CallExpr, std::make_unique>("type")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  S, CallExpr, std::make_unique>("arg")));
+}
+
 TEST(QualType, hasCanonicalType) {
   EXPECT_TRUE(notMatches("typedef int &int_ref;"
"int a;"
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4885,7 +4885,7 @@
 
   // This test is cheaper compared to the big matcher in the next if.
   // Therefore, please keep this order.
-  if (FProto) {
+  if (FProto && FProto->getNumParams() > ParamIndex) {
 QualType ParamType = FProto->getParamType(ParamIndex);
 if (ParamMatcher.matches(ParamType, Finder, &ParamMatches)) {
   Result.addMatch(ParamMatches);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-11-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Parse/ParsePragma.cpp:511
+RISCVPragmaHandler = std::make_unique(Actions);
+PP.AddPragmaHandler(RISCVPragmaHandler.get());
+  }

Since this is a clang specific pragma should it be `#pragma clang riscv 
intrinsic`? gcc's pragma for SVE is `#pragma GCC aarch64 "arm_sve.h"`



Comment at: clang/lib/Parse/ParsePragma.cpp:3842
+  }
+
+  PP.setPredefines("#define __riscv_pragma_vector_intrinsics");

Do we need to check that there are no tokens left to parse? Quick look at other 
handles I see a check for tok::eod



Comment at: clang/lib/Sema/SemaLookup.cpp:904
+  QualType &RetType,
+  SmallVector &ArgTypes) {
+  // Get the QualType instance of the return type.

Can this be SmallVectorImpl?



Comment at: clang/lib/Sema/SemaLookup.cpp:921
+  QualType &BuiltinFuncType, QualType &RetType,
+  SmallVector &ArgTypes) {
+  FunctionProtoType::ExtProtoInfo PI(

SmallVectorImpl



Comment at: clang/lib/Sema/SemaLookup.cpp:929
+
+static unsigned GetTargetFeatures(const TargetInfo &TI) {
+  bool HasF = TI.hasFeature("f");

Use a fixed size type like uint32_t since it is a bit vector.



Comment at: clang/lib/Sema/SemaLookup.cpp:949
+Sema &S, LookupResult &LR, IdentifierInfo *II, Preprocessor &PP,
+const unsigned FctIndex, const unsigned Len, const unsigned BuiltinIndex) {
+

const on integer arguments doesn't make a much sense. It just prevents you from 
assigning over the variable in the function body.



Comment at: clang/lib/Sema/SemaLookup.cpp:966
+  ASTContext &Context = S.Context;
+  unsigned RVVTargetFeatures = GetTargetFeatures(Context.getTargetInfo());
+

Use a fixed size type like uint32_t here or uint8_t to match RequiredExts,



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1513
+  OS << "enum RVVTypeID {\n";
+  StringMap Seen;
+  for (const auto &T : TypeMap) {

Use StringSet?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1516
+auto *RVVTy = T.first;
+if (Seen.find(RVVTy->getShortStr()) == Seen.end()) {
+  OS << "  RVVT_" + RVVTy->getShortStr() << ",\n";

With StringSet you can use
```
if (Seen.insert(RVVTy->getShortStr()).second)
```

The .second field from the pair will tell if you the insert happened or not.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1551
+StringRef IName = Def->getName();
+if (FctOverloadMap.find(IName) == FctOverloadMap.end()) {
+  FctOverloadMap.insert(std::make_pair(

I don't think you need to insert anything here. The 
`FctOverloadMap[IName].push_back(` line below will construct an empty entry 
before the push_back if it doesn't already exist.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1575
+  StringRef GName = Def->getMangledName();
+  if (FctOverloadMap.find(GName) == FctOverloadMap.end()) {
+FctOverloadMap.insert(std::make_pair(

I don't think you need to insert anything. The push_back line will take care of 
it.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1616
+  // List of signatures known to be emitted.
+  std::vector KnownSignatures;
+

Can this be a vector of unique_ptrs?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1622
+// Gather all signatures for the current function.
+auto *CurSignatureList = new BuiltinIndexListTy();
+for (const auto &Signature : Fct.second)

Can this be a unique_ptr?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1639
+  *Candidate == *CurSignatureList) {
+if (CanReuseSignature(Candidate, Fct.second)) {
+  SignatureListMap.find(Candidate)->second.Names.push_back(Fct.first);

I think this condition can be an additional && on the previous if?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1640
+if (CanReuseSignature(Candidate, Fct.second)) {
+  SignatureListMap.find(Candidate)->second.Names.push_back(Fct.first);
+  SignatureListMap.find(Candidate)->second.BuiltinIndex.push_back(

Don't call SignatureListMap.find(Candidate) twice.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1677
+// Report an error when seeing an entry that is too large for the
+// current index type (unsigned short).  When hitting this, the type
+// of SignatureTable will need to be changed.

I'd use uint16_t rather than unsigned short.



Comment at: clang/utils/T

[PATCH] D114560: [OPENMP]Fix PR51327: Range based for loop not working if range's type is a template.

2021-11-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, mikerice.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Need to postpone anlysis of the ranged for loops till the actual
instantiation to avoid erroneous emission of error messages.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114560

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_loop_auto.cpp


Index: clang/test/OpenMP/for_loop_auto.cpp
===
--- /dev/null
+++ clang/test/OpenMP/for_loop_auto.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print -std=c++20 %s -Wsign-conversion 
| FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++20 -include-pch %t -fsyntax-only -verify 
%s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print -std=c++20 %s 
-Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++20 -include-pch %t -fsyntax-only 
-verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK:  template <> void do_loop(const auto &v) {
+// CHECK-NEXT: #pragma omp parallel for
+// CHECK-NEXT:for (const auto &i : v)
+// CHECK-NEXT:  ;
+// CHECK-NEXT: }
+
+void do_loop(const auto &v) {
+#pragma omp parallel for
+  for (const auto &i : v)
+;
+}
+#endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -8804,6 +8804,9 @@
   }
   assert(((For && For->getBody()) || (CXXFor && CXXFor->getBody())) &&
  "No loop body.");
+  // Postpone analysis in dependent contexts for ranged for loops.
+  if (CXXFor && SemaRef.CurContext->isDependentContext())
+return false;
 
   OpenMPIterationSpaceChecker ISC(SemaRef, SupportsNonRectangular, DSA,
   For ? For->getForLoc() : 
CXXFor->getForLoc());


Index: clang/test/OpenMP/for_loop_auto.cpp
===
--- /dev/null
+++ clang/test/OpenMP/for_loop_auto.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print -std=c++20 %s -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print -std=c++20 %s -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK:  template <> void do_loop(const auto &v) {
+// CHECK-NEXT: #pragma omp parallel for
+// CHECK-NEXT:for (const auto &i : v)
+// CHECK-NEXT:  ;
+// CHECK-NEXT: }
+
+void do_loop(const auto &v) {
+#pragma omp parallel for
+  for (const auto &i : v)
+;
+}
+#endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -8804,6 +8804,9 @@
   }
   assert(((For && For->getBody()) || (CXXFor && CXXFor->getBody())) &&
  "No loop body.");
+  // Postpone analysis in dependent contexts for ranged for loops.
+  if (CXXFor && SemaRef.CurContext->isDependentContext())
+return false;
 
   OpenMPIterationSpaceChecker ISC(SemaRef, SupportsNonRectangular, DSA,
   For ? For->getForLoc() : CXXFor->getForLoc());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2021-11-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:69
 {"zfh", RISCVExtensionVersion{0, 1}},
+{"zfinx", RISCVExtensionVersion{1, 0}},
+{"zdinx", RISCVExtensionVersion{1, 0}},

Do we need to enforce that these can't be mixed with F, D, and Zfh?



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1718
+!getSTI().hasFeature(RISCV::FeatureStdExtF) &&
+!getSTI().hasFeature(RISCV::FeatureStdExtD) &&
+!getSTI().hasFeature(RISCV::FeatureStdExtZfh)));

D and Zfh imply F. Is it enough to just check F?



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoF.td:77
 let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
-class FPFMAS_rrr_frm
-: RVInstR4Frm<0b00, opcode, (outs FPR32:$rd),
-  (ins FPR32:$rs1, FPR32:$rs2, FPR32:$rs3, frmarg:$funct3),
+class FPFMAS_rrr_frm_single

Can we merge this with FPFMAD_rrr_frm_single and FPFMAH_rrr_frm_single by 
passing the 0b00/0b01/0b10 value from 
FPFMAS_rrr_frm/FPFMAD_rrr_frm/FPFMAH_rrr_frm?

This applies to most of the `_single` classes. We should share them if possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2021-11-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoD.td:489
 
+let Predicates = [HasStdExtZdinx] in {
+def : InstAlias<"fabs.d $rd, $rs", (FSGNJX_D_INX GPRF64Op:$rd, GPRF64Op:$rs, 
GPRF64Op:$rs)>;

Aren't these aliases only valid for RV64. You need IN32X aliases for RV32 right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[PATCH] D114553: [HIP] Add atomic load, atomic store and atomic cmpxchng_weak builtin support in HIP-clang

2021-11-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

we also need a sema test like clang/test/SemaOpenCL/atomic-ops.cl




Comment at: clang/test/CodeGenCUDA/atomic-ops.cu:30-32
+  val = __hip_atomic_load(ptr, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  __hip_atomic_store(ptr, ptr2, 5);
+  flag = __hip_atomic_compare_exchange_weak(ptr, ptr2, &val, desired, 
__HIP_MEMORY_SCOPE_WORKGROUP);

all three builtins need to accept memory order parameter. check 
clang/test/CodeGenOpenCL/atomic-ops.cl for reference


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114553

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


  1   2   >