[PATCH] D112519: parallel-libs: remove some artifacts

2021-10-26 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.
sylvestre.ledru added reviewers: dblaikie, jlebar.
sylvestre.ledru requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112519

Files:
  clang/docs/ClangFormattedStatus.rst
  clang/docs/tools/clang-formatted-files.txt
  llvm/docs/Proposals/GitHubMove.rst
  llvm/docs/Proposals/VariableNames.rst


Index: llvm/docs/Proposals/VariableNames.rst
===
--- llvm/docs/Proposals/VariableNames.rst
+++ llvm/docs/Proposals/VariableNames.rst
@@ -338,7 +338,6 @@
* compiler-rt
* libunwind
* openmp
-   * parallel-libs
* polly
* lldb
 
Index: llvm/docs/Proposals/GitHubMove.rst
===
--- llvm/docs/Proposals/GitHubMove.rst
+++ llvm/docs/Proposals/GitHubMove.rst
@@ -750,7 +750,7 @@
 
   subprojects=( clang clang-tools-extra compiler-rt debuginfo-tests libclc
 libcxx libcxxabi libunwind lld lldb llgo llvm openmp
-parallel-libs polly pstl )
+polly pstl )
 
   # Import histories for upstream split projects (this was probably
   # already done for the ``migrate-downstream-fork.py`` run).
@@ -853,7 +853,7 @@
 
   subprojects=( clang clang-tools-extra compiler-rt debuginfo-tests libclc
 libcxx libcxxabi libunwind lld lldb llgo llvm openmp
-parallel-libs polly pstl )
+polly pstl )
 
   # Import histories for upstream split projects (this was probably
   # already done for the ``migrate-downstream-fork.py`` run).
Index: clang/docs/tools/clang-formatted-files.txt
===
--- clang/docs/tools/clang-formatted-files.txt
+++ clang/docs/tools/clang-formatted-files.txt
@@ -7801,15 +7801,6 @@
 openmp/tools/multiplex/tests/custom_data_storage/second-tool.h
 openmp/tools/multiplex/tests/print/first-tool.h
 openmp/tools/multiplex/tests/print/second-tool.h
-parallel-libs/acxxel/acxxel.cpp
-parallel-libs/acxxel/opencl_acxxel.cpp
-parallel-libs/acxxel/span.h
-parallel-libs/acxxel/status.h
-parallel-libs/acxxel/examples/opencl_example.cpp
-parallel-libs/acxxel/tests/multi_device_test.cpp
-parallel-libs/acxxel/tests/opencl_test.cpp
-parallel-libs/acxxel/tests/span_test.cpp
-parallel-libs/acxxel/tests/status_test.cpp
 polly/include/polly/Canonicalization.h
 polly/include/polly/CodePreparation.h
 polly/include/polly/DeadCodeElimination.h
Index: clang/docs/ClangFormattedStatus.rst
===
--- clang/docs/ClangFormattedStatus.rst
+++ clang/docs/ClangFormattedStatus.rst
@@ -7804,21 +7804,6 @@
  - `2`
  - `0`
  - :good:`100%`
-   * - parallel-libs/acxxel
- - `6`
- - `4`
- - `2`
- - :part:`66%`
-   * - parallel-libs/acxxel/examples
- - `1`
- - `1`
- - `0`
- - :good:`100%`
-   * - parallel-libs/acxxel/tests
- - `5`
- - `4`
- - `1`
- - :part:`80%`
* - polly/include/polly
  - `26`
  - `26`


Index: llvm/docs/Proposals/VariableNames.rst
===
--- llvm/docs/Proposals/VariableNames.rst
+++ llvm/docs/Proposals/VariableNames.rst
@@ -338,7 +338,6 @@
* compiler-rt
* libunwind
* openmp
-   * parallel-libs
* polly
* lldb
 
Index: llvm/docs/Proposals/GitHubMove.rst
===
--- llvm/docs/Proposals/GitHubMove.rst
+++ llvm/docs/Proposals/GitHubMove.rst
@@ -750,7 +750,7 @@
 
   subprojects=( clang clang-tools-extra compiler-rt debuginfo-tests libclc
 libcxx libcxxabi libunwind lld lldb llgo llvm openmp
-parallel-libs polly pstl )
+polly pstl )
 
   # Import histories for upstream split projects (this was probably
   # already done for the ``migrate-downstream-fork.py`` run).
@@ -853,7 +853,7 @@
 
   subprojects=( clang clang-tools-extra compiler-rt debuginfo-tests libclc
 libcxx libcxxabi libunwind lld lldb llgo llvm openmp
-parallel-libs polly pstl )
+polly pstl )
 
   # Import histories for upstream split projects (this was probably
   # already done for the ``migrate-downstream-fork.py`` run).
Index: clang/docs/tools/clang-formatted-files.txt
===
--- clang/docs/tools/clang-formatted-files.txt
+++ clang/docs/tools/clang-formatted-files.txt
@@ -7801,15 +7801,6 @@
 openmp/tools/multiplex/tests/custom_data_storage/second-tool.h
 openmp/tools/multiplex/tests/print/first-tool.h
 openmp/tools/multiplex/tests/print/second-tool.h
-parallel-libs/acxxel/acxxel.cpp
-parallel-libs/acxxel/opencl_acxxel.cpp
-parallel-libs/acxxel/span.h
-parallel-libs/acxxel/status.h
-parallel-libs/acxxel/exampl

[PATCH] D111870: [clangd] Add a way to enable IncludeCleaner through config

2021-10-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev marked 9 inline comments as done.
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:215
+D.Message = "Included header is unused";
+D.Name = "clangd-include-cleaner";
+// FIXME: This range should be the whole line with target #include.

sammccall wrote:
> sammccall wrote:
> > Source should be `Clangd` I think (our first?).
> > 
> > Name should be something like "unused-include": this doesn't need to echo 
> > the tool name.
> clangd-unused-header -> unused-header
> 
> (there's a test, but it's stale)
what do you mean by "stale"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111870

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


[PATCH] D111870: [clangd] Add a way to enable IncludeCleaner through config

2021-10-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 382214.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.

Resolve review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111870

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1479,6 +1479,44 @@
   AllOf(Diag(Test.range("deprecated"), "'bar' is deprecated"),
 WithTag(DiagnosticTag::Deprecated;
 }
+
+TEST(DiagnosticsTest, IncludeCleaner) {
+  Annotations Test(R"cpp(
+$fix[[  $diag[[#include "unused.h"]]
+]]  #include "used.h"
+
+  void foo() {
+used();
+  }
+  )cpp");
+  TestTU TU;
+  TU.Code = Test.code().str();
+  TU.AdditionalFiles["unused.h"] = R"cpp(
+void unused() {}
+  )cpp";
+  TU.AdditionalFiles["used.h"] = R"cpp(
+void used() {}
+  )cpp";
+  // Off by default.
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  Config Cfg;
+  Cfg.Diagnostics.UnusedIncludes = Config::UnusedIncludesPolicy::Strict;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(
+  *TU.build().getDiagnostics(),
+  UnorderedElementsAre(AllOf(
+  Diag(Test.range("diag"), "included header \"unused.h\" is not used"),
+  WithTag(DiagnosticTag::Unnecessary), DiagSource(Diag::Clangd),
+  WithFix(Fix(Test.range("fix"), "", "remove #include directive");
+  Cfg.Diagnostics.SuppressAll = true;
+  WithContextValue SuppressAllWithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  Cfg.Diagnostics.SuppressAll = false;
+  Cfg.Diagnostics.Suppress = {"unused-includes"};
+  WithContextValue SuppressFilterWithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -67,6 +67,7 @@
 CheckOptions:
   IgnoreMacros: true
   example-check.ExampleOption: 0
+  UnusedIncludes: Strict
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
@@ -83,6 +84,8 @@
   EXPECT_THAT(Results[3].Diagnostics.ClangTidy.CheckOptions,
   ElementsAre(PairVal("IgnoreMacros", "true"),
   PairVal("example-check.ExampleOption", "0")));
+  EXPECT_TRUE(Results[3].Diagnostics.UnusedIncludes);
+  EXPECT_EQ("Strict", *Results[3].Diagnostics.UnusedIncludes.getValue());
 }
 
 TEST(ParseYAML, Locations) {
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -244,6 +244,25 @@
   }
 }
 
+TEST_F(ConfigCompileTests, DiagnosticsIncludeCleaner) {
+  // Defaults to None.
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::None);
+
+  Frag = {};
+  Frag.Diagnostics.UnusedIncludes.emplace("None");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::None);
+
+  Frag = {};
+  Frag.Diagnostics.UnusedIncludes.emplace("Strict");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::Strict);
+}
+
 TEST_F(ConfigCompileTests, DiagnosticSuppression) {
   Frag.Diagnostics.Suppress.emplace_back("bugprone-use-after-move");
   Frag.Diagnostics.Suppress.emplace_back("unreachable-code");
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -18,6 +18,7 @@
 #include "FeatureModule.h"
 #include "Headers.h"
 #include "HeuristicResolver.h"
+#include "IncludeCleaner.h"
 #include "IncludeFixer.h"
 #include "Preamble.h

[PATCH] D111870: [clangd] Add a way to enable IncludeCleaner through config

2021-10-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 382215.
kbobyrev added a comment.

Use IncludeCleaner to get rid of unused include in IncludeCleaner.cpp 🆒


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111870

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1479,6 +1479,44 @@
   AllOf(Diag(Test.range("deprecated"), "'bar' is deprecated"),
 WithTag(DiagnosticTag::Deprecated;
 }
+
+TEST(DiagnosticsTest, IncludeCleaner) {
+  Annotations Test(R"cpp(
+$fix[[  $diag[[#include "unused.h"]]
+]]  #include "used.h"
+
+  void foo() {
+used();
+  }
+  )cpp");
+  TestTU TU;
+  TU.Code = Test.code().str();
+  TU.AdditionalFiles["unused.h"] = R"cpp(
+void unused() {}
+  )cpp";
+  TU.AdditionalFiles["used.h"] = R"cpp(
+void used() {}
+  )cpp";
+  // Off by default.
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  Config Cfg;
+  Cfg.Diagnostics.UnusedIncludes = Config::UnusedIncludesPolicy::Strict;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(
+  *TU.build().getDiagnostics(),
+  UnorderedElementsAre(AllOf(
+  Diag(Test.range("diag"), "included header \"unused.h\" is not used"),
+  WithTag(DiagnosticTag::Unnecessary), DiagSource(Diag::Clangd),
+  WithFix(Fix(Test.range("fix"), "", "remove #include directive");
+  Cfg.Diagnostics.SuppressAll = true;
+  WithContextValue SuppressAllWithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  Cfg.Diagnostics.SuppressAll = false;
+  Cfg.Diagnostics.Suppress = {"unused-includes"};
+  WithContextValue SuppressFilterWithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -67,6 +67,7 @@
 CheckOptions:
   IgnoreMacros: true
   example-check.ExampleOption: 0
+  UnusedIncludes: Strict
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
@@ -83,6 +84,8 @@
   EXPECT_THAT(Results[3].Diagnostics.ClangTidy.CheckOptions,
   ElementsAre(PairVal("IgnoreMacros", "true"),
   PairVal("example-check.ExampleOption", "0")));
+  EXPECT_TRUE(Results[3].Diagnostics.UnusedIncludes);
+  EXPECT_EQ("Strict", *Results[3].Diagnostics.UnusedIncludes.getValue());
 }
 
 TEST(ParseYAML, Locations) {
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -244,6 +244,25 @@
   }
 }
 
+TEST_F(ConfigCompileTests, DiagnosticsIncludeCleaner) {
+  // Defaults to None.
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::None);
+
+  Frag = {};
+  Frag.Diagnostics.UnusedIncludes.emplace("None");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::None);
+
+  Frag = {};
+  Frag.Diagnostics.UnusedIncludes.emplace("Strict");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::Strict);
+}
+
 TEST_F(ConfigCompileTests, DiagnosticSuppression) {
   Frag.Diagnostics.Suppress.emplace_back("bugprone-use-after-move");
   Frag.Diagnostics.Suppress.emplace_back("unreachable-code");
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -18,6 +18,7 @@
 #include "FeatureModule.h"
 #include "Headers.h"
 #include "HeuristicResolver.h"
+#include "IncludeCleaner.h"
 #include "IncludeFixer.h"
 #include "Preamb

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

2021-10-26 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence marked 6 inline comments as done.
achieveartificialintelligence added inline comments.



Comment at: llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp:164
 
+static DecodeStatus DecodeGPRF16RegisterClass(MCInst &Inst, uint64_t RegNo,
+  uint64_t Address,

MaskRay wrote:
> Use `functionName`.
> 
> There is inconsistency in the code base but `functionName` is used much more 
> than `FunctionName`.
I fix this in D112520



Comment at: llvm/lib/Target/RISCV/RISCVRegisterInfo.td:539
 
+let RegAltNameIndices = [ABIRegAltName] in {
+  foreach Index = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,

jrtc27 wrote:
> This needs to be coordinated with D95588; you both define GPR pairs for RV32 
> but in different ways. There needs to be only one.
After D95588 is accepted, we will reuse this.


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] D111711: [clangd] IncludeCleaner: Don't consider the definition as usage for function forward declarations

2021-10-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:42
 
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+// Function definition will require redeclarations to be included.

i've got a feeling that this might have nasty side effects in the presence of 
functions with defaulted-arguments, but they're pretty obscure (like declare a 
function with a default parameter in a header, then in the main file both 
include the header and have a forward declaration of the function, now that 
forward declaration can't have the default parameter because the one in the 
header has. but who does that really). so i suppose it won't result in any 
false positives in practice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111711

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


[PATCH] D112447: [clangd] IncludeCleaner: Support macros

2021-10-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 382221.
kbobyrev marked 4 inline comments as done.
kbobyrev added a comment.

Try another strategy to reduce the number of processed tokens (doesn't work in
all cases).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112447

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -103,6 +103,26 @@
   "struct ^X { enum ^Language { ^CXX = 42, Python = 9000}; };",
   "int Lang = X::CXX;",
   },
+  // Macros
+  {
+  "#define ^CONSTANT 42",
+  "int Foo = CONSTANT;",
+  },
+  {
+  "#define ^FOO x",
+  "#define BAR FOO",
+  },
+  {
+  "#define INNER 42\n"
+  "#define ^OUTER INNER",
+  "int answer = OUTER;",
+  },
+  {
+  "#define ^ANSWER 42\n"
+  "#define ^SQUARE(X) X * X",
+  "int sq = SQUARE(ANSWER);",
+  },
+  // Misc
   {
   "enum class ^Color : int;",
   "enum class Color : int {};",
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -33,11 +33,13 @@
 using ReferencedLocations = llvm::DenseSet;
 /// Finds locations of all symbols used in the main file.
 ///
-/// Uses RecursiveASTVisitor to go through main file AST and computes all the
-/// locations used symbols are coming from. Returned locations may be macro
-/// expansions, and are not resolved to their spelling/expansion location. 
These
-/// locations are later used to determine which headers should be marked as
-/// "used" and "directly used".
+/// - For non-macros uses RecursiveASTVisitor to go through main file AST and
+///   computes all the locations used symbols are coming from. Returned
+///   locations may be macro expansions, and are not resolved to their spelling
+///   or expansion location. These locations are later used to determine which
+///   headers should /   be marked as "used" and "directly used".
+/// - For macros iteratates over \p AST tokens and collects locations of the
+///   used macro definition.
 ///
 /// We use this to compute unused headers, so we:
 ///
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -7,9 +7,12 @@
 
//===--===//
 
 #include "IncludeCleaner.h"
+#include "SourceCode.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 
 namespace clang {
 namespace clangd {
@@ -142,13 +145,27 @@
   }
 };
 
+// Gets the tokens from the main file, iterates through them and adds 
definition
+// locations for the found macros.
+void findReferencedMacros(ParsedAST &AST, ReferencedLocations &Result) {
+  trace::Span Tracer("findReferencedMacros");
+  auto &PP = AST.getPreprocessor();
+  for (const auto &MacroName : AST.getMacros().Names.keys()) {
+dlog("Processing MacroName: {0}", MacroName);
+auto Definition = PP.getMacroDefinition(PP.getIdentifierInfo(MacroName));
+auto Loc = Definition.getMacroInfo()->getDefinitionLoc();
+if (Loc.isValid())
+  Result.insert(Loc);
+  }
+}
+
 } // namespace
 
 ReferencedLocations findReferencedLocations(ParsedAST &AST) {
   ReferencedLocations Result;
   ReferencedLocationCrawler Crawler(Result);
   Crawler.TraverseAST(AST.getASTContext());
-  // FIXME(kirillbobyrev): Handle macros.
+  findReferencedMacros(AST, Result);
   return Result;
 }
 


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -103,6 +103,26 @@
   "struct ^X { enum ^Language { ^CXX = 42, Python = 9000}; };",
   "int Lang = X::CXX;",
   },
+  // Macros
+  {
+  "#define ^CONSTANT 42",
+  "int Foo = CONSTANT;",
+  },
+  {
+  "#define ^FOO x",
+  "#define BAR FOO",
+  },
+  {
+  "#define INNER 42\n"
+  "#define ^OUTER INNER",
+  "int answer = OUTER;",
+  },
+  {
+  "#define ^ANSWER 42\n"
+  "#define ^SQUARE(X) X * X",
+  

[PATCH] D112447: [clangd] IncludeCleaner: Support macros

2021-10-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:140
+// locations for the found macros.
+void findReferencedMacros(ParsedAST &AST, ReferencedLocations &Result) {
+  auto Tokens =

sammccall wrote:
> sammccall wrote:
> > can you add a trace for this and verify that it's not a signficant amount 
> > of time on a macro-heavy file (e.g. unittests?)
> > 
> > locateMacroAt wasn't designed to be called in a loop like this, but it 
> > seems plausible it'll be fine
> > 
> iterating over all the tokens and examining them individually seems like 
> we're doing too much work.
> 
> ParsedAST.MainFileMacros.Names already knows the names of all macros 
> referenced from the main file.
> PP.getLocalMacroDirectiveHistory() will give you the last seen definition for 
> a given macro name. If we want, we can also get the previous definitions.
> 
> This seems like it should be close enough, and wade through many fewer tokens?
Hmm, this doesn't really work for "unmaterialized" macros, i.e. 
`ParsedAST::getMacros().Names` doesn't have `FOO` in this case:

```
// foo.h
#define FOO

// foo.cpp
#define BAR FOO
```

Is that a bug in `CollectMainFileMacros` we want to fix or is this intended 
behavior and we'd need to iterate through the tokens?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112447

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


[clang-tools-extra] c521288 - [clangd] IncludeCleaner: Don't consider the definition as usage for function forward declarations

2021-10-26 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-10-26T10:37:10+02:00
New Revision: c521288ed391bd29a37f1c444d08ae542df5341c

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

LOG: [clangd] IncludeCleaner: Don't consider the definition as usage for 
function forward declarations

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index aea34a73d3f57..4178b27857250 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -39,6 +39,13 @@ class ReferencedLocationCrawler
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+// Function definition will require redeclarations to be included.
+if (FD == FD->getDefinition())
+  add(FD);
+return true;
+  }
+
   bool VisitCXXConstructExpr(CXXConstructExpr *CCE) {
 add(CCE->getConstructor());
 return true;

diff  --git a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp 
b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
index 783ab773b283e..978d3794fa0e0 100644
--- a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -79,6 +79,19 @@ TEST(IncludeCleaner, ReferencedLocations) {
   "struct ^X { ^X(int) {} int ^foo(); };",
   "auto x = X(42); auto y = x.foo();",
   },
+  // Function
+  {
+  "void ^foo();",
+  "void foo() {}",
+  },
+  {
+  "void foo() {}",
+  "void foo();",
+  },
+  {
+  "inline void ^foo() {}",
+  "void bar() { foo(); }",
+  },
   // Static function
   {
   "struct ^X { static bool ^foo(); }; bool X::^foo() {}",



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


[PATCH] D111711: [clangd] IncludeCleaner: Don't consider the definition as usage for function forward declarations

2021-10-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc521288ed391: [clangd] IncludeCleaner: Don't consider 
the definition as usage for function… (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111711

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -79,6 +79,19 @@
   "struct ^X { ^X(int) {} int ^foo(); };",
   "auto x = X(42); auto y = x.foo();",
   },
+  // Function
+  {
+  "void ^foo();",
+  "void foo() {}",
+  },
+  {
+  "void foo() {}",
+  "void foo();",
+  },
+  {
+  "inline void ^foo() {}",
+  "void bar() { foo(); }",
+  },
   // Static function
   {
   "struct ^X { static bool ^foo(); }; bool X::^foo() {}",
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -39,6 +39,13 @@
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+// Function definition will require redeclarations to be included.
+if (FD == FD->getDefinition())
+  add(FD);
+return true;
+  }
+
   bool VisitCXXConstructExpr(CXXConstructExpr *CCE) {
 add(CCE->getConstructor());
 return true;


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -79,6 +79,19 @@
   "struct ^X { ^X(int) {} int ^foo(); };",
   "auto x = X(42); auto y = x.foo();",
   },
+  // Function
+  {
+  "void ^foo();",
+  "void foo() {}",
+  },
+  {
+  "void foo() {}",
+  "void foo();",
+  },
+  {
+  "inline void ^foo() {}",
+  "void bar() { foo(); }",
+  },
   // Static function
   {
   "struct ^X { static bool ^foo(); }; bool X::^foo() {}",
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -39,6 +39,13 @@
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+// Function definition will require redeclarations to be included.
+if (FD == FD->getDefinition())
+  add(FD);
+return true;
+  }
+
   bool VisitCXXConstructExpr(CXXConstructExpr *CCE) {
 add(CCE->getConstructor());
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112521: [CUDA][NFC] Fix inexact warning message about lambdas

2021-10-26 Thread Ben Shi via Phabricator via cfe-commits
benshi001 created this revision.
benshi001 added reviewers: tra, fodinabor, Hahnfeld, yaxunl.
benshi001 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112521

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/test/Parser/lambda-attr.cu


Index: clang/test/Parser/lambda-attr.cu
===
--- clang/test/Parser/lambda-attr.cu
+++ clang/test/Parser/lambda-attr.cu
@@ -6,36 +6,36 @@
 
 __attribute__((device)) void device_attr() {
   ([]() __attribute__((device)) { device_fn(); })();
-  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after 
'()' in lambdas}}
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after 
the parameter list in lambdas}}
   ([] __attribute__((device)) () { device_fn(); })();
   ([] __attribute__((device)) { device_fn(); })();
 
   ([&]() __attribute__((device)){ device_fn(); })();
-  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after 
'()' in lambdas}}
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after 
the parameter list in lambdas}}
   ([&] __attribute__((device)) () { device_fn(); })();
   ([&] __attribute__((device)) { device_fn(); })();
 
   ([&](int) __attribute__((device)){ device_fn(); })(0);
-  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after 
'()' in lambdas}}
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after 
the parameter list in lambdas}}
   ([&] __attribute__((device)) (int) { device_fn(); })(0);
 }
 
 __attribute__((host)) __attribute__((device)) void host_device_attrs() {
   ([]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
-  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' 
in lambdas}}
-  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after 
'()' in lambdas}}
+  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after the 
parameter list in lambdas}}
+  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after 
the parameter list in lambdas}}
   ([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
   ([] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
 
   ([&]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
-  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' 
in lambdas}}
-  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after 
'()' in lambdas}}
+  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after the 
parameter list in lambdas}}
+  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after 
the parameter list in lambdas}}
   ([&] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
   ([&] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
 
   ([&](int) __attribute__((host)) __attribute__((device)){ hd_fn(); })(0);
-  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' 
in lambdas}}
-  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after 
'()' in lambdas}}
+  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after the 
parameter list in lambdas}}
+  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after 
the parameter list in lambdas}}
   ([&] __attribute__((host)) __attribute__((device)) (int) { hd_fn(); })(0);
 }
 
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1495,7 +1495,7 @@
   InGroup;
 
 def warn_cuda_attr_lambda_position : Warning<
-  "nvcc does not allow '__%0__' to appear after '()' in lambdas">,
+  "nvcc does not allow '__%0__' to appear after the parameter list in 
lambdas">,
   InGroup;
 def warn_pragma_force_cuda_host_device_bad_arg : Warning<
   "incorrect use of #pragma clang force_cuda_host_device begin|end">,


Index: clang/test/Parser/lambda-attr.cu
===
--- clang/test/Parser/lambda-attr.cu
+++ clang/test/Parser/lambda-attr.cu
@@ -6,36 +6,36 @@
 
 __attribute__((device)) void device_attr() {
   ([]() __attribute__((device)) { device_fn(); })();
-  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after the parameter list in lambdas}}
   ([] __attribute__((device)) () { device_fn(); })();
   ([] __attribute__((device)) { device_fn(); })();
 
   ([&]() __attribute__((device)){ device_fn(); })();
-  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
+  // expected-warning@-1 {{nvcc do

[PATCH] D112521: [CUDA][NFC] Fix inexact warning message about lambdas

2021-10-26 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

Acutally lambdas with CUDA attributes can have non-empty parameter list, and 
the original warning message is inexact.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112521

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


[PATCH] D112359: [RISCV] Unify depedency check and extension implication parsing logics

2021-10-26 Thread Yueh-Ting Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 382225.
eopXD added a comment.

Fix test fail and clang-format error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112359

Files:
  clang/test/CodeGen/RISCV/riscv-metadata.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64f-lp64d-abi.c
  clang/test/CodeGen/riscv32-ilp32d-abi.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2062,7 +2062,11 @@
 "unexpected token in '.attribute' directive"))
 return true;
 
-  if (Tag == RISCVAttrs::ARCH) {
+  if (IsIntegerValue)
+getTargetStreamer().emitAttribute(Tag, IntegerValue);
+  else if (Tag != RISCVAttrs::ARCH)
+getTargetStreamer().emitTextAttribute(Tag, StringValue);
+  else {
 StringRef Arch = StringValue;
 for (auto Feature : RISCVFeatureKV)
   if (llvm::RISCVISAInfo::isSupportedExtensionFeature(Feature.Key))
@@ -2093,35 +2097,9 @@
   setFeatureBits(RISCV::Feature64Bit, "64bit");
 else
   return Error(ValueExprLoc, "bad arch string " + Arch);
-  }
 
-  if (IsIntegerValue)
-getTargetStreamer().emitAttribute(Tag, IntegerValue);
-  else {
-if (Tag != RISCVAttrs::ARCH) {
-  getTargetStreamer().emitTextAttribute(Tag, StringValue);
-} else {
-  std::vector FeatureVector;
-  RISCVFeatures::toFeatureVector(FeatureVector, getSTI().getFeatureBits());
-
-  // Parse that by RISCVISAInfo->
-  unsigned XLen = getFeatureBits(RISCV::Feature64Bit) ? 64 : 32;
-  auto ParseResult = llvm::RISCVISAInfo::parseFeatures(XLen, FeatureVector);
-  if (!ParseResult) {
-std::string Buffer;
-raw_string_ostream OutputErrMsg(Buffer);
-handleAllErrors(ParseResult.takeError(),
-[&](llvm::StringError &ErrMsg) {
-  OutputErrMsg << ErrMsg.getMessage();
-});
-
-return Error(ValueExprLoc, OutputErrMsg.str());
-  }
-  auto &ISAInfo = *ParseResult;
-
-  // Then emit the arch string.
-  getTargetStreamer().emitTextAttribute(Tag, ISAInfo->toString());
-}
+// Then emit the arch string.
+getTargetStreamer().emitTextAttribute(Tag, ISAInfo->toString());
   }
 
   return false;
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -411,7 +411,6 @@
   assert(XLen == 32 || XLen == 64);
   std::unique_ptr ISAInfo(new RISCVISAInfo(XLen));
 
-  bool HasE = false;
   for (auto &Feature : Features) {
 StringRef ExtName = Feature;
 bool Experimental = false;
@@ -430,29 +429,19 @@
 if (ExtensionInfoIterator == ExtensionInfos.end())
   continue;
 
-if (Add) {
-  if (ExtName == "e") {
-if (XLen != 32)
-  return createStringError(
-  errc::invalid_argument,
-  "standard user-level extension 'e' requires 'rv32'");
-HasE = true;
-  }
-
+if (Add)
   ISAInfo->addExtension(ExtName, ExtensionInfoIterator->Version.Major,
 ExtensionInfoIterator->Version.Minor);
-} else
-  ISAInfo->Exts.erase(ExtName.str());
-  }
-  if (!HasE) {
-if (auto Version = findDefaultVersion("i"))
-  ISAInfo->addExtension("i", Version->Major, Version->Minor);
 else
-  llvm_unreachable("Default extension version for 'i' not found?");
+  ISAInfo->Exts.erase(ExtName.str());
   }
 
+  ISAInfo->updateImplication();
   ISAInfo->updateFLen();
 
+  if (Error Result = ISAInfo->checkDependency())
+return std::move(Result);
+
   return std::move(ISAInfo);
 }
 
@@ -478,7 +467,6 @@
   // The canonical order specified in ISA manual.
   // Ref: Table 22.1 in RISC-V User-Level ISA V2.2
   StringRef StdExts = AllStdExts;
-  bool HasF = false, HasD = false;
   char Baseline = Arch[4];
 
   // First letter should be 'e', 'i' or 'g'.
@@ -499,8 +487,6 @@
   case 'g':
 // g = imafd
 StdExts = StdExts.drop_front(4);
-HasF = true;
-HasD = true;
 break;
   }
 
@@ -581,34 +567,14 @@
 
 // The order is OK, then push it into features.
 // TODO: Use version number when setting target features
-switch (C) {
-default:
-  // Currently LLVM supports only "mafdcbv".
+// Currently LLVM supports only "mafdcbv".
+StringRef SupportedStandardExtens

[PATCH] D111986: [Clang] Add elementwise abs builtin.

2021-10-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 382226.
fhahn marked 2 inline comments as done.
fhahn added a comment.

Rebased after recent changes in D111985 : 
changes the return type of SemaBuiltinElementwiseMathOneArg to bool and drop 
the CallResult argument. Also added tests with const, typedef'ed and variables 
with address space


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111986

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c

Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -2,6 +2,7 @@
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 typedef int int3 __attribute__((ext_vector_type(3)));
+typedef unsigned unsigned4 __attribute__((ext_vector_type(4)));
 
 struct Foo {
   char *p;
@@ -11,6 +12,26 @@
 typedef int bar;
 bar b;
 
+void test_builtin_elementwise_abs(int i, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+  struct Foo s = __builtin_elementwise_abs(i);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+
+  i = __builtin_elementwise_abs();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_abs(i, i);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  i = __builtin_elementwise_abs(v);
+  // expected-error@-1 {{assigning to 'int' from incompatible type 'float4' (vector of 4 'float' values)}}
+
+  u = __builtin_elementwise_abs(u);
+  // expected-error@-1 {{argument must have a signed integer or floating point type, but was an unsigned integer type}}
+
+  uv = __builtin_elementwise_abs(uv);
+  // expected-error@-1 {{argument must have a signed integer or floating point type, but was an unsigned integer type}}
+}
+
 void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, int *p) {
   i = __builtin_elementwise_max(p, d);
   // expected-error@-1 {{argument types do not match, 'int *' != 'double'}}
Index: clang/test/CodeGen/builtins-elementwise-math.c
===
--- clang/test/CodeGen/builtins-elementwise-math.c
+++ clang/test/CodeGen/builtins-elementwise-math.c
@@ -8,12 +8,48 @@
 typedef int bar;
 bar b;
 
+void test_builtin_elementwise_abs(float f1, float f2, double d1, double d2,
+  float4 vf1, float4 vf2, si8 vi1, si8 vi2,
+  long long int i1, long long int i2) {
+  // CHECK-LABEL: define void @test_builtin_elementwise_abs(
+  // CHECK:  [[F1:%.+]] = load float, float* %f1.addr, align 4
+  // CHECK-NEXT:  call float @llvm.fabs.f32(float [[F1]])
+  f2 = __builtin_elementwise_abs(f1);
+
+  // CHECK:  [[D1:%.+]] = load double, double* %d1.addr, align 8
+  // CHECK-NEXT: call double @llvm.fabs.f64(double [[D1]])
+  d2 = __builtin_elementwise_abs(d1);
+
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call <4 x float> @llvm.fabs.v4f32(<4 x float> [[VF1]])
+  vf2 = __builtin_elementwise_abs(vf1);
+
+  // CHECK:  [[I1:%.+]] = load i64, i64* %i1.addr, align 8
+  // CHECK-NEXT: call i64 @llvm.abs.i64(i64 [[I1]], i1 false)
+  i2 = __builtin_elementwise_abs(i1);
+
+  // CHECK:  [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16
+  // CHECK-NEXT: call <8 x i16> @llvm.abs.v8i16(<8 x i16> [[VI1]], i1 false)
+  vi2 = __builtin_elementwise_abs(vi1);
+
+  // CHECK:  [[CVI2:%.+]] = load <8 x i16>, <8 x i16>* %cvi2, align 16
+  // CHECK-NEXT: call <8 x i16> @llvm.abs.v8i16(<8 x i16> [[CVI2]], i1 false)
+  const si8 cvi2 = vi2;
+  vi2 = __builtin_elementwise_abs(cvi2);
+
+  // CHECK:  [[IA1:%.+]] = load i32, i32 addrspace(1)* @int_as_one, align 4
+  // CHECK-NEXT: call i32 @llvm.abs.i32(i32 [[IA1]], i1 false)
+  b = __builtin_elementwise_abs(int_as_one);
+
+  // CHECK:   call i32 @llvm.abs.i32(i32 -10, i1 false)
+  b = __builtin_elementwise_abs(-10);
+}
+
 void test_builtin_elementwise_max(float f1, float f2, double d1, double d2,
   float4 vf1, float4 vf2, long long int i1,
   long long int i2, si8 vi1, si8 vi2,
   unsigned u1, unsigned u2, u4 vu1, u4 vu2) {
   // CHECK-LABEL: define void @test_builtin_elementwise_max(
-
   // CHECK:  [[F1:%.+]] = load float, float* %f1.addr, align 4
   // CHECK-NEXT: [[F2:%.+]] = load float, float* %f2.addr, align 4
   // CHECK-NEXT:  call float @llvm.maxnum.f32(fl

[PATCH] D111047: CUDA/HIP: Allow __int128 on the host side

2021-10-26 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 382228.
linjamaki added a comment.

Rephrase expressions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111047

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCUDA/allow-int128.cu
  clang/test/SemaCUDA/spirv-int128.cu


Index: clang/test/SemaCUDA/spirv-int128.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/spirv-int128.cu
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple spirv64 -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+
+#define __device__ __attribute__((device))
+
+__int128 h_glb;
+
+__device__ __int128 d_unused;
+
+// expected-note@+1 {{'d_glb' defined here}}
+__device__ __int128 d_glb;
+
+__device__ __int128 bar() {
+  // expected-error@+1 {{'d_glb' requires 128 bit size '__int128' type 
support, but target 'spirv64' does not support it}}
+  return d_glb;
+}
Index: clang/test/SemaCUDA/allow-int128.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/allow-int128.cu
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple nvptx \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+
+// expected-no-diagnostics
+#define __device__ __attribute__((device))
+
+__int128 h_glb;
+__device__ __int128 d_unused;
+__device__ __int128 d_glb;
+__device__ __int128 bar() {
+  return d_glb;
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1496,8 +1496,8 @@
   }
   case DeclSpec::TST_int128:
 if (!S.Context.getTargetInfo().hasInt128Type() &&
-!S.getLangOpts().SYCLIsDevice &&
-!(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice))
+!(S.getLangOpts().SYCLIsDevice || S.getLangOpts().CUDAIsDevice ||
+  (S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice)))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__int128";
 if (DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned)
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1855,7 +1855,8 @@
 }
 
 void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) {
-  if (!LangOpts.SYCLIsDevice && !(LangOpts.OpenMP && LangOpts.OpenMPIsDevice))
+  if (!(LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice) 
||
+LangOpts.CUDAIsDevice))
 return;
 
   if (isUnevaluatedContext() || Ty.isNull())


Index: clang/test/SemaCUDA/spirv-int128.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/spirv-int128.cu
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple spirv64 -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+
+#define __device__ __attribute__((device))
+
+__int128 h_glb;
+
+__device__ __int128 d_unused;
+
+// expected-note@+1 {{'d_glb' defined here}}
+__device__ __int128 d_glb;
+
+__device__ __int128 bar() {
+  // expected-error@+1 {{'d_glb' requires 128 bit size '__int128' type support, but target 'spirv64' does not support it}}
+  return d_glb;
+}
Index: clang/test/SemaCUDA/allow-int128.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/allow-int128.cu
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple nvptx \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+
+// expected-no-diagnostics
+#define __device__ __attribute__((device))
+
+__int128 h_glb;
+__device__ __int128 d_unused;
+__device__ __int128 d_glb;
+__device__ __int128 bar() {
+  return d_glb;
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1496,8 +1496,8 @@
   }
   case DeclSpec::TST_int128:
 if (!S.Context.getTargetInfo().hasInt128Type() &&
-!S.getLangOpts().SYCLIsDevice &&
-!(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice))
+!(S.getLangOpts().SYCLIsDevice || S.getLangOpts().CUDAIsDevice ||
+  (S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice)))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__int128";
 if (DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned)
Index: clang/lib/Sema/Sema.cpp
=

[PATCH] D111870: [clangd] Add a way to enable IncludeCleaner through config

2021-10-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Awesome, let's ship it!
Only nits on the text, feel free to ignore any you don't like




Comment at: clang-tools-extra/clangd/ConfigFragment.h:213
 
+/// Controls how clangd will treat and warn users on suboptimal include
+/// usage.

brevity: consider "correct" or "diagnose" instead of "treat and warn users on".
specificity: consider "unnecessary #include directives" instead of "suboptimal 
include usage".



Comment at: clang-tools-extra/clangd/ConfigFragment.h:217
+/// When set to Strict, clangd will warn about all headers that are not 
used
+/// (no symbols referenced in the main file come from that header) in the
+/// main file but are directly included from it.

We're glossing over the key idea ("come from") here, and mixing what the Strict 
policy is about with what the feature is about. I think we can be a bit more 
precise.

I'd add a second sentence to the first paragraph, elaborating a little:
```
clangd can warn if a header is `#included` but not used, and suggest removing 
it.
```

And then we can define the Strict policy, and mention its limitations.

```
Strict means a header is unused if it does not *directly* provide any symbol 
used in the file.
Removing it may still break compilation if it transitively includes headers 
that are used.
This should be fixed by including those headers directly.
```



Comment at: clang-tools-extra/clangd/ConfigFragment.h:220
+///
+/// FIXME(kirillbobyrev): Removing that header might break the code if it
+/// transitively includes used headers and these headers are not included

I think at least the "fixme" part isn't suitable for public docs.
We also don't mention what we want to do instead.

I'd suggest:
 - move this to the part of the code that generates fixes
 - mention that we if it's transitively used, we could suggest replacing it 
with the needed `#include`s instead (I think this is actually pretty 
feasible...)
 - while there, maybe also add a FIXME that we should suggest adding IWYU 
pragma export/keep as an alternative fixes (once we honor that)



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:251
+Diag D;
+D.Message = llvm::formatv("included header {0} is not used", Inc->Written);
+D.Name = "unused-includes";

This is totally up to you, but wanted to be explicit with what I meant about 
basename...

If the path is long, this can be: `included header 
this/is/a/long/path/to/some/header.h is not used`
Depending how you feel about having to visually scan past the path to get to 
the end of the sentence, you might choose to trade precision for brevity: 
`included header header.h is not used`.

This is `llvm::sys::path::filename(stripHeaderQuotes(Inc->Written), posix)`, 
with stripHeaderQuotes to be written.

Again, I don't feel strongly, your call



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:215
+D.Message = "Included header is unused";
+D.Name = "clangd-include-cleaner";
+// FIXME: This range should be the whole line with target #include.

kbobyrev wrote:
> sammccall wrote:
> > sammccall wrote:
> > > Source should be `Clangd` I think (our first?).
> > > 
> > > Name should be something like "unused-include": this doesn't need to echo 
> > > the tool name.
> > clangd-unused-header -> unused-header
> > 
> > (there's a test, but it's stale)
> what do you mean by "stale"?
You'd updated the diagnostic name, but not the suppression check. I was going 
to suggest a test for suppression, and realized you had one, it was also 
testing the old name though.

LG now!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111870

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


[PATCH] D112296: [Analyzer][solver] Handle adjustments in constraint assignor remainder

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



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1623
 if (!Constraint.containsZero()) {
-  State = RCM.assumeSymNE(State, LHS, Zero, Zero);
+  State = RCM.assumeSymRel(State, LHS, BO_NE, Zero);
   if (!State)

ASDenysPetrov wrote:
> martong wrote:
> > martong wrote:
> > > ASDenysPetrov wrote:
> > > > martong wrote:
> > > > > ASDenysPetrov wrote:
> > > > > > What I see, you're still trying to avoid using `State->assume`, 
> > > > > > which I recommend in a parent revision, but coming closer using its 
> > > > > > guts.
> > > > > So, it would look like this:
> > > > > ```
> > > > > State = 
> > > > > State->assume(Builder.makeSymbolVal(LHS).castAs(), 
> > > > > true);
> > > > > ```
> > > > > The main  reason why we cannot use `State->assume` is that it boils 
> > > > > down to `RangedConstraintManager::assumeSym` that has a specific 
> > > > > logic for the `boolean` assumption. I.e. the operator is being 
> > > > > negated in a case:
> > > > > ```
> > > > > if (BinaryOperator::isComparisonOp(op) && op != BO_Cmp) {
> > > > >   if (!Assumption)
> > > > > op = BinaryOperator::negateComparisonOp(op);
> > > > > 
> > > > >   return assumeSymRel(State, SIE->getLHS(), op, SIE->getRHS());
> > > > > }
> > > > > ```
> > > > > You can try it for yourself, and see that the test case added in this 
> > > > > patch will not pass if we were to use `State->assume`. Essentially, 
> > > > > we have to evade the special "bool" logic, and the closest we can get 
> > > > > is using `assumeSymRel`.
> > > > > 
> > > > > Besides that, by using `State->assume` we would have a superfluous 
> > > > > conversion chain `Symbol->SVal->Symbol` until we reach 
> > > > > `assumeSymRel`. 
> > > > >You can try it for yourself, and see that the test case added in this 
> > > > >patch will not pass if we were to use `State->assume.`
> > > > I can't confirm. Your test case passed when I replaced with `State = 
> > > > State->assume(Builder.makeSymbolVal(LHS).castAs(), 
> > > > true);`.
> > > > > specific logic for the boolean assumption. I.e. the operator is being 
> > > > > negated in a case:
> > > > That just simplifies the expression, say, you want to find whether `x > 
> > > > 5 is false`, than the Solver finds for you whether 
> > > > `x <= 5 is true`, which is an equivalent.
> > > > > Essentially, we have to evade the special "bool" logic
> > > > There is no problem with //bool// logic. It's an equivalent of `SVal != 
> > > > 0` when //true//, and `SVal == 0` when //false//. Nothing more.
> > > > 
> > > > All in all I see the problem to use `assume`. Not because of this 
> > > > function itself, but because you do it incorrect by getting an `SVal` 
> > > > from `LHS` with `makeSymbolVal`. We should get it with `State->getSVal` 
> > > > which needs `LocationContext` as a second parameter. And that's the 
> > > > challenge, to pass `LocationContext` here, since 
> > > > `RangedConstraintManager` doesn't use it, at least for now.
> > > > I can't confirm. Your test case passed when I replaced with `State = 
> > > > State->assume(Builder.makeSymbolVal(LHS).castAs(), 
> > > > true);`.
> > > 
> > > Actually, since the last time I tried with `State->assume` we merged 
> > > D110913. If you revert the changes of that patch you'll see that this 
> > > test case indeed fails. However, here is a slightly modified case that 
> > > fails even on the current llvm/main branch with `State->assume` but 
> > > passes with `assumeSymRel`:
> > > ```
> > > void rem_constant_adj(int x, int y) {
> > >   if ((x + y + 1) % 3 == 0) // (x + y + 1) % 3 != 0 -> x + y + 1 != 0 -> 
> > > x != -1
> > > return;
> > >   clang_analyzer_eval(x + y + 1 != 0); // expected-warning{{TRUE}}
> > >   clang_analyzer_eval(x + y != -1);// expected-warning{{TRUE}}
> > >   (void)(x * y); // keep the constraints alive.
> > > }
> > > ```
> > > 
> > > The only change is that we have `x + y` instead of `x`. 
> > > 
> > > Now, the explanation for the original test case when we have `(x + 1) % 
> > > 3`: When we ask the value of `x != -1` then `assumeDual` evaluates the 
> > > TRUE case which is feasible and then it tries to evaluate the FALSE case, 
> > > so it queries `x == -1` is true. However, this kicks in the 
> > > simplification, which simplifies the previous constraint of `x+1, [not 
> > > 0]` to `-1 + 1, [not 0]` which is a contradiction, thus an infeasible 
> > > state is returned.
> > > When we have `x + y` in the test case, then simplification cannot 
> > > simplify `x + y + 1`, thus the situation is different.
> > > 
> > > So, the main problem with `State->assume` is that it does not compute the 
> > > adjustment. I.e. when we have `x + 1` as LHS then `assumeSym(LHS)` calls 
> > > into `assumeSymUnsupported` and that does not compute the adjustment. The 
> > > only functions that compute the adjustment are `assumeSymRel` and 
> > > `assumeSymIncl

[PATCH] D111047: CUDA/HIP: Allow __int128 on the host side

2021-10-26 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

Thanks for the review. Updated the patch with the style suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111047

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


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

2021-10-26 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

Gentle ping. Is anything needed to be addressed to get this patch accepted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108621

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


[PATCH] D110549: [HIPSPV][1/4] Refactor HIP tool chain

2021-10-26 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

Gentle ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110549

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


[PATCH] D110618: [HIPSPV][2/4] Add HIPSPV tool chain

2021-10-26 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

Gentle ping. Is anything needed to be addressed to get this patch accepted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110618

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


[PATCH] D109506: [clangd] Print current request context along with the stack trace

2021-10-26 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hi,
It seems like this patch may cause timeouts. I've seen it myself and also in 
this bot:
http://lab.llvm.org:8011/#/builders/52/builds/11791

When I got the timeout in our downstream CI I think it was the Clangd :: 
crash.test that had problems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

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


[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@martong (inline)




Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1757-1760
+  // FIXME: Nevertheless, we can't do the same for cases, like:
+  //   const char *str = "123"; // literal length is 4
+  //   char c = str[41];// offset is 41
+  // It should be properly handled before reaching this point.

ASDenysPetrov wrote:
> martong wrote:
> > Thanks for updating the patch! However, this `FIXME` makes me worried. Do 
> > you think you could pass the `Decl` itself to `getSValFromInitListExpr` in 
> > order to be able to check whether the type is a pointer or an array? 
> This worried me as well. Currently I can't find a way to get the `Decl` for 
> `SL`.
> 
We can load this as is for now with mentioning the known issue.


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

https://reviews.llvm.org/D107339

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


[PATCH] D112001: [Clang] Add min/max reduction builtins.

2021-10-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 382240.
fhahn added a comment.

Rebased after recent changes in D111985  
https://reviews.llvm.org/D111985: changes the return type of 
SemaBuiltinReduceMath to bool and drop the CallResult argument.

Also added tests with const and variables with address space and moved tests to 
builtins-reduction-math.c instead of builtins-elementwise-math.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112001

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-reduction-math.c
  clang/test/Sema/builtins-reduction-math.c

Index: clang/test/Sema/builtins-reduction-math.c
===
--- /dev/null
+++ clang/test/Sema/builtins-reduction-math.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -pedantic -verify -triple=x86_64-apple-darwin9
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef int int3 __attribute__((ext_vector_type(3)));
+typedef unsigned unsigned4 __attribute__((ext_vector_type(4)));
+
+struct Foo {
+  char *p;
+};
+
+void test_builtin_reduce_max(int i, float4 v, int3 iv) {
+  struct Foo s = __builtin_reduce_max(iv);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+
+  i = __builtin_reduce_max(v, v);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  i = __builtin_reduce_max();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_reduce_max(i);
+  // expected-error@-1 {{argument must have a vector type, but was 'int'}}
+}
+
+void test_builtin_reduce_min(int i, float4 v, int3 iv) {
+  struct Foo s = __builtin_reduce_min(iv);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+
+  i = __builtin_reduce_min(v, v);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  i = __builtin_reduce_min();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_reduce_min(i);
+  // expected-error@-1 {{argument must have a vector type, but was 'int'}}
+}
Index: clang/test/CodeGen/builtins-reduction-math.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-reduction-math.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef short int si8 __attribute__((ext_vector_type(8)));
+typedef unsigned int u4 __attribute__((ext_vector_type(4)));
+
+__attribute__((address_space(1))) float4 vf1_as_one;
+
+void test_builtin_reduce_max(float4 vf1, si8 vi1, u4 vu1) {
+  // CHECK-LABEL: define void @test_builtin_reduce_max(
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call float @llvm.vector.reduce.fmax.v4f32(<4 x float> [[VF1]])
+  float r1 = __builtin_reduce_max(vf1);
+
+  // CHECK:  [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16
+  // CHECK-NEXT: call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> [[VI1]])
+  short r2 = __builtin_reduce_max(vi1);
+
+  // CHECK:  [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16
+  // CHECK-NEXT: call i32 @llvm.vector.reduce.umax.v4i32(<4 x i32> [[VU1]])
+  unsigned r3 = __builtin_reduce_max(vu1);
+
+  // CHECK:  [[VF1_AS1:%.+]] = load <4 x float>, <4 x float> addrspace(1)* @vf1_as_one, align 16
+  // CHECK-NEXT: [[RDX1:%.+]] = call float @llvm.vector.reduce.fmax.v4f32(<4 x float> [[VF1_AS1]])
+  // CHECK-NEXT: fpext float [[RDX1]] to double
+  const double r4 = __builtin_reduce_max(vf1_as_one);
+
+  // CHECK:  [[CVI1:%.+]] = load <8 x i16>, <8 x i16>* %cvi1, align 16
+  // CHECK-NEXT: [[RDX2:%.+]] = call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> [[CVI1]])
+  // CHECK-NEXT: sext i16 [[RDX2]] to i64
+  const si8 cvi1 = vi1;
+  unsigned long long r5 = __builtin_reduce_max(cvi1);
+}
+
+void test_builtin_reduce_min(float4 vf1, si8 vi1, u4 vu1) {
+  // CHECK-LABEL: define void @test_builtin_reduce_min(
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call float @llvm.vector.reduce.fmin.v4f32(<4 x float> [[VF1]])
+  float r1 = __builtin_reduce_min(vf1);
+
+  // CHECK:  [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16
+  // CHECK-NEXT: call i16 @llvm.vector.reduce.smin.v8i16(<8 x i16> [[VI1]])
+  short r2 = __builtin_reduce_min(vi1);
+
+  // CHECK:  [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16
+  // CHECK-NEXT: call i32 @llvm.vector.reduce.umin.v4i32(<4 x i32> [[VU1]])
+  unsigned r3 = __builtin_reduce_min(vu1);
+
+  // CHECK:

[PATCH] D111870: [clangd] Add a way to enable IncludeCleaner through config

2021-10-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 382242.
kbobyrev marked 4 inline comments as done.
kbobyrev added a comment.

Resolve the review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111870

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1479,6 +1479,44 @@
   AllOf(Diag(Test.range("deprecated"), "'bar' is deprecated"),
 WithTag(DiagnosticTag::Deprecated;
 }
+
+TEST(DiagnosticsTest, IncludeCleaner) {
+  Annotations Test(R"cpp(
+$fix[[  $diag[[#include "unused.h"]]
+]]  #include "used.h"
+
+  void foo() {
+used();
+  }
+  )cpp");
+  TestTU TU;
+  TU.Code = Test.code().str();
+  TU.AdditionalFiles["unused.h"] = R"cpp(
+void unused() {}
+  )cpp";
+  TU.AdditionalFiles["used.h"] = R"cpp(
+void used() {}
+  )cpp";
+  // Off by default.
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  Config Cfg;
+  Cfg.Diagnostics.UnusedIncludes = Config::UnusedIncludesPolicy::Strict;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(
+  *TU.build().getDiagnostics(),
+  UnorderedElementsAre(AllOf(
+  Diag(Test.range("diag"), "included header unused.h is not used"),
+  WithTag(DiagnosticTag::Unnecessary), DiagSource(Diag::Clangd),
+  WithFix(Fix(Test.range("fix"), "", "remove #include directive");
+  Cfg.Diagnostics.SuppressAll = true;
+  WithContextValue SuppressAllWithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  Cfg.Diagnostics.SuppressAll = false;
+  Cfg.Diagnostics.Suppress = {"unused-includes"};
+  WithContextValue SuppressFilterWithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -67,6 +67,7 @@
 CheckOptions:
   IgnoreMacros: true
   example-check.ExampleOption: 0
+  UnusedIncludes: Strict
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
@@ -83,6 +84,8 @@
   EXPECT_THAT(Results[3].Diagnostics.ClangTidy.CheckOptions,
   ElementsAre(PairVal("IgnoreMacros", "true"),
   PairVal("example-check.ExampleOption", "0")));
+  EXPECT_TRUE(Results[3].Diagnostics.UnusedIncludes);
+  EXPECT_EQ("Strict", *Results[3].Diagnostics.UnusedIncludes.getValue());
 }
 
 TEST(ParseYAML, Locations) {
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -244,6 +244,25 @@
   }
 }
 
+TEST_F(ConfigCompileTests, DiagnosticsIncludeCleaner) {
+  // Defaults to None.
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::None);
+
+  Frag = {};
+  Frag.Diagnostics.UnusedIncludes.emplace("None");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::None);
+
+  Frag = {};
+  Frag.Diagnostics.UnusedIncludes.emplace("Strict");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::Strict);
+}
+
 TEST_F(ConfigCompileTests, DiagnosticSuppression) {
   Frag.Diagnostics.Suppress.emplace_back("bugprone-use-after-move");
   Frag.Diagnostics.Suppress.emplace_back("unreachable-code");
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -18,6 +18,7 @@
 #include "FeatureModule.h"
 #include "Headers.h"
 #include "HeuristicResolver.h"
+#include "IncludeCleaner.h"
 #include "IncludeFixer.h"
 #include "Preamble.h

[PATCH] D110622: [HIPSPV][3/4] Enable SPIR-V emission for HIP

2021-10-26 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 382244.
linjamaki added a comment.

Improve `--offload` option description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110622

Files:
  clang/include/clang/Basic/Cuda.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/Inputs/hipspv-dev-lib/a/a.bc
  clang/test/Driver/Inputs/hipspv-dev-lib/b/b.bc
  clang/test/Driver/Inputs/hipspv-dev-lib/hipspv-spirv64.bc
  clang/test/Driver/Inputs/hipspv/bin/.hipVersion
  clang/test/Driver/Inputs/hipspv/lib/hip-device-lib/hipspv-spirv64.bc
  clang/test/Driver/Inputs/hipspv/lib/libLLVMHipSpvPasses.so
  clang/test/Driver/Inputs/pass-plugin.so
  clang/test/Driver/hipspv-device-libs.hip
  clang/test/Driver/hipspv-pass-plugin.hip
  clang/test/Driver/hipspv-toolchain-rdc.hip
  clang/test/Driver/hipspv-toolchain.hip
  clang/test/Driver/invalid-offload-options.cpp

Index: clang/test/Driver/invalid-offload-options.cpp
===
--- /dev/null
+++ clang/test/Driver/invalid-offload-options.cpp
@@ -0,0 +1,18 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -### -x hip -target x86_64-linux-gnu --offload= \
+// RUN:   --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
+// RUN: 2>&1 | FileCheck --check-prefix=INVALID-TARGET %s
+// RUN: %clang -### -x hip -target x86_64-linux-gnu --offload=foo   \
+// RUN:   --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
+// RUN: 2>&1 | FileCheck --check-prefix=INVALID-TARGET %s
+
+// INVALID-TARGET: error: Invalid or unsupported offload target: '{{.*}}'
+
+// RUN: %clang -### -x hip -target x86_64-linux-gnu --offload=foo,bar \
+// RUN:   --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
+// RUN: 2>&1 | FileCheck --check-prefix=TOO-MANY-TARGETS %s
+
+// TOO-MANY-TARGETS: error: Only one offload target is supported in HIP.
Index: clang/test/Driver/hipspv-toolchain.hip
===
--- /dev/null
+++ clang/test/Driver/hipspv-toolchain.hip
@@ -0,0 +1,37 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -### -target x86_64-linux-gnu --offload=spirv64 \
+// RUN:   --hip-path=%S/Inputs/hipspv -nohipwrapperinc %s \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "spirv64"
+// CHECK-SAME: "-aux-triple" "{{.*}}" "-emit-llvm-bc"
+// CHECK-SAME: "-fcuda-is-device"
+// CHECK-SAME: "-fcuda-allow-variadic-functions"
+// CHECK-SAME: "-mlink-builtin-bitcode" {{".*/hipspv/lib/hip-device-lib/hipspv-spirv64.bc"}}
+// CHECK-SAME: "-isystem" {{".*/hipspv/include"}}
+// CHECK-SAME: "-fhip-new-launch-api"
+// CHECK-SAME: "-o" [[DEV_BC:".*bc"]]
+// CHECK-SAME: "-x" "hip"
+
+// CHECK: {{".*llvm-link"}} [[DEV_BC]] "-o" [[LINK_BC:".*bc"]]
+
+// CHECK: {{".*opt"}} [[LINK_BC]] "-load-pass-plugin"
+// CHECK-SAME: {{".*/hipspv/lib/libLLVMHipSpvPasses.so"}}
+// CHECK-SAME: "-passes=hip-post-link-passes" "-o" [[LOWER_BC:".*bc"]]
+
+// CHECK: {{".*llvm-spirv"}} "--spirv-max-version=1.1" "--spirv-ext=+all"
+// CHECK-SAME: [[LOWER_BC]] "-o" "[[SPIRV_OUT:.*out]]"
+
+// CHECK: {{".*clang-offload-bundler"}} "-type=o" "-bundle-align=4096"
+// CHECK-SAME: "-targets=host-x86_64-unknown-linux,hip-spirv64generic"
+// CHECK-SAME: "-inputs={{.*}},[[SPIRV_OUT]]" "-outputs=[[BUNDLE:.*hipfb]]"
+
+// CHECK: [[CLANG]] "-cc1" "-triple" {{".*"}} "-aux-triple" "spirv64"
+// CHECK-SAME: "-emit-obj"
+// CHECK-SAME: "-fcuda-include-gpubinary" "[[BUNDLE]]"
+// CHECK-SAME: "-o" [[OBJ_HOST:".*o"]] "-x" "hip"
+
+// CHECK: {{".*ld.*"}} {{.*}}[[OBJ_HOST]]
Index: clang/test/Driver/hipspv-toolchain-rdc.hip
===
--- /dev/null
+++ clang/test/Driver/hipspv-toolchain-rdc.hip
@@ -0,0 +1,63 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -### -x hip -target x86_64-linux-gnu --offload=spirv64 \
+// RUN:   -fgpu-rdc --hip-path=%S/Inputs/hipspv -nohipwrapperinc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s
+
+// Emit objects for host side path
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-aux-triple" "spirv64"
+// CHECK-SAME: "-emit-obj"
+// CHECK-SAME: "-fgpu-rdc"
+// CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
+// CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
+
+// CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-aux-triple" "spirv64"
+// CHECK-SAME: 

[PATCH] D112359: [RISCV] Unify depedency check and extension implication parsing logics

2021-10-26 Thread Yueh-Ting Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 382250.
eopXD added a comment.

Update code and test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112359

Files:
  clang/test/CodeGen/RISCV/riscv-metadata.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64f-lp64d-abi.c
  clang/test/CodeGen/riscv32-ilp32d-abi.cpp
  clang/test/Driver/riscv-arch.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2062,7 +2062,11 @@
 "unexpected token in '.attribute' directive"))
 return true;
 
-  if (Tag == RISCVAttrs::ARCH) {
+  if (IsIntegerValue)
+getTargetStreamer().emitAttribute(Tag, IntegerValue);
+  else if (Tag != RISCVAttrs::ARCH)
+getTargetStreamer().emitTextAttribute(Tag, StringValue);
+  else {
 StringRef Arch = StringValue;
 for (auto Feature : RISCVFeatureKV)
   if (llvm::RISCVISAInfo::isSupportedExtensionFeature(Feature.Key))
@@ -2070,7 +2074,7 @@
 
 auto ParseResult = llvm::RISCVISAInfo::parseArchString(
 StringValue, /*EnableExperimentalExtension=*/true,
-/*ExperimentalExtensionVersionCheck=*/false);
+/*ExperimentalExtensionVersionCheck=*/true);
 if (!ParseResult) {
   std::string Buffer;
   raw_string_ostream OutputErrMsg(Buffer);
@@ -2093,35 +2097,9 @@
   setFeatureBits(RISCV::Feature64Bit, "64bit");
 else
   return Error(ValueExprLoc, "bad arch string " + Arch);
-  }
 
-  if (IsIntegerValue)
-getTargetStreamer().emitAttribute(Tag, IntegerValue);
-  else {
-if (Tag != RISCVAttrs::ARCH) {
-  getTargetStreamer().emitTextAttribute(Tag, StringValue);
-} else {
-  std::vector FeatureVector;
-  RISCVFeatures::toFeatureVector(FeatureVector, getSTI().getFeatureBits());
-
-  // Parse that by RISCVISAInfo->
-  unsigned XLen = getFeatureBits(RISCV::Feature64Bit) ? 64 : 32;
-  auto ParseResult = llvm::RISCVISAInfo::parseFeatures(XLen, FeatureVector);
-  if (!ParseResult) {
-std::string Buffer;
-raw_string_ostream OutputErrMsg(Buffer);
-handleAllErrors(ParseResult.takeError(),
-[&](llvm::StringError &ErrMsg) {
-  OutputErrMsg << ErrMsg.getMessage();
-});
-
-return Error(ValueExprLoc, OutputErrMsg.str());
-  }
-  auto &ISAInfo = *ParseResult;
-
-  // Then emit the arch string.
-  getTargetStreamer().emitTextAttribute(Tag, ISAInfo->toString());
-}
+// Then emit the arch string.
+getTargetStreamer().emitTextAttribute(Tag, ISAInfo->toString());
   }
 
   return false;
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -360,6 +360,11 @@
 
 if (ExperimentalExtensionVersionCheck &&
 (MajorStr.empty() && MinorStr.empty())) {
+  if (auto DefaultVersion = findDefaultVersion(Ext)) {
+Major = DefaultVersion->Major;
+Minor = DefaultVersion->Minor;
+return Error::success();
+  }
   std::string Error =
   "experimental extension requires explicit version number `" +
   Ext.str() + "`";
@@ -411,7 +416,6 @@
   assert(XLen == 32 || XLen == 64);
   std::unique_ptr ISAInfo(new RISCVISAInfo(XLen));
 
-  bool HasE = false;
   for (auto &Feature : Features) {
 StringRef ExtName = Feature;
 bool Experimental = false;
@@ -430,29 +434,19 @@
 if (ExtensionInfoIterator == ExtensionInfos.end())
   continue;
 
-if (Add) {
-  if (ExtName == "e") {
-if (XLen != 32)
-  return createStringError(
-  errc::invalid_argument,
-  "standard user-level extension 'e' requires 'rv32'");
-HasE = true;
-  }
-
+if (Add)
   ISAInfo->addExtension(ExtName, ExtensionInfoIterator->Version.Major,
 ExtensionInfoIterator->Version.Minor);
-} else
-  ISAInfo->Exts.erase(ExtName.str());
-  }
-  if (!HasE) {
-if (auto Version = findDefaultVersion("i"))
-  ISAInfo->addExtension("i", Version->Major, Version->Minor);
 else
-  llvm_unreachable("Default extension version for 'i' not found?");
+  ISAInfo->Exts.erase(ExtName.str());
   }
 
+  ISAInfo->updateImplication();
   ISAInfo->updateFLen();
 
+  if (Error Result = ISAInfo->c

[PATCH] D112359: [RISCV] Unify depedency check and extension implication parsing logics

2021-10-26 Thread Yueh-Ting Chen via Phabricator via cfe-commits
eopXD added a comment.

The test cases are modified because unifying the logic here shows the place 
where clang / llvm deal with target feature inconsistently.
I think it would be beneficial if we have them consistent.

- Test cases with `clang -cc1` originally don't do dependency check to target 
feature specified
  - This patch add target feature so that dependency checks can pass

- Originally clang driver's `-march` enforces version to be specified, while 
llvm allows `.attribute arch` to not specify version (and picks the default one)
  - This patch lets clang search for default version if no version is specified 
(so delete `NOVERS` test case in `clang/test/Driver/riscv-arch.c`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112359

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


[clang-tools-extra] 6d314ee - [clangd] Add a way to enable IncludeCleaner through config

2021-10-26 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-10-26T12:53:05+02:00
New Revision: 6d314ee570975610ef85e8c56659f00857b49744

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

LOG: [clangd] Add a way to enable IncludeCleaner through config

This is useful for dogfooding the feature and spotting bugs.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/Diagnostics.h
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/IncludeCleaner.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 72694788cfbf..0e48d2f0ceb6 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -86,6 +86,7 @@ struct Config {
 ExternalIndexSpec External;
   } Index;
 
+  enum UnusedIncludesPolicy { Strict, None };
   /// Controls warnings and errors when parsing code.
   struct {
 bool SuppressAll = false;
@@ -97,6 +98,8 @@ struct Config {
   std::string Checks;
   llvm::StringMap CheckOptions;
 } ClangTidy;
+
+UnusedIncludesPolicy UnusedIncludes = None;
   } Diagnostics;
 
   /// Style of the codebase.

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index ad117b3d77be..a7b881a28ac0 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -414,6 +414,16 @@ struct FragmentCompiler {
   C.Diagnostics.Suppress.insert(N);
   });
 
+if (F.UnusedIncludes)
+  if (auto Val = compileEnum(
+ "UnusedIncludes", **F.UnusedIncludes)
+ .map("Strict", Config::UnusedIncludesPolicy::Strict)
+ .map("None", Config::UnusedIncludesPolicy::None)
+ .value())
+Out.Apply.push_back([Val](const Params &, Config &C) {
+  C.Diagnostics.UnusedIncludes = *Val;
+});
+
 compile(std::move(F.ClangTidy));
   }
 

diff  --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index 8e4110e6dba1..a9ca7b462ec1 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -210,6 +210,20 @@ struct Fragment {
 /// This often has other advantages, such as skipping some analysis.
 std::vector> Suppress;
 
+/// Controls how clangd will correct "unnecessary #include directives.
+/// clangd can warn if a header is `#include`d but not used, and suggest
+/// removing it.
+//
+/// Strict means a header is unused if it does not *directly* provide any
+/// symbol used in the file. Removing it may still break compilation if it
+/// transitively includes headers that are used. This should be fixed by
+/// including those headers directly.
+///
+/// Valid values are:
+/// - Strict
+/// - None
+llvm::Optional> UnusedIncludes;
+
 /// Controls how clang-tidy will run over the code base.
 ///
 /// The settings are merged with any settings found in .clang-tidy

diff  --git a/clang-tools-extra/clangd/ConfigYAML.cpp 
b/clang-tools-extra/clangd/ConfigYAML.cpp
index 8a493346d2ce..331c18333045 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -118,6 +118,9 @@ class Parser {
   if (auto Values = scalarValues(N))
 F.Suppress = std::move(*Values);
 });
+Dict.handle("UnusedIncludes", [&](Node &N) {
+  F.UnusedIncludes = scalarValue(N, "UnusedIncludes");
+});
 Dict.handle("ClangTidy", [&](Node &N) { parse(F.ClangTidy, N); });
 Dict.parse(N);
   }

diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index c4f174993e2d..6dd69192497f 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -485,6 +485,9 @@ void toLSPDiags(
   case Diag::ClangTidy:
 Main.source = "clang-tidy";
 break;
+  case Diag::Clangd:
+Main.source = "clangd";
+break;
   case Diag::ClangdConfig:
 Main.source = "clangd-config";
 break;

diff  --git a/clang-tools-extra/clangd/Diagnostics.h 
b/clang-tools-extra/clangd/Diagnostics.h
index b9155ae4a7d1..a422c785db34 100644
--- a/c

[PATCH] D111870: [clangd] Add a way to enable IncludeCleaner through config

2021-10-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6d314ee57097: [clangd] Add a way to enable IncludeCleaner 
through config (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111870

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1479,6 +1479,44 @@
   AllOf(Diag(Test.range("deprecated"), "'bar' is deprecated"),
 WithTag(DiagnosticTag::Deprecated;
 }
+
+TEST(DiagnosticsTest, IncludeCleaner) {
+  Annotations Test(R"cpp(
+$fix[[  $diag[[#include "unused.h"]]
+]]  #include "used.h"
+
+  void foo() {
+used();
+  }
+  )cpp");
+  TestTU TU;
+  TU.Code = Test.code().str();
+  TU.AdditionalFiles["unused.h"] = R"cpp(
+void unused() {}
+  )cpp";
+  TU.AdditionalFiles["used.h"] = R"cpp(
+void used() {}
+  )cpp";
+  // Off by default.
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  Config Cfg;
+  Cfg.Diagnostics.UnusedIncludes = Config::UnusedIncludesPolicy::Strict;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(
+  *TU.build().getDiagnostics(),
+  UnorderedElementsAre(AllOf(
+  Diag(Test.range("diag"), "included header unused.h is not used"),
+  WithTag(DiagnosticTag::Unnecessary), DiagSource(Diag::Clangd),
+  WithFix(Fix(Test.range("fix"), "", "remove #include directive");
+  Cfg.Diagnostics.SuppressAll = true;
+  WithContextValue SuppressAllWithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  Cfg.Diagnostics.SuppressAll = false;
+  Cfg.Diagnostics.Suppress = {"unused-includes"};
+  WithContextValue SuppressFilterWithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -67,6 +67,7 @@
 CheckOptions:
   IgnoreMacros: true
   example-check.ExampleOption: 0
+  UnusedIncludes: Strict
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
@@ -83,6 +84,8 @@
   EXPECT_THAT(Results[3].Diagnostics.ClangTidy.CheckOptions,
   ElementsAre(PairVal("IgnoreMacros", "true"),
   PairVal("example-check.ExampleOption", "0")));
+  EXPECT_TRUE(Results[3].Diagnostics.UnusedIncludes);
+  EXPECT_EQ("Strict", *Results[3].Diagnostics.UnusedIncludes.getValue());
 }
 
 TEST(ParseYAML, Locations) {
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -244,6 +244,25 @@
   }
 }
 
+TEST_F(ConfigCompileTests, DiagnosticsIncludeCleaner) {
+  // Defaults to None.
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::None);
+
+  Frag = {};
+  Frag.Diagnostics.UnusedIncludes.emplace("None");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::None);
+
+  Frag = {};
+  Frag.Diagnostics.UnusedIncludes.emplace("Strict");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
+Config::UnusedIncludesPolicy::Strict);
+}
+
 TEST_F(ConfigCompileTests, DiagnosticSuppression) {
   Frag.Diagnostics.Suppress.emplace_back("bugprone-use-after-move");
   Frag.Diagnostics.Suppress.emplace_back("unreachable-code");
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -18,6 +18,7 @@
 #include "FeatureModule.h"
 #include "Headers.h"
 #include "HeuristicResolver.h"
+#include "IncludeCleaner.h"
 #in

[PATCH] D109506: [clangd] Print current request context along with the stack trace

2021-10-26 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D109506#3086214 , @smeenai wrote:

> In D109506#3086183 , @thakis wrote:
>
>> This doesn't build on windows: http://45.33.8.238/win/47615/step_4.txt
>>
>> Please take a look and revert for now if it takes a while to fix.
>
> I pushed rGba94b8bdffb4 
>  as a 
> speculative fix. I'll keep an eye on that bot. Thanks for the heads up.

Thanks, now it builds. But the test added in this change fails: 
http://45.33.8.238/win/47645/step_9.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

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


[PATCH] D112285: [PowerPC] PPC backend optimization to lower int_ppc_tdw/int_ppc_tw intrinsics to TDI/TWI machine instructions

2021-10-26 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:5003
+N->getConstantOperandVal(1) == Intrinsic::ppc_tw) {
+  int16_t SImm;
+  if (isIntS16Immediate(N->getOperand(3), SImm)) {

I think a couple of improvements can be made here:
1. Populate the `Opcode` and `Ops` array based on various conditions and add a 
single call to `SelectNodeTo()`
2. Handle the first input being constant (and then flip the condition)



Comment at: 
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll:131
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tdi 3, 3, 32767
+; CHECK-NEXT:blr

Can we add `-ppc-asm-full-reg-names` to the RUN lines so it is more clear which 
operand is a register and which is an immediate. This works on AIX now since 
https://reviews.llvm.org/D94282 landed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112285

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


[PATCH] D112050: [clang] NFC: return void in an alternative expression after call to void function.

2021-10-26 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou added a comment.

ping 
Just a ping, to see if there are any comments :-P


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112050

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


[PATCH] D109506: [clangd] Print current request context along with the stack trace

2021-10-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Here's another test failure: 
https://green.lab.llvm.org/green/job/clang-stage1-RA/24998
Can you revert if the fix is not trivial?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

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


Re: [clang] 2edb89c - Lex arguments for __has_cpp_attribute and friends as expanded tokens

2021-10-26 Thread Aaron Ballman via cfe-commits
On Mon, Oct 25, 2021 at 8:41 PM Nico Weber  wrote:
>
> Was this reviewed anywhere?

Post-commit review (as attribute code owner).

> I'll note that some internal project apparently used to check `#if 
> __has_attribute(__unsafe_unretained)`. That used to silently (and incorrectly 
> I think) always return 0 as far as I can tell, but now it fails with:
>
> ```
> $ out/gn/bin/clang -c foo.mm
> foo.mm:1:21: error: missing ')' after '__attribute__'
> #if __has_attribute(__unsafe_unretained)
> ^~~
> :350:42: note: expanded from here
> #define __unsafe_unretained __attribute__((objc_ownership(none)))
> ~^
> foo.mm:1:20: note: to match this '('
> #if __has_attribute(__unsafe_unretained)
>^
> 1 error generated.
> ```
>
> That's arguably a progression and I'm still finding out what the intent there 
> was (maybe `#ifdef __unsafe_unretained`?).
>
> So nothing to do here I think, but I thought I'd mention it.

Oh, that's interesting! If think `#ifdef __unsafe_unretained` is
likely what they were going for, but there are circumstances where
it's defined to be an empty expansion, so that might not be fully
correct.

> Looks like the reason for this check was that 
> https://github.com/llvm/llvm-project/blob/3b42fc8a07c37e47efae80c931eff7e63103e0e9/clang/include/clang/Basic/Attr.td#L1946
>  contains __unsafe_unretained despite it just being a macro here: 
> http://llvm-cs.pcc.me.uk/tools/clang/lib/Frontend/InitPreprocessor.cpp#1019
>
> Is that Attr.td entry incorrect?

I did some digging:

The attribute was added three years ago in
https://github.com/llvm/llvm-project/commit/e43e2b3667f9bc29c23be5235b53a7d7afcdb181
The empty macro was added six years ago in
https://github.com/llvm/llvm-project/commit/28ea04fc4caa40a04220c61bbcadd9d692aa0c7f
The nonempty macro was added eleven years ago in
https://github.com/llvm/llvm-project/commit/5d36a8cc700ef258df055baf95a248f85f36

I think the entry in Attr.td is correct-ish. It specifies there's an
attribute that's spelled with a keyword spelling, but TokenKinds.def
does not define a keyword for __unsafe_unretained (and keywords
defined in Attr.td are not automagically turned into keywords in
TokenKinds.def); this acts as a way to connect the macro to the
attribute for maintainers. So there is no __unsafe_unretained keyword,
it's actually a macro which is sometimes not defined, sometimes
defined to be empty, and sometimes defined to be another attribute.
The type attribute from Attr.td is still used by the type system and
is added automatically when the lifetime qualifier is OCL_ExplicitNone
(https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaType.cpp#L6706).
However, I say "correct-ish" because I think the keyword spelling used
in Attr.td is incorrect -- ObjCInertUnsafeUnretainedAttr is a
different attribute than the one you get from the expansion of
__unsafe_unretained, so while the attribute and the macro are related,
they're not the same thing. As best I can tell,
ObjCInertUnsafeUnretainedAttr can only ever be created implicitly, so
I think the entry in Attr.td should have its spelling removed and a
comment added that says `// This attribute has no spellings as it is
only ever created implicitly.` as with other implicit-defined
attributes. Richard, do you agree?

All that said, __has_attribute() does not tell you anything about
keyword attributes, only GNU-style attributes. __unsafe_unretained is
not a GNU spelling, so I agree that the construct never returned true
for you before.

~Aaron

>
> On Sun, Oct 17, 2021 at 7:58 AM Aaron Ballman via cfe-commits 
>  wrote:
>>
>>
>> Author: Aaron Ballman
>> Date: 2021-10-17T07:54:48-04:00
>> New Revision: 2edb89c746848c52964537268bf03e7906bf2542
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542.diff
>>
>> LOG: Lex arguments for __has_cpp_attribute and friends as expanded tokens
>>
>> The C and C++ standards require the argument to __has_cpp_attribute and
>> __has_c_attribute to be expanded ([cpp.cond]p5). It would make little sense
>> to expand the argument to those operators but not expand the argument to
>> __has_attribute and __has_declspec, so those were both also changed in this
>> patch.
>>
>> Note that it might make sense for the other builtins to also expand their
>> argument, but it wasn't as clear to me whether the behavior would be correct
>> there, and so they were left for a future revision.
>>
>> Added:
>> clang/test/Preprocessor/has_attribute_errors.cpp
>>
>> Modified:
>> clang/docs/ReleaseNotes.rst
>> clang/lib/Lex/PPMacroExpansion.cpp
>> clang/test/Preprocessor/has_attribute.c
>> clang/test/Preprocessor/has_attribute.cpp
>> clang/test/Preprocessor/has_c_attribute.c
>>
>> Removed:
>>
>>
>>
>> ###

[PATCH] D112527: [clangd] Fix a hover crash on templated spaceship operator.

2021-10-26 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, yaxunl.
adamcz requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

We make assumption that:
getDeclForComment(getDeclForComment(X)) == getDeclForComment(X)
but this is not true if you have a template
instantionation of a template instantiation, which is the case when, for
example, you have a <=> operator in a templated class.

This fix makes getDeclForComment() call itself recursively to ensure
this property is always true.

Fixes https://github.com/clangd/clangd/issues/901


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112527

Files:
  clang-tools-extra/clangd/Hover.cpp
  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
@@ -2934,6 +2934,35 @@
 def)pt";
   EXPECT_EQ(HI.present().asPlainText(), ExpectedPlaintext);
 }
+
+TEST(Hover, SpaceshipTemplateNoCrash) {
+  Annotations T(R"cpp(
+  namespace std {
+  struct strong_ordering {
+int n;
+constexpr operator int() const { return n; }
+static const strong_ordering equal, greater, less;
+  };
+  constexpr strong_ordering strong_ordering::equal = {0};
+  constexpr strong_ordering strong_ordering::greater = {1};
+  constexpr strong_ordering strong_ordering::less = {-1};
+  }
+
+  template 
+  struct S {
+// Foo bar baz
+friend auto operator<=>(S, S) = default;
+  };
+  static_assert(S() =^= S());
+)cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.ExtraArgs.push_back("-std=c++20");
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  EXPECT_EQ(HI->Documentation, "Foo bar baz");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -262,24 +262,31 @@
 // Returns the decl that should be used for querying comments, either from 
index
 // or AST.
 const NamedDecl *getDeclForComment(const NamedDecl *D) {
+  const NamedDecl *DeclForComment = D;
   if (const auto *TSD = llvm::dyn_cast(D)) {
 // Template may not be instantiated e.g. if the type didn't need to be
 // complete; fallback to primary template.
 if (TSD->getTemplateSpecializationKind() == TSK_Undeclared)
-  return TSD->getSpecializedTemplate();
+  DeclForComment = TSD->getSpecializedTemplate();
 if (const auto *TIP = TSD->getTemplateInstantiationPattern())
-  return TIP;
+  DeclForComment = TIP;
   }
   if (const auto *TSD = llvm::dyn_cast(D)) {
 if (TSD->getTemplateSpecializationKind() == TSK_Undeclared)
-  return TSD->getSpecializedTemplate();
+  DeclForComment = TSD->getSpecializedTemplate();
 if (const auto *TIP = TSD->getTemplateInstantiationPattern())
-  return TIP;
+  DeclForComment = TIP;
   }
   if (const auto *FD = D->getAsFunction())
 if (const auto *TIP = FD->getTemplateInstantiationPattern())
-  return TIP;
-  return D;
+  DeclForComment = TIP;
+  // Ensure that getDeclForComment(getDeclForComment(X)) = 
getDeclForComment(X).
+  // This is usually not needed, but in strange cases of comparision operators
+  // being instantiated from spasceship operater, which itself is a template
+  // instinstantiation the recursrive call is necessary.
+  if (D != DeclForComment)
+DeclForComment = getDeclForComment(DeclForComment);
+  return DeclForComment;
 }
 
 // Look up information about D from the index, and add it to Hover.


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2934,6 +2934,35 @@
 def)pt";
   EXPECT_EQ(HI.present().asPlainText(), ExpectedPlaintext);
 }
+
+TEST(Hover, SpaceshipTemplateNoCrash) {
+  Annotations T(R"cpp(
+  namespace std {
+  struct strong_ordering {
+int n;
+constexpr operator int() const { return n; }
+static const strong_ordering equal, greater, less;
+  };
+  constexpr strong_ordering strong_ordering::equal = {0};
+  constexpr strong_ordering strong_ordering::greater = {1};
+  constexpr strong_ordering strong_ordering::less = {-1};
+  }
+
+  template 
+  struct S {
+// Foo bar baz
+friend auto operator<=>(S, S) = default;
+  };
+  static_assert(S() =^= S());
+)cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.ExtraArgs.push_back("-std=c++20");
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  EXPECT_EQ(HI->Docume

[PATCH] D112408: [WIP][RISCV] Add the zve extension according to the v1.0-rc2 spec

2021-10-26 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCV.td:182
 
+def FeatureExtZve32x
+: SubtargetFeature<"experimental-zve32x", "HasStdExtZve32x", "true",

craig.topper wrote:
> frasercrmck wrote:
> > Do we need to define distinct `SubtargetFeature`s for each of these 
> > extensions or could they be broken down into a single `MaxEEW` feature (32 
> > or 64) in conjunction with the pre-existing F/D features. This seems like 
> > it's more complicated than it needs to be.
> I don't think it is quite that simple. Couldn't you have a scalar D and have 
> zve64f vector?
Yes, that's fair. Though I still think we can create a more intuitive system of 
`Predicate`s to handle the TableGen aspects, as you've begun to do in D112496.



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:141
+  // either v or zve* suppaort v instructions
+  bool hasStdExtV() const { return HasStdExtV || HasStdExtZve32x; }
+  bool hasStdExtZve32x() const { return HasStdExtZve32x; }

craig.topper wrote:
> frasercrmck wrote:
> > Is this correct? I thought we'd keep `hasStdExtV` as being the 
> > single-letter V extension, and Zve32x isn't that.
> I just put up D112496 to stop using hasStdExtV everywhere.
Ah right now I see what this was trying to do. I think your patch helps things, 
thanks.



Comment at: llvm/test/CodeGen/RISCV/rvv/fixed-vectors-bitcast.ll:158
 ; CHECK-NEXT:vmv.x.s a0, v8
+; CHECK-NEXT:lui a1, 1048560
+; CHECK-NEXT:or a0, a0, a1

craig.topper wrote:
> frasercrmck wrote:
> > What's going on here, do you know?
> I believe this is coming from the nan-boxing for f16 in 
> RISCVTargetLowering::splitValueIntoRegisterParts. The addition of +f must 
> have changed PartVT from i32/i64 to f32. Even though we're using i32 for the 
> return due to ABI.
Ah, interesting. I can't tell if that's a bug fix, i.e., if it's invalid to 
compile this test without `f` - though shouldn't we pass `experimental-zfh` by 
that same logic? Regardless, maybe we could split this off and pre-commit it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112408

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


[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:16695
+  TheCall->setArg(1, B.get());
+  TheCall->setType(TyB);
+  return false;

I think you want to set this to `Res`, because that's the common type between 
`TyB` and `TyA`, right? That will also ensure that qualifiers are stripped, I 
believe. e.g.,
```
const int a = 2;
int b = 1;
static_assert(!std::is_const_v);
static_assert(!std::is_const_v);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111985

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


[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8747-8748
 
+def err_elementwise_math_arg_types_mismatch : Error <
+  "argument types do not match, %0 != %1">;
+

Does `err_typecheck_call_different_arg_types` suffice?



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8750-8751
+
+def err_elementwise_math_invalid_arg_type: Error <
+  "argument type %0 is not supported">;
+

It'd be nice to avoid this entirely as the diagnostic situation is one we would 
have elsewhere (so we should be able to use common diagnostic checking code 
from here and places like `SemaBuiltinMatrixColumnMajorLoad()` ideally).



Comment at: clang/lib/Sema/SemaChecking.cpp:16662-16667
+  if (!Ty->getAs() && !ConstantMatrixType::isValidElementType(Ty)) 
{
+S.Diag(Loc, diag::err_elementwise_math_invalid_arg_type) << Ty;
+return true;
+  }
+  return false;
+}

Related to the comment above on the diagnostic, I'm wondering if we want to 
abstract this into a helper function that gets used by all the elementwise 
builtins you're adding?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111985

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


[PATCH] D112406: [Driver][AArch64]Add driver support for neoverse-512tvb target

2021-10-26 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto updated this revision to Diff 382273.
CarolineConcatto added a comment.

- Rebase and remove support on for ARM 32 bits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112406

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/misched-fusion-aes.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -1134,6 +1134,14 @@
  AArch64::AEK_SVE2 | AArch64::AEK_SVE2BITPERM |
  AArch64::AEK_BF16 | AArch64::AEK_I8MM,
  "8.5-A"),
+ARMCPUTestParams(
+"neoverse-512tvb", "armv8.4-a", "crypto-neon-fp-armv8",
+AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
+AArch64::AEK_RCPC | AArch64::AEK_CRC | AArch64::AEK_FP |
+AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
+AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+AArch64::AEK_CRYPTO | AArch64::AEK_FP16 | AArch64::AEK_BF16,
+"8.4-A"),
 ARMCPUTestParams("thunderx2t99", "armv8.1-a", "crypto-neon-fp-armv8",
  AArch64::AEK_NONE | AArch64::AEK_CRC |
  AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
@@ -1189,7 +1197,7 @@
  AArch64::AEK_LSE | AArch64::AEK_RDM,
  "8.2-A")));
 
-static constexpr unsigned NumAArch64CPUArchs = 49;
+static constexpr unsigned NumAArch64CPUArchs = 50;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/CodeGen/AArch64/misched-fusion-aes.ll
===
--- llvm/test/CodeGen/AArch64/misched-fusion-aes.ll
+++ llvm/test/CodeGen/AArch64/misched-fusion-aes.ll
@@ -14,6 +14,7 @@
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-n1 | FileCheck %s
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-n2 | FileCheck %s
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-v1 | FileCheck %s
+; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-512tvb | FileCheck %s
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m3  | FileCheck %s
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m4  | FileCheck %s
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m5  | FileCheck %s
Index: llvm/test/CodeGen/AArch64/cpus.ll
===
--- llvm/test/CodeGen/AArch64/cpus.ll
+++ llvm/test/CodeGen/AArch64/cpus.ll
@@ -21,6 +21,7 @@
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-e1 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-n1 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-n2 2>&1 | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-512tvb 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-v1 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m3 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m4 2>&1 | FileCheck %s
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -68,6 +68,7 @@
 NeoverseE1,
 NeoverseN1,
 NeoverseN2,
+Neoverse512TVB,
 NeoverseV1,
 Saphira,
 ThunderX2T99,
Index: llvm/lib/Target/AArch64/AArch64Subtarget.cpp
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -164,6 +164,11 @@
 PrefFunctionLogAlignment = 4;
 VScaleForTuning = 2;
 break;
+  case Neoverse512TVB:
+PrefFunctionLogAlignment = 4;
+VScaleForTuning = 1;
+MaxInterleaveFactor = 4;
+break;
   case Saphira:
 MaxInterleaveFactor = 4;
 // FIXME: remove this to enable 64-bit SLP if performance looks good.
Index: llvm/lib/Target/AArch64/AArch64.td
===
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -836,6 +836,11 @@
   FeaturePostRAScheduler,
   FeatureFuseAES
   ]>;
+def

[PATCH] D109506: [clangd] Print current request context along with the stack trace

2021-10-26 Thread Emma Blink via Phabricator via cfe-commits
0x1eaf added a comment.

I think this should work-around end-to-end test failure on Windows:

  diff --git a/clang-tools-extra/clangd/test/crash.test 
b/clang-tools-extra/clangd/test/crash.test
  index 1197e1ab07c3..68ef54808f09 100644
  --- a/clang-tools-extra/clangd/test/crash.test
  +++ b/clang-tools-extra/clangd/test/crash.test
  @@ -1,3 +1,4 @@
  +# REQUIRES: shell
   # Overflow the recursive json parser, prevent `yes` error due to broken pipe 
and `clangd` SIGSEGV from being treated as a failure.
   # RUN: (yes '[' || :) | head -n 5 | (clangd --input-style=delimited 2>&1 
|| :) | FileCheck %s
   #  CHECK: Signalled while processing message:

Alternatively, the test can be completely disabled for the time being.

I don't have commit access, should I create a new revision for review with the 
test change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

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


[clang-tools-extra] 51be706 - [clangd] Remove tricky integration test that flakes/fails on some platforms.

2021-10-26 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-10-26T14:19:05+02:00
New Revision: 51be7061d025139ba66869d5d99c7157a3ae9edd

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

LOG: [clangd] Remove tricky integration test that flakes/fails on some 
platforms.

This functionality is covered by unittests, will add a better
integration test soon.

Added: 


Modified: 


Removed: 
clang-tools-extra/clangd/test/crash.test



diff  --git a/clang-tools-extra/clangd/test/crash.test 
b/clang-tools-extra/clangd/test/crash.test
deleted file mode 100644
index 1197e1ab07c3..
--- a/clang-tools-extra/clangd/test/crash.test
+++ /dev/null
@@ -1,5 +0,0 @@
-# Overflow the recursive json parser, prevent `yes` error due to broken pipe 
and `clangd` SIGSEGV from being treated as a failure.
-# RUN: (yes '[' || :) | head -n 5 | (clangd --input-style=delimited 2>&1 
|| :) | FileCheck %s
-#  CHECK: Signalled while processing message:
-# CHECK-NEXT: [
-# CHECK-NEXT: [



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


[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I thought of another test case -- should these new functions work on complex 
types? (Those are weird enough we may want to consider adding both Sema and 
CodeGen tests if we do support them, and Sema tests alone if we don't.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111985

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


[PATCH] D111986: [Clang] Add elementwise abs builtin.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8754
+def err_elementwise_math_invalid_arg_type_2: Error <
+  "argument must have a %0 type, but was %1">;
+

I feel like we must already have a diagnostic that covers this case...



Comment at: clang/lib/Sema/SemaChecking.cpp:16547
+  Expr *A = TheCall->getArg(0);
+  QualType TyA = A->getType();
+

Should this type undergo the usual promotions?



Comment at: clang/test/Sema/builtins-elementwise-math.c:25
+  u = __builtin_elementwise_abs(u);
+  // expected-error@-1 {{argument must have a signed integer or floating point 
type, but was an unsigned integer type}}
+

fhahn wrote:
> scanon wrote:
> > For the purposes of C++ templates it might be nice to allow `abs` on 
> > unsigned (as the identity function). I don't have strong feelings though, 
> > and a library wrapping the builtins can do this themselves.
> yeah that would be an option. I don't have any strong feelings either
I was wondering about this myself, but also don't have strong opinions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111986

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


[PATCH] D109506: [clangd] Print current request context along with the stack trace

2021-10-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D109506#3087055 , @0x1eaf wrote:

> I think this should work-around end-to-end test failure on Windows:
>
>   diff --git a/clang-tools-extra/clangd/test/crash.test 
> b/clang-tools-extra/clangd/test/crash.test
>   index 1197e1ab07c3..68ef54808f09 100644
>   --- a/clang-tools-extra/clangd/test/crash.test
>   +++ b/clang-tools-extra/clangd/test/crash.test
>   @@ -1,3 +1,4 @@
>   +# REQUIRES: shell
># Overflow the recursive json parser, prevent `yes` error due to broken 
> pipe and `clangd` SIGSEGV from being treated as a failure.
># RUN: (yes '[' || :) | head -n 5 | (clangd --input-style=delimited 
> 2>&1 || :) | FileCheck %s
>#  CHECK: Signalled while processing message:
>
> Alternatively, the test can be completely disabled for the time being.
>
> I don't have commit access, should I create a new revision for review with 
> the test change?

I just removed this test for now, we're also seeing problems on mac (I believe 
because stack overflow can do something other than signal), and flakiness on 
linux+tsan.
This functionality is covered by unittests that are not failing.

We should probably work on an integration test that is a bit more principled, 
probably using `#pragma clang __debug llvm_fatal_error` which calls abort(). 
It's annoying because we disable those pragmas for obvious reasons...

@smeenai thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

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


[PATCH] D112406: [Driver][AArch64]Add driver support for neoverse-512tvb target

2021-10-26 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto marked an inline comment as done.
CarolineConcatto added a comment.

Thank you for your review @dmgreen  and @tschuett.
I rebase the patch, now  VScaleForTuning  is being set.
And I removed support for neoverse-512tvb from Arm 32 bits. 
@paulwalker-arm pointed me that neoverse-512tvb is only supported by AArch64.




Comment at: llvm/lib/Support/Host.cpp:216
 .Case("0xd49", "neoverse-n2")
+.Case("0xd4a", "neoverse-512tvb")
 .Default("generic");

dmgreen wrote:
> This doesn't sound right - for a fake cpu to work with -mcpu=native.
Good catch, I should have removed that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112406

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


[PATCH] D112001: [Clang] Add min/max reduction builtins.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:16606-16609
+  const VectorType *VecTy = TyA->getAs();
+  if (!VecTy)
+return Diag(A->getBeginLoc(), 
diag::err_elementwise_math_invalid_arg_type_2)
+   << "vector" << TyA;

What about type sugar?



Comment at: clang/lib/Sema/SemaChecking.cpp:16611
+
+  TheCall->setType(VecTy->getElementType());
+  return false;

Should this type undergo the usual conversions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112001

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


[PATCH] D107450: [clang-tidy] Fix wrong FixIt in performance-move-const-arg

2021-10-26 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.
Herald added a subscriber: carlosgalvezp.

Kindly ping. @whisperity, @aaron.ballman, @Quuxplusone


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

https://reviews.llvm.org/D107450

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


[PATCH] D112447: [clangd] IncludeCleaner: Support macros

2021-10-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 382277.
kbobyrev added a comment.

Skip the tokens that are not identifiers or weren't defined as macros, attach
tracer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112447

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -103,6 +103,26 @@
   "struct ^X { enum ^Language { ^CXX = 42, Python = 9000}; };",
   "int Lang = X::CXX;",
   },
+  // Macros
+  {
+  "#define ^CONSTANT 42",
+  "int Foo = CONSTANT;",
+  },
+  {
+  "#define ^FOO x",
+  "#define BAR FOO",
+  },
+  {
+  "#define INNER 42\n"
+  "#define ^OUTER INNER",
+  "int answer = OUTER;",
+  },
+  {
+  "#define ^ANSWER 42\n"
+  "#define ^SQUARE(X) X * X",
+  "int sq = SQUARE(ANSWER);",
+  },
+  // Misc
   {
   "enum class ^Color : int;",
   "enum class Color : int {};",
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -33,11 +33,13 @@
 using ReferencedLocations = llvm::DenseSet;
 /// Finds locations of all symbols used in the main file.
 ///
-/// Uses RecursiveASTVisitor to go through main file AST and computes all the
-/// locations used symbols are coming from. Returned locations may be macro
-/// expansions, and are not resolved to their spelling/expansion location. These
-/// locations are later used to determine which headers should be marked as
-/// "used" and "directly used".
+/// - For non-macros uses RecursiveASTVisitor to go through main file AST and
+///   computes all the locations used symbols are coming from. Returned
+///   locations may be macro expansions, and are not resolved to their spelling
+///   or expansion location. These locations are later used to determine which
+///   headers should /   be marked as "used" and "directly used".
+/// - For macros iteratates over \p AST tokens and collects locations of the
+///   used macro definition.
 ///
 /// We use this to compute unused headers, so we:
 ///
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -7,9 +7,13 @@
 //===--===//
 
 #include "IncludeCleaner.h"
+#include "SourceCode.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 
 namespace clang {
 namespace clangd {
@@ -142,13 +146,35 @@
   }
 };
 
+// Gets the tokens from the main file, iterates through them and adds definition
+// locations for the found macros.
+void findReferencedMacros(ParsedAST &AST, ReferencedLocations &Result) {
+  trace::Span Tracer("IncludeCleaner::findReferencedMacros");
+  auto &SM = AST.getSourceManager();
+  auto &PP = AST.getPreprocessor();
+  auto Tokens =
+  AST.getTokens().spelledTokens(AST.getSourceManager().getMainFileID());
+  for (const syntax::Token &Tok : Tokens) {
+if (Tok.kind() != tok::identifier ||
+!PP.getIdentifierInfo(Tok.text(SM))->hadMacroDefinition()) {
+  continue;
+}
+auto Macro = locateMacroAt(Tok, PP);
+if (!Macro)
+  continue;
+auto Loc = Macro->Info->getDefinitionLoc();
+if (Loc.isValid())
+  Result.insert(Loc);
+  }
+}
+
 } // namespace
 
 ReferencedLocations findReferencedLocations(ParsedAST &AST) {
   ReferencedLocations Result;
   ReferencedLocationCrawler Crawler(Result);
   Crawler.TraverseAST(AST.getASTContext());
-  // FIXME(kirillbobyrev): Handle macros.
+  findReferencedMacros(AST, Result);
   return Result;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111434: [PowerPC] PPC backend optimization on conditional trap intrustions

2021-10-26 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:1011
+  case PPC::TDI:
+  case PPC::TWI: {
+MachineInstr *LiMIA = getVRegDefOrNull(&MI.getOperand(1), MRI);

Seems that we should be able to handle all 4 in the same block:
- Check that both operands are `LI[8]`/`LI[S][8]+ORI[8]` or an immediate
- Set the variables for the three constants
- Determine if this is an unconditional trap or never trap
- Emit the correct instruction


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

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


[PATCH] D112447: [clangd] IncludeCleaner: Support macros

2021-10-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 382278.
kbobyrev added a comment.

Rebase on top of main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112447

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -116,6 +116,26 @@
   "struct ^X { enum ^Language { ^CXX = 42, Python = 9000}; };",
   "int Lang = X::CXX;",
   },
+  // Macros
+  {
+  "#define ^CONSTANT 42",
+  "int Foo = CONSTANT;",
+  },
+  {
+  "#define ^FOO x",
+  "#define BAR FOO",
+  },
+  {
+  "#define INNER 42\n"
+  "#define ^OUTER INNER",
+  "int answer = OUTER;",
+  },
+  {
+  "#define ^ANSWER 42\n"
+  "#define ^SQUARE(X) X * X",
+  "int sq = SQUARE(ANSWER);",
+  },
+  // Misc
   {
   "enum class ^Color : int;",
   "enum class Color : int {};",
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -33,11 +33,13 @@
 using ReferencedLocations = llvm::DenseSet;
 /// Finds locations of all symbols used in the main file.
 ///
-/// Uses RecursiveASTVisitor to go through main file AST and computes all the
-/// locations used symbols are coming from. Returned locations may be macro
-/// expansions, and are not resolved to their spelling/expansion location. These
-/// locations are later used to determine which headers should be marked as
-/// "used" and "directly used".
+/// - For non-macros uses RecursiveASTVisitor to go through main file AST and
+///   computes all the locations used symbols are coming from. Returned
+///   locations may be macro expansions, and are not resolved to their spelling
+///   or expansion location. These locations are later used to determine which
+///   headers should /   be marked as "used" and "directly used".
+/// - For macros iteratates over \p AST tokens and collects locations of the
+///   used macro definition.
 ///
 /// We use this to compute unused headers, so we:
 ///
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -11,8 +11,11 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 
@@ -168,13 +171,35 @@
   return Result;
 }
 
+// Gets the tokens from the main file, iterates through them and adds definition
+// locations for the found macros.
+void findReferencedMacros(ParsedAST &AST, ReferencedLocations &Result) {
+  trace::Span Tracer("IncludeCleaner::findReferencedMacros");
+  auto &SM = AST.getSourceManager();
+  auto &PP = AST.getPreprocessor();
+  auto Tokens =
+  AST.getTokens().spelledTokens(AST.getSourceManager().getMainFileID());
+  for (const syntax::Token &Tok : Tokens) {
+if (Tok.kind() != tok::identifier ||
+!PP.getIdentifierInfo(Tok.text(SM))->hadMacroDefinition()) {
+  continue;
+}
+auto Macro = locateMacroAt(Tok, PP);
+if (!Macro)
+  continue;
+auto Loc = Macro->Info->getDefinitionLoc();
+if (Loc.isValid())
+  Result.insert(Loc);
+  }
+}
+
 } // namespace
 
 ReferencedLocations findReferencedLocations(ParsedAST &AST) {
   ReferencedLocations Result;
   ReferencedLocationCrawler Crawler(Result);
   Crawler.TraverseAST(AST.getASTContext());
-  // FIXME(kirillbobyrev): Handle macros.
+  findReferencedMacros(AST, Result);
   return Result;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107450: [clang-tidy] Fix wrong FixIt in performance-move-const-arg

2021-10-26 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:140
+  diag(InvocationParm->getLocation(),
+   "consider changing the %0st parameter of %1 from %2 to 'const %3 
&'",
+   DiagnosticIDs::Note)





Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:260
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect [performance-move-const-arg]
+  // CHECK-MESSAGES: :[[@LINE-9]]:28: note: consider changing the 2st 
parameter of showInt from 'int &&' to 'const int &'
+}




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

https://reviews.llvm.org/D107450

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


[PATCH] D112491: Add `LambdaCapture`-related matchers.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm a bit confused as to why this is necessary. We already have 
`lambdaExpr(hasAnyCapture(varDecl(hasName("whatever"` and 
`lambdaExpr(hasAnyCapture(cxxThisExpr()))`, so I'm not certain why we need this 
as a parallel construct?




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4629-4630
+///   matches `[x](){}`.
+AST_MATCHER_P(LambdaCapture, refersToVarDecl, internal::Matcher,
+  InnerMatcher) {
+  auto *capturedVar = Node.getCapturedVar();

The name here is a bit unclear -- whether it is the matcher matching `int x;` 
or the `x` from the capture is not clear from the name. The comment suggests 
it's matching `x` from the capture, but I think it's actually matching the `int 
x;` variable declaration.

Being clear on what's matched here is important when we think about 
initializers:
```
void foo() {
  int x = 12;
  auto f = [x = 100](){};
}
```
and
```
lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("x"), 
hasInitializer(integerLiteral(equals(100))
```
Would you expect this to match? (This might be a good test case to add.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112491

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


[PATCH] D109506: [clangd] Print current request context along with the stack trace

2021-10-26 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Thanks for the fixes! My bots are happy now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

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


[PATCH] D107450: [clang-tidy] Fix wrong FixIt in performance-move-const-arg

2021-10-26 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

I think this is becoming okay and looks safe enough. I can't really grasp what 
`HasCheckedMoveSet` means, and how it synergises with storing `CallExpr`s so 
maybe a better name should be added. Do you mean `AlreadyCheckedMoves`? When is 
it possible that the same `CallExpr` of `std::move` will be matched multiple 
times?

In general going from `T&&` to `const T&` would be a broken change if the 
function implementation //calls// a non-const member method on the `T` 
instance, but I can be convinced that saying `consider [...]` instead of 
generating a bogus fix-it is enough, there is hopefully no need to extensively 
analyse and guard against this.

There has been a new release since the patch was proposed so a rebase should be 
needed.
@aaron.ballman What do you think, does this warrant a ReleaseNotes entry?


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

https://reviews.llvm.org/D107450

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


[PATCH] D112530: [clangd] AddUsing: Fix support for template specializations.

2021-10-26 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
adamcz requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Before this change, we would add "using std::vector" instead of
just "using std::vector;", which would not even compile.

Fixes https://github.com/clangd/clangd/issues/904


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112530

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/unittests/tweaks/AddUsingTests.cpp


Index: clang-tools-extra/clangd/unittests/tweaks/AddUsingTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/AddUsingTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/AddUsingTests.cpp
@@ -444,6 +444,17 @@
 #include "test.hpp"
 using one::two::cc;using one::two::ee::ee_one;
 cc c;
+)cpp"},
+// Template (like std::vector).
+{R"cpp(
+#include "test.hpp"
+one::v^ec foo;
+)cpp",
+ R"cpp(
+#include "test.hpp"
+using one::vec;
+
+vec foo;
 )cpp"}};
   llvm::StringMap EditedFiles;
   for (const auto &Case : Cases) {
@@ -461,6 +472,7 @@
 };
 }
 using uu = two::cc;
+template struct vec {};
 })cpp";
   EXPECT_EQ(apply(SubCase, &EditedFiles), Case.ExpectedSource);
 }
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -278,8 +278,14 @@
   if (!QualifierToRemove)
 return false;
 
-  auto SpelledTokens =
-  TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));
+  auto NameRange = E.getSourceRange();
+  if (auto T = E.getNamedTypeLoc().getAs()) 
{
+// Remove the template arguments from the name.
+NameRange = SourceRange(NameRange.getBegin(),
+T.getLAngleLoc().getLocWithOffset(-1));
+  }
+
+  auto SpelledTokens = TB.spelledForExpanded(TB.expandedTokens(NameRange));
   if (!SpelledTokens)
 return false;
   auto SpelledRange = syntax::Token::range(SM, SpelledTokens->front(),


Index: clang-tools-extra/clangd/unittests/tweaks/AddUsingTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/AddUsingTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/AddUsingTests.cpp
@@ -444,6 +444,17 @@
 #include "test.hpp"
 using one::two::cc;using one::two::ee::ee_one;
 cc c;
+)cpp"},
+// Template (like std::vector).
+{R"cpp(
+#include "test.hpp"
+one::v^ec foo;
+)cpp",
+ R"cpp(
+#include "test.hpp"
+using one::vec;
+
+vec foo;
 )cpp"}};
   llvm::StringMap EditedFiles;
   for (const auto &Case : Cases) {
@@ -461,6 +472,7 @@
 };
 }
 using uu = two::cc;
+template struct vec {};
 })cpp";
   EXPECT_EQ(apply(SubCase, &EditedFiles), Case.ExpectedSource);
 }
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -278,8 +278,14 @@
   if (!QualifierToRemove)
 return false;
 
-  auto SpelledTokens =
-  TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));
+  auto NameRange = E.getSourceRange();
+  if (auto T = E.getNamedTypeLoc().getAs()) {
+// Remove the template arguments from the name.
+NameRange = SourceRange(NameRange.getBegin(),
+T.getLAngleLoc().getLocWithOffset(-1));
+  }
+
+  auto SpelledTokens = TB.spelledForExpanded(TB.expandedTokens(NameRange));
   if (!SpelledTokens)
 return false;
   auto SpelledRange = syntax::Token::range(SM, SpelledTokens->front(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112334: [clang-tidy] Suppress readability-static-access-through-instance for CUDA built-in variables

2021-10-26 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D112334#3084533 , @aaron.ballman 
wrote:

> In D112334#3081213 , @carlosgalvezp 
> wrote:
>
>> Btw, regarding this `CHECK-MESSAGES-NOT`, how does it work? I can't find it 
>> in `check_clang_tidy.py`. Wouldn't the test fail anyway if unexpected 
>> warnings are printed?
>
> FileCheck matches input CHECK lines with output lines, so if there's no CHECK 
> line for a particular output, FileCheck won't report any problems with it. 
> (`-verify` is used by the frontend to verify diagnostics, but that's not 
> something that can be used within clang-tidy currently.) That said, I'm not 
> entirely certain of the mechanisms behind `CHECK-MESSAGES-NOT` in the python 
> scripts.

Just a clarification for the record, as I came across this too. There is no 
business logic per se associated with `CHECK-MESSAGES-NOT`. I think it's some 
sort of a bad example that we observed and taken from each other and sometimes 
overusing. `CHECK-MESSAGES-NOT` is useful in the context where there is a 
warning that currently isn't emitted (because the check isn't fully finished, 
or depends on a //FIXME// or something) but you **want** the message to appear 
later in the code. It indicates what should be there, but currently isn't there 
and we are not expecting it. The moment the check is further developed, it's 
easy to cut back the `-NOT` part (`2t-ld2w` if you're using Vim) and turn it 
into a proper check that //expects// the warning to be there. (And of course, 
hopefully also emits it!)

Semantically, it is equivalent to saying `// NO-WARN: Clang is awesome!` or `// 
MY-LITTLE-PONY` or whatever in the text. It will be ignored by the script. 😉  
The script only triggers for `CHECK-MESSAGES:`, `CHECK-FIXES:` and 
`CHECK-NOTES:` and the prefixes you may or may not be able to specify at 
invocation explicitly.

IMHO if we never want that warning to pop it is misleading and noise to add the 
would-be text of a warning there. If you want to indicate that there is no need 
for a warning (any warning emitted by the check!), I believe it is better to 
use `// NO-WARN`. That indicates both the intent that the code in that line or 
nearby //SHOULD PASS// but also clearly documents that it wasn't a developer 
oversight that the test appears as a "negative case" (i.e. you did not 
//forget// to add the `CHECK-` lines in).


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

https://reviews.llvm.org/D112334

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


[PATCH] D112334: [clang-tidy] Suppress readability-static-access-through-instance for CUDA built-in variables

2021-10-26 Thread Whisperity via Phabricator via cfe-commits
whisperity closed this revision.
whisperity added a comment.

@carlosgalvezp Force pushes are prevented by the serverside integration so we 
couldn't force push even if we wanted to. What one could do is to revert the 
patch and land it again (or land an empty patch that has the association line 
in the message...) but both of those would be just excess noise in the (already 
wy too noisy!) history.

Hopefully this will help.


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

https://reviews.llvm.org/D112334

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


[PATCH] D112287: [clang] Implement CFG construction for @try and @catch

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

lgtm, just some nits.




Comment at: clang/lib/Analysis/CFG.cpp:485
 
-  // This can point either to a try or a __try block. The frontend forbids
-  // mixing both kinds in one function, so having one for both is enough.
+  // This can point to either to a C++ try, an Objective-C @try, or a SEH 
__try.
+  // try and @try can be mixed and generally work the same.

One "to" too much in "to either to a ...".
Should probably be *an* SEH __try (at least in my head, that S is pronounced 
"ess").



Comment at: clang/lib/Analysis/CFG.cpp:3888
+
+  // We set Block to NULL to allow lazy creation of a new block (if necessary)
+  Block = nullptr;

ultra nit: period.



Comment at: clang/lib/Analysis/CFG.cpp:3895
 CFGBlock *CFGBuilder::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
   // FIXME: This isn't complete.  We basically treat @throw like a return
   //  statement.

does the fixme still stand?



Comment at: clang/lib/Analysis/CFG.cpp:3941
+  bool HasCatchAll = false;
+  for (unsigned h = 0; h < Terminator->getNumCatchStmts(); ++h) {
+// The code after the try is the implicit successor.

Why h? Could this be a range for instead? Otherwise for (i = .., e = ..., i != 
e) is the classic llvm style.



Comment at: clang/lib/Analysis/CFG.cpp:5790
+  OS << "@catch (";
+  if (CS->getCatchParamDecl())
+CS->getCatchParamDecl()->print(OS, 
PrintingPolicy(Helper.getLangOpts()),

maybe

```
if (const VarDecl *PD = CS->getCatchParamDecl())
  PD->print(...)
```



Comment at: clang/test/Sema/warn-unreachable.m:1
+// RUN: %clang_cc1 %s -fsyntax-only -fobjc-exceptions -verify 
-Wunreachable-code
+

Not important, but I think it's much more common to have %s at the end. Same 
for the other test file.


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

https://reviews.llvm.org/D112287

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


[PATCH] D46081: [analyzer] Expand conversion check to check more expressions for overflow and underflow

2021-10-26 Thread Whisperity via Phabricator via cfe-commits
whisperity added reviewers: martong, steakhal.
whisperity added a subscriber: balazske.
whisperity added a comment.
Herald added subscribers: manas, ASDenysPetrov, donat.nagy.

Pinging my people here, perhaps you being more knowledgeable in the analyser 
can say if this patch is salvageable in any way? Or did the state of the art 
moved past this in the years that went by? The patch itself doesn't look huge, 
but outside my direct expertise.


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

https://reviews.llvm.org/D46081

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


[PATCH] D112398: [RISCV] Add ABI testing for Float16.

2021-10-26 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added a comment.

It looks as though all checks are checking the same thing? Presumably this is 
expected? I wonder if allowing an extra combined check 
(`--check-prefixes=CHECK,CHECK-ZFH-ILP32F` or something) would make it more 
obvious when things *are* different between the different configs.

I'm not familiar with how `Float16` is supposed to behave if the target doesn't 
advertise support `zfh`, but I come more from OpenCL where it's either fully 
supported or "storage-only", in which case I wouldn't expect a `fadd` to get 
past the frontend (or maybe it'd enforce promotion to `float`?). This isn't 
necessarily a blocker - I'm just showing the limits of my knowledge in this 
area.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112398

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


[PATCH] D112504: [OpenMP] Wrap (v)printf in the new RT and use same handling for AMD

2021-10-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGGPUBuiltin.cpp:128
   return RValue::get(Builder.CreateCall(
   VprintfFunc, {Args[0].getRValue(*this).getScalarVal(), BufferPtr}));
 }

>>! In D112504#3086474, @JonChesterfield wrote:
> That's an interesting approach.
> 
> Do you happen to know where I can find details of the data format behind that 
> void*? Have been meaning to look at writing printf for amdgpu as host side 
> decoding of that buffer. If the compiler knows how long it is, that would be 
> a useful third argument.

We actually do know. Above we allocate and fill the buffer. For the OpenMP 
wrapper you could easily add a third argument later in order to facilitate an 
OpenMP runtime printf impl. I would even like it to be target agnostic (e.g., 
replace the default CUDA route on request). That said, we should tackle that 
separately, wdyt?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112504

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


[PATCH] D112406: [Driver][AArch64]Add driver support for neoverse-512tvb target

2021-10-26 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Thanks. If the cpu has a 512 bit total vector bandwidth, should the 
VScaleForTuning be 1 or 2 (or higher)? llvm doesn't usually deal with total 
bandwidth a lot, perhaps not as much as it should.

@david-arm any thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112406

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


[libunwind] 56b7461 - [libunwind] Take 2: Use the from-scratch testing configuration by default

2021-10-26 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2021-10-26T09:34:40-04:00
New Revision: 56b74613bf9168bb79e0088b424ec0b6dd0a66c9

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

LOG: [libunwind] Take 2: Use the from-scratch testing configuration by default

Summary:
This commit switches libunwind from using the complicated logic in
libc++'s testing configuration to a from-scratch configuration.
I tried to make sure that all cases that were handled in the old
config were handled by this one too, so hopefully this shouldn't
break anyone. However, if you encounter issues with this change,
please let me know and feel free to revert if I don't reply quickly.

This change was engineered to be easily revertable.

This commit is a re-application of 5a8ad80b6fa5, which was reverted in
070a2ddcb665 because it broke the Bootstrapping build. This has now been
addressed by tweaking the from-scratch config.

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

Added: 


Modified: 
libunwind/CMakeLists.txt

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 6933d74f04fe..96477e24a259 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -90,7 +90,13 @@ set(LIBUNWIND_TEST_LINKER_FLAGS "" CACHE STRING
 "Additional linker flags for test programs.")
 set(LIBUNWIND_TEST_COMPILER_FLAGS "" CACHE STRING
 "Additional compiler flags for test programs.")
-set(LIBUNWIND_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" 
CACHE STRING
+
+if (LIBUNWIND_ENABLE_SHARED)
+  set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-shared.cfg.in")
+else()
+  set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-static.cfg.in")
+endif()
+set(LIBUNWIND_TEST_CONFIG "${LIBUNWIND_DEFAULT_TEST_CONFIG}" CACHE STRING
   "The path to the Lit testing configuration to use when running the tests.
If a relative path is provided, it is assumed to be relative to 
'/libunwind/test/configs'.")
 if (NOT IS_ABSOLUTE "${LIBUNWIND_TEST_CONFIG}")



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


[PATCH] D110065: [AArch64] Add support for the 'R' architecture profile.

2021-10-26 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea updated this revision to Diff 382288.
labrinea marked an inline comment as done.
labrinea added a comment.

Added a comment explaining system register lookups by alternative name as 
suggested and rebased on top of https://reviews.llvm.org/D111551. @john.brawn 
you may want to re-review the patch as the rebase had conflicts in 
`llvm/lib/Target/AArch64/AArch64.td`.


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

https://reviews.llvm.org/D110065

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64SystemOperands.td
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
  llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
  llvm/test/CodeGen/AArch64/arm64-crc32.ll
  llvm/test/MC/AArch64/arm64-branch-encoding.s
  llvm/test/MC/AArch64/arm64-system-encoding.s
  llvm/test/MC/AArch64/armv8.1a-lse.s
  llvm/test/MC/AArch64/armv8.1a-pan.s
  llvm/test/MC/AArch64/armv8.1a-rdma.s
  llvm/test/MC/AArch64/armv8.2a-at.s
  llvm/test/MC/AArch64/armv8.2a-crypto.s
  llvm/test/MC/AArch64/armv8.2a-dotprod-errors.s
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.2a-persistent-memory.s
  llvm/test/MC/AArch64/armv8.2a-uao.s
  llvm/test/MC/AArch64/armv8r-inst.s
  llvm/test/MC/AArch64/armv8r-sysreg.s
  llvm/test/MC/AArch64/armv8r-unsupported-inst.s
  llvm/test/MC/AArch64/armv8r-unsupported-sysreg.s
  llvm/test/MC/AArch64/basic-a64-instructions.s
  llvm/test/MC/AArch64/ras-extension.s
  llvm/test/MC/Disassembler/AArch64/arm64-branch.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-complex.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-js.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-dit.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-flag.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-ras.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-tlb.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-trace.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-virt.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-predres.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-specrestrict.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-ssbs.txt
  llvm/test/MC/Disassembler/AArch64/armv8a-el3.txt
  llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
  llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt

Index: llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
===
--- llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
+++ llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
@@ -1257,27 +1257,21 @@
 0xe1 0xff 0x1f 0xd4
 
 # CHECK: hvc  #{{1|0x1}}
-# CHECK: smc  #{{12000|0x2ee0}}
 # CHECK: brk  #{{12|0xc}}
 # CHECK: hlt  #{{123|0x7b}}
 0x22 0x0 0x0 0xd4
-0x3 0xdc 0x5 0xd4
 0x80 0x1 0x20 0xd4
 0x60 0xf 0x40 0xd4
 
 # CHECK: dcps1#{{42|0x2a}}
 # CHECK: dcps2#{{9|0x9}}
-# CHECK: dcps3#{{1000|0x3e8}}
 0x41 0x5 0xa0 0xd4
 0x22 0x1 0xa0 0xd4
-0x3 0x7d 0xa0 0xd4
 
 # CHECK: dcps1
 # CHECK: dcps2
-# CHECK: dcps3
 0x1 0x0 0xa0 0xd4
 0x2 0x0 0xa0 0xd4
-0x3 0x0 0xa0 0xd4
 
 #--
 # Extract (immediate)
@@ -3258,13 +3252,11 @@
 # CHECK: msr  {{hacr_el2|HACR_EL2}}, x12
 # CHECK: msr  {{mdcr_el3|MDCR_EL3}}, x12
 # CHECK: msr  {{ttbr0_el1|TTBR0_EL1}}, x12
-# CHECK: msr  {{ttbr0_el2|TTBR0_EL2}}, x12
 # CHECK: msr  {{ttbr0_el3|TTBR0_EL3}}, x12
 # CHECK: msr  {{ttbr1_el1|TTBR1_EL1}}, x12
 # CHECK: msr  {{tcr_el1|TCR_EL1}}, x12
 # CHECK: msr  {{tcr_el2|TCR_EL2}}, x12
 # CHECK: msr  {{tcr_el3|TCR_EL3}}, x12
-# CHECK: msr  {{vttbr_el2|VTTBR_EL2}}, x12
 # CHECK: msr  {{vtcr_el2|VTCR_EL2}}, x12
 # CHECK: msr  {{dacr32_el2|DACR32_EL2}}, x12
 # CHECK: msr  {{spsr_el1|SPSR_EL1}}, x12
@@ -3554,13 +3546,11 @@
 # CHECK: mrs  x9, {{hacr_el2|HACR_EL2}}
 # CHECK: mrs  x9, {{mdcr_el3|MDCR_EL3}}
 # CHECK: mrs  x9, {{ttbr0_el1|TTBR0_EL1}}
-# CHECK: mrs  x9, {{ttbr0_el2|TTBR0_EL2}}
 # CHECK: mrs  x9, {{ttbr0_el3|TTBR0_EL3}}
 # CHECK: mrs  x9, {{ttbr1_el1|TTBR1_EL1}}
 # CHECK: mrs  x9, {{tcr_el1|TCR_EL1}}
 # CHECK: mrs  x9, {{tcr_el2|TCR_EL2}}
 # CHECK: mrs  x9, {{tcr_el3|TCR_EL3}}
-# CHECK: mrs  x9, {{vttbr_el2|VTTBR_EL2}}
 # CHECK: mrs  x9, {{vtcr_el2|VTCR_EL2}}
 # CHECK: mrs  x9, {{dacr32_el2|DACR32_EL2}}
 # CHECK: mrs  x9, {{spsr_el1|SPSR_EL1}}
Index: llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
=

[PATCH] D112334: [clang-tidy] Suppress readability-static-access-through-instance for CUDA built-in variables

2021-10-26 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

@whisperity Understood, thanks for the help! I'll take more care to remember 
the reference next time :) I added it as a comment in Github for reference so 
there's at least some traceability.


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

https://reviews.llvm.org/D112334

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


[PATCH] D112532: [Matrix] Replace some err kinds with err_builtin_invalid_arg_type. (NFC)

2021-10-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: aaron.ballman, erichkeane, rjmccall.
Herald added a subscriber: tschuett.
fhahn requested review of this revision.
Herald added a project: clang.

Replace some custom matrix diagnostic kinds with the more generic
err_builtin_invalid_arg_type introduced in D111985 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112532

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp


Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -16578,7 +16578,8 @@
 
   auto *MType = Matrix->getType()->getAs();
   if (!MType) {
-Diag(Matrix->getBeginLoc(), diag::err_builtin_matrix_arg);
+Diag(Matrix->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+<< 1 << "matrix" << Matrix->getType();
 return ExprError();
   }
 
@@ -16649,15 +16650,17 @@
   auto *PtrTy = PtrExpr->getType()->getAs();
   QualType ElementTy;
   if (!PtrTy) {
-Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-<< PtrArgIdx + 1;
+Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+<< PtrArgIdx + 1 << "pointer to a valid matrix element type"
+<< PtrExpr->getType();
 ArgError = true;
   } else {
 ElementTy = PtrTy->getPointeeType().getUnqualifiedType();
 
 if (!ConstantMatrixType::isValidElementType(ElementTy)) {
-  Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-  << PtrArgIdx + 1;
+  Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+  << PtrArgIdx + 1 << "pointer to a valid matrix element type"
+  << PtrExpr->getType();
   ArgError = true;
 }
   }
@@ -16756,7 +16759,8 @@
 
   auto *MatrixTy = MatrixExpr->getType()->getAs();
   if (!MatrixTy) {
-Diag(MatrixExpr->getBeginLoc(), diag::err_builtin_matrix_arg) << 0;
+Diag(MatrixExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+<< 1 << "matrix" << MatrixExpr->getType();
 ArgError = true;
   }
 
@@ -16775,8 +16779,9 @@
   // Check pointer argument.
   auto *PtrTy = PtrExpr->getType()->getAs();
   if (!PtrTy) {
-Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-<< PtrArgIdx + 1;
+Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+<< PtrArgIdx + 1 << "pointer to a valid matrix element type"
+<< PtrExpr->getType();
 ArgError = true;
   } else {
 QualType ElementTy = PtrTy->getPointeeType();
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11318,11 +11318,8 @@
   "matrix row and column subscripts cannot be separated by any expression">;
 def err_matrix_subscript_comma: Error<
   "comma expressions are not allowed as indices in matrix subscript 
expressions">;
-def err_builtin_matrix_arg: Error<"1st argument must be a matrix">;
 def err_builtin_matrix_scalar_unsigned_arg: Error<
   "%0 argument must be a constant unsigned integer expression">;
-def err_builtin_matrix_pointer_arg: Error<
-  "%ordinal0 argument must be a pointer to a valid matrix element type">;
 def err_builtin_matrix_pointer_arg_mismatch: Error<
   "the pointee of the 2nd argument must match the element type of the 1st 
argument (%0 != %1)">;
 def err_builtin_matrix_store_to_const: Error<


Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -16578,7 +16578,8 @@
 
   auto *MType = Matrix->getType()->getAs();
   if (!MType) {
-Diag(Matrix->getBeginLoc(), diag::err_builtin_matrix_arg);
+Diag(Matrix->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+<< 1 << "matrix" << Matrix->getType();
 return ExprError();
   }
 
@@ -16649,15 +16650,17 @@
   auto *PtrTy = PtrExpr->getType()->getAs();
   QualType ElementTy;
   if (!PtrTy) {
-Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-<< PtrArgIdx + 1;
+Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+<< PtrArgIdx + 1 << "pointer to a valid matrix element type"
+<< PtrExpr->getType();
 ArgError = true;
   } else {
 ElementTy = PtrTy->getPointeeType().getUnqualifiedType();
 
 if (!ConstantMatrixType::isValidElementType(ElementTy)) {
-  Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-  << PtrArgIdx + 1;
+  Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+  << PtrArgIdx + 1 << "pointer to a valid matrix element type"
+  << PtrExpr->getType();
   ArgError = true;
 }
   }
@@ -16756,7 +16759,8 @@
 
   a

[PATCH] D112287: [clang] Implement CFG construction for @try and @catch

2021-10-26 Thread Nico Weber via Phabricator via cfe-commits
thakis marked 4 inline comments as done.
thakis added a comment.

Thanks, all done.

Looks like there's no range access to a try's catch blocks, so no for-range 
loop for now. Maybe I'll add range accessors for those later.




Comment at: clang/lib/Analysis/CFG.cpp:3895
 CFGBlock *CFGBuilder::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
   // FIXME: This isn't complete.  We basically treat @throw like a return
   //  statement.

hans wrote:
> does the fixme still stand?
No, I think this is done now. Removed, thanks.



Comment at: clang/lib/Analysis/CFG.cpp:5790
+  OS << "@catch (";
+  if (CS->getCatchParamDecl())
+CS->getCatchParamDecl()->print(OS, 
PrintingPolicy(Helper.getLangOpts()),

hans wrote:
> maybe
> 
> ```
> if (const VarDecl *PD = CS->getCatchParamDecl())
>   PD->print(...)
> ```
oh yes, that's much nicer. thanks, done.


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

https://reviews.llvm.org/D112287

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


[clang] d054b31 - [clang] Use consistent punctuation at end of Block NULL comment

2021-10-26 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-10-26T09:45:22-04:00
New Revision: d054b31d5975f6cffeef8c9f3fa57e1c4b60d427

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

LOG: [clang] Use consistent punctuation at end of Block NULL comment

No behavior change.

Added: 


Modified: 
clang/lib/Analysis/CFG.cpp

Removed: 




diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 8a3051a2f9ee..190e0d94ee99 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -3288,7 +3288,7 @@ CFGBlock *CFGBuilder::VisitLabelStmt(LabelStmt *L) {
   if (badCFG)
 return nullptr;
 
-  // We set Block to NULL to allow lazy creation of a new block (if necessary);
+  // We set Block to NULL to allow lazy creation of a new block (if necessary).
   Block = nullptr;
 
   // This block is now the implicit successor of other blocks.
@@ -4274,7 +4274,7 @@ CFGBlock *CFGBuilder::VisitCaseStmt(CaseStmt *CS) {
shouldAddCase(switchExclusivelyCovered, switchCond,
  CS, *Context));
 
-  // We set Block to NULL to allow lazy creation of a new block (if necessary)
+  // We set Block to NULL to allow lazy creation of a new block (if necessary).
   Block = nullptr;
 
   if (TopBlock) {
@@ -4310,7 +4310,7 @@ CFGBlock *CFGBuilder::VisitDefaultStmt(DefaultStmt 
*Terminator) {
   // (including a fall-through to the code after the switch statement) to 
always
   // be the last successor of a switch-terminated block.
 
-  // We set Block to NULL to allow lazy creation of a new block (if necessary)
+  // We set Block to NULL to allow lazy creation of a new block (if necessary).
   Block = nullptr;
 
   // This block is now the implicit successor of other blocks.
@@ -4409,7 +4409,7 @@ CFGBlock *CFGBuilder::VisitCXXCatchStmt(CXXCatchStmt *CS) 
{
   if (badCFG)
 return nullptr;
 
-  // We set Block to NULL to allow lazy creation of a new block (if necessary)
+  // We set Block to NULL to allow lazy creation of a new block (if necessary).
   Block = nullptr;
 
   return CatchBlock;



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


[clang] aa42785 - [clang] Simplify CFG block printing code a bit

2021-10-26 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-10-26T09:45:22-04:00
New Revision: aa42785d01cb498c1eb880e9f0e08f01006839c6

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

LOG: [clang] Simplify CFG block printing code a bit

No behavior change.

Added: 


Modified: 
clang/lib/Analysis/CFG.cpp

Removed: 




diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 190e0d94ee99..39c0f14c7b89 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -5683,21 +5683,18 @@ static void print_block(raw_ostream &OS, const CFG* cfg,
   OS << L->getName();
 else if (CaseStmt *C = dyn_cast(Label)) {
   OS << "case ";
-  if (C->getLHS())
-C->getLHS()->printPretty(OS, &Helper,
- PrintingPolicy(Helper.getLangOpts()));
-  if (C->getRHS()) {
+  if (const Expr *LHS = C->getLHS())
+LHS->printPretty(OS, &Helper, PrintingPolicy(Helper.getLangOpts()));
+  if (const Expr *RHS = C->getRHS()) {
 OS << " ... ";
-C->getRHS()->printPretty(OS, &Helper,
- PrintingPolicy(Helper.getLangOpts()));
+RHS->printPretty(OS, &Helper, PrintingPolicy(Helper.getLangOpts()));
   }
 } else if (isa(Label))
   OS << "default";
 else if (CXXCatchStmt *CS = dyn_cast(Label)) {
   OS << "catch (";
-  if (CS->getExceptionDecl())
-CS->getExceptionDecl()->print(OS, PrintingPolicy(Helper.getLangOpts()),
-  0);
+  if (const VarDecl *ED = CS->getExceptionDecl())
+ED->print(OS, PrintingPolicy(Helper.getLangOpts()), 0);
   else
 OS << "...";
   OS << ")";



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


[clang] 0b7c9ad - [clang] Make loop in CFGBuilder::VisitCXXTryStmt() more canonical

2021-10-26 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-10-26T09:45:22-04:00
New Revision: 0b7c9addce69ca089a23334490758907dd4ab0db

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

LOG: [clang] Make loop in CFGBuilder::VisitCXXTryStmt() more canonical

No behavior change.

Added: 


Modified: 
clang/lib/Analysis/CFG.cpp

Removed: 




diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 39c0f14c7b89..18598e6eba33 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -4338,10 +4338,10 @@ CFGBlock *CFGBuilder::VisitCXXTryStmt(CXXTryStmt 
*Terminator) {
   NewTryTerminatedBlock->setTerminator(Terminator);
 
   bool HasCatchAll = false;
-  for (unsigned h = 0; h getNumHandlers(); ++h) {
+  for (unsigned I = 0, E = Terminator->getNumHandlers(); I != E; ++I) {
 // The code after the try is the implicit successor.
 Succ = TrySuccessor;
-CXXCatchStmt *CS = Terminator->getHandler(h);
+CXXCatchStmt *CS = Terminator->getHandler(I);
 if (CS->getExceptionDecl() == nullptr) {
   HasCatchAll = true;
 }



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


[clang] 04f3079 - [clang] Implement CFG construction for @try and @catch

2021-10-26 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-10-26T09:45:22-04:00
New Revision: 04f30795f1663843b219393040946136786aa591

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

LOG: [clang] Implement CFG construction for @try and @catch

@finally is still not implemented.

With this, clang can emit -Wreturn-type warnings for functions containing
@try/@catch (but not yet @finally), and -Wunreachable-code also works for those
functions.

The implementation is similar to D36914.

Part of PR46693.

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

Added: 
clang/test/Sema/warn-unreachable.m
clang/test/Sema/warn-unreachable.mm

Modified: 
clang/lib/Analysis/CFG.cpp
clang/test/Sema/warn-unreachable.c
clang/test/SemaObjC/try-catch.m

Removed: 




diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 18598e6eba33..1ac960862ddb 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -482,8 +482,10 @@ class CFGBuilder {
   CFGBlock *SwitchTerminatedBlock = nullptr;
   CFGBlock *DefaultCaseBlock = nullptr;
 
-  // This can point either to a try or a __try block. The frontend forbids
-  // mixing both kinds in one function, so having one for both is enough.
+  // This can point to either a C++ try, an Objective-C @try, or an SEH __try.
+  // try and @try can be mixed and generally work the same.
+  // The frontend forbids mixing SEH __try with either try or @try.
+  // So having one for all three is enough.
   CFGBlock *TryTerminatedBlock = nullptr;
 
   // Current position in local scope.
@@ -2286,7 +2288,7 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc,
   return VisitObjCAtCatchStmt(cast(S));
 
 case Stmt::ObjCAutoreleasePoolStmtClass:
-return VisitObjCAutoreleasePoolStmt(cast(S));
+  return VisitObjCAutoreleasePoolStmt(cast(S));
 
 case Stmt::ObjCAtSynchronizedStmtClass:
   return VisitObjCAtSynchronizedStmt(cast(S));
@@ -3253,8 +3255,7 @@ CFGBlock *CFGBuilder::VisitSEHTryStmt(SEHTryStmt 
*Terminator) {
   Succ = SEHTrySuccessor;
 
   // Save the current "__try" context.
-  SaveAndRestore save_try(TryTerminatedBlock,
-  NewTryTerminatedBlock);
+  SaveAndRestore SaveTry(TryTerminatedBlock, 
NewTryTerminatedBlock);
   cfg->addTryDispatchBlock(TryTerminatedBlock);
 
   // Save the current value for the __leave target.
@@ -3700,11 +3701,6 @@ CFGBlock 
*CFGBuilder::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
   return addStmt(S->getSynchExpr());
 }
 
-CFGBlock *CFGBuilder::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
-  // FIXME
-  return NYS();
-}
-
 CFGBlock *CFGBuilder::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
   autoCreateBlock();
 
@@ -3865,16 +3861,37 @@ CFGBlock *CFGBuilder::VisitWhileStmt(WhileStmt *W) {
   return EntryConditionBlock;
 }
 
-CFGBlock *CFGBuilder::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
-  // FIXME: For now we pretend that @catch and the code it contains does not
-  //  exit.
-  return Block;
+CFGBlock *CFGBuilder::VisitObjCAtCatchStmt(ObjCAtCatchStmt *CS) {
+  // ObjCAtCatchStmt are treated like labels, so they are the first statement
+  // in a block.
+
+  // Save local scope position because in case of exception variable ScopePos
+  // won't be restored when traversing AST.
+  SaveAndRestore save_scope_pos(ScopePos);
+
+  if (CS->getCatchBody())
+addStmt(CS->getCatchBody());
+
+  CFGBlock *CatchBlock = Block;
+  if (!CatchBlock)
+CatchBlock = createBlock();
+
+  appendStmt(CatchBlock, CS);
+
+  // Also add the ObjCAtCatchStmt as a label, like with regular labels.
+  CatchBlock->setLabel(CS);
+
+  // Bail out if the CFG is bad.
+  if (badCFG)
+return nullptr;
+
+  // We set Block to NULL to allow lazy creation of a new block (if necessary).
+  Block = nullptr;
+
+  return CatchBlock;
 }
 
 CFGBlock *CFGBuilder::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
-  // FIXME: This isn't complete.  We basically treat @throw like a return
-  //  statement.
-
   // If we were in the middle of a block we stop processing that block.
   if (badCFG)
 return nullptr;
@@ -3882,14 +3899,78 @@ CFGBlock 
*CFGBuilder::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
   // Create the new block.
   Block = createBlock(false);
 
-  // The Exit block is the only successor.
-  addSuccessor(Block, &cfg->getExit());
+  if (TryTerminatedBlock)
+// The current try statement is the only successor.
+addSuccessor(Block, TryTerminatedBlock);
+  else
+// otherwise the Exit block is the only successor.
+addSuccessor(Block, &cfg->getExit());
 
   // Add the statement to the block.  This may create new blocks if S contains
   // control-flow (short-circuit operations).
   return VisitStmt(S, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitObjCA

[PATCH] D112287: [clang] Implement CFG construction for @try and @catch

2021-10-26 Thread Nico Weber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG04f30795f166: [clang] Implement CFG construction for @try 
and @catch (authored by thakis).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D112287?vs=381450&id=382293#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112287

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/Sema/warn-unreachable.c
  clang/test/Sema/warn-unreachable.m
  clang/test/Sema/warn-unreachable.mm
  clang/test/SemaObjC/try-catch.m

Index: clang/test/SemaObjC/try-catch.m
===
--- clang/test/SemaObjC/try-catch.m
+++ clang/test/SemaObjC/try-catch.m
@@ -34,7 +34,12 @@
 @try {}
 // the exception name is optional (weird)
 @catch (NSException *) {}
-}
+} // expected-warning {{non-void function does not return a value}}
+
+- (NSDictionary *)anotherFunction {
+@try {}
+@finally {}
+} // FIXME: This should warn about a missing return too.
 @end
 
 int foo() {
Index: clang/test/Sema/warn-unreachable.mm
===
--- /dev/null
+++ clang/test/Sema/warn-unreachable.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-exceptions -fcxx-exceptions -verify -Wunreachable-code %s
+
+void f();
+
+void g3() {
+  try {
+@try {
+  f();
+  throw 4; // caught by @catch, not by outer c++ catch.
+  f(); // expected-warning {{will never be executed}}
+} @catch (...) {
+}
+f(); // not-unreachable
+  } catch (...) {
+  }
+}
Index: clang/test/Sema/warn-unreachable.m
===
--- /dev/null
+++ clang/test/Sema/warn-unreachable.m
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-exceptions -verify -Wunreachable-code %s
+
+void f();
+
+void g1() {
+  @try {
+f();
+@throw @"";
+f();  // expected-warning{{will never be executed}}
+  } @catch(id i) {
+f();
+  }
+
+  // Completely empty.
+  @try {
+  } @catch(...) {
+  }
+
+  @try {
+f();
+return;
+  } @catch(id i = nil) {  // Catch block should not be marked as unreachable.
+// Empty @catch body.
+  }
+}
+
+void g2() {
+  @try {
+// Nested @try.
+@try {
+  f();
+  @throw @"";
+  f(); // expected-warning{{will never be executed}}
+} @catch(...) {
+}
+f();
+@throw @"";
+f(); // expected-warning{{will never be executed}}
+  } @catch(...) {
+f();
+  }
+}
+
+void g3() {
+  @try {
+@try {
+  f();
+} @catch (...) {
+  @throw @""; // should exit outer try
+}
+@throw @"";
+f(); // expected-warning{{never be executed}}
+  } @catch (...) {
+  }
+}
Index: clang/test/Sema/warn-unreachable.c
===
--- clang/test/Sema/warn-unreachable.c
+++ clang/test/Sema/warn-unreachable.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wunreachable-code-aggressive -Wno-unused-value -Wno-covered-switch-default -I %S/Inputs
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wunreachable-code-aggressive -Wno-unused-value -Wno-covered-switch-default -I %S/Inputs %s
 // RUN: %clang_cc1 -fsyntax-only -fblocks -Wunreachable-code-aggressive -Wno-unused-value -Wno-covered-switch-default -fdiagnostics-parseable-fixits -I %S/Inputs %s 2>&1 | FileCheck %s
 
 #include "warn-unreachable.h"
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -482,8 +482,10 @@
   CFGBlock *SwitchTerminatedBlock = nullptr;
   CFGBlock *DefaultCaseBlock = nullptr;
 
-  // This can point either to a try or a __try block. The frontend forbids
-  // mixing both kinds in one function, so having one for both is enough.
+  // This can point to either a C++ try, an Objective-C @try, or an SEH __try.
+  // try and @try can be mixed and generally work the same.
+  // The frontend forbids mixing SEH __try with either try or @try.
+  // So having one for all three is enough.
   CFGBlock *TryTerminatedBlock = nullptr;
 
   // Current position in local scope.
@@ -2286,7 +2288,7 @@
   return VisitObjCAtCatchStmt(cast(S));
 
 case Stmt::ObjCAutoreleasePoolStmtClass:
-return VisitObjCAutoreleasePoolStmt(cast(S));
+  return VisitObjCAutoreleasePoolStmt(cast(S));
 
 case Stmt::ObjCAtSynchronizedStmtClass:
   return VisitObjCAtSynchronizedStmt(cast(S));
@@ -3253,8 +3255,7 @@
   Succ = SEHTrySuccessor;
 
   // Save the current "__try" context.
-  SaveAndRestore save_try(TryTerminatedBlock,
-  NewTryTerminatedBlock);
+  SaveAndRestore SaveTry(TryTerminatedBlock, NewTryTerminatedBlock);
   cfg->addTryDispatchBlock(TryTerminatedBlock);
 
   // Sa

[PATCH] D112406: [Driver][AArch64]Add driver support for neoverse-512tvb target

2021-10-26 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added a comment.

In D112406#3087191 , @dmgreen wrote:

> Thanks. If the cpu has a 512 bit total vector bandwidth, should the 
> VScaleForTuning be 1 or 2 (or higher)? llvm doesn't usually deal with total 
> bandwidth a lot, perhaps not as much as it should.
>
> @david-arm any thoughts?

The total vector bandwidth includes unrolling so currently having 
`VScaleForTuning=1` and `MaxInterleaveFactor=4` implies 512 tvb.  If the target 
has >128bit vectors then vector loops will likely have more work than they can 
handle in parallel but as long as that does not negatively affect register 
pressure it shouldn't be a problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112406

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


[PATCH] D112534: [PoC][RISCV] Use an attribute to declare C intrinsics with different policy.

2021-10-26 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai created this revision.
HsiangKai added reviewers: kito-cheng, craig.topper, frasercrmck, rogfer01.
Herald added subscribers: achieveartificialintelligence, StephenFan, vkmr, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, 
shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Herald added a reviewer: aaron.ballman.
HsiangKai requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This patch provides a proof-of-concept implementation of the proposal.
https://github.com/riscv-non-isa/rvv-intrinsic-doc/issues/120

In this patch, we create a new attribute rvv_policy to annotate C
intrinsics with its tail/inactive elements policy. The syntax is

__attribute__((rvv_policy(tama)))
vint32m1_t vadd_tama(...);

The possible policy is tama, tamu, tuma, tumu.
ta: tail agnostic
tu: tail undisturbed
ma: inactive masked-off agnostic
mu: inactive masked-off undisturbed

This attribute is used in riscv_vector.h.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112534

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd-policy.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd-tu.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -204,6 +204,10 @@
   // Emit the macros for mapping C/C++ intrinsic function to builtin functions.
   void emitIntrinsicFuncDef(raw_ostream &o) const;
 
+  // Emit the declarations for mapping C/C++ intrinsic function to builtin
+  // functions.
+  void emitIntrinsicWithPolicyFuncDef(raw_ostream &o) const;
+
   // Emit the mangled function definition.
   void emitMangledFuncDef(raw_ostream &o) const;
 };
@@ -835,9 +839,28 @@
   if (isMask()) {
 if (hasVL()) {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);\n";
-  if (hasPolicy())
-OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(),"
-   " TAIL_UNDISTURBED));\n";
+  if (hasPolicy()) {
+OS << "  if (PolicyAttr) {\n";
+OS << "switch (PolicyAttr->getPolicy()) {\n";
+OS << "default:\n";
+OS << "  PolicyValue = 0;\n";
+OS << "  break;\n";
+OS << "case RISCVVPolicyAttr::TAMU:\n";
+OS << "  PolicyValue = TAIL_AGNOSTIC;\n";
+OS << "  break;\n";
+OS << "case RISCVVPolicyAttr::TUMA:\n";
+OS << "  PolicyValue = MASK_AGNOSTIC;\n";
+OS << "  break;\n";
+OS << "case RISCVVPolicyAttr::TAMA:\n";
+OS << "  PolicyValue = MASK_AGNOSTIC | TAIL_AGNOSTIC;\n";
+OS << "  break;\n";
+OS << "}\n";
+OS << "  } else {\n";
+OS << "PolicyValue = 0;\n";
+OS << "  }\n";
+OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(), "
+  "PolicyValue));\n";
+  }
 } else {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end());\n";
 }
@@ -873,6 +896,30 @@
   OS << ");\n";
 }
 
+void RVVIntrinsic::emitIntrinsicWithPolicyFuncDef(raw_ostream &OS) const {
+  if (!isMask())
+return;
+
+  const char *policySuffix[] = {"tumu", "tamu", "tuma", "tama"};
+
+  for (unsigned i = 0; i < 4; ++i) {
+OS << "__rvv_ai ";
+OS << "__attribute__((__clang_builtin_alias__(";
+OS << "__builtin_rvv_" << getBuiltinName() << ")))\n";
+OS << "__attribute__((rvv_policy(" << policySuffix[i] << ")))\n";
+StringRef IntrinsicName = getName().substr(0, getName().size() - 2);
+OS << OutputType->getTypeStr() << " " << IntrinsicName << "_"
+   << policySuffix[i] << "(";
+// Emit function arguments
+if (!InputTypes.empty()) {
+  ListSeparator LS;
+  for (unsigned i = 0; i < InputTypes.size(); ++i)
+OS << LS << InputTypes[i]->getTypeStr();
+}
+OS << ");\n";
+  }
+}
+
 void RVVIntrinsic::emitMangledFuncDef(raw_ostream &OS) const {
   OS << "__attribute__((__clang_builtin_alias__(";
   OS << "__builtin_rvv_" << getBuiltinName() << ")))\n";
@@ -989,6 +1036,10 @@
 Inst.emitIntrinsicFuncDef(OS);
   });
 
+  emitArchMacroAndBody(Defs, OS, [](raw_ostream &OS, const RVVIntrinsic &Inst) {
+Inst.emitIntrinsicWithPolicyFuncDef(OS);
+  });
+
   OS << "#undef __rvv_ai\n\n";
 
   OS << "#define __riscv_v_intrinsic_overloading 1\n";
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vadd-tu.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vadd-tu.c
@@ -0,0 +1,24 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc

[PATCH] D112534: [PoC][RISCV] Use an attribute to declare C intrinsics with different policy.

2021-10-26 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 382298.
HsiangKai added a comment.

Remove redundant test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112534

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd-policy.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -204,6 +204,10 @@
   // Emit the macros for mapping C/C++ intrinsic function to builtin functions.
   void emitIntrinsicFuncDef(raw_ostream &o) const;
 
+  // Emit the declarations for mapping C/C++ intrinsic function to builtin
+  // functions.
+  void emitIntrinsicWithPolicyFuncDef(raw_ostream &o) const;
+
   // Emit the mangled function definition.
   void emitMangledFuncDef(raw_ostream &o) const;
 };
@@ -835,9 +839,28 @@
   if (isMask()) {
 if (hasVL()) {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);\n";
-  if (hasPolicy())
-OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(),"
-   " TAIL_UNDISTURBED));\n";
+  if (hasPolicy()) {
+OS << "  if (PolicyAttr) {\n";
+OS << "switch (PolicyAttr->getPolicy()) {\n";
+OS << "default:\n";
+OS << "  PolicyValue = 0;\n";
+OS << "  break;\n";
+OS << "case RISCVVPolicyAttr::TAMU:\n";
+OS << "  PolicyValue = TAIL_AGNOSTIC;\n";
+OS << "  break;\n";
+OS << "case RISCVVPolicyAttr::TUMA:\n";
+OS << "  PolicyValue = MASK_AGNOSTIC;\n";
+OS << "  break;\n";
+OS << "case RISCVVPolicyAttr::TAMA:\n";
+OS << "  PolicyValue = MASK_AGNOSTIC | TAIL_AGNOSTIC;\n";
+OS << "  break;\n";
+OS << "}\n";
+OS << "  } else {\n";
+OS << "PolicyValue = 0;\n";
+OS << "  }\n";
+OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(), "
+  "PolicyValue));\n";
+  }
 } else {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end());\n";
 }
@@ -873,6 +896,30 @@
   OS << ");\n";
 }
 
+void RVVIntrinsic::emitIntrinsicWithPolicyFuncDef(raw_ostream &OS) const {
+  if (!isMask())
+return;
+
+  const char *policySuffix[] = {"tumu", "tamu", "tuma", "tama"};
+
+  for (unsigned i = 0; i < 4; ++i) {
+OS << "__rvv_ai ";
+OS << "__attribute__((__clang_builtin_alias__(";
+OS << "__builtin_rvv_" << getBuiltinName() << ")))\n";
+OS << "__attribute__((rvv_policy(" << policySuffix[i] << ")))\n";
+StringRef IntrinsicName = getName().substr(0, getName().size() - 2);
+OS << OutputType->getTypeStr() << " " << IntrinsicName << "_"
+   << policySuffix[i] << "(";
+// Emit function arguments
+if (!InputTypes.empty()) {
+  ListSeparator LS;
+  for (unsigned i = 0; i < InputTypes.size(); ++i)
+OS << LS << InputTypes[i]->getTypeStr();
+}
+OS << ");\n";
+  }
+}
+
 void RVVIntrinsic::emitMangledFuncDef(raw_ostream &OS) const {
   OS << "__attribute__((__clang_builtin_alias__(";
   OS << "__builtin_rvv_" << getBuiltinName() << ")))\n";
@@ -989,6 +1036,10 @@
 Inst.emitIntrinsicFuncDef(OS);
   });
 
+  emitArchMacroAndBody(Defs, OS, [](raw_ostream &OS, const RVVIntrinsic &Inst) {
+Inst.emitIntrinsicWithPolicyFuncDef(OS);
+  });
+
   OS << "#undef __rvv_ai\n\n";
 
   OS << "#define __riscv_v_intrinsic_overloading 1\n";
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vadd-policy.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vadd-policy.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-feature +experimental-v \
+// RUN:   -target-feature +experimental-zfh -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: @test_vadd_vv_i8m1_tama(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vadd.mask.nxv8i8.nxv8i8.i64( [[MASKEDOFF:%.*]],  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8m1_t test_vadd_vv_i8m1_tama(vbool8_t mask, vint8m1_t maskedoff, vint8m1_t op1, vint8m1_t op2, size_t vl) {
+  return vadd_vv_i8m1_tama(mask, maskedoff, op1, op2, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vadd_vv_i8m1_tamu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vadd.mask.nxv8i8.nxv8i8.i64( [[MASKEDOFF:%.*]],  

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 382300.
fhahn marked 3 inline comments as done.
fhahn added a comment.

Address latest comments, thanks

- Added a generic `err_builtin_invalid_arg_type` diagnostic kind, which can 
also be used for some of the matrix type mismatches (see D112532 
).
- Dropped `err_elementwise_math_arg_types_mismatch` in favor of the existing 
`err_typecheck_call_different_arg_types`.
- Use `Res` to set the call type
- Add tests with _Complex, which gets rejected.
- add C++ test that check constness of builtins.



In D111985#3087057 , @aaron.ballman 
wrote:

> I thought of another test case -- should these new functions work on complex 
> types? (Those are weird enough we may want to consider adding both Sema and 
> CodeGen tests if we do support them, and Sema tests alone if we don't.)

At the moment they should not work with complex types (like C99's _Complex). 
The problem there is that there is no dedicated IR type and the LLVM intrinsics 
do not support complex types. So at the moment we cannot lower such operations 
effectively.

I think it would make sense to extend them to complex types once we can better 
model those operations in LLVM IR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111985

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c
  clang/test/SemaCXX/builtins-elementwise-math.cpp

Index: clang/test/SemaCXX/builtins-elementwise-math.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtins-elementwise-math.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -std=c++17 -pedantic -verify -triple=x86_64-apple-darwin9
+
+// Simple is_const implementation.
+struct true_type {
+  static const bool value = true;
+};
+
+struct false_type {
+  static const bool value = false;
+};
+
+template  struct is_const : false_type {};
+template  struct is_const : true_type {};
+
+// expected-no-diagnostics
+
+void test_builtin_elementwise_max() {
+  const int a = 2;
+  int b = 1;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
+
+void test_builtin_elementwise_min() {
+  const int a = 2;
+  int b = 1;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
Index: clang/test/Sema/builtins-elementwise-math.c
===
--- /dev/null
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -std=c99 %s -pedantic -verify -triple=x86_64-apple-darwin9
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef int int3 __attribute__((ext_vector_type(3)));
+
+struct Foo {
+  char *p;
+};
+
+__attribute__((address_space(1))) int int_as_one;
+typedef int bar;
+bar b;
+
+void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, int *p) {
+  i = __builtin_elementwise_max(p, d);
+  // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}
+
+  struct Foo foo = __builtin_elementwise_max(i, i);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+
+  i = __builtin_elementwise_max(i);
+  // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
+
+  i = __builtin_elementwise_max();
+  // expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
+
+  i = __builtin_elementwise_max(i, i, i);
+  // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
+
+  i = __builtin_elementwise_max(v, iv);
+  // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
+
+  s = __builtin_elementwise_max(i, s);
+
+  enum e { one,
+   two };
+  i = __builtin_elementwise_max(one, two);
+
+  enum f { three };
+  enum f x = __builtin_elementwise_max(one, three);
+
+  _ExtInt(32) ext;
+  ext = __builtin_elementwise_max(ext, ext);
+
+  const int ci;
+  i = __builtin_elementwise_max(ci, i);
+  i = __builtin_elementwise_max(i, ci);
+  i = __builtin_elementwise_max(ci, ci);
+
+  i = __builtin_elementwise_max(i, int_as_one); // ok (attributes don't match)?
+  i = __builtin_elementwise_max(i, b);  // ok (sugar doesn't match)?
+
+  int A[10];
+  A = __builtin_elementwise_max(A, A);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}}
+
+  int(ii);
+  int j;
+  j = __builtin_elementwise_max(i, j);
+
+  _Complex float c1, c2;
+  c1 = __builtin_elementwise_max(c1, c2);
+  // expec

[PATCH] D112532: [Matrix] Replace some err kinds with err_builtin_invalid_arg_type. (NFC)

2021-10-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I'm fine with this change in general... but did this not manage to break any 
tests?




Comment at: clang/lib/Sema/SemaChecking.cpp:16654
+Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+<< PtrArgIdx + 1 << "pointer to a valid matrix element type"
+<< PtrExpr->getType();

Can you make these be a "select" instead?  It makes it really difficult to 
localize if we do this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112532

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


[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked 3 inline comments as done.
fhahn added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8747-8748
 
+def err_elementwise_math_arg_types_mismatch : Error <
+  "argument types do not match, %0 != %1">;
+

aaron.ballman wrote:
> Does `err_typecheck_call_different_arg_types` suffice?
 `err_typecheck_call_different_arg_types` is sufficient, thanks!



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8750-8751
+
+def err_elementwise_math_invalid_arg_type: Error <
+  "argument type %0 is not supported">;
+

aaron.ballman wrote:
> It'd be nice to avoid this entirely as the diagnostic situation is one we 
> would have elsewhere (so we should be able to use common diagnostic checking 
> code from here and places like `SemaBuiltinMatrixColumnMajorLoad()` ideally).
I turned the diagnostic kind into a more generic one and also put up a patch to 
use them instead some of the custom matrix diagnostic kinds (D112532). WDYT?

I'm not sure if there's much potential for sharing the checking code, as it 
looks like most places check for slightly different things (or the check is 
quite compact already).



Comment at: clang/lib/Sema/SemaChecking.cpp:16662-16667
+  if (!Ty->getAs() && !ConstantMatrixType::isValidElementType(Ty)) 
{
+S.Diag(Loc, diag::err_elementwise_math_invalid_arg_type) << Ty;
+return true;
+  }
+  return false;
+}

aaron.ballman wrote:
> Related to the comment above on the diagnostic, I'm wondering if we want to 
> abstract this into a helper function that gets used by all the elementwise 
> builtins you're adding?
Unfortunately I am not sure which code this is referring to. The element type 
check is already a generic function to be used to check the new builtins with 1 
arg and the reduction builtins. 



Comment at: clang/lib/Sema/SemaChecking.cpp:16695
+  TheCall->setArg(1, B.get());
+  TheCall->setType(TyB);
+  return false;

aaron.ballman wrote:
> I think you want to set this to `Res`, because that's the common type between 
> `TyB` and `TyA`, right? That will also ensure that qualifiers are stripped, I 
> believe. e.g.,
> ```
> const int a = 2;
> int b = 1;
> static_assert(!std::is_const_v);
> static_assert(!std::is_const_v);
> ```
Agreed, using `TyB` is confusing, so I updated it. I *think* it was still doing 
the right thing, because `TyB` is to `B`'s type after conversion, so I *think* 
that would be to common type already. 

I also added a `.cpp` Sema test file to check the constness.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111985

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


[PATCH] D112504: [OpenMP] Wrap (v)printf in the new RT and use same handling for AMD

2021-10-26 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Nice! Yep, can add a size argument later. Will want it to control copying the 
payload over to the host


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112504

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


[PATCH] D110065: [AArch64] Add support for the 'R' architecture profile.

2021-10-26 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea updated this revision to Diff 382294.
labrinea added a comment.

Added v8.1a_ops on AppleA10. However, the target parser lists it as v8.0a, 
which seems odd. Out of the scope of this patch anyway.


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

https://reviews.llvm.org/D110065

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64SystemOperands.td
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
  llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
  llvm/test/CodeGen/AArch64/arm64-crc32.ll
  llvm/test/MC/AArch64/arm64-branch-encoding.s
  llvm/test/MC/AArch64/arm64-system-encoding.s
  llvm/test/MC/AArch64/armv8.1a-lse.s
  llvm/test/MC/AArch64/armv8.1a-pan.s
  llvm/test/MC/AArch64/armv8.1a-rdma.s
  llvm/test/MC/AArch64/armv8.2a-at.s
  llvm/test/MC/AArch64/armv8.2a-crypto.s
  llvm/test/MC/AArch64/armv8.2a-dotprod-errors.s
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.2a-persistent-memory.s
  llvm/test/MC/AArch64/armv8.2a-uao.s
  llvm/test/MC/AArch64/armv8r-inst.s
  llvm/test/MC/AArch64/armv8r-sysreg.s
  llvm/test/MC/AArch64/armv8r-unsupported-inst.s
  llvm/test/MC/AArch64/armv8r-unsupported-sysreg.s
  llvm/test/MC/AArch64/basic-a64-instructions.s
  llvm/test/MC/AArch64/ras-extension.s
  llvm/test/MC/Disassembler/AArch64/arm64-branch.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-complex.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-js.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-dit.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-flag.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-ras.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-tlb.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-trace.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-virt.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-predres.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-specrestrict.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-ssbs.txt
  llvm/test/MC/Disassembler/AArch64/armv8a-el3.txt
  llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
  llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt

Index: llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
===
--- llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
+++ llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
@@ -1257,27 +1257,21 @@
 0xe1 0xff 0x1f 0xd4
 
 # CHECK: hvc  #{{1|0x1}}
-# CHECK: smc  #{{12000|0x2ee0}}
 # CHECK: brk  #{{12|0xc}}
 # CHECK: hlt  #{{123|0x7b}}
 0x22 0x0 0x0 0xd4
-0x3 0xdc 0x5 0xd4
 0x80 0x1 0x20 0xd4
 0x60 0xf 0x40 0xd4
 
 # CHECK: dcps1#{{42|0x2a}}
 # CHECK: dcps2#{{9|0x9}}
-# CHECK: dcps3#{{1000|0x3e8}}
 0x41 0x5 0xa0 0xd4
 0x22 0x1 0xa0 0xd4
-0x3 0x7d 0xa0 0xd4
 
 # CHECK: dcps1
 # CHECK: dcps2
-# CHECK: dcps3
 0x1 0x0 0xa0 0xd4
 0x2 0x0 0xa0 0xd4
-0x3 0x0 0xa0 0xd4
 
 #--
 # Extract (immediate)
@@ -3258,13 +3252,11 @@
 # CHECK: msr  {{hacr_el2|HACR_EL2}}, x12
 # CHECK: msr  {{mdcr_el3|MDCR_EL3}}, x12
 # CHECK: msr  {{ttbr0_el1|TTBR0_EL1}}, x12
-# CHECK: msr  {{ttbr0_el2|TTBR0_EL2}}, x12
 # CHECK: msr  {{ttbr0_el3|TTBR0_EL3}}, x12
 # CHECK: msr  {{ttbr1_el1|TTBR1_EL1}}, x12
 # CHECK: msr  {{tcr_el1|TCR_EL1}}, x12
 # CHECK: msr  {{tcr_el2|TCR_EL2}}, x12
 # CHECK: msr  {{tcr_el3|TCR_EL3}}, x12
-# CHECK: msr  {{vttbr_el2|VTTBR_EL2}}, x12
 # CHECK: msr  {{vtcr_el2|VTCR_EL2}}, x12
 # CHECK: msr  {{dacr32_el2|DACR32_EL2}}, x12
 # CHECK: msr  {{spsr_el1|SPSR_EL1}}, x12
@@ -3554,13 +3546,11 @@
 # CHECK: mrs  x9, {{hacr_el2|HACR_EL2}}
 # CHECK: mrs  x9, {{mdcr_el3|MDCR_EL3}}
 # CHECK: mrs  x9, {{ttbr0_el1|TTBR0_EL1}}
-# CHECK: mrs  x9, {{ttbr0_el2|TTBR0_EL2}}
 # CHECK: mrs  x9, {{ttbr0_el3|TTBR0_EL3}}
 # CHECK: mrs  x9, {{ttbr1_el1|TTBR1_EL1}}
 # CHECK: mrs  x9, {{tcr_el1|TCR_EL1}}
 # CHECK: mrs  x9, {{tcr_el2|TCR_EL2}}
 # CHECK: mrs  x9, {{tcr_el3|TCR_EL3}}
-# CHECK: mrs  x9, {{vttbr_el2|VTTBR_EL2}}
 # CHECK: mrs  x9, {{vtcr_el2|VTCR_EL2}}
 # CHECK: mrs  x9, {{dacr32_el2|DACR32_EL2}}
 # CHECK: mrs  x9, {{spsr_el1|SPSR_EL1}}
Index: llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
@@ -1,5 +1,6 @@
 # RUN: llvm-mc -triple aarch64-no

[clang-tools-extra] 1c2e249 - [clangd] IncludeCleaner: don't stop the traversal

2021-10-26 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-10-26T16:08:54+02:00
New Revision: 1c2e249f938c50e1b331a1f7adc83c0a381f3897

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

LOG: [clangd] IncludeCleaner: don't stop the traversal

I was under the impression that `return false;` in the
RecursiveASTVisitor stops the traversal for the subtree but it appears
that it stops the whole tree traversal, so this change introduces a bug
where `ReferencedLocationCrawler` will not collect any symbols past an
enum.

This is a follow-up on D112209.

Added: 


Modified: 
clang-tools-extra/clangd/IncludeCleaner.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index 50f5a926111e..af82c96e494a 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -98,7 +98,7 @@ class ReferencedLocationCrawler
   bool VisitEnumDecl(EnumDecl *D) {
 if (D->isThisDeclarationADefinition() && D->getIntegerTypeSourceInfo())
   add(D);
-return false;
+return true;
   }
 
 private:



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


[PATCH] D111199: [Clang][LLVM][Attr] support btf_type_tag attribute

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: rsmith, dblaikie.
aaron.ballman added a comment.

Adding some additional reviewers who may have more opinions about the changes 
in CodeGen.




Comment at: clang/include/clang/Basic/AttrDocs.td:2029-2034
+Clang supports the ``__attribute__((btf_type_tag("ARGUMENT")))`` attribute for
+all targets. If -g is specified, for variable declaration type, function return
+type, function argument type, or typedef underlying type, if these types
+are pointer types, the ``ARGUMENT`` info will be preserved in IR and be emitted
+to dwarf. FOR BPF trgets, the ``ARGUMENT`` info will be eimitted to .BTF ELF
+section too.





Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:941-947
+if (auto MTL = TL.getAs()) {
+  TL = MTL.getInnerLoc();
+} else if (auto ATL = TL.getAs()) {
+  TL = ATL.getModifiedLoc();
+} else {
+  break;
+}

Phab's diff view is not helpful here -- removing the curly braces around 
single-line statements per our usual coding standards.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1337
+  TypeLoc TL;
+  if (auto TSI = Ty->getDecl()->getTypeSourceInfo())
+TL = TSI->getTypeLoc();





Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1447-1448
+  TypeLoc ParamTL;
+  if (auto Param = FTL.getParam(Idx)) {
+if (auto TSI = Param->getTypeSourceInfo())
+  ParamTL = TSI->getTypeLoc();

Can you spell out the types here?



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1646
+TypeLoc TL;
+if (auto TSI = field->getTypeSourceInfo())
+  TL = TSI->getTypeLoc();





Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4061
+  if (const auto *FD = dyn_cast(D)) {
+if (auto TSI = FD->getTypeSourceInfo())
+  TL = TSI->getTypeLoc();





Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4468
+TypeLoc TL;
+if (auto TSI = VD->getTypeSourceInfo())
+  TL = TSI->getTypeLoc();





Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:5196
+TypeLoc TL;
+if (auto TSI = D->getTypeSourceInfo())
+  TL = TSI->getTypeLoc();





Comment at: clang/lib/Sema/SemaType.cpp:6526
+  }
+
+  ASTContext &Ctx = S.Context;

Should you also validate that the type is a pointer type?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99

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


[PATCH] D112532: [Matrix] Replace some err kinds with err_builtin_invalid_arg_type. (NFC)

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In general, I like the direction of this cleanup. Thanks!

In D112532#3087293 , @erichkeane 
wrote:

> I'm fine with this change in general... but did this not manage to break any 
> tests?

Precommit CI says things are broken: 
https://buildkite.com/llvm-project/premerge-checks/builds/62247#63e5ea73-b0b3-4df4-898a-dd05d1f4bf81


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112532

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


[PATCH] D112527: [clangd] Fix a hover crash on templated spaceship operator.

2021-10-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Hover.cpp:271
+  DeclForComment = TSD->getSpecializedTemplate();
 if (const auto *TIP = TSD->getTemplateInstantiationPattern())
+  DeclForComment = TIP;

can we also turn these `if`s into `else if`s (similarly for `if`s at the top 
level) just to make sure we don't change behaviour (i suppose it should be 
fine, as the TIP will always be null in the case of undeclared specializations, 
but better safe than sorry).



Comment at: clang-tools-extra/clangd/Hover.cpp:286
+  // being instantiated from spasceship operater, which itself is a template
+  // instinstantiation the recursrive call is necessary.
+  if (D != DeclForComment)

s/instinstantiation/instantiation (unless you intentionally put a double `inst` 
:P)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112527

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


[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111985

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


[PATCH] D112227: [libomptarget] Build DeviceRTL for amdgpu

2021-10-26 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 382306.
JonChesterfield added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112227

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  openmp/libomptarget/DeviceRTL/CMakeLists.txt
  openmp/libomptarget/DeviceRTL/src/Configuration.cpp
  openmp/libomptarget/DeviceRTL/src/Synchronization.cpp

Index: openmp/libomptarget/DeviceRTL/src/Synchronization.cpp
===
--- openmp/libomptarget/DeviceRTL/src/Synchronization.cpp
+++ openmp/libomptarget/DeviceRTL/src/Synchronization.cpp
@@ -68,8 +68,23 @@
 ///{
 #pragma omp begin declare variant match(device = {arch(amdgcn)})
 
-uint32_t atomicInc(uint32_t *Address, uint32_t Val, int Ordering) {
-  return __builtin_amdgcn_atomic_inc32(Address, Val, Ordering, "");
+uint32_t atomicInc(uint32_t *A, uint32_t V, int Ordering) {
+  // builtin_amdgcn_atomic_inc32 should expand to this switch when
+  // passed a runtime value, but does not do so yet. Workaround here.
+  switch (Ordering) {
+  default:
+__builtin_unreachable();
+  case __ATOMIC_RELAXED:
+return __builtin_amdgcn_atomic_inc32(A, V, __ATOMIC_RELAXED, "");
+  case __ATOMIC_ACQUIRE:
+return __builtin_amdgcn_atomic_inc32(A, V, __ATOMIC_ACQUIRE, "");
+  case __ATOMIC_RELEASE:
+return __builtin_amdgcn_atomic_inc32(A, V, __ATOMIC_RELEASE, "");
+  case __ATOMIC_ACQ_REL:
+return __builtin_amdgcn_atomic_inc32(A, V, __ATOMIC_ACQ_REL, "");
+  case __ATOMIC_SEQ_CST:
+return __builtin_amdgcn_atomic_inc32(A, V, __ATOMIC_SEQ_CST, "");
+  }
 }
 
 uint32_t SHARED(namedBarrierTracker);
@@ -126,17 +141,64 @@
   fence::team(__ATOMIC_RELEASE);
 }
 
+// sema checking of amdgcn_fence is aggressive. Intention is to patch clang
+// so that it is usable within a template environment and so that a runtime
+// value of the memory order is expanded to this switch within clang/llvm.
+void fenceTeam(int Ordering) {
+  switch (Ordering) {
+  default:
+__builtin_unreachable();
+  case __ATOMIC_ACQUIRE:
+return __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "workgroup");
+  case __ATOMIC_RELEASE:
+return __builtin_amdgcn_fence(__ATOMIC_RELEASE, "workgroup");
+  case __ATOMIC_ACQ_REL:
+return __builtin_amdgcn_fence(__ATOMIC_ACQ_REL, "workgroup");
+  case __ATOMIC_SEQ_CST:
+return __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "workgroup");
+  }
+}
+void fenceKernel(int Ordering) {
+  switch (Ordering) {
+  default:
+__builtin_unreachable();
+  case __ATOMIC_ACQUIRE:
+return __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent");
+  case __ATOMIC_RELEASE:
+return __builtin_amdgcn_fence(__ATOMIC_RELEASE, "agent");
+  case __ATOMIC_ACQ_REL:
+return __builtin_amdgcn_fence(__ATOMIC_ACQ_REL, "agent");
+  case __ATOMIC_SEQ_CST:
+return __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "agent");
+  }
+}
+void fenceSystem(int Ordering) {
+  switch (Ordering) {
+  default:
+__builtin_unreachable();
+  case __ATOMIC_ACQUIRE:
+return __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "");
+  case __ATOMIC_RELEASE:
+return __builtin_amdgcn_fence(__ATOMIC_RELEASE, "");
+  case __ATOMIC_ACQ_REL:
+return __builtin_amdgcn_fence(__ATOMIC_ACQ_REL, "");
+  case __ATOMIC_SEQ_CST:
+return __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "");
+  }
+}
+
 void syncWarp(__kmpc_impl_lanemask_t) {
   // AMDGCN doesn't need to sync threads in a warp
 }
 
 void syncThreads() { __builtin_amdgcn_s_barrier(); }
 
-void fenceTeam(int Ordering) { __builtin_amdgcn_fence(Ordering, "workgroup"); }
-
-void fenceKernel(int Ordering) { __builtin_amdgcn_fence(Ordering, "agent"); }
-
-void fenceSystem(int Ordering) { __builtin_amdgcn_fence(Ordering, ""); }
+// TODO: Don't have wavefront lane locks. Possibly can't have them.
+void unsetLock(omp_lock_t *) { __builtin_trap(); }
+int testLock(omp_lock_t *) { __builtin_trap(); }
+void initLock(omp_lock_t *) { __builtin_trap(); }
+void destroyLock(omp_lock_t *) { __builtin_trap(); }
+void setLock(omp_lock_t *) { __builtin_trap(); }
 
 #pragma omp end declare variant
 ///}
@@ -238,7 +300,7 @@
 }
 
 void atomic::store(uint32_t *Addr, uint32_t V, int Ordering) {
-   impl::atomicStore(Addr, V, Ordering);
+  impl::atomicStore(Addr, V, Ordering);
 }
 
 uint32_t atomic::inc(uint32_t *Addr, uint32_t V, int Ordering) {
Index: openmp/libomptarget/DeviceRTL/src/Configuration.cpp
===
--- openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -20,14 +20,14 @@
 
 #pragma omp declare target
 
-extern uint32_t __omp_rtl_debug_kind;
+// extern uint32_t __omp_rtl_debug_kind;
 
 // TOOD: We want to change the name as soon as the old runtime is gone.
 DeviceEnvironmentTy CONSTANT(omptarget_device_environment)
 __attribute__((used));
 
 uint32_t config::getDebugKind() {
-  return __omp_rtl_deb

[PATCH] D107450: [clang-tidy] Fix wrong FixIt in performance-move-const-arg

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D107450#3087103 , @whisperity 
wrote:

> There has been a new release since the patch was proposed so a rebase should 
> be needed.
> @aaron.ballman What do you think, does this warrant a ReleaseNotes entry?

I think a release note for this would be helpful, yes!


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

https://reviews.llvm.org/D107450

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


[PATCH] D112530: [clangd] AddUsing: Fix support for template specializations.

2021-10-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks!




Comment at: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp:284
+// Remove the template arguments from the name.
+NameRange = SourceRange(NameRange.getBegin(),
+T.getLAngleLoc().getLocWithOffset(-1));

nit: `NameRange.setEnd(T.getTemplateNameLoc())`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112530

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


[PATCH] D112459: [AArch64] Enablement of Cortex-X2

2021-10-26 Thread Mubashar Ahmad via Phabricator via cfe-commits
mubashar_ updated this revision to Diff 382309.
mubashar_ marked 2 inline comments as done.
mubashar_ added a comment.

Made adjustments to AArch64.td and AArch64Subtarget.cpp files.


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

https://reviews.llvm.org/D112459

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/Driver/aarch64-cpus.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -1008,6 +1008,17 @@
  AArch64::AEK_DOTPROD | AArch64::AEK_RCPC |
  AArch64::AEK_SSBS,
  "8.2-A"),
+ARMCPUTestParams("cortex-x2", "armv9-a", "neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_FP |
+ AArch64::AEK_SIMD | AArch64::AEK_RAS |
+ AArch64::AEK_LSE | AArch64::AEK_RDM |
+ AArch64::AEK_RCPC | AArch64::AEK_SVE2 |
+ AArch64::AEK_DOTPROD | AArch64::AEK_MTE |
+ AArch64::AEK_PAUTH | AArch64::AEK_I8MM |
+ AArch64::AEK_BF16 | AArch64::AEK_SVE2BITPERM |
+ AArch64::AEK_SSBS | AArch64::AEK_SB |
+ AArch64::AEK_FP16FML,
+ "9-A"),
 ARMCPUTestParams("cyclone", "armv8-a", "crypto-neon-fp-armv8",
  AArch64::AEK_NONE | AArch64::AEK_CRYPTO |
  AArch64::AEK_FP | AArch64::AEK_SIMD,
@@ -1189,7 +1200,7 @@
  AArch64::AEK_LSE | AArch64::AEK_RDM,
  "8.2-A")));
 
-static constexpr unsigned NumAArch64CPUArchs = 49;
+static constexpr unsigned NumAArch64CPUArchs = 50;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -62,6 +62,7 @@
 CortexA78C,
 CortexR82,
 CortexX1,
+CortexX2,
 ExynosM3,
 Falkor,
 Kryo,
Index: llvm/lib/Target/AArch64/AArch64Subtarget.cpp
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -104,6 +104,10 @@
   case CortexX1:
 PrefFunctionLogAlignment = 4;
 break;
+  case CortexX2:
+PrefFunctionLogAlignment = 4;
+VScaleForTuning = 1;
+break;
   case A64FX:
 CacheLineSize = 256;
 PrefFunctionLogAlignment = 3;
Index: llvm/lib/Target/AArch64/AArch64.td
===
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -684,6 +684,12 @@
   FeatureFuseAES,
   FeaturePostRAScheduler]>;
 
+def TuneX2 : SubtargetFeature<"cortex-x2", "ARMProcFamily", "CortexX2",
+  "Cortex-X2 ARM processors", [
+  FeatureFuseAES,
+  FeaturePostRAScheduler,
+  FeatureCmpBccFusion]>;
+
 def TuneA64FX : SubtargetFeature<"a64fx", "ARMProcFamily", "A64FX",
  "Fujitsu A64FX processors", [
  FeaturePostRAScheduler,
@@ -929,6 +935,10 @@
   list X1   = [HasV8_2aOps, FeatureCrypto, FeatureFPARMv8,
  FeatureNEON, FeatureRCPC, FeaturePerfMon,
  FeatureSPE, FeatureFullFP16, FeatureDotProd];
+  list X2   = [HasV9_0aOps, FeatureNEON, FeaturePerfMon,
+ FeatureMatMulInt8, FeatureBF16, FeatureAM,
+ FeatureMTE, FeatureETE, FeatureSVE2BitPerm,
+ FeatureFP16FML];
   list A64FX= [HasV8_2aOps, FeatureFPARMv8, FeatureNEON,
  FeatureSHA2, FeaturePerfMon, FeatureFullFP16,
  FeatureSVE, FeatureComplxNum];
@@ -1030,6 +1040,8 @@
  [TuneR82]>;
 def : ProcessorModel<"cortex-x1", CortexA57Model, ProcessorFeatures.X1,
  [TuneX1]>;
+def : ProcessorModel<"cortex-x2", CortexA57Model, ProcessorFeatures.X2,
+ [TuneX2]>;
 def : ProcessorModel<"neoverse-e1", CortexA53Model,
  ProcessorFeatures.NeoverseE1, [TuneNeoverseE1]>;
 def : Processor

[PATCH] D112459: [AArch64] Enablement of Cortex-X2

2021-10-26 Thread Mubashar Ahmad via Phabricator via cfe-commits
mubashar_ added a comment.

Addressed comments from @dmgreen.


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

https://reviews.llvm.org/D112459

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


[clang] 025988d - Specify Clang vector builtins.

2021-10-26 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2021-10-26T15:34:31+01:00
New Revision: 025988ded6b2a57022dbf9775f35a1a933584bfa

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

LOG: Specify Clang vector builtins.

This patch specifies a set of vector builtins for Clang, as discussed on
cfe-dev:
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068999.html
https://lists.llvm.org/pipermail/cfe-dev/2021-October/069070.html

Reviewed By: scanon

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

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 74f8f3dc3551..38443cee1935 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -506,6 +506,83 @@ See also :ref:`langext-__builtin_shufflevector`, 
:ref:`langext-__builtin_convert
   If it's an extension (OpenCL) vector, it's only available in C and OpenCL C.
   And it selects base on signedness of the condition operands (OpenCL v1.1 
s6.3.9).
 
+Vector Builtins
+---
+
+**Note: The implementation of vector builtins is work-in-progress and 
incomplete.**
+
+In addition to the operators mentioned above, Clang provides a set of builtins
+to perform additional operations on certain scalar and vector types.
+
+Let ``T`` be one of the following types:
+
+* an integer type (as in C2x 6.2.5p19), but excluding enumerated types and 
_Bool
+* the standard floating types float or double
+* a half-precision floating point type, if one is supported on the target
+* a vector type.
+
+For scalar types, consider the operation applied to a vector with a single 
element.
+
+*Elementwise Builtins*
+
+Each builtin returns a vector equivalent to applying the specified operation
+elementwise to the input.
+
+Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = 
±infinity
+
+= 
 
=
+ Name  Operation   
 Supported element types
+= 
 
=
+ T __builtin_elementwise_abs(T x)  return the absolute value of a 
number x; the absolute value of   signed integer and floating point types
+   the most negative integer remains 
the most negative integer
+ T __builtin_elementwise_ceil(T x) return the smallest integral value 
greater than or equal to xfloating point types
+ T __builtin_elementwise_floor(T x)return the largest integral value 
less than or equal to xfloating point types
+ T __builtin_elementwise_roundeven(T x)round x to the nearest integer 
value in floating point format,   floating point types
+   rounding halfway cases to even 
(that is, to the nearest value
+   that is an even integer), 
regardless of the current rounding
+   direction.
+ T__builtin_elementwise_trunc(T x) return the integral value nearest 
to but no larger infloating point types
+   magnitude than x
+ T __builtin_elementwise_max(T x, T y) return x or y, whichever is larger  
 integer and floating point types
+ T __builtin_elementwise_min(T x, T y) return x or y, whichever is smaller 
 integer and floating point types
+= 
 
=
+
+
+*Reduction Builtins*
+
+Each builtin returns a scalar equivalent to applying the specified
+operation(x, y) as recursive even-odd pairwise reduction to all vector
+elements. ``operation(x, y)`` is repeatedly applied to each non-overlapping
+even-odd element pair with indices ``i * 2`` and ``i * 2 + 1`` with
+``i in [0, Number of elements / 2)``. If the numbers of elements is not a
+power of 2, the vector is widened with neutral elements for the reduction
+at the end to the next power of 2.
+
+Example:
+
+.. code-block:: c++
+
+__builtin_reduce_add([e3, e2, e1, e0]) = __builtin_reduced_add([e3 + e2, 
e1 + e0])
+   = (e3 + e2) + (e1 + e0)
+
+
+Let ``VT`` be a vector type and ``ET`` the element type of ``VT``.
+
+=== 
 
=

[PATCH] D111529: Specify Clang vector builtins.

2021-10-26 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG025988ded6b2: Specify Clang vector builtins. (authored by 
fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -506,6 +506,83 @@
   If it's an extension (OpenCL) vector, it's only available in C and OpenCL C.
   And it selects base on signedness of the condition operands (OpenCL v1.1 
s6.3.9).
 
+Vector Builtins
+---
+
+**Note: The implementation of vector builtins is work-in-progress and 
incomplete.**
+
+In addition to the operators mentioned above, Clang provides a set of builtins
+to perform additional operations on certain scalar and vector types.
+
+Let ``T`` be one of the following types:
+
+* an integer type (as in C2x 6.2.5p19), but excluding enumerated types and 
_Bool
+* the standard floating types float or double
+* a half-precision floating point type, if one is supported on the target
+* a vector type.
+
+For scalar types, consider the operation applied to a vector with a single 
element.
+
+*Elementwise Builtins*
+
+Each builtin returns a vector equivalent to applying the specified operation
+elementwise to the input.
+
+Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = 
±infinity
+
+= 
 
=
+ Name  Operation   
 Supported element types
+= 
 
=
+ T __builtin_elementwise_abs(T x)  return the absolute value of a 
number x; the absolute value of   signed integer and floating point types
+   the most negative integer remains 
the most negative integer
+ T __builtin_elementwise_ceil(T x) return the smallest integral value 
greater than or equal to xfloating point types
+ T __builtin_elementwise_floor(T x)return the largest integral value 
less than or equal to xfloating point types
+ T __builtin_elementwise_roundeven(T x)round x to the nearest integer 
value in floating point format,   floating point types
+   rounding halfway cases to even 
(that is, to the nearest value
+   that is an even integer), 
regardless of the current rounding
+   direction.
+ T__builtin_elementwise_trunc(T x) return the integral value nearest 
to but no larger infloating point types
+   magnitude than x
+ T __builtin_elementwise_max(T x, T y) return x or y, whichever is larger  
 integer and floating point types
+ T __builtin_elementwise_min(T x, T y) return x or y, whichever is smaller 
 integer and floating point types
+= 
 
=
+
+
+*Reduction Builtins*
+
+Each builtin returns a scalar equivalent to applying the specified
+operation(x, y) as recursive even-odd pairwise reduction to all vector
+elements. ``operation(x, y)`` is repeatedly applied to each non-overlapping
+even-odd element pair with indices ``i * 2`` and ``i * 2 + 1`` with
+``i in [0, Number of elements / 2)``. If the numbers of elements is not a
+power of 2, the vector is widened with neutral elements for the reduction
+at the end to the next power of 2.
+
+Example:
+
+.. code-block:: c++
+
+__builtin_reduce_add([e3, e2, e1, e0]) = __builtin_reduced_add([e3 + e2, 
e1 + e0])
+   = (e3 + e2) + (e1 + e0)
+
+
+Let ``VT`` be a vector type and ``ET`` the element type of ``VT``.
+
+=== 
 
==
+ NameOperation 
   Supported element types
+=== 
 
==
+ ET __builtin_reduce_max(VT a)   return x or y, whichever is larger; 
If exactly one argument is   integer and floating point types
+ a NaN, return the other argument. If 
both arguments are NaNs,
+ 

[PATCH] D112409: [clang-tidy] Add check 'cert-err33-c'.

2021-10-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 382312.
balazske added a comment.

Improved the documentation.
Small code layout changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112409

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/clang-tidy/checks/bugprone-unused-return-value.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-err33-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst

Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -114,6 +114,7 @@
`cert-dcl50-cpp `_,
`cert-dcl58-cpp `_,
`cert-env33-c `_,
+   `cert-err33-c `_,
`cert-err34-c `_,
`cert-err52-cpp `_,
`cert-err58-cpp `_,
@@ -333,6 +334,7 @@
`cert-dcl03-c `_, `misc-static-assert `_, "Yes"
`cert-dcl16-c `_, `readability-uppercase-literal-suffix `_, "Yes"
`cert-dcl37-c `_, `bugprone-reserved-identifier `_, "Yes"
+   `cert-err33-c `_, `bugprone-unused-return-value `_,
`cert-dcl51-cpp `_, `bugprone-reserved-identifier `_, "Yes"
`cert-dcl54-cpp `_, `misc-new-delete-overloads `_,
`cert-dcl59-cpp `_, `google-build-namespaces `_,
Index: clang-tools-extra/docs/clang-tidy/checks/cert-err33-c.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-err33-c.rst
@@ -0,0 +1,199 @@
+.. title:: clang-tidy - cert-err33-c
+
+cert-err33-c
+
+
+Warns on unused function return values. Many of the standard library functions
+return a value that indicates if the call was successful. Ignoring the returned
+value can cause unexpected behavior if an error has occured. The following
+functions are checked:
+
+* aligned_alloc()
+* asctime_s()
+* at_quick_exit()
+* atexit()
+* bsearch()
+* bsearch_s()
+* btowc()
+* c16rtomb()
+* c32rtomb()
+* calloc()
+* clock()
+* cnd_broadcast()
+* cnd_init()
+* cnd_signal()
+* cnd_timedwait()
+* cnd_wait()
+* ctime_s()
+* fclose()
+* fflush()
+* fgetc()
+* fgetpos()
+* fgets()
+* fgetwc()
+* fopen()
+* fopen_s()
+* fprintf()
+* fprintf_s()
+* fputc()
+* fputs()
+* fputwc()
+* fputws()
+* fread()
+* freopen()
+* freopen_s()
+* fscanf()
+* fscanf_s()
+* fseek()
+* fsetpos()
+* ftell()
+* fwprintf()
+* fwprintf_s()
+* fwrite()
+* fwscanf()
+* fwscanf_s()
+* getc()
+* getchar()
+* getenv()
+* getenv_s()
+* gets_s()
+* getwc()
+* getwchar()
+* gmtime()
+* gmtime_s()
+* localtime()
+* localtime_s()
+* malloc()
+* mbrtoc16()
+* mbrtoc32()
+* mbsrtowcs()
+* mbsrtowcs_s()
+* mbstowcs()
+* mbstowcs_s()
+* memchr()
+* mktime()
+* mtx_init()
+* mtx_lock()
+* mtx_timedlock()
+* mtx_trylock()
+* mtx_unlock()
+* printf_s()
+* putc()
+* putwc()
+* raise()
+* realloc()
+* remove()
+* rename()
+* setlocale()
+* setvbuf()
+* scanf()
+* scanf_s()
+* signal()
+* snprintf()
+* snprintf_s()
+* sprintf()
+* sprintf_s()
+* sscanf()
+* sscanf_s()
+* strchr()
+* strerror_s()
+* strftime()
+* strpbrk()
+* strrchr()
+* strstr()
+* strtod()
+* strtof()
+* strtoimax()
+* strtok()
+* strtok_s()
+* strtol()
+* strtold()
+* strtoll()
+* strtoumax()
+* strtoul()
+* strtoull()
+* strxfrm()
+* swprintf()
+* swprintf_s()
+* swscanf()
+* swscanf_s()
+* thrd_create()
+* thrd_detach()
+* thrd_join()
+* thrd_sleep()
+* time()
+* timespec_get()
+* tmpfile()
+* tmpfile_s()
+* tmpnam()
+* tmpnam_s()
+* tss_create()
+* tss_get()
+* tss_set()
+* ungetc()
+* ungetwc()
+* vfprintf()
+* vfprintf_s()
+* vfscanf()
+* vfscanf_s()
+* vfwprintf()
+* vfwprintf_s()
+* vfwscanf()
+* vfwscanf_s()
+* vprintf_s()
+* vscanf()
+* vscanf_s()
+* vsnprintf()
+* vsnprintf_s()
+* vsprintf()
+* vsprintf_s()
+* vsscanf()
+* vsscanf_s()
+* vswprintf()
+* vswprintf_s()
+* vswscanf()
+* vswscanf_s()
+* vwprintf_s()
+* vwscanf()
+* vwscanf_s()
+* wcrtomb()
+* wcschr()
+* wcsftime()
+* wcspbrk()
+* wcsrchr()
+* wcsrtombs()
+* wcsrtombs_s()
+* wcsstr()
+* wcstod()
+* wcstof()
+* wcstoimax()
+* wcstok()
+* wcstok_s()
+* wcstol()
+* wcstold()
+* wcstoll()
+* wcstombs()
+* wcstombs_s()
+* wcstoumax()
+* wcstoul()
+* wcstoull()
+* wcsxfrm()
+* wctob()
+* wctrans()
+* wctype()
+* wmemchr()
+* wprintf_s()
+* wscanf()
+* wscanf_s()
+
+This check is an alias of check `bugprone-unused-return-value `_
+with a fixed set of functions.
+
+The check corresponds to a part of CERT C Coding Standard rule `ERR33-C.
+Detect and handle standard library errors
+`_.
+The list of checked functions is taken from the rule, with following exception:
+
+* The check can not differentiate if a function is called with ``NULL``
+  argument. Therefore the following functions are not checked:
+  ``mblen``, ``mbrlen``, ``mbrtowc``, ``mbtowc``, ``wctomb``, ``wctomb_s``
Index: clang-tools-extra/doc

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1643-1654
+  const VarRegion *VR = dyn_cast(R->getSuperRegion());
+  SmallVector SValOffsets;
+  SValOffsets.push_back(R->getIndex());
+  if (const ElementRegion *ER = dyn_cast(R->getSuperRegion())) {
+const ElementRegion *LastER = nullptr;
+do {
+  SValOffsets.push_back(ER->getIndex());

steakhal wrote:
> I dislike this part of code. It has side effects all over the place.
> Please use immediately called lambdas to describe your intentions in a more 
> //pure// manner.
> 
> Besides that, when I see `ElementRegions`, I'm always scared. They sometimes 
> represent reinterpret casts.
> Since you have dealt with so many casts and region store stuff in the past, 
> I'm assuming you have thought about this here.
> Although, I'm still scared slightly, and I'd like to have evidence of this 
> thought process. Likely some assertions or at least some comments? Could you 
> @ASDenysPetrov elaborate on this?
> Please use immediately called lambdas.
I'll do.
> They sometimes represent reinterpret casts. ...  I'm assuming you have 
> thought about this here.
Yes. This is my another revision in the stack. You are welcome: D110927



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1656
+
+  // TODO: Add a test case for this check.
+  if (!VR)

martong wrote:
> Please address this TODO.
I found the tests:
  - Analysis/MemRegion.cpp
  - Analysis/ctor.mm
  - Analysis/mpichecker.cpp
  - Analysis/string.c
They cover this check.



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

https://reviews.llvm.org/D111654

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


[PATCH] D111434: [PowerPC] PPC backend optimization on conditional trap intrustions

2021-10-26 Thread Amy Kwan via Phabricator via cfe-commits
amyk added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:1011
+  case PPC::TDI:
+  case PPC::TWI: {
+MachineInstr *LiMIA = getVRegDefOrNull(&MI.getOperand(1), MRI);

nemanjai wrote:
> Seems that we should be able to handle all 4 in the same block:
> - Check that both operands are `LI[8]`/`LI[S][8]+ORI[8]` or an immediate
> - Set the variables for the three constants
> - Determine if this is an unconditional trap or never trap
> - Emit the correct instruction
+1



Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:1013
+MachineInstr *LiMIA = getVRegDefOrNull(&MI.getOperand(1), MRI);
+// will not optimize if no value set
+if (!(LiMIA && (LiMIA->getOpcode() == PPC::LI ||

nit: Capitalize and add a period (and for all other comments).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

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


[PATCH] D112285: [PowerPC] PPC backend optimization to lower int_ppc_tdw/int_ppc_tw intrinsics to TDI/TWI machine instructions

2021-10-26 Thread Amy Kwan via Phabricator via cfe-commits
amyk added inline comments.



Comment at: 
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll:131
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tdi 3, 3, 32767
+; CHECK-NEXT:blr

nemanjai wrote:
> Can we add `-ppc-asm-full-reg-names` to the RUN lines so it is more clear 
> which operand is a register and which is an immediate. This works on AIX now 
> since https://reviews.llvm.org/D94282 landed.
Maybe it would be good to pre-commit the change with `-ppc-asm-full-reg-names` 
added to the run lines so then this patch can only contain the pertinent 
`td`/`tdi`/`tw`/`twi` changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112285

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


[PATCH] D112409: [clang-tidy] Add check 'cert-err33-c'.

2021-10-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 8 inline comments as done.
balazske added a comment.

I was not sure how the aliasing is to be handled if the check is not exactly 
the same as the original. (This was a topic on the mailing list.) I like it 
more if only those checks are aliases that are exactly the same. But for now it 
will remain as it was before, otherwise this has to be changed for all aliases.




Comment at: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp:52
+// FIXME: The check can be improved to handle such cases.
+const llvm::StringRef CertErr33CCheckedFunctions = "::aligned_alloc;"
+   "::asctime_s;"

aaron.ballman wrote:
> Was this list generated automatically or manually? (Just wondering how hard 
> to match it to the CERT rule -- spot checking hasn't found issues so far.)
I am not sure, I have the list for longer time, but it is almost sure that it 
was generated by using text editor macros. The number of functions is correct 
(with the excluded ones).



Comment at: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp:328
 Opts["cert-str34-c.DiagnoseSignedUnsignedCharComparisons"] = "false";
+Opts["cert-err33-c.CheckedFunctions"] = CertErr33CCheckedFunctions;
 return Options;

carlosgalvezp wrote:
> Same here
This is correct: 'str34' before 'err33'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112409

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


[PATCH] D112409: [clang-tidy] Add check 'cert-err33-c'.

2021-10-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/cert-err33-c.rst:1
+.. title:: clang-tidy - cert-err33-c
+

carlosgalvezp wrote:
> I believe we usually mention that this is an alias to another check, and then 
> redirect the user to that original check.
Automatic redirect does not work here because there is something to read in the 
page. This  check has its own description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112409

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


[PATCH] D112409: [clang-tidy] Add check 'cert-err33-c'.

2021-10-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 382323.
balazske added a comment.

Added to release notes, added new links to documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112409

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-unused-return-value.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-err33-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst

Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -114,6 +114,7 @@
`cert-dcl50-cpp `_,
`cert-dcl58-cpp `_,
`cert-env33-c `_,
+   `cert-err33-c `_,
`cert-err34-c `_,
`cert-err52-cpp `_,
`cert-err58-cpp `_,
@@ -333,6 +334,7 @@
`cert-dcl03-c `_, `misc-static-assert `_, "Yes"
`cert-dcl16-c `_, `readability-uppercase-literal-suffix `_, "Yes"
`cert-dcl37-c `_, `bugprone-reserved-identifier `_, "Yes"
+   `cert-err33-c `_, `bugprone-unused-return-value `_,
`cert-dcl51-cpp `_, `bugprone-reserved-identifier `_, "Yes"
`cert-dcl54-cpp `_, `misc-new-delete-overloads `_,
`cert-dcl59-cpp `_, `google-build-namespaces `_,
Index: clang-tools-extra/docs/clang-tidy/checks/cert-err33-c.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-err33-c.rst
@@ -0,0 +1,199 @@
+.. title:: clang-tidy - cert-err33-c
+
+cert-err33-c
+
+
+Warns on unused function return values. Many of the standard library functions
+return a value that indicates if the call was successful. Ignoring the returned
+value can cause unexpected behavior if an error has occured. The following
+functions are checked:
+
+* aligned_alloc()
+* asctime_s()
+* at_quick_exit()
+* atexit()
+* bsearch()
+* bsearch_s()
+* btowc()
+* c16rtomb()
+* c32rtomb()
+* calloc()
+* clock()
+* cnd_broadcast()
+* cnd_init()
+* cnd_signal()
+* cnd_timedwait()
+* cnd_wait()
+* ctime_s()
+* fclose()
+* fflush()
+* fgetc()
+* fgetpos()
+* fgets()
+* fgetwc()
+* fopen()
+* fopen_s()
+* fprintf()
+* fprintf_s()
+* fputc()
+* fputs()
+* fputwc()
+* fputws()
+* fread()
+* freopen()
+* freopen_s()
+* fscanf()
+* fscanf_s()
+* fseek()
+* fsetpos()
+* ftell()
+* fwprintf()
+* fwprintf_s()
+* fwrite()
+* fwscanf()
+* fwscanf_s()
+* getc()
+* getchar()
+* getenv()
+* getenv_s()
+* gets_s()
+* getwc()
+* getwchar()
+* gmtime()
+* gmtime_s()
+* localtime()
+* localtime_s()
+* malloc()
+* mbrtoc16()
+* mbrtoc32()
+* mbsrtowcs()
+* mbsrtowcs_s()
+* mbstowcs()
+* mbstowcs_s()
+* memchr()
+* mktime()
+* mtx_init()
+* mtx_lock()
+* mtx_timedlock()
+* mtx_trylock()
+* mtx_unlock()
+* printf_s()
+* putc()
+* putwc()
+* raise()
+* realloc()
+* remove()
+* rename()
+* setlocale()
+* setvbuf()
+* scanf()
+* scanf_s()
+* signal()
+* snprintf()
+* snprintf_s()
+* sprintf()
+* sprintf_s()
+* sscanf()
+* sscanf_s()
+* strchr()
+* strerror_s()
+* strftime()
+* strpbrk()
+* strrchr()
+* strstr()
+* strtod()
+* strtof()
+* strtoimax()
+* strtok()
+* strtok_s()
+* strtol()
+* strtold()
+* strtoll()
+* strtoumax()
+* strtoul()
+* strtoull()
+* strxfrm()
+* swprintf()
+* swprintf_s()
+* swscanf()
+* swscanf_s()
+* thrd_create()
+* thrd_detach()
+* thrd_join()
+* thrd_sleep()
+* time()
+* timespec_get()
+* tmpfile()
+* tmpfile_s()
+* tmpnam()
+* tmpnam_s()
+* tss_create()
+* tss_get()
+* tss_set()
+* ungetc()
+* ungetwc()
+* vfprintf()
+* vfprintf_s()
+* vfscanf()
+* vfscanf_s()
+* vfwprintf()
+* vfwprintf_s()
+* vfwscanf()
+* vfwscanf_s()
+* vprintf_s()
+* vscanf()
+* vscanf_s()
+* vsnprintf()
+* vsnprintf_s()
+* vsprintf()
+* vsprintf_s()
+* vsscanf()
+* vsscanf_s()
+* vswprintf()
+* vswprintf_s()
+* vswscanf()
+* vswscanf_s()
+* vwprintf_s()
+* vwscanf()
+* vwscanf_s()
+* wcrtomb()
+* wcschr()
+* wcsftime()
+* wcspbrk()
+* wcsrchr()
+* wcsrtombs()
+* wcsrtombs_s()
+* wcsstr()
+* wcstod()
+* wcstof()
+* wcstoimax()
+* wcstok()
+* wcstok_s()
+* wcstol()
+* wcstold()
+* wcstoll()
+* wcstombs()
+* wcstombs_s()
+* wcstoumax()
+* wcstoul()
+* wcstoull()
+* wcsxfrm()
+* wctob()
+* wctrans()
+* wctype()
+* wmemchr()
+* wprintf_s()
+* wscanf()
+* wscanf_s()
+
+This check is an alias of check `bugprone-unused-return-value `_
+with a fixed set of functions.
+
+The check corresponds to a part of CERT C Coding Standard rule `ERR33-C.
+Detect and handle standard library errors
+`_.
+The list of checked functions is taken from the rule, with following exception:
+
+* The check can not differentiate if a function is called with ``NULL``
+  argument. Therefore the following functions are not checked:
+  ``mblen``, ``mbrlen``, ``mbrtowc``, ``mbtowc``, ``wctomb

  1   2   3   >