[clang] 09d1f6e - [clang] Fix copy constructor of CompilerInvocation

2021-04-14 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-04-14T09:13:35+02:00
New Revision: 09d1f6e6b74c9330d80c0346a271a43efbe0384d

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

LOG: [clang] Fix copy constructor of CompilerInvocation

The `CompilerInvocationBase` class factors out members of `CompilerInvocation` 
that need special handling (initialization or copy constructor), so that 
`CompilerInvocation` can be implemented as a simple value object.

Currently, the `AnalyzerOpts` member of `CompilerInvocation` violates that 
setup. This patch extracts the member to `CompilerInvocationBase` and handles 
it in the copy constructor the same way other it handles other members.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index 05b7769f20ef3..132a43a7def2a 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -78,6 +78,9 @@ class CompilerInvocationBase {
   /// Options controlling the preprocessor (aside from \#include handling).
   std::shared_ptr PreprocessorOpts;
 
+  /// Options controlling the static analyzer.
+  AnalyzerOptionsRef AnalyzerOpts;
+
   CompilerInvocationBase();
   CompilerInvocationBase(const CompilerInvocationBase &X);
   CompilerInvocationBase &operator=(const CompilerInvocationBase &) = delete;
@@ -110,6 +113,8 @@ class CompilerInvocationBase {
   const PreprocessorOptions &getPreprocessorOpts() const {
 return *PreprocessorOpts;
   }
+
+  AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; }
 };
 
 /// Helper class for holding the data necessary to invoke the compiler.
@@ -118,9 +123,6 @@ class CompilerInvocationBase {
 /// compiler, including data such as the include paths, the code generation
 /// options, the warning flags, and so on.
 class CompilerInvocation : public CompilerInvocationBase {
-  /// Options controlling the static analyzer.
-  AnalyzerOptionsRef AnalyzerOpts;
-
   MigratorOptions MigratorOpts;
 
   /// Options controlling IRgen and the backend.
@@ -139,8 +141,6 @@ class CompilerInvocation : public CompilerInvocationBase {
   PreprocessorOutputOptions PreprocessorOutputOpts;
 
 public:
-  CompilerInvocation() : AnalyzerOpts(new AnalyzerOptions()) {}
-
   /// @name Utility Methods
   /// @{
 
@@ -203,8 +203,6 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// @name Option Subgroups
   /// @{
 
-  AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; }
-
   MigratorOptions &getMigratorOpts() { return MigratorOpts; }
   const MigratorOptions &getMigratorOpts() const { return MigratorOpts; }
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index b18bc0b284ee5..b71143fdd0bb5 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -113,14 +113,16 @@ CompilerInvocationBase::CompilerInvocationBase()
 : LangOpts(new LangOptions()), TargetOpts(new TargetOptions()),
   DiagnosticOpts(new DiagnosticOptions()),
   HeaderSearchOpts(new HeaderSearchOptions()),
-  PreprocessorOpts(new PreprocessorOptions()) {}
+  PreprocessorOpts(new PreprocessorOptions()),
+  AnalyzerOpts(new AnalyzerOptions()) {}
 
 CompilerInvocationBase::CompilerInvocationBase(const CompilerInvocationBase &X)
 : LangOpts(new LangOptions(*X.getLangOpts())),
   TargetOpts(new TargetOptions(X.getTargetOpts())),
   DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
   HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
-  PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())) {}
+  PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
+  AnalyzerOpts(new AnalyzerOptions(*X.getAnalyzerOpts())) {}
 
 CompilerInvocationBase::~CompilerInvocationBase() = default;
 

diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 066d02b02fa9d..5062a2e6cb8fe 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -97,6 +97,18 @@ TEST(ContainsN, Two) {
   ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
 }
 
+// Copy constructor performs a deep copy of reference-counted pointers.
+
+TEST(CompilerInvocationTest, DeepCopyConstructor) {
+  CompilerInvocation A;
+  A.getAnalyzerOpts()->Config["Key"] = "Old";
+
+  CompilerInvocation B(A);

[PATCH] D99568: [clang] Fix copy constructor of CompilerInvocation

2021-04-14 Thread Jan Svoboda 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 rG09d1f6e6b74c: [clang] Fix copy constructor of 
CompilerInvocation (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99568

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -97,6 +97,18 @@
   ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
 }
 
+// Copy constructor performs a deep copy of reference-counted pointers.
+
+TEST(CompilerInvocationTest, DeepCopyConstructor) {
+  CompilerInvocation A;
+  A.getAnalyzerOpts()->Config["Key"] = "Old";
+
+  CompilerInvocation B(A);
+  B.getAnalyzerOpts()->Config["Key"] = "New";
+
+  ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypath to false.
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -113,14 +113,16 @@
 : LangOpts(new LangOptions()), TargetOpts(new TargetOptions()),
   DiagnosticOpts(new DiagnosticOptions()),
   HeaderSearchOpts(new HeaderSearchOptions()),
-  PreprocessorOpts(new PreprocessorOptions()) {}
+  PreprocessorOpts(new PreprocessorOptions()),
+  AnalyzerOpts(new AnalyzerOptions()) {}
 
 CompilerInvocationBase::CompilerInvocationBase(const CompilerInvocationBase &X)
 : LangOpts(new LangOptions(*X.getLangOpts())),
   TargetOpts(new TargetOptions(X.getTargetOpts())),
   DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
   HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
-  PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())) {}
+  PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
+  AnalyzerOpts(new AnalyzerOptions(*X.getAnalyzerOpts())) {}
 
 CompilerInvocationBase::~CompilerInvocationBase() = default;
 
Index: clang/include/clang/Frontend/CompilerInvocation.h
===
--- clang/include/clang/Frontend/CompilerInvocation.h
+++ clang/include/clang/Frontend/CompilerInvocation.h
@@ -78,6 +78,9 @@
   /// Options controlling the preprocessor (aside from \#include handling).
   std::shared_ptr PreprocessorOpts;
 
+  /// Options controlling the static analyzer.
+  AnalyzerOptionsRef AnalyzerOpts;
+
   CompilerInvocationBase();
   CompilerInvocationBase(const CompilerInvocationBase &X);
   CompilerInvocationBase &operator=(const CompilerInvocationBase &) = delete;
@@ -110,6 +113,8 @@
   const PreprocessorOptions &getPreprocessorOpts() const {
 return *PreprocessorOpts;
   }
+
+  AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; }
 };
 
 /// Helper class for holding the data necessary to invoke the compiler.
@@ -118,9 +123,6 @@
 /// compiler, including data such as the include paths, the code generation
 /// options, the warning flags, and so on.
 class CompilerInvocation : public CompilerInvocationBase {
-  /// Options controlling the static analyzer.
-  AnalyzerOptionsRef AnalyzerOpts;
-
   MigratorOptions MigratorOpts;
 
   /// Options controlling IRgen and the backend.
@@ -139,8 +141,6 @@
   PreprocessorOutputOptions PreprocessorOutputOpts;
 
 public:
-  CompilerInvocation() : AnalyzerOpts(new AnalyzerOptions()) {}
-
   /// @name Utility Methods
   /// @{
 
@@ -203,8 +203,6 @@
   /// @name Option Subgroups
   /// @{
 
-  AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; }
-
   MigratorOptions &getMigratorOpts() { return MigratorOpts; }
   const MigratorOptions &getMigratorOpts() const { return MigratorOpts; }
 


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -97,6 +97,18 @@
   ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
 }
 
+// Copy constructor performs a deep copy of reference-counted pointers.
+
+TEST(CompilerInvocationTest, DeepCopyConstructor) {
+  CompilerInvocation A;
+  A.getAnalyzerOpts()->Config["Key"] = "Old";
+
+  CompilerInvocation B(A);
+  B.getAnalyzerOpts()->Config["Key"] = "New";
+
+  ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypat

[PATCH] D100450: [libTooling] Add smart pointer support to the `access` Stencil

2021-04-14 Thread Shu-Chun Weng via Phabricator via cfe-commits
scw created this revision.
scw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This extends smart pointer support beyond the existing `maybeDeref` and
`maybeAddressOf`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100450

Files:
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp


Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -392,6 +392,37 @@
   testExpr(Id, Snippet, access(Id, "field"), "x->field");
 }
 
+TEST_F(StencilTest, AccessOpSmartPointer) {
+  StringRef Snippet = R"cc(
+Smart x;
+x;
+  )cc";
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "x->field");
+}
+
+TEST_F(StencilTest, AccessOpSmartPointerDereference) {
+  StringRef Snippet = R"cc(
+Smart x;
+*x;
+  )cc";
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "(*x).field");
+}
+
+TEST_F(StencilTest, AccessOpSmartPointerMemberCall) {
+  StringRef Snippet = R"cc(
+Smart x;
+x->Field;
+  )cc";
+  StringRef Id = "id";
+  auto StmtMatch =
+  matchStmt(Snippet, memberExpr(hasObjectExpression(expr().bind(Id;
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT_EXPECTED(access(Id, "field")->eval(StmtMatch->Result),
+   HasValue("x->field"));
+}
+
 TEST_F(StencilTest, AccessOpExplicitThis) {
   using clang::ast_matchers::hasObjectExpression;
   using clang::ast_matchers::memberExpr;
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -323,10 +323,23 @@
 return llvm::make_error(errc::invalid_argument,
  "Id not bound: " + Data.BaseId);
   if (!E->isImplicitCXXThis()) {
-if (llvm::Optional S =
-E->getType()->isAnyPointerType()
-? tooling::buildArrow(*E, *Match.Context)
-: tooling::buildDot(*E, *Match.Context))
+llvm::Optional S;
+if (E->getType()->isAnyPointerType() ||
+isSmartPointerType(E->getType(), *Match.Context)) {
+  // Strip off any operator->. This can only occur inside an actual arrow
+  // member access, so we treat it as equivalent to an actual object
+  // expression.
+  if (const auto *OpCall = dyn_cast(E)) {
+if (OpCall->getOperator() == clang::OO_Arrow &&
+OpCall->getNumArgs() == 1) {
+  E = OpCall->getArg(0);
+}
+  }
+  S = tooling::buildArrow(*E, *Match.Context);
+} else {
+  S = tooling::buildDot(*E, *Match.Context);
+}
+if (S.hasValue())
   *Result += *S;
 else
   return llvm::make_error(


Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -392,6 +392,37 @@
   testExpr(Id, Snippet, access(Id, "field"), "x->field");
 }
 
+TEST_F(StencilTest, AccessOpSmartPointer) {
+  StringRef Snippet = R"cc(
+Smart x;
+x;
+  )cc";
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "x->field");
+}
+
+TEST_F(StencilTest, AccessOpSmartPointerDereference) {
+  StringRef Snippet = R"cc(
+Smart x;
+*x;
+  )cc";
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "(*x).field");
+}
+
+TEST_F(StencilTest, AccessOpSmartPointerMemberCall) {
+  StringRef Snippet = R"cc(
+Smart x;
+x->Field;
+  )cc";
+  StringRef Id = "id";
+  auto StmtMatch =
+  matchStmt(Snippet, memberExpr(hasObjectExpression(expr().bind(Id;
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT_EXPECTED(access(Id, "field")->eval(StmtMatch->Result),
+   HasValue("x->field"));
+}
+
 TEST_F(StencilTest, AccessOpExplicitThis) {
   using clang::ast_matchers::hasObjectExpression;
   using clang::ast_matchers::memberExpr;
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -323,10 +323,23 @@
 return llvm::make_error(errc::invalid_argument,
  "Id not bound: " + Data.BaseId);
   if (!E->isImplicitCXXThis()) {
-if (llvm::Optional S =
-E->getType()->isAnyPointerType()
-? tooling::buildArrow(*E, *Match.Context)
-: tooling::buildDot(*E, *Match.Context))
+llvm::Optional S;
+if (E->getType()->isAnyPointerType() ||
+isSmartPointerType(E->getType(), *Match.Context)) {
+  // Strip off any operator->. This can only occur inside an actual arrow
+  // member access, so we treat it as equivalent to an actual object

[PATCH] D93185: [docs] Use make_unique in FrontendAction example

2021-04-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added subscribers: MaskRay, dblaikie.
dblaikie added a comment.

@thakis - just FYI, Phab doesn't send mail to the mailing list when a patch is 
approved without any text. Please include some text when approving patches to 
make sure there's a record on the mailing list. (@maskray has a browser script 
or the like to automate this - I forget if it's posted somewhere to link to... 
maybe in the llvm phab docs)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93185

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


[clang-tools-extra] 530456c - [clang-tidy] Add new check 'bugprone-unhandled-exception-at-new'.

2021-04-14 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-04-14T09:33:11+02:00
New Revision: 530456caf9088b8eb237c0ab75086722ce0f2950

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

LOG: [clang-tidy] Add new check 'bugprone-unhandled-exception-at-new'.

Reviewed By: aaron.ballman

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

Added: 
clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-exception-at-new.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 9cdadf7bf92ba..595a30e8d8ce3 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -61,6 +61,7 @@
 #include "TooSmallLoopVariableCheck.h"
 #include "UndefinedMemoryManipulationCheck.h"
 #include "UndelegatedConstructorCheck.h"
+#include "UnhandledExceptionAtNewCheck.h"
 #include "UnhandledSelfAssignmentCheck.h"
 #include "UnusedRaiiCheck.h"
 #include "UnusedReturnValueCheck.h"
@@ -178,6 +179,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-undelegated-constructor");
 CheckFactories.registerCheck(
 "bugprone-unhandled-self-assignment");
+CheckFactories.registerCheck(
+"bugprone-unhandled-exception-at-new");
 CheckFactories.registerCheck(
 "bugprone-unused-raii");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index b16dbf576c374..022e5c5842ee2 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -56,6 +56,7 @@ add_clang_library(clangTidyBugproneModule
   TooSmallLoopVariableCheck.cpp
   UndefinedMemoryManipulationCheck.cpp
   UndelegatedConstructorCheck.cpp
+  UnhandledExceptionAtNewCheck.cpp
   UnhandledSelfAssignmentCheck.cpp
   UnusedRaiiCheck.cpp
   UnusedReturnValueCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
new file mode 100644
index 0..c558b3148c9d5
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
@@ -0,0 +1,78 @@
+//===--- UnhandledExceptionAtNewCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UnhandledExceptionAtNewCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+AST_MATCHER_P(CXXTryStmt, hasHandlerFor,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  for (unsigned NH = Node.getNumHandlers(), I = 0; I < NH; ++I) {
+const CXXCatchStmt *CatchS = Node.getHandler(I);
+// Check for generic catch handler (match anything).
+if (CatchS->getCaughtType().isNull())
+  return true;
+ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
+if (InnerMatcher.matches(CatchS->getCaughtType(), Finder, &Result)) {
+  *Builder = std::move(Result);
+  return true;
+}
+  }
+  return false;
+}
+
+AST_MATCHER(CXXNewExpr, mayThrow) {
+  FunctionDecl *OperatorNew = Node.getOperatorNew();
+  if (!OperatorNew)
+return false;
+  return !OperatorNew->getType()->castAs()->isNothrow();
+}
+
+UnhandledExceptionAtNewCheck::UnhandledExceptionAtNewCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {}
+
+void UnhandledExceptionAtNewCheck::registerMatchers(MatchFinder *Finder) {
+  auto BadAllocType =
+  recordType(hasDeclaration(cxxRecordDecl(hasName("::std::bad_alloc";
+  auto ExceptionType =
+  recordType(hasDeclaration(cxxRecordDecl(hasName("::std::exception";
+  auto BadAllocReferenceType = referenceType(pointee(BadAllocType));
+  auto ExceptionReferenceType = referenceType(pointee(ExceptionType));
+
+  auto CatchBadAlloc

[PATCH] D97196: [clang-tidy] Add new check 'bugprone-unhandled-exception-at-new'.

2021-04-14 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG530456caf908: [clang-tidy] Add new check 
'bugprone-unhandled-exception-at-new'. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97196

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-exception-at-new.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp
@@ -0,0 +1,208 @@
+// RUN: %check_clang_tidy -std=c++14 %s bugprone-unhandled-exception-at-new %t
+
+namespace std {
+typedef __typeof__(sizeof(0)) size_t;
+enum class align_val_t : std::size_t {};
+class exception {};
+class bad_alloc : public exception {};
+class bad_array_new_length : public bad_alloc {};
+struct nothrow_t {};
+extern const nothrow_t nothrow;
+} // namespace std
+
+void *operator new(std::size_t, const std::nothrow_t &) noexcept;
+void *operator new(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept;
+void *operator new(std::size_t, void *) noexcept;
+
+class A {};
+typedef std::bad_alloc badalloc1;
+using badalloc2 = std::bad_alloc;
+using badalloc3 = std::bad_alloc &;
+
+void *operator new(std::size_t, int, int);
+void *operator new(std::size_t, int, int, int) noexcept;
+
+struct ClassSpecificNew {
+  void *operator new(std::size_t);
+  void *operator new(std::size_t, std::align_val_t);
+  void *operator new(std::size_t, int, int) noexcept;
+  void *operator new(std::size_t, int, int, int);
+};
+
+void f1() noexcept {
+  int *I1 = new int;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: missing exception handler for allocation failure at 'new'
+  try {
+int *I2 = new int;
+try {
+  int *I3 = new int;
+} catch (A) {
+}
+  } catch (std::bad_alloc) {
+  }
+
+  try {
+int *I = new int;
+  } catch (std::bad_alloc &) {
+  }
+
+  try {
+int *I = new int;
+  } catch (const std::bad_alloc &) {
+  }
+
+  try {
+int *I = new int;
+  } catch (badalloc1) {
+  }
+
+  try {
+int *I = new int;
+  } catch (badalloc1 &) {
+  }
+
+  try {
+int *I = new int;
+  } catch (const badalloc1 &) {
+  }
+
+  try {
+int *I = new int;
+  } catch (badalloc2) {
+  }
+
+  try {
+int *I = new int;
+  } catch (badalloc3) {
+  }
+
+  try {
+int *I = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: missing exception handler for allocation failure at 'new'
+  } catch (std::bad_alloc *) {
+  }
+
+  try {
+int *I = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: missing exception handler for allocation failure at 'new'
+  } catch (A) {
+  }
+}
+
+void f2() noexcept {
+  try {
+int *I = new int;
+  } catch (A) {
+  } catch (std::bad_alloc) {
+  }
+
+  try {
+int *I = new int;
+  } catch (...) {
+  }
+
+  try {
+int *I = new int;
+  } catch (const std::exception &) {
+  }
+
+  try {
+int *I = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: missing exception handler for allocation failure at 'new'
+  } catch (const std::bad_array_new_length &) {
+  }
+}
+
+void f_new_nothrow() noexcept {
+  int *I1 = new (std::nothrow) int;
+  int *I2 = new (static_cast(1), std::nothrow) int;
+}
+
+void f_new_placement() noexcept {
+  char buf[100];
+  int *I = new (buf) int;
+}
+
+void f_new_user_defined() noexcept {
+  int *I1 = new (1, 2) int;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: missing exception handler for allocation failure at 'new'
+  int *I2 = new (1, 2, 3) int;
+}
+
+void f_class_specific() noexcept {
+  ClassSpecificNew *N1 = new ClassSpecificNew;
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: missing exception handler for allocation failure at 'new'
+  ClassSpecificNew *N2 = new (static_cast(1)) ClassSpecificNew;
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: missing exception handler for allocation failure at 'new'
+  ClassSpecificNew *N3 = new (1, 2) ClassSpecificNew;
+  ClassSpecificNew *N4 = new (1, 2, 3) ClassSpecificNew;
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: missing exception handler for allocation failure at 'new'
+}
+
+void f_est_none() {
+  int *I = new int;
+}
+
+void f_est_noexcept_false() noexcept(false) {
+  int *I = new int;
+}
+
+void f_est_noexcept_true() noexcept(true) {
+  int *I = new int;
+  // CHECK-MESSAGES: :

[PATCH] D100378: [AST] Use IntrusiveRefCntPtr for Introspection LocationCall.

2021-04-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/Tooling/NodeIntrospection.cpp:60
+  if (LHS.first == RHS.first)
+return LHS.second->name() < RHS.second->name();
+  return LHS.first < RHS.first;

njames93 wrote:
> This is a slight change in behaviour, The old implementation used the 
> operator< on a `std::shared_ptr`.
> That in turns boils down to a comparison on the raw pointer, which is less 
> than ideal.
Why is that less than ideal? Does the ordering need to be stable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100378

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


[PATCH] D97196: [clang-tidy] Add new check 'bugprone-unhandled-exception-at-new'.

2021-04-14 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

This appears to be failing on the PS4 linux bot likely due to the PS4 target 
has exceptions disabled by default. Can you take a look?

https://lab.llvm.org/buildbot/#/builders/139/builds/2441


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97196

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


[PATCH] D100378: [AST] Use IntrusiveRefCntPtr for Introspection LocationCall.

2021-04-14 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang/lib/Tooling/NodeIntrospection.cpp:60
+  if (LHS.first == RHS.first)
+return LHS.second->name() < RHS.second->name();
+  return LHS.first < RHS.first;

dblaikie wrote:
> njames93 wrote:
> > This is a slight change in behaviour, The old implementation used the 
> > operator< on a `std::shared_ptr`.
> > That in turns boils down to a comparison on the raw pointer, which is less 
> > than ideal.
> Why is that less than ideal? Does the ordering need to be stable?
It's not strictly necessary that the ordering is stable. but when printing the 
contents of the map it would be nice if there was some obvious ordering. This 
also (partially) mimics the behaviour of the comparison for 
`std::pair`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100378

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


[PATCH] D93978: [clangd] Use dirty filesystem when performing cross file tweaks

2021-04-14 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.
Herald added a project: clang-tools-extra.

Sorry, I thought this had already gone in!

LG, sorry for the back and forth.




Comment at: clang-tools-extra/clangd/ClangdServer.cpp:575
   return CB(InpAST.takeError());
-auto Selections = tweakSelection(Sel, *InpAST);
+// FIXME: Should we use the dirty fs here?
+auto FS = TFS.view(llvm::None);

njames93 wrote:
> Regarding this, Is it wise to set the contract so that Tweak::prepare isn't 
> allowed to do IO so we should just pass a nullptr here, inline with how 
> prepareRename works.
Yes, I think so.



Comment at: clang-tools-extra/clangd/refactor/Tweak.cpp:54
+  SelectionEnd(RangeEnd), ASTSelection(std::move(ASTSelection)),
+  FS(FS ? FS
+: &AST.getSourceManager().getFileManager().getVirtualFileSystem()) 
{

I'm no longer convinced this fallback is a good idea.
We want prepare() to do no IO, ideally we'd assert if we do. But by falling 
back to the AST FS, we'll mask that problem.

There are only two callsites that need this fallback (TweakTesting & Check) - I 
think we should just inline what we mean there.



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:67
+   const Tweak::Selection &Sel,
+   llvm::vfs::FileSystem *FS) {
+  if (auto Source = getCorrespondingHeaderOrSource(FileName, FS))

why take this as an explicit parameter rather than just accessing (and 
asserting) Sel.FS?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93978

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


[PATCH] D100378: [AST] Use IntrusiveRefCntPtr for Introspection LocationCall.

2021-04-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/Tooling/NodeIntrospection.cpp:60
+  if (LHS.first == RHS.first)
+return LHS.second->name() < RHS.second->name();
+  return LHS.first < RHS.first;

njames93 wrote:
> dblaikie wrote:
> > njames93 wrote:
> > > This is a slight change in behaviour, The old implementation used the 
> > > operator< on a `std::shared_ptr`.
> > > That in turns boils down to a comparison on the raw pointer, which is 
> > > less than ideal.
> > Why is that less than ideal? Does the ordering need to be stable?
> It's not strictly necessary that the ordering is stable. but when printing 
> the contents of the map it would be nice if there was some obvious ordering. 
> This also (partially) mimics the behaviour of the comparison for 
> `std::pair`.
seems like a strange tradeoff to me for the LLVM codebase - we have lots of 
unstable maps & don't try to make them nicer for printing - especially if that 
would come at any performance cost, like doing string comparisons.


Does the SourceRange+SharedLocationCall need stability? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100378

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


[clang-tools-extra] bda2028 - [clang-tidy] Add exception flag to bugprone-unhandled-exception-at-new test.

2021-04-14 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-04-14T10:01:05+02:00
New Revision: bda20282cb94faa97b2e50cb592eff3dec94f6b0

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

LOG: [clang-tidy] Add exception flag to bugprone-unhandled-exception-at-new 
test.

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp
index 433a266cc185..6883463b0ae5 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14 %s bugprone-unhandled-exception-at-new %t
+// RUN: %check_clang_tidy -std=c++14 %s bugprone-unhandled-exception-at-new %t 
-- -- -fexceptions
 
 namespace std {
 typedef __typeof__(sizeof(0)) size_t;



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


[PATCH] D100378: [AST] Use IntrusiveRefCntPtr for Introspection LocationCall.

2021-04-14 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang/lib/Tooling/NodeIntrospection.cpp:60
+  if (LHS.first == RHS.first)
+return LHS.second->name() < RHS.second->name();
+  return LHS.first < RHS.first;

dblaikie wrote:
> njames93 wrote:
> > dblaikie wrote:
> > > njames93 wrote:
> > > > This is a slight change in behaviour, The old implementation used the 
> > > > operator< on a `std::shared_ptr`.
> > > > That in turns boils down to a comparison on the raw pointer, which is 
> > > > less than ideal.
> > > Why is that less than ideal? Does the ordering need to be stable?
> > It's not strictly necessary that the ordering is stable. but when printing 
> > the contents of the map it would be nice if there was some obvious 
> > ordering. This also (partially) mimics the behaviour of the comparison for 
> > `std::pair`.
> seems like a strange tradeoff to me for the LLVM codebase - we have lots of 
> unstable maps & don't try to make them nicer for printing - especially if 
> that would come at any performance cost, like doing string comparisons.
> 
> 
> Does the SourceRange+SharedLocationCall need stability? 
The purpose behind this functionality is partly based on getting clang-query to 
show how to get display what source location accessors can be used for specific 
nodes(http://ce.steveire.com/z/V3k6Rl). As this is for a user facing and not a 
particularly hot path, I think its worth a couple extra cycles to give 
stability.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100378

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


[PATCH] D100378: [AST] Use IntrusiveRefCntPtr for Introspection LocationCall.

2021-04-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/Tooling/NodeIntrospection.cpp:60
+  if (LHS.first == RHS.first)
+return LHS.second->name() < RHS.second->name();
+  return LHS.first < RHS.first;

njames93 wrote:
> dblaikie wrote:
> > njames93 wrote:
> > > dblaikie wrote:
> > > > njames93 wrote:
> > > > > This is a slight change in behaviour, The old implementation used the 
> > > > > operator< on a `std::shared_ptr`.
> > > > > That in turns boils down to a comparison on the raw pointer, which is 
> > > > > less than ideal.
> > > > Why is that less than ideal? Does the ordering need to be stable?
> > > It's not strictly necessary that the ordering is stable. but when 
> > > printing the contents of the map it would be nice if there was some 
> > > obvious ordering. This also (partially) mimics the behaviour of the 
> > > comparison for `std::pair`.
> > seems like a strange tradeoff to me for the LLVM codebase - we have lots of 
> > unstable maps & don't try to make them nicer for printing - especially if 
> > that would come at any performance cost, like doing string comparisons.
> > 
> > 
> > Does the SourceRange+SharedLocationCall need stability? 
> The purpose behind this functionality is partly based on getting clang-query 
> to show how to get display what source location accessors can be used for 
> specific nodes(http://ce.steveire.com/z/V3k6Rl). As this is for a user facing 
> and not a particularly hot path, I think its worth a couple extra cycles to 
> give stability.
Oh. If this is user-facing then in must be stable/deterministic (for 
reproducibility, testing, etc).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100378

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


[PATCH] D100455: [clang] Rename CompilerInvocationBase to RefBase, split out ValueBase

2021-04-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch documents the reason `CompilerInvocationBase` exists and renames it 
to more descriptive `CompilerInvocationRefBase`.

To make the distinction obvious, it also splits out new 
`CompilerInvocationValueBase` class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100455

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

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -109,14 +109,15 @@
 // Initialization.
 //===--===//
 
-CompilerInvocationBase::CompilerInvocationBase()
+CompilerInvocationRefBase::CompilerInvocationRefBase()
 : LangOpts(new LangOptions()), TargetOpts(new TargetOptions()),
   DiagnosticOpts(new DiagnosticOptions()),
   HeaderSearchOpts(new HeaderSearchOptions()),
   PreprocessorOpts(new PreprocessorOptions()),
   AnalyzerOpts(new AnalyzerOptions()) {}
 
-CompilerInvocationBase::CompilerInvocationBase(const CompilerInvocationBase &X)
+CompilerInvocationRefBase::CompilerInvocationRefBase(
+const CompilerInvocationRefBase &X)
 : LangOpts(new LangOptions(*X.getLangOpts())),
   TargetOpts(new TargetOptions(X.getTargetOpts())),
   DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
@@ -124,7 +125,7 @@
   PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
   AnalyzerOpts(new AnalyzerOptions(*X.getAnalyzerOpts())) {}
 
-CompilerInvocationBase::~CompilerInvocationBase() = default;
+CompilerInvocationRefBase::~CompilerInvocationRefBase() = default;
 
 //===--===//
 // Normalizers
Index: clang/include/clang/Frontend/CompilerInvocation.h
===
--- clang/include/clang/Frontend/CompilerInvocation.h
+++ clang/include/clang/Frontend/CompilerInvocation.h
@@ -61,7 +61,15 @@
  DiagnosticsEngine *Diags = nullptr,
  bool DefaultDiagColor = true);
 
-class CompilerInvocationBase {
+/// The base class of CompilerInvocation with reference semantics.
+///
+/// This class stores option objects behind reference-counted pointers. This is
+/// useful for clients that want to keep some option object around even after
+/// CompilerInvocation gets destroyed, without making a copy.
+///
+/// This is a separate class so that we can implement the copy constructor and
+/// assignment here and leave them defaulted in the rest of CompilerInvocation.
+class CompilerInvocationRefBase {
 public:
   /// Options controlling the language variant.
   std::shared_ptr LangOpts;
@@ -81,10 +89,11 @@
   /// Options controlling the static analyzer.
   AnalyzerOptionsRef AnalyzerOpts;
 
-  CompilerInvocationBase();
-  CompilerInvocationBase(const CompilerInvocationBase &X);
-  CompilerInvocationBase &operator=(const CompilerInvocationBase &) = delete;
-  ~CompilerInvocationBase();
+  CompilerInvocationRefBase();
+  CompilerInvocationRefBase(const CompilerInvocationRefBase &X);
+  CompilerInvocationRefBase &
+  operator=(const CompilerInvocationRefBase &) = delete;
+  ~CompilerInvocationRefBase();
 
   LangOptions *getLangOpts() { return LangOpts.get(); }
   const LangOptions *getLangOpts() const { return LangOpts.get(); }
@@ -117,12 +126,9 @@
   AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; }
 };
 
-/// Helper class for holding the data necessary to invoke the compiler.
-///
-/// This class is designed to represent an abstract "invocation" of the
-/// compiler, including data such as the include paths, the code generation
-/// options, the warning flags, and so on.
-class CompilerInvocation : public CompilerInvocationBase {
+/// The base class of CompilerInvocation with value semantics.
+class CompilerInvocationValueBase {
+protected:
   MigratorOptions MigratorOpts;
 
   /// Options controlling IRgen and the backend.
@@ -141,9 +147,46 @@
   PreprocessorOutputOptions PreprocessorOutputOpts;
 
 public:
-  /// @name Utility Methods
-  /// @{
+  MigratorOptions &getMigratorOpts() { return MigratorOpts; }
+  const MigratorOptions &getMigratorOpts() const { return MigratorOpts; }
+
+  CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; }
+  const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
+
+  DependencyOutputOptions &getDependencyOutputOpts() {
+return DependencyOutputOpts;
+  }
+
+  const DependencyOutputOptions &getDependencyOutputOpts() const {
+return DependencyOutputOpts;
+  }
 
+  FileSystemOptions &getFileSystemOpts() { return FileS

[clang] 1c4108a - [i386] Modify the alignment of __m128/__m256/__m512 vector type according i386 abi.

2021-04-14 Thread via cfe-commits

Author: Liu, Chen3
Date: 2021-04-14T16:44:54+08:00
New Revision: 1c4108ab661d43e21b1d1c804d8a403e5b0cf7d6

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

LOG: [i386] Modify the alignment of __m128/__m256/__m512 vector type according 
i386 abi.

According to i386 System V ABI:

1. when __m256 are required to be passed on the stack, the stack pointer must 
be aligned on a 0 mod 32 byte boundary at the time of the call.
2. when __m512 are required to be passed on the stack, the stack pointer must 
be aligned on a 0 mod 64 byte boundary at the time of the call.

The current method of clang passing __m512 parameter are as follow:

1. when target supports avx512, passing it with 64 byte alignment;
2. when target supports avx, passing it with 32 byte alignment;
3. Otherwise, passing it with 16 byte alignment.

Passing __m256 parameter are as follow:

1. when target supports avx or avx512, passing it with 32 byte alignment;
2. Otherwise, passing it with 16 byte alignment.

This pach will passing __m128/__m256/__m512 following i386 System V ABI and
apply it to Linux only since other System V OS (e.g Darwin, PS4 and FreeBSD) 
don't
want to spend any effort dealing with the ramifications of ABI breaks at 
present.

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

Added: 
clang/test/CodeGen/x86_32-align-linux.c

Modified: 
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 7f4deb21d6ed..55e38741e287 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -1105,6 +1105,7 @@ class X86_32ABIInfo : public SwiftABIInfo {
   bool IsWin32StructABI;
   bool IsSoftFloatABI;
   bool IsMCUABI;
+  bool IsLinuxABI;
   unsigned DefaultNumRegisterParameters;
 
   static bool isRegisterSize(unsigned Size) {
@@ -1167,9 +1168,9 @@ class X86_32ABIInfo : public SwiftABIInfo {
 unsigned NumRegisterParameters, bool SoftFloatABI)
 : SwiftABIInfo(CGT), IsDarwinVectorABI(DarwinVectorABI),
   IsRetSmallStructInRegABI(RetSmallStructInRegABI),
-  IsWin32StructABI(Win32StructABI),
-  IsSoftFloatABI(SoftFloatABI),
+  IsWin32StructABI(Win32StructABI), IsSoftFloatABI(SoftFloatABI),
   IsMCUABI(CGT.getTarget().getTriple().isOSIAMCU()),
+  IsLinuxABI(CGT.getTarget().getTriple().isOSLinux()),
   DefaultNumRegisterParameters(NumRegisterParameters) {}
 
   bool shouldPassIndirectlyForSwift(ArrayRef scalars,
@@ -1594,6 +1595,14 @@ unsigned 
X86_32ABIInfo::getTypeStackAlignInBytes(QualType Ty,
   if (Align <= MinABIStackAlignInBytes)
 return 0; // Use default alignment.
 
+  if (IsLinuxABI) {
+// Exclude other System V OS (e.g Darwin, PS4 and FreeBSD) since we don't
+// want to spend any effort dealing with the ramifications of ABI breaks.
+//
+// If the vector type is __m128/__m256/__m512, return the default 
alignment.
+if (Ty->isVectorType() && (Align == 16 || Align == 32 || Align == 64))
+  return Align;
+  }
   // On non-Darwin, the stack type alignment is always 4.
   if (!IsDarwinVectorABI) {
 // Set explicit alignment, since we may need to realign the top.

diff  --git a/clang/test/CodeGen/x86_32-align-linux.c 
b/clang/test/CodeGen/x86_32-align-linux.c
new file mode 100644
index ..6e6ddd757b6f
--- /dev/null
+++ b/clang/test/CodeGen/x86_32-align-linux.c
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu 
-target-feature +avx -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu 
-target-feature +avx512f -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: define dso_local void @testm128
+// CHECK-LABEL: %argp.cur = load i8*, i8** %args, align 4
+// CHECK-NEXT:  %0 = ptrtoint i8* %argp.cur to i32
+// CHECK-NEXT:  %1 = add i32 %0, 15
+// CHECK-NEXT:  %2 = and i32 %1, -16
+// CHECK-NEXT:  %argp.cur.aligned = inttoptr i32 %2 to i8*
+void testm128(int argCount, ...) {
+  __m128 res;
+  __builtin_va_list args;
+  __builtin_va_start(args, argCount);
+  res = __builtin_va_arg(args, __m128);
+  __builtin_va_end(args);
+}
+
+// CHECK-LABEL: define dso_local void @testm256
+// CHECK-LABEL: %argp.cur = load i8*, i8** %args, align 4
+// CHECK-NEXT:  %0 = ptrtoint i8* %argp.cur to i32
+// CHECK-NEXT:  %1 = add i32 %0, 31
+// CHECK-NEXT:  %2 = and i32 %1, -32
+// CHECK-NEXT:  %argp.cur.aligned = inttoptr i32 %2 to i8*
+void testm256(int argCount, ...) {
+  __m256 res;
+  __builtin_va_list args;
+  __builtin_va_start(args, argCount);
+  res = __builtin_va_arg(args, __m256);
+  __builtin_va_end(args);
+}
+
+// CHE

[PATCH] D78564: [i386] Modify the alignment of __m128/__m256/__m512 vector type according i386 abi.

2021-04-14 Thread LiuChen 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 rG1c4108ab661d: [i386] Modify the alignment of 
__m128/__m256/__m512 vector type according i386… (authored by LiuChen3).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78564

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/x86_32-align-linux.c

Index: clang/test/CodeGen/x86_32-align-linux.c
===
--- /dev/null
+++ clang/test/CodeGen/x86_32-align-linux.c
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu -target-feature +avx -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu -target-feature +avx512f -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: define dso_local void @testm128
+// CHECK-LABEL: %argp.cur = load i8*, i8** %args, align 4
+// CHECK-NEXT:  %0 = ptrtoint i8* %argp.cur to i32
+// CHECK-NEXT:  %1 = add i32 %0, 15
+// CHECK-NEXT:  %2 = and i32 %1, -16
+// CHECK-NEXT:  %argp.cur.aligned = inttoptr i32 %2 to i8*
+void testm128(int argCount, ...) {
+  __m128 res;
+  __builtin_va_list args;
+  __builtin_va_start(args, argCount);
+  res = __builtin_va_arg(args, __m128);
+  __builtin_va_end(args);
+}
+
+// CHECK-LABEL: define dso_local void @testm256
+// CHECK-LABEL: %argp.cur = load i8*, i8** %args, align 4
+// CHECK-NEXT:  %0 = ptrtoint i8* %argp.cur to i32
+// CHECK-NEXT:  %1 = add i32 %0, 31
+// CHECK-NEXT:  %2 = and i32 %1, -32
+// CHECK-NEXT:  %argp.cur.aligned = inttoptr i32 %2 to i8*
+void testm256(int argCount, ...) {
+  __m256 res;
+  __builtin_va_list args;
+  __builtin_va_start(args, argCount);
+  res = __builtin_va_arg(args, __m256);
+  __builtin_va_end(args);
+}
+
+// CHECK-LABEL: define dso_local void @testm512
+// CHECK-LABEL: %argp.cur = load i8*, i8** %args, align 4
+// CHECK-NEXT:  %0 = ptrtoint i8* %argp.cur to i32
+// CHECK-NEXT:  %1 = add i32 %0, 63
+// CHECK-NEXT:  %2 = and i32 %1, -64
+// CHECK-NEXT:  %argp.cur.aligned = inttoptr i32 %2 to i8*
+void testm512(int argCount, ...) {
+  __m512 res;
+  __builtin_va_list args;
+  __builtin_va_start(args, argCount);
+  res = __builtin_va_arg(args, __m512);
+  __builtin_va_end(args);
+}
+
+// CHECK-LABEL: define dso_local void @testPastArguments
+// CHECK: call void (i32, ...) @testm128(i32 1, <4 x float> %0)
+// CHECK: call void (i32, ...) @testm256(i32 1, <8 x float> %1)
+// CHECK: call void (i32, ...) @testm512(i32 1, <16 x float> %2)
+void testPastArguments(void) {
+  __m128 a;
+  __m256 b;
+  __m512 c;
+  testm128(1, a);
+  testm256(1, b);
+  testm512(1, c);
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1105,6 +1105,7 @@
   bool IsWin32StructABI;
   bool IsSoftFloatABI;
   bool IsMCUABI;
+  bool IsLinuxABI;
   unsigned DefaultNumRegisterParameters;
 
   static bool isRegisterSize(unsigned Size) {
@@ -1167,9 +1168,9 @@
 unsigned NumRegisterParameters, bool SoftFloatABI)
 : SwiftABIInfo(CGT), IsDarwinVectorABI(DarwinVectorABI),
   IsRetSmallStructInRegABI(RetSmallStructInRegABI),
-  IsWin32StructABI(Win32StructABI),
-  IsSoftFloatABI(SoftFloatABI),
+  IsWin32StructABI(Win32StructABI), IsSoftFloatABI(SoftFloatABI),
   IsMCUABI(CGT.getTarget().getTriple().isOSIAMCU()),
+  IsLinuxABI(CGT.getTarget().getTriple().isOSLinux()),
   DefaultNumRegisterParameters(NumRegisterParameters) {}
 
   bool shouldPassIndirectlyForSwift(ArrayRef scalars,
@@ -1594,6 +1595,14 @@
   if (Align <= MinABIStackAlignInBytes)
 return 0; // Use default alignment.
 
+  if (IsLinuxABI) {
+// Exclude other System V OS (e.g Darwin, PS4 and FreeBSD) since we don't
+// want to spend any effort dealing with the ramifications of ABI breaks.
+//
+// If the vector type is __m128/__m256/__m512, return the default alignment.
+if (Ty->isVectorType() && (Align == 16 || Align == 32 || Align == 64))
+  return Align;
+  }
   // On non-Darwin, the stack type alignment is always 4.
   if (!IsDarwinVectorABI) {
 // Set explicit alignment, since we may need to realign the top.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78564: [i386] Modify the alignment of __m128/__m256/__m512 vector type according i386 abi.

2021-04-14 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added a comment.

Thanks for your review. Hope this patch won't cause too many ABI issues in the 
future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78564

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


Re: [clang] 1c4108a - [i386] Modify the alignment of __m128/__m256/__m512 vector type according i386 abi.

2021-04-14 Thread Roman Lebedev via cfe-commits
Reminder to please ensure that all reviews are subscribed to the
appropriate mailing lists.
This one omitted cfe-dev.

On Wed, Apr 14, 2021 at 11:47 AM via cfe-commits
 wrote:
>
>
> Author: Liu, Chen3
> Date: 2021-04-14T16:44:54+08:00
> New Revision: 1c4108ab661d43e21b1d1c804d8a403e5b0cf7d6
>
> URL: 
> https://github.com/llvm/llvm-project/commit/1c4108ab661d43e21b1d1c804d8a403e5b0cf7d6
> DIFF: 
> https://github.com/llvm/llvm-project/commit/1c4108ab661d43e21b1d1c804d8a403e5b0cf7d6.diff
>
> LOG: [i386] Modify the alignment of __m128/__m256/__m512 vector type 
> according i386 abi.
>
> According to i386 System V ABI:
>
> 1. when __m256 are required to be passed on the stack, the stack pointer must 
> be aligned on a 0 mod 32 byte boundary at the time of the call.
> 2. when __m512 are required to be passed on the stack, the stack pointer must 
> be aligned on a 0 mod 64 byte boundary at the time of the call.
>
> The current method of clang passing __m512 parameter are as follow:
>
> 1. when target supports avx512, passing it with 64 byte alignment;
> 2. when target supports avx, passing it with 32 byte alignment;
> 3. Otherwise, passing it with 16 byte alignment.
>
> Passing __m256 parameter are as follow:
>
> 1. when target supports avx or avx512, passing it with 32 byte alignment;
> 2. Otherwise, passing it with 16 byte alignment.
>
> This pach will passing __m128/__m256/__m512 following i386 System V ABI and
> apply it to Linux only since other System V OS (e.g Darwin, PS4 and FreeBSD) 
> don't
> want to spend any effort dealing with the ramifications of ABI breaks at 
> present.
>
> Differential Revision: https://reviews.llvm.org/D78564
>
> Added:
> clang/test/CodeGen/x86_32-align-linux.c
>
> Modified:
> clang/lib/CodeGen/TargetInfo.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
> b/clang/lib/CodeGen/TargetInfo.cpp
> index 7f4deb21d6ed..55e38741e287 100644
> --- a/clang/lib/CodeGen/TargetInfo.cpp
> +++ b/clang/lib/CodeGen/TargetInfo.cpp
> @@ -1105,6 +1105,7 @@ class X86_32ABIInfo : public SwiftABIInfo {
>bool IsWin32StructABI;
>bool IsSoftFloatABI;
>bool IsMCUABI;
> +  bool IsLinuxABI;
>unsigned DefaultNumRegisterParameters;
>
>static bool isRegisterSize(unsigned Size) {
> @@ -1167,9 +1168,9 @@ class X86_32ABIInfo : public SwiftABIInfo {
>  unsigned NumRegisterParameters, bool SoftFloatABI)
>  : SwiftABIInfo(CGT), IsDarwinVectorABI(DarwinVectorABI),
>IsRetSmallStructInRegABI(RetSmallStructInRegABI),
> -  IsWin32StructABI(Win32StructABI),
> -  IsSoftFloatABI(SoftFloatABI),
> +  IsWin32StructABI(Win32StructABI), IsSoftFloatABI(SoftFloatABI),
>IsMCUABI(CGT.getTarget().getTriple().isOSIAMCU()),
> +  IsLinuxABI(CGT.getTarget().getTriple().isOSLinux()),
>DefaultNumRegisterParameters(NumRegisterParameters) {}
>
>bool shouldPassIndirectlyForSwift(ArrayRef scalars,
> @@ -1594,6 +1595,14 @@ unsigned 
> X86_32ABIInfo::getTypeStackAlignInBytes(QualType Ty,
>if (Align <= MinABIStackAlignInBytes)
>  return 0; // Use default alignment.
>
> +  if (IsLinuxABI) {
> +// Exclude other System V OS (e.g Darwin, PS4 and FreeBSD) since we don't
> +// want to spend any effort dealing with the ramifications of ABI breaks.
> +//
> +// If the vector type is __m128/__m256/__m512, return the default 
> alignment.
> +if (Ty->isVectorType() && (Align == 16 || Align == 32 || Align == 64))
> +  return Align;
> +  }
>// On non-Darwin, the stack type alignment is always 4.
>if (!IsDarwinVectorABI) {
>  // Set explicit alignment, since we may need to realign the top.
>
> diff  --git a/clang/test/CodeGen/x86_32-align-linux.c 
> b/clang/test/CodeGen/x86_32-align-linux.c
> new file mode 100644
> index ..6e6ddd757b6f
> --- /dev/null
> +++ b/clang/test/CodeGen/x86_32-align-linux.c
> @@ -0,0 +1,60 @@
> +// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu 
> -emit-llvm -o - %s | FileCheck %s
> +// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu 
> -target-feature +avx -emit-llvm -o - %s | FileCheck %s
> +// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu 
> -target-feature +avx512f -emit-llvm -o - %s | FileCheck %s
> +
> +#include 
> +
> +// CHECK-LABEL: define dso_local void @testm128
> +// CHECK-LABEL: %argp.cur = load i8*, i8** %args, align 4
> +// CHECK-NEXT:  %0 = ptrtoint i8* %argp.cur to i32
> +// CHECK-NEXT:  %1 = add i32 %0, 15
> +// CHECK-NEXT:  %2 = and i32 %1, -16
> +// CHECK-NEXT:  %argp.cur.aligned = inttoptr i32 %2 to i8*
> +void testm128(int argCount, ...) {
> +  __m128 res;
> +  __builtin_va_list args;
> +  __builtin_va_start(args, argCount);
> +  res = __builtin_va_arg(args, __m128);
> +  __builtin_va_end(args);
> +}
> +
> +// CHECK-LABEL: define dso_local void @testm256
> +// CHECK-LABEL: %argp.cur = load i8*, i8** %a

[PATCH] D89649: Fix __has_unique_object_representations with no_unique_address

2021-04-14 Thread Whisperity via Phabricator via cfe-commits
whisperity added subscribers: dblaikie, erik.pilkington, martong, whisperity.
whisperity added a reviewer: shafik.
whisperity added a comment.

Adding a few subscribers I could find from the original bugzilla entry, + 
perhaps a few reviewers to help us.


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

https://reviews.llvm.org/D89649

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


[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-04-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D94355#2665532 , @gulfem wrote:

>> Would you be ok with reverting this change until I can sort that out, or can 
>> we disable the pass for those targets until then?
>
> I will disable the pass for those targets for now.
> When the issue is resolved, I would like to enable it for those targets as 
> well.

FYI, I pushed the fix for the aarch64-coff issue now (D99572 
, rGd5c5cf5ce8d921fc8c5e1b608c298a1ffa688d37 
) and 
pushed another commit to remove the code for disabling the pass on aarch64 
(rG57b259a852a6383880f5d0875d848420bb3c2945 
).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[PATCH] D100460: [clang] Move deep copy into CompilerInvocation::clone

2021-04-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added subscribers: martong, usaxena95, kadircet, arphaman, javed.absar.
jansvoboda11 requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

The copy constructor of `CompilerInvocation` performs a deep copy of the 
reference-counted pointers stored in its base class.

This behaviour might be surprising, since it doesn't follow the default 
semantics of `std::shared_ptr` and `llvm::IntrusiveRefCntPtr`.

In this patch, the copy constructor is declared private and the `clone()` 
method is introduced, making the behaviour obvious.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100460

Files:
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/ARCMigrate/ARCMT.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/ChainedIncludesSource.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -97,18 +97,34 @@
   ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
 }
 
-// Copy constructor performs a deep copy of reference-counted pointers.
+// Clone performs deep copy of reference-counted pointers.
 
-TEST(CompilerInvocationTest, DeepCopyConstructor) {
+TEST(CompilerInvocationTest, CloneWithMoveConstructor) {
   CompilerInvocation A;
   A.getAnalyzerOpts()->Config["Key"] = "Old";
 
-  CompilerInvocation B(A);
+  CompilerInvocation B(A.clone());
   B.getAnalyzerOpts()->Config["Key"] = "New";
 
   ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
 }
 
+TEST(CompilerInvocationTest, CloneWithMoveAssignment) {
+  CompilerInvocation A;
+  A.getAnalyzerOpts()->Config["Key"] = "Old";
+
+  CompilerInvocation B;
+  B = A.clone();
+  B.getAnalyzerOpts()->Config["Key"] = "New";
+
+  ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
+}
+
+TEST(CompilerInvocationTest, NotCopyConstructibleNorAssignable) {
+  ASSERT_FALSE(std::is_copy_constructible::value);
+  ASSERT_FALSE(std::is_copy_assignable::value);
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypath to false.
 
Index: clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
+++ clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
@@ -64,7 +64,8 @@
 return;
   }
 
-  auto Invocation = std::make_shared(CI.getInvocation());
+  auto Invocation =
+  std::make_shared(CI.getInvocation().clone());
 
   FrontendOptions &FrontendOpts = Invocation->getFrontendOpts();
   InputKind IK = Language::CXX; // FIXME
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -244,7 +244,7 @@
 CompilerInstance Instance(CI.getPCHContainerOperations(),
   &CI.getModuleCache());
 Instance.setInvocation(
-std::make_shared(CI.getInvocation()));
+std::make_shared(CI.getInvocation().clone()));
 Instance.createDiagnostics(
 new ForwardingDiagnosticConsumer(CI.getDiagnosticClient()),
 /*ShouldOwnClient=*/true);
Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -317,7 +317,8 @@
 PreambleCallbacks &Callbacks) {
   assert(VFS && "VFS is null");
 
-  auto PreambleInvocation = std::make_shared(Invocation);
+  auto PreambleInvocation =
+  std::make_shared(Invocation.clone());
   FrontendOptions &FrontendOpts = PreambleInvocation->getFrontendOpts();
   PreprocessorOptions &PreprocessorOpts =
   PreambleInvocation->getPreprocessorOpts();
@@ -501,7 +502,8 @@
   Bounds.Size <= MainFileBuffer.getBufferSize() &&
   "Buffer is too large. Bounds were calculated from a different buffer?");
 
-  auto PreambleInvocation = std::make_shared(Invocation);
+  auto PreambleInvocation =
+  std::make_shared(Invocation.clone());
   PreprocessorOptions &PreprocessorOpts =
   PreambleInvocation->getPreprocessorOpts();
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/

[PATCH] D100425: [WebAssembly] Codegen for f64x2.convert_low_i32x4_{s,u}

2021-04-14 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td:1104-1107
+defm "" : SIMDConvert;
+defm "" : SIMDConvert;
+defm "" : SIMDConvert;
+defm "" : SIMDConvert;

Not related to this CL, but we write encoding as decimals for some instructions 
and hexadecimals in others?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100425

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


[PATCH] D92024: [clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

2021-04-14 Thread Alex Orlov via Phabricator via cfe-commits
aorlov added a comment.

@krisb

In D92024#2677857 , @krisb wrote:

> Do we still need the following tests:
>
> - clang/test/CXX/temp/temp.spec/temp.explicit/p11.cpp
> - clang/test/CXX/temp/temp.spec/temp.explicit/p12.cpp
>
> ?

We can remove **p11.cpp** and partially **p12.cpp**, because **p12** has 
another kind of test in `namespace test0{ ... }`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92024

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


[PATCH] D92024: [clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

2021-04-14 Thread Alex Orlov via Phabricator via cfe-commits
aorlov added inline comments.



Comment at: clang/test/CXX/temp/temp.spec/func.spec.cpp:105
+template  void func10(A::B, int x) {}
+template  void func11(A::C, A::D, int) {}
+template  void func12() {}

krisb wrote:
> aorlov wrote:
> > krisb wrote:
> > > Before this patch clang diagnosed cases like 
> > > 
> > > ```
> > > class A { class C {}; };
> > > template  void func(A::C) {}
> > > ```
> > > Why is it no longer the case?
> > > 
> > Your example generates an error `error: 'C' is a private member of 'A'` on 
> > latest clang.
> > This patch is intended to implement a proposal [[ 
> > http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0692r1.html | 
> > p0692r1]] and consider this example as valid.
> > Did I understand your question correctly?
> It doesn't seem the aforementioned example falls under any of the cases from 
> P0692R1 unless I misinterpreted its wordings.
> It's a primary template, right?
> Consider also the following example for which clang issues the error in both 
> cases (before and after the patch):
> ```
> class A { class C {}; };
> template  A::C func();
> ```
> I'm also wondering about something like:
> ```
> class A { class C {}; };
> template  T func() {}
> template <> A::C func();
> ```
Oh, I caught the point.
The paper says that the usual access checking rules do **not** apply to:
  - partial specialization
  - explicit instantiation
  - explicit specialization
Also it comes out from the Standard that the usual access checking rules 
**applies** to __primary__ templates, only if they are not declared as 
//friends//.

> ```
> class A { class C {}; };
> template  void func(A::C) {}
> ```
> It's a primary template, right?
Yes, it is a primary template.  The access checking rules should work here. But 
they do not after this patch. This is a mistake I will sort out.

> Consider also the following example for which clang issues the error in both 
> cases (before and after the patch):
> ```
> class A { class C {}; };
> template  A::C func();
> ```
This is also a primary template and should be handled with the access rules. 
The patch turns it off. This is a mistake. I'll handle.
> I'm also wondering about something like:
> ```
> class A { class C {}; };
> template  T func() {}
> template <> A::C func();
> ```
This is an explicit specialization. It should not issue any errors here. The 
patch handles it correctly. It's OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92024

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:2379
   unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
-  if (TargetAS != 0)
+  if (TargetAS != 0 || Context.getASTContext().getLangOpts().SYCLIsDevice)
 ASString = "AS" + llvm::utostr(TargetAS);

bader wrote:
> Anastasia wrote:
> > bader wrote:
> > > Anastasia wrote:
> > > > Any reason not to use OpenCL mangling? If you do then you might be able 
> > > > to link against libraries compiled for OpenCL. Also you will get more 
> > > > stable naming i.e. it would not differ from target to target. 
> > > > Any reason not to use OpenCL mangling? If you do then you might be able 
> > > > to link against libraries compiled for OpenCL. Also you will get more 
> > > > stable naming i.e. it would not differ from target to target. 
> > > 
> > > I'm not sure I understand your suggestion. Could you elaborate on "OpenCL 
> > > mangling", please?
> > > 
> > > Let me clarify the problem this change addresses. The test case covering 
> > > it is located in 
> > > `clang/test/CodeGenSYCL/address-space-parameter-conversions.cpp` lines 
> > > 86-91.
> > > 
> > > ```
> > > template 
> > > void tmpl(T t) {}
> > > 
> > > int *NoAS;
> > > __attribute__((opencl_private)) int *PRIV;
> > > 
> > > tmpl(PRIV);
> > > // CHECK-DAG: [[PRIV_LOAD5:%[a-zA-Z0-9]+]] = load i32*, i32* 
> > > addrspace(4)* [[PRIV]].ascast
> > > // CHECK-DAG: call spir_func void [[PRIV_TMPL:@[a-zA-Z0-9_]+]](i32* 
> > > [[PRIV_LOAD5]])
> > > tmpl(NoAS);
> > > // CHECK-DAG: [[NoAS_LOAD5:%[a-zA-Z0-9]+]] = load i32 addrspace(4)*, i32 
> > > addrspace(4)* addrspace(4)* [[NoAS]].ascast
> > > // CHECK-DAG: call spir_func void [[GEN_TMPL:@[a-zA-Z0-9_]+]](i32 
> > > addrspace(4)* [[NoAS_LOAD5]])
> > > ```
> > > Clang has separate code paths for mangling types w/ and w/o address space 
> > > attributes (i.e. using `Default` address space).
> > > 
> > > Address space is not mangled if there is no AS attribute (`Default`) or 
> > > if address space attribute is maps to `0` target address space. SPIR 
> > > target maps `*_private` address space to `0`, which causes name conflict 
> > > for the example above.
> > > 
> > > This change for SYCL compiler enables mangling for non-default address 
> > > space attributes regardless of their mapping to target address space.
> > It's just that all language address spaces are mangled with the source 
> > spelling in Italium ABI right now, if you check the `else` statement. I 
> > don't think it is part of the official spec yet but it might be better to 
> > stick to the same pattern if possible.
> > It's just that all language address spaces are mangled with the source 
> > spelling in Italium ABI right now, if you check the `else` statement. I 
> > don't think it is part of the official spec yet but it might be better to 
> > stick to the same pattern if possible.
> 
> I would really love to avoid changes to the mangler (e.g. to be able to link 
> binaries produced by different front-end like SYCL/OpenCL/CUDA), but I don't 
> know the better way to address the issue 
> Sorry, I don't get what do you suggest here. Could you clarify what exactly I 
> should change, please?
For now I am just trying to understand why you are not adopting similar 
mangling scheme as for other language address spaces since it gives more stable 
mangling irrespective from the target compiled for.

If you plan to link libraries from other frontends i.e. OpenCL or CUDA the 
mangling you use is different from what they produce. Just have a look at the  
line 2470 that explains OpenCL mangling or line 2494 explaining CUDA mangling. 
FYI similar scheme applies to other language address spaces, so the `AS` 
was only really used for the address spaces that have no source spelling i.e. 
no language semantics.



Comment at: clang/lib/Basic/Targets/SPIR.h:129
+TargetInfo::adjust(Opts);
+setAddressSpaceMap(/*DefaultIsGeneric=*/Opts.SYCLIsDevice);
+  }

bader wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > Ok, do you still plan to add a `FIXME` as mentioned previously explaining 
> > > why we need to reset the map here?
> > Btw I was just thinking of another alternative here.
> > 
> > What do you think about just setting a value in `Default` AS entry then we 
> > wouldn't need any extra map at all in this case? So something like:
> > 
> > 
> > ```
> > AddrSpaceMap[LangAS::Default] = AddrSpaceMap[LangAS::opencl_generic];
> > ```
> > with a good explanation in `FIXME`? :)
> > 
> > Btw I was just thinking of another alternative here.
> > 
> > What do you think about just setting a value in `Default` AS entry then we 
> > wouldn't need any extra map at all in this case? So something like:
> > 
> > 
> > ```
> > AddrSpaceMap[LangAS::Default] = AddrSpaceMap[LangAS::opencl_generic];
> > ```
> > with a good explanation in `FIXME`? :)
> > 
> 
> I think this won't work because Addr

[PATCH] D100466: clang-format: [JS] merge import lines.

2021-04-14 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: krasimir.
mprobst requested review of this revision.
Herald added a project: clang.

Multiple lines importing from the same URL can be merged:

  import {X} from 'a';
  import {Y} from 'a';

Merge to:

  import {X, Y} from 'a';

This change implements this merge operation. It takes care not to merge in
various corner case situations (default imports, star imports).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100466

Files:
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/SortImportsTestJS.cpp

Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -307,6 +307,52 @@
  "import {A} from 'a';\n");
 }
 
+TEST_F(SortImportsTestJS, MergeImports) {
+  // basic operation
+  verifySort("import {X, Y} from 'a';\n"
+ "import {Z} from 'z';\n"
+ "\n"
+ "X + Y + Z;\n",
+ "import {X} from 'a';\n"
+ "import {Z} from 'z';\n"
+ "import {Y} from 'a';\n"
+ "\n"
+ "X + Y + Z;\n");
+
+  // empty imports
+  verifySort("import {A} from 'foo';\n", "import {} from 'foo';\n"
+ "import {A} from 'foo';");
+
+  // ignores import *
+  verifySort("import * as foo from 'foo';\n"
+ "import {A} from 'foo';\n",
+ "import   * as foo from 'foo';\n"
+ "import {A} from 'foo';\n");
+
+  // ignores default import
+  verifySort("import X from 'foo';\n"
+ "import {A} from 'foo';\n",
+ "importX from 'foo';\n"
+ "import {A} from 'foo';\n");
+
+  // keeps comments
+  // known issue: loses the 'also a' comment.
+  verifySort("// a\n"
+ "import {/* x */ X, /* y */ Y} from 'a';\n"
+ "// z\n"
+ "import {Z} from 'z';\n"
+ "\n"
+ "X + Y + Z;\n",
+ "// a\n"
+ "import {/* y */ Y} from 'a';\n"
+ "// z\n"
+ "import {Z} from 'z';\n"
+ "// also a\n"
+ "import {/* x */ X} from 'a';\n"
+ "\n"
+ "X + Y + Z;\n");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -83,8 +83,13 @@
   // Prefix from "import * as prefix". Empty for symbol imports and `export *`.
   // Implies an empty names list.
   StringRef Prefix;
+  // Default import from "import DefaultName from '...';".
+  StringRef DefaultImport;
   // Symbols from `import {SymbolA, SymbolB, ...} from ...;`.
   SmallVector Symbols;
+  // The source location just after { and just before } in the import.
+  // Extracted eagerly to allow modification of Symbols later on.
+  SourceLocation SymbolsStart, SymbolsEnd;
   // Textual position of the import/export, including preceding and trailing
   // comments.
   SourceRange Range;
@@ -146,6 +151,41 @@
 });
 bool ReferencesInOrder = llvm::is_sorted(Indices);
 
+// Merge module references:
+// After sorting, find all references that import named symbols from the
+// same URL and merge their names. E.g.
+//   import {X} from 'a';
+//   import {Y} from 'a';
+// should be rewritten to:
+//   import {X, Y} from 'a';
+// Note: this removes merged imports from Indices, but not from References.
+// The loop below iterates Indices, so things work out.
+JsModuleReference *PreviousReference = &References[Indices[0]];
+auto *it = std::next(Indices.begin());
+bool ImportsMerged = false;
+while (it != std::end(Indices)) {
+  JsModuleReference *Reference = &References[*it];
+  // Skip:
+  //   import 'foo';
+  //   import * as foo from 'foo'; on either previous or this.
+  //   import Default from 'foo'; on either previous or this.
+  //   mismatching
+  if (Reference->Category == JsModuleReference::SIDE_EFFECT ||
+  !PreviousReference->Prefix.empty() || !Reference->Prefix.empty() ||
+  !PreviousReference->DefaultImport.empty() ||
+  !Reference->DefaultImport.empty() || Reference->Symbols.empty() ||
+  PreviousReference->URL != Reference->URL) {
+PreviousReference = Reference;
+++it;
+continue;
+  }
+  // Merge symbols from identical imports.
+  PreviousReference->Symbols.append(Reference->Symbols);
+  ImportsMerged = true;
+  // Remove the merged import.
+  it = Indices.erase(it);
+}
+
 std::string ReferencesText;
 bool SymbolsInOrder = true;
 for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
@@ -164,7 +204,7 @@
   }
 }

[clang] 3637c5c - [clang] [AArch64] Fix Windows va_arg handling for larger structs

2021-04-14 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-04-14T14:51:53+03:00
New Revision: 3637c5c8ec3d4dc0b87eb4e3ee9c9ae8816cade2

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

LOG: [clang] [AArch64] Fix Windows va_arg handling for larger structs

Aggregate types over 16 bytes are passed by reference.

Contrary to the x86_64 ABI, smaller structs with an odd (non power
of two) are padded and passed in registers.

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/ms_abi_aarch64.c

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 55e38741e287..3ff3eed15608 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -6121,7 +6121,13 @@ Address AArch64ABIInfo::EmitDarwinVAArg(Address 
VAListAddr, QualType Ty,
 
 Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const {
-  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false,
+  bool IsIndirect = false;
+
+  // Composites larger than 16 bytes are passed by reference.
+  if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) > 128)
+IsIndirect = true;
+
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect,
   CGF.getContext().getTypeInfoInChars(Ty),
   CharUnits::fromQuantity(8),
   /*allowHigherAlign*/ false);

diff  --git a/clang/test/CodeGen/ms_abi_aarch64.c 
b/clang/test/CodeGen/ms_abi_aarch64.c
index bbb4be94d7dc..52685618176b 100644
--- a/clang/test/CodeGen/ms_abi_aarch64.c
+++ b/clang/test/CodeGen/ms_abi_aarch64.c
@@ -1,5 +1,13 @@
-// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm < %s | FileCheck 
-check-prefix=LINUX %s
-// RUN: %clang_cc1 -triple aarch64-pc-win32 -emit-llvm < %s | FileCheck 
-check-prefix=WIN64 %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm < %s | FileCheck 
-check-prefixes=LINUX,COMMON %s
+// RUN: %clang_cc1 -triple aarch64-pc-win32 -emit-llvm < %s | FileCheck 
-check-prefixes=WIN64,COMMON %s
+
+struct small_odd {
+  char a, b, c;
+};
+
+struct larger {
+  int a, b, c, d, e;
+};
 
 void __attribute__((ms_abi)) f1(void);
 void f2(void);
@@ -48,6 +56,26 @@ void __attribute__((ms_abi)) f4(int a, ...) {
   // WIN64: call void @llvm.va_end
 }
 
+void __attribute__((ms_abi)) f4_2(int a, ...) {
+  // LINUX-LABEL: define{{.*}} win64cc void @f4_2
+  // WIN64-LABEL: define dso_local void @f4_2
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap, a);
+  // COMMON: %[[AP:.*]] = alloca i8*
+  // COMMON: call void @llvm.va_start
+  struct small_odd s1 = __builtin_va_arg(ap, struct small_odd);
+  // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* 
%[[AP_CUR]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to %struct.small_odd*
+  struct larger s2 = __builtin_va_arg(ap, struct larger);
+  // COMMON: %[[AP_CUR2:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT3:.*]] = getelementptr inbounds i8, i8* 
%[[AP_CUR2]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT3]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR2]] to %struct.larger**
+  __builtin_ms_va_end(ap);
+}
+
 // Let's verify that normal va_lists work right on Win64, too.
 void f5(int a, ...) {
   // WIN64-LABEL: define dso_local void @f5



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


[PATCH] D100374: [clang] [AArch64] Fix Windows va_arg handling for larger structs

2021-04-14 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3637c5c8ec3d: [clang] [AArch64] Fix Windows va_arg handling 
for larger structs (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100374

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ms_abi_aarch64.c


Index: clang/test/CodeGen/ms_abi_aarch64.c
===
--- clang/test/CodeGen/ms_abi_aarch64.c
+++ clang/test/CodeGen/ms_abi_aarch64.c
@@ -1,5 +1,13 @@
-// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm < %s | FileCheck 
-check-prefix=LINUX %s
-// RUN: %clang_cc1 -triple aarch64-pc-win32 -emit-llvm < %s | FileCheck 
-check-prefix=WIN64 %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm < %s | FileCheck 
-check-prefixes=LINUX,COMMON %s
+// RUN: %clang_cc1 -triple aarch64-pc-win32 -emit-llvm < %s | FileCheck 
-check-prefixes=WIN64,COMMON %s
+
+struct small_odd {
+  char a, b, c;
+};
+
+struct larger {
+  int a, b, c, d, e;
+};
 
 void __attribute__((ms_abi)) f1(void);
 void f2(void);
@@ -48,6 +56,26 @@
   // WIN64: call void @llvm.va_end
 }
 
+void __attribute__((ms_abi)) f4_2(int a, ...) {
+  // LINUX-LABEL: define{{.*}} win64cc void @f4_2
+  // WIN64-LABEL: define dso_local void @f4_2
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap, a);
+  // COMMON: %[[AP:.*]] = alloca i8*
+  // COMMON: call void @llvm.va_start
+  struct small_odd s1 = __builtin_va_arg(ap, struct small_odd);
+  // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* 
%[[AP_CUR]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to %struct.small_odd*
+  struct larger s2 = __builtin_va_arg(ap, struct larger);
+  // COMMON: %[[AP_CUR2:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT3:.*]] = getelementptr inbounds i8, i8* 
%[[AP_CUR2]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT3]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR2]] to %struct.larger**
+  __builtin_ms_va_end(ap);
+}
+
 // Let's verify that normal va_lists work right on Win64, too.
 void f5(int a, ...) {
   // WIN64-LABEL: define dso_local void @f5
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -6121,7 +6121,13 @@
 
 Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const {
-  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false,
+  bool IsIndirect = false;
+
+  // Composites larger than 16 bytes are passed by reference.
+  if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) > 128)
+IsIndirect = true;
+
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect,
   CGF.getContext().getTypeInfoInChars(Ty),
   CharUnits::fromQuantity(8),
   /*allowHigherAlign*/ false);


Index: clang/test/CodeGen/ms_abi_aarch64.c
===
--- clang/test/CodeGen/ms_abi_aarch64.c
+++ clang/test/CodeGen/ms_abi_aarch64.c
@@ -1,5 +1,13 @@
-// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm < %s | FileCheck -check-prefix=LINUX %s
-// RUN: %clang_cc1 -triple aarch64-pc-win32 -emit-llvm < %s | FileCheck -check-prefix=WIN64 %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm < %s | FileCheck -check-prefixes=LINUX,COMMON %s
+// RUN: %clang_cc1 -triple aarch64-pc-win32 -emit-llvm < %s | FileCheck -check-prefixes=WIN64,COMMON %s
+
+struct small_odd {
+  char a, b, c;
+};
+
+struct larger {
+  int a, b, c, d, e;
+};
 
 void __attribute__((ms_abi)) f1(void);
 void f2(void);
@@ -48,6 +56,26 @@
   // WIN64: call void @llvm.va_end
 }
 
+void __attribute__((ms_abi)) f4_2(int a, ...) {
+  // LINUX-LABEL: define{{.*}} win64cc void @f4_2
+  // WIN64-LABEL: define dso_local void @f4_2
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap, a);
+  // COMMON: %[[AP:.*]] = alloca i8*
+  // COMMON: call void @llvm.va_start
+  struct small_odd s1 = __builtin_va_arg(ap, struct small_odd);
+  // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to %struct.small_odd*
+  struct larger s2 = __builtin_va_arg(ap, struct larger);
+  // COMMON: %[[AP_CUR2:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT3:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR2]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT3]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR2]] to %struct.larger**
+  __builtin_ms_va_end(ap);
+}
+
 // Let's verify that n

[PATCH] D100467: [clang] [AArch64] Fix handling of HFAs passed to Windows variadic functions

2021-04-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, efriedma, TomTan, maxim-kuvyrkov.
Herald added subscribers: danielkiss, kristof.beyls.
mstorsjo requested review of this revision.
Herald added a project: clang.

The documentation says that for variadic functions, all composites
are treated similarly, no special handling of HFAs/HVAs, not even
for the fixed arguments of a variadic function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100467

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ms_abi_aarch64.c

Index: clang/test/CodeGen/ms_abi_aarch64.c
===
--- clang/test/CodeGen/ms_abi_aarch64.c
+++ clang/test/CodeGen/ms_abi_aarch64.c
@@ -94,3 +94,39 @@
   __builtin_va_end(ap);
   // WIN64: call void @llvm.va_end
 }
+
+struct HFA {
+  float a, b, c;
+};
+
+__attribute__((ms_abi)) void msabi_hfa(struct HFA a);
+__attribute__((ms_abi)) void msabi_hfa_vararg(struct HFA a, int b, ...);
+
+void call_msabi_hfa(void) {
+  // COMMON-LABEL: define{{.*}} void @call_msabi_hfa()
+  // WIN64: call void @msabi_hfa([3 x float] {{.*}})
+  // LINUX: call win64cc void @msabi_hfa([3 x float] {{.*}})
+  msabi_hfa((struct HFA){1.0f, 2.0f, 3.0f});
+}
+
+void call_msabi_hfa_vararg(void) {
+  // COMMON-LABEL: define{{.*}} void @call_msabi_hfa_vararg()
+  // WIN64: call void ([2 x i64], i32, ...) @msabi_hfa_vararg([2 x i64] {{.*}}, i32 4, [2 x i64] {{.*}})
+  // LINUX: call win64cc void ([2 x i64], i32, ...) @msabi_hfa_vararg([2 x i64] {{.*}}, i32 4, [2 x i64] {{.*}})
+  msabi_hfa_vararg((struct HFA){1.0f, 2.0f, 3.0f}, 4,
+   (struct HFA){5.0f, 6.0f, 7.0f});
+}
+
+__attribute__((ms_abi)) void get_msabi_hfa_vararg(int a, ...) {
+  // COMMON-LABEL: define{{.*}} void @get_msabi_hfa_vararg
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap, a);
+  // COMMON: %[[AP:.*]] = alloca i8*
+  // COMMON: call void @llvm.va_start
+  struct HFA b = __builtin_va_arg(ap, struct HFA);
+  // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 16
+  // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to %struct.HFA*
+  __builtin_ms_va_end(ap);
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5418,7 +5418,8 @@
   bool isDarwinPCS() const { return Kind == DarwinPCS; }
 
   ABIArgInfo classifyReturnType(QualType RetTy, bool IsVariadic) const;
-  ABIArgInfo classifyArgumentType(QualType RetTy) const;
+  ABIArgInfo classifyArgumentType(QualType RetTy, bool IsVariadic,
+  unsigned CallingConvention) const;
   ABIArgInfo coerceIllegalVector(QualType Ty) const;
   bool isHomogeneousAggregateBaseType(QualType Ty) const override;
   bool isHomogeneousAggregateSmallEnough(const Type *Ty,
@@ -5432,7 +5433,8 @@
   classifyReturnType(FI.getReturnType(), FI.isVariadic());
 
 for (auto &it : FI.arguments())
-  it.info = classifyArgumentType(it.type);
+  it.info = classifyArgumentType(it.type, FI.isVariadic(),
+ FI.getCallingConvention());
   }
 
   Address EmitDarwinVAArg(Address VAListAddr, QualType Ty,
@@ -5635,7 +5637,9 @@
   return getNaturalAlignIndirect(Ty, /*ByVal=*/false);
 }
 
-ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty) const {
+ABIArgInfo
+AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadic,
+ unsigned CallingConvention) const {
   Ty = useFirstFieldIfTransparentUnion(Ty);
 
   // Handle illegal vector types here.
@@ -5681,7 +5685,10 @@
   // Homogeneous Floating-point Aggregates (HFAs) need to be expanded.
   const Type *Base = nullptr;
   uint64_t Members = 0;
-  if (isHomogeneousAggregate(Ty, Base, Members)) {
+  bool IsWin64 = Kind == Win64 || CallingConvention == llvm::CallingConv::Win64;
+  // In variadic functions on Windows, all composite types are treated alike,
+  // no special handling of HFAs/HVAs.
+  if (isHomogeneousAggregate(Ty, Base, Members) && (!IsWin64 || !IsVariadic)) {
 return ABIArgInfo::getDirect(
 llvm::ArrayType::get(CGT.ConvertType(QualType(Base, 0)), Members));
   }
@@ -5838,10 +5845,10 @@
   return Members <= 4;
 }
 
-Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr,
-QualType Ty,
-CodeGenFunction &CGF) const {
-  ABIArgInfo AI = classifyArgumentType(Ty);
+Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty,
+   CodeGenFunction &CGF) const {
+  ABIArgInfo AI = classifyArgumentType(Ty, /*IsVariadic=*/true,
+   CGF.CurFnInfo->getCallingConvention());
   bool IsIndirect = AI.isIndirect();
 
  

[PATCH] D100468: [clang] [test] Share patterns in CodeGen/ms_abi_aarch64.c between cases. NFC.

2021-04-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, efriedma, TomTan, maxim-kuvyrkov.
Herald added subscribers: danielkiss, kristof.beyls.
mstorsjo requested review of this revision.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100468

Files:
  clang/test/CodeGen/ms_abi_aarch64.c


Index: clang/test/CodeGen/ms_abi_aarch64.c
===
--- clang/test/CodeGen/ms_abi_aarch64.c
+++ clang/test/CodeGen/ms_abi_aarch64.c
@@ -18,8 +18,7 @@
   // LINUX: call win64cc void @f1()
   // WIN64: call void @f1()
   f2();
-  // LINUX: call void @f2()
-  // WIN64: call void @f2()
+  // COMMON: call void @f2()
 }
 // LINUX: declare win64cc void @f1()
 // LINUX: declare void @f2()
@@ -32,28 +31,19 @@
   // WIN64-LABEL: define dso_local void @f4
   __builtin_ms_va_list ap;
   __builtin_ms_va_start(ap, a);
-  // LINUX: %[[AP:.*]] = alloca i8*
-  // LINUX: call void @llvm.va_start
-  // WIN64: %[[AP:.*]] = alloca i8*
-  // WIN64: call void @llvm.va_start
+  // COMMON: %[[AP:.*]] = alloca i8*
+  // COMMON: call void @llvm.va_start
   int b = __builtin_va_arg(ap, int);
-  // LINUX: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
-  // LINUX-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], 
i64 8
-  // LINUX-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
-  // LINUX-NEXT: bitcast i8* %[[AP_CUR]] to i32*
-  // WIN64: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
-  // WIN64-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], 
i64 8
-  // WIN64-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
-  // WIN64-NEXT: bitcast i8* %[[AP_CUR]] to i32*
+  // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* 
%[[AP_CUR]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to i32*
   __builtin_ms_va_list ap2;
   __builtin_ms_va_copy(ap2, ap);
-  // LINUX: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
-  // LINUX-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
-  // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
-  // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
+  // COMMON: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
   __builtin_ms_va_end(ap);
-  // LINUX: call void @llvm.va_end
-  // WIN64: call void @llvm.va_end
+  // COMMON: call void @llvm.va_end
 }
 
 void __attribute__((ms_abi)) f4_2(int a, ...) {


Index: clang/test/CodeGen/ms_abi_aarch64.c
===
--- clang/test/CodeGen/ms_abi_aarch64.c
+++ clang/test/CodeGen/ms_abi_aarch64.c
@@ -18,8 +18,7 @@
   // LINUX: call win64cc void @f1()
   // WIN64: call void @f1()
   f2();
-  // LINUX: call void @f2()
-  // WIN64: call void @f2()
+  // COMMON: call void @f2()
 }
 // LINUX: declare win64cc void @f1()
 // LINUX: declare void @f2()
@@ -32,28 +31,19 @@
   // WIN64-LABEL: define dso_local void @f4
   __builtin_ms_va_list ap;
   __builtin_ms_va_start(ap, a);
-  // LINUX: %[[AP:.*]] = alloca i8*
-  // LINUX: call void @llvm.va_start
-  // WIN64: %[[AP:.*]] = alloca i8*
-  // WIN64: call void @llvm.va_start
+  // COMMON: %[[AP:.*]] = alloca i8*
+  // COMMON: call void @llvm.va_start
   int b = __builtin_va_arg(ap, int);
-  // LINUX: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
-  // LINUX-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
-  // LINUX-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
-  // LINUX-NEXT: bitcast i8* %[[AP_CUR]] to i32*
-  // WIN64: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
-  // WIN64-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
-  // WIN64-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
-  // WIN64-NEXT: bitcast i8* %[[AP_CUR]] to i32*
+  // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to i32*
   __builtin_ms_va_list ap2;
   __builtin_ms_va_copy(ap2, ap);
-  // LINUX: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
-  // LINUX-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
-  // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
-  // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
+  // COMMON: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
   __builtin_ms_va_end(ap);
-  // LINUX: call void @llvm.va_end
-  // WIN64: call void @llvm.va_end
+  // COMMON: call void @llvm.va_end
 }
 
 void __attribute__((ms_abi)) f4_2(int a, ...) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-04-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D80344#2684450 , @tentzen wrote:

> Hi,



> (Last call for review!!)

Please refer to https://llvm.org/docs/CodeReview.html

> Is there any more comments? This review has lasted for more than a year now. 
> I believe I had addressed or answered all questions and concerns. Thank all 
> reviewers' precious feedbacks.
> For late comers, again
> (1) Original llvm-dev [RFC] discussions can be found in these two threads 
> below:
> https://lists.llvm.org/pipermail/llvm-dev/2020-March/140541.html
> https://lists.llvm.org/pipermail/llvm-dev/2020-April/141338.html
>
> (2) John McCall had done a thorough and insightful review. please see details 
> above.



> (3) Finally, a prototype of entire Windows SEH implementation (including both 
> HW exception handling and local unwind) is stored in 
> https://github.com/tentzen/llvm-project.  This prototype had been stressed by 
> a Microsoft Windows internal SEH test suite.
> Note this check-in is just part-1 of HW exception handling.

So can you actually post the other patches as reviews?

> Could please someone accept it as a record?
> thank you!




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D100276: [clang] p1099 using enum part 1

2021-04-14 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan updated this revision to Diff 337416.
urnathan added a comment.

Remove orthogonal lbstdc++ FIXME comment


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

https://reviews.llvm.org/D100276

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3.cpp
  clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7-cxx20.cpp

Index: clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7-cxx20.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7-cxx20.cpp
@@ -0,0 +1,149 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+
+// p1099 'using SCOPEDENUM::MEMBER;'
+
+namespace Bob {
+enum class Kevin {
+  Stuart,
+  AlsoStuart
+#if __cplusplus >= 202002L
+  // expected-note@-3{{target of using declaration}}
+  // expected-note@-3{{target of using declaration}}
+#endif
+};
+}
+
+using Bob::Kevin::Stuart;
+#if __cplusplus < 202002L
+// expected-error@-2{{using declaration cannot refer to a scoped enumerator}}
+#else
+using Bob::Kevin::Stuart;
+
+auto b = Stuart;
+
+namespace Foo {
+int Stuart; // expected-note{{conflicting declaration}}
+using Bob::Kevin::Stuart; // expected-error{{target of using declaration conflicts}}
+
+using Bob::Kevin::AlsoStuart; // expected-note{{using declaration}}
+int AlsoStuart; // expected-error{{declaration conflicts with target}}
+}
+#endif
+
+
+namespace One {
+
+// derived from [namespace.udecl]/3
+enum class button { up, down };
+struct S {
+  using button::up;
+#if __cplusplus < 202002L
+  // expected-error@-2{{using declaration in class}}
+#else
+  button b = up;
+#endif
+};
+
+#if __cplusplus >= 202002L
+// some more
+struct T : S {
+  button c = up;
+};
+#endif
+enum E2 {e2};
+}
+
+namespace Two {
+enum class E1 {e1};
+
+struct S {
+  using One::e2;
+#if __cplusplus < 202002L
+  // expected-error@-2{{using declaration in class}}
+#else
+  One::E2 c = e2;
+#endif
+};
+
+}
+
+namespace Three {
+
+enum E3{e3};
+struct e3;
+
+struct S {
+  using Three::e3; // expected-error{{using declaration in class}}
+
+  enum class E4 {e4};
+  enum E5 {e5};
+};
+
+using S::e5;
+using S::E4::e4;
+#if __cplusplus < 202002L
+// expected-error@-3{{using declaration cannot refer to class member}}
+// expected-note@-4{{use a constexpr variable instead}}
+// expected-error@-4{{using declaration cannot refer to a scoped enumerator}}
+#else
+auto a = e4;
+auto b = e5;
+#endif
+}
+
+namespace Four {
+
+template
+struct TPL {
+  enum class E1 {e1};
+  struct IN {
+enum class E2 {e2};
+  };
+protected:
+  enum class E3 {e3}; // expected-note{{declared protected here}}
+};
+
+using TPL::E1::e1;
+#if __cplusplus < 202002L
+// expected-error@-2{{cannot refer to a scoped enumerator}}
+#else
+using TPL::IN::E2::e2;
+
+auto a = e1;
+auto b = e2;
+#endif
+
+enum class E4 {e4};
+template
+struct DER : TPL
+{
+  using TPL::E1::e1;
+#if __cplusplus < 202002L
+  // expected-error@-2{{'TPL::E1::', which is not a class}}
+  // expected-error@-3{{'TPL::E1::', which is not a class}}
+#endif
+  using TPL::E3::e3; // expected-error{{is a protected member}}
+#if __cplusplus < 202002L
+  // expected-error@-2{{'TPL::E3::', which is not a class}}
+  // expected-error@-3{{'TPL::E3::', which is not a class}}
+#endif
+  
+  using E4::e4;
+#if __cplusplus < 202002L
+  // expected-error@-2{{which is not a class}}
+#else
+  auto Foo () { return e1;}
+  auto Bar () { return e2;}
+#endif
+};
+
+DER x; // expected-note{{requested here}}
+DER y;
+#if __cplusplus < 202002L
+// expected-note@-2{{requested here}}
+#else
+auto y1 = y.Foo ();
+auto y2 = y.Bar ();
+#endif
+}
Index: clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3.cpp
===
--- clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3.cpp
+++ clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3.cpp
@@ -17,6 +17,7 @@
 };
 
 class C {
+public:
   int g();
 };
 
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3063,10 +3063,9 @@
   }
 
   if (!NewUD->isInvalidDecl() &&
-  SemaRef.CheckUsingDeclQualifier(D->getUsingLoc(), D->hasTypename(),
-  SS, NameInfo, D->getLocation()))
+  SemaRef.CheckUsingDeclQualifier(D->getUsingLoc(), D->hasTypename(), SS,
+  NameInfo, D->getLocation(), nullptr, D))
 NewUD->setInvalidDecl();
-
   SemaRef.Context.setInstantiatedFromUsingDecl(NewUD, D);
   NewUD->setAccess(D->getAccess());
   Owner->addDecl(NewUD);
@@ -3075,6 +3074,9 @@
   if (NewUD->isInvalidDecl(

[PATCH] D100471: [C++4OpenCL] Add extra diagnostics for kernel argument types

2021-04-14 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm created this revision.
olestrohm added reviewers: Anastasia, svenvh.
olestrohm added a project: clang.
Herald added subscribers: ldrumm, jfb, yaxunl.
olestrohm requested review of this revision.
Herald added a subscriber: cfe-commits.

Adds extra error diagnostics when using unsupported types in kernel arguments.

This fixes https://bugs.llvm.org/show_bug.cgi?id=48099


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100471

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCLCXX/invalid-kernel.clcpp


Index: clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
===
--- clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
+++ clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
@@ -5,6 +5,7 @@
 };
 
 template 
+//expected-error@+1{{'T' cannot be used as the type of a kernel parameter}}
 kernel void templ(T par) { //expected-error{{kernel functions cannot be used 
in a template declaration, instantiation or specialization}}
 }
 
@@ -15,3 +16,29 @@
 kernel void foo(int); //expected-note{{previous declaration is here}}
 
 kernel void foo(float); //expected-error{{conflicting types for 'foo'}}
+
+struct POD {
+  int a;
+  int b;
+};
+
+kernel void pod_v(POD in) {}
+kernel void pod_p(__global POD*__private in) {}
+
+struct StandardLayout {
+  int a;
+  int b;
+  StandardLayout(int a, int b) : a(a), b(b) {}
+};
+
+kernel void standard_v(StandardLayout in) {} //expected-error{{'__private 
StandardLayout' cannot be used as the type of a kernel parameter}}
+kernel void standard_p(__global StandardLayout*__private in) {}
+
+struct Trivial {
+  int a;
+private:
+  int b;
+};
+
+kernel void trivial_v(Trivial in) {} //expected-error{{'__private Trivial' 
cannot be used as the type of a kernel parameter}}
+kernel void trivial_p(__global Trivial*__private in) {} 
//expected-error{{'__global Trivial *__private' cannot be used as the type of a 
kernel parameter}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8665,6 +8665,14 @@
 
   return PtrPtrKernelParam;
 }
+
+   // C++ for OpenCL v1.0 s2.4:
+   // Moreover the types used in parameters of the kernel functions must 
be:
+   // Standard layout types for pointer parameters. The same applies to
+   // reference if an implementation supports them in kernel parameters.
+if (!PointeeType->isAtomicType() && !PointeeType->isVoidType() && 
!PointeeType->isStandardLayoutType())
+ return InvalidKernelParam;
+
 return PtrKernelParam;
   }
 
@@ -8689,9 +8697,6 @@
   PT->isHalfType())
 return InvalidKernelParam;
 
-  if (PT->isRecordType())
-return RecordKernelParam;
-
   // Look into an array argument to check if it has a forbidden type.
   if (PT->isArrayType()) {
 const Type *UnderlyingTy = PT->getPointeeOrArrayElementType();
@@ -8701,6 +8706,16 @@
 return getOpenCLKernelParameterType(S, QualType(UnderlyingTy, 0));
   }
 
+  // C++ for OpenCL v1.0 s2.4:
+  // Moreover the types used in parameters of the kernel functions must be:
+  // Trivial and standard-layout types C++17 [basic.types] (plain old data 
types)
+  // for parameters passed by value;
+  if (!PT->isOpenCLSpecificType() && !PT.isPODType(S.Context))
+return InvalidKernelParam;
+
+  if (PT->isRecordType())
+return RecordKernelParam;
+
   return ValidKernelParam;
 }
 


Index: clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
===
--- clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
+++ clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
@@ -5,6 +5,7 @@
 };
 
 template 
+//expected-error@+1{{'T' cannot be used as the type of a kernel parameter}}
 kernel void templ(T par) { //expected-error{{kernel functions cannot be used in a template declaration, instantiation or specialization}}
 }
 
@@ -15,3 +16,29 @@
 kernel void foo(int); //expected-note{{previous declaration is here}}
 
 kernel void foo(float); //expected-error{{conflicting types for 'foo'}}
+
+struct POD {
+  int a;
+  int b;
+};
+
+kernel void pod_v(POD in) {}
+kernel void pod_p(__global POD*__private in) {}
+
+struct StandardLayout {
+  int a;
+  int b;
+  StandardLayout(int a, int b) : a(a), b(b) {}
+};
+
+kernel void standard_v(StandardLayout in) {} //expected-error{{'__private StandardLayout' cannot be used as the type of a kernel parameter}}
+kernel void standard_p(__global StandardLayout*__private in) {}
+
+struct Trivial {
+  int a;
+private:
+  int b;
+};
+
+kernel void trivial_v(Trivial in) {} //expected-error{{'__private Trivial' cannot be used as the type of a kernel parameter}}
+kernel void trivial_p(__global Trivial*__private in) {} //expected-error{{'__global Trivial *__private' cannot be used as the type of a kernel parameter}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- c

[PATCH] D99503: [clang-format] Inconsistent behavior regarding line break before access modifier

2021-04-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

can you clang-format so it passes the pre-merge checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99503

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


[PATCH] D99503: [clang-format] Inconsistent behavior regarding line break before access modifier

2021-04-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:8977
+   "};\n",
+   NoEmptyLines);
   verifyFormat("struct foo {\n"

if you left a line between this test or added your test at the end it wouldn't 
have cut the existing test in two. I can't easily tell if you are changing or 
adding tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99503

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


[PATCH] D100372: [Clang][ARM] Define __VFP_FP__ macro unconditionally

2021-04-14 Thread Peter Smith via Phabricator via cfe-commits
peter.smith accepted this revision.
peter.smith added reviewers: compnerd, rengolin.
peter.smith added a comment.
This revision is now accepted and ready to land.

I think this is the right thing to do. GCC changed to unconditionally set the 
macro with https://gcc.gnu.org/legacy-ml/gcc-patches/2016-10/msg01025.html my 
understanding is that the macro means that floating point representation uses 
the VFP format and not the FPA format (predecessor to VFP, not supported by 
clang, found in very old systems), it does not mean that there is a VFP unit 
present.

see https://wiki.debian.org/ArmEabiPort for the mutually exclusive 
`__MAVERICK__` whcih refers to https://wiki.debian.org/ArmEabiMaverickCrunch 
the processor that had the FPA FPU.

I've set LGTM, and added a few more non-Arm people involved in the area for 
visibility, will be good to give them a chance to comment before committing.




Comment at: clang/lib/Basic/Targets/ARM.cpp:758
 
+  Builder.defineMacro("__VFP_FP__");
+

Worth a comment like "__VFP_FP__ means that the floating point format is VFP, 
not that a hardware FPU is present. The VFP format is the only one supported by 
clang."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100372

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


[PATCH] D96524: [OpenCL] Add support of OpenCL C 3.0 __opencl_c_fp64

2021-04-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I would prefer if we try to take a slightly different route i.e. if two 
features are identical (e.g. `cl_khr_fp64` and `__opencl_c_fp64`) we make sure 
that they are both set identical in Target options or command-line interface 
using early check and a diagnostic in the driver. This could be done at the end 
of the frontend options setup. Then for the rest of the compilation including 
header parsing, we can confidently keep checking only one of them because we 
know that they are both set consistently and that they are indeed identical. If 
you stick to checking for `cl_khr_fp64` you can avoid most of the modifications 
completely.

I have added more details in the code comments. :)




Comment at: clang/lib/Basic/OpenCLOptions.cpp:41
+  auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
+  return CLVer >= 300 ? isAvailableOption("__opencl_c_fp64", LO)
+  : isAvailableOption("cl_khr_fp64", LO);

btw since `cl_khr_fp64` is available in all versions could we not just check 
only for it?



Comment at: clang/lib/Basic/TargetInfo.cpp:398
+auto CLVer = Opts.OpenCLCPlusPlus ? 200 : Opts.OpenCLVersion;
+if (CLVer >= 300) {
+  auto &OCLOpts = getSupportedOpenCLOpts();

azabaznov wrote:
> Anastasia wrote:
> > azabaznov wrote:
> > > Anastasia wrote:
> > > > I suggest we move this onto `OpenCLOptions::addSupport`.
> > > This should stay here to control simultaneous macro definitions
> > Could we leave this bit out? These are set correctly by the targets 
> > already... and I think targets do need to set those explicitly indeed. I 
> > don't see big value in this functionality right now.
> There are 2 reasons why it should be here
> 
> 1) Simultaneous macro definition
> 
> 2) Correct option processing: we need to remove `cl_khr_fp64` macro if 
> `-cl-ext=-__opencl_c_fp64` specified
Ok as I said I would prefer to stick to an explicit interface though, i.e. 
every feature should be set explicitly
`-cl-ext=-__opencl_c_fp64,-cl_khr_fp64`
as the interface gets too messy otherwise...

I believe we won't have that many of those case - is it just fp64, fp16 and 
images?

If you are worried about the inconsistent uses (which is a valid concern!) how 
about we just add a check with a diagnostic in clang driver about the 
consistency of the setup between the language, command-line options and the 
target. We already discussed such check in other use cases - to help avoid 
using incorrect language versions that the target has no support. 

I think this route will be easier than keeping consistency automatically and 
silently overriding the options i.e. we already had bad experiences with bugs 
due to such logic. A diagnostic would be very helpful both to application 
developers and tooling developers and help to avoid extra complexity in clang 
too.



Comment at: clang/lib/Headers/opencl-c-base.h:530
 
-#ifdef cl_khr_fp64
+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
 #define as_double(x) __builtin_astype((x), double)

Let's only use one macro as they signal the same. I don't mind which one you 
choose perhaps `__opencl_c_fp64` could be used since we can freely define it in 
the earliest versions or we can continue using `cl_khr_fp64` then no changes 
are needed other then making sure it is defined when `__opencl_c_fp64` is 
defined which can be done at the top of this header btw.



Comment at: clang/lib/Headers/opencl-c.h:4635
 
-#ifdef cl_khr_fp64
+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable

Anastasia wrote:
> azabaznov wrote:
> > azabaznov wrote:
> > > Anastasia wrote:
> > > > svenvh wrote:
> > > > > Wondering if we need a similar change in 
> > > > > `clang/lib/Headers/opencl-c-base.h` to guard the double vector 
> > > > > types?
> > > > Instead of growing the guard condition, I suggest we only check for one 
> > > > for example the feature macro and then make sure the feature macro is 
> > > > defined in `opencl-c-base.h` if the extensions that aliases to the 
> > > > feature is supported. However, it would also be ok to do the opposite 
> > > > since the extensions and the corresponding features should both be 
> > > > available.
> > > > 
> > > > FYI, something similar was done in https://reviews.llvm.org/D92004.
> > > > 
> > > > This will also help to propagate the functionality into Tablegen header 
> > > > because we won't need to extend it to work with multiple extensions but 
> > > > we might still need to do the rename.
> > > Yeah, I overlooked this place... Thanks!
> > I don't think that growing of this condition will hurt in some cases... 
> > Note, that unifying condition check makes sense if some features are 
> > unconditionally supported for OpenCL C 2.0, such as generic address space 
> > for example. In other cases (such as fp64, 3d image writes, sub

[PATCH] D100466: clang-format: [JS] merge import lines.

2021-04-14 Thread Hana Joo via Phabricator via cfe-commits
h-joo added inline comments.



Comment at: clang/lib/Format/SortJavaScriptImports.cpp:154
 
+// Merge module references:
+// After sorting, find all references that import named symbols from the

Would it be better if this were a named function?



Comment at: clang/lib/Format/SortJavaScriptImports.cpp:164
+JsModuleReference *PreviousReference = &References[Indices[0]];
+auto *it = std::next(Indices.begin());
+bool ImportsMerged = false;

nit : `It`?



Comment at: clang/unittests/Format/SortImportsTestJS.cpp:333
+  // ignores default import
+  verifySort("import X from 'foo';\n"
+ "import {A} from 'foo';\n",

I'm a bit confused on what this is trying to test. Could you explain?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100466

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


[PATCH] D100396: [SYCL] Enable `opencl_global_[host,device]` attributes for SYCL

2021-04-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Ok, this looks like a straightforward addition. I will finalize this review 
once the parent review is completed though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100396

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


[PATCH] D99330: [clang-tidy] [test] Tweak a regex pattern to accommodate for quirks in MSYS based grep

2021-04-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo abandoned this revision.
mstorsjo added a comment.

Not needed, handled by D99938  for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99330

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


[PATCH] D100450: [libTooling] Add smart pointer support to the `access` Stencil

2021-04-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/unittests/Tooling/StencilTest.cpp:410
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "(*x).field");
+}

Hmm. Looks like we could use smart pointer support in tooling::buildAddressOf 
as well.  If you're interested, the code is at
clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp line 94
but I understand if you want to stop here. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100450

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


[PATCH] D100473: [clang] Implement CompilerInvocation copy assignment

2021-04-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch implements the copy assignment for `CompilerInvocation`.

Eventually, the deep-copy operation will be moved into a `clone()` method 
(D100460 ), but until then, this is necessary 
for basic ergonomics.

Depends on D100455 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100473

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -97,7 +97,7 @@
   ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
 }
 
-// Copy constructor performs a deep copy of reference-counted pointers.
+// Copy constructor/assignment perform deep copy of reference-counted pointers.
 
 TEST(CompilerInvocationTest, DeepCopyConstructor) {
   CompilerInvocation A;
@@ -109,6 +109,17 @@
   ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
 }
 
+TEST(CompilerInvocationTest, DeepCopyAssignment) {
+  CompilerInvocation A;
+  A.getAnalyzerOpts()->Config["Key"] = "Old";
+
+  CompilerInvocation B;
+  B = A;
+  B.getAnalyzerOpts()->Config["Key"] = "New";
+
+  ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypath to false.
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -125,6 +125,17 @@
   PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
   AnalyzerOpts(new AnalyzerOptions(*X.getAnalyzerOpts())) {}
 
+CompilerInvocationRefBase &
+CompilerInvocationRefBase::operator=(CompilerInvocationRefBase X) {
+  LangOpts.swap(X.LangOpts);
+  TargetOpts.swap(X.TargetOpts);
+  DiagnosticOpts.swap(X.DiagnosticOpts);
+  HeaderSearchOpts.swap(X.HeaderSearchOpts);
+  PreprocessorOpts.swap(X.PreprocessorOpts);
+  AnalyzerOpts.swap(X.AnalyzerOpts);
+  return *this;
+}
+
 CompilerInvocationRefBase::~CompilerInvocationRefBase() = default;
 
 
//===--===//
Index: clang/include/clang/Frontend/CompilerInvocation.h
===
--- clang/include/clang/Frontend/CompilerInvocation.h
+++ clang/include/clang/Frontend/CompilerInvocation.h
@@ -91,8 +91,7 @@
 
   CompilerInvocationRefBase();
   CompilerInvocationRefBase(const CompilerInvocationRefBase &X);
-  CompilerInvocationRefBase &
-  operator=(const CompilerInvocationRefBase &) = delete;
+  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase X);
   ~CompilerInvocationRefBase();
 
   LangOptions *getLangOpts() { return LangOpts.get(); }


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -97,7 +97,7 @@
   ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
 }
 
-// Copy constructor performs a deep copy of reference-counted pointers.
+// Copy constructor/assignment perform deep copy of reference-counted pointers.
 
 TEST(CompilerInvocationTest, DeepCopyConstructor) {
   CompilerInvocation A;
@@ -109,6 +109,17 @@
   ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
 }
 
+TEST(CompilerInvocationTest, DeepCopyAssignment) {
+  CompilerInvocation A;
+  A.getAnalyzerOpts()->Config["Key"] = "Old";
+
+  CompilerInvocation B;
+  B = A;
+  B.getAnalyzerOpts()->Config["Key"] = "New";
+
+  ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypath to false.
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -125,6 +125,17 @@
   PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
   AnalyzerOpts(new AnalyzerOptions(*X.getAnalyzerOpts())) {}
 
+CompilerInvocationRefBase &
+CompilerInvocationRefBase::operator=(CompilerInvocationRefBase X) {
+  LangOpts.swap(X.LangOpts);
+  TargetOpts.swap(X.TargetOpts);
+  DiagnosticOpts.swap(X.DiagnosticOpts);
+  HeaderSearchOpts.swap(X.HeaderSearchOpts);
+  PreprocessorOpts.swap(X.PreprocessorOpts);
+  AnalyzerOpts.swap(X.AnalyzerOpt

[PATCH] D99231: [AST] Add introspection support for more base nodes

2021-04-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:2270
   SourceLocation getEllipsisLoc() const {
-assert(isPackExpansion() && "Initializer is not a pack expansion");
+if (!isPackExpansion())
+  return {};

steveire wrote:
> njames93 wrote:
> > steveire wrote:
> > > njames93 wrote:
> > > > I'm not sure about this change, but I'm guessing there's not a nice way 
> > > > to predicate these kinds of things
> > > Yep.
> > @rsmith @aaron.ballman Any issues with changing the contract of these 
> > functions to not assert for the purpose of this feature?
> This was really just missing from 
> https://github.com/llvm/llvm-project/commit/54272e5b , as in the commit 
> message.
I'm fine with such a change, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99231

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


[PATCH] D100471: [C++4OpenCL] Add extra diagnostics for kernel argument types

2021-04-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCLCXX/invalid-kernel.clcpp:44
+kernel void trivial_v(Trivial in) {} //expected-error{{'__private Trivial' 
cannot be used as the type of a kernel parameter}}
+kernel void trivial_p(__global Trivial*__private in) {} 
//expected-error{{'__global Trivial *__private' cannot be used as the type of a 
kernel parameter}}

Let's also test atomic and void pointer type since you are checking it in your 
patch?

This should be extended to references btw since clang implements them as a 
pointer type so we can allow that too.

Similarly for by-value parameters - let's test an OpenCL type too. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100471

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


[clang] 856c49d - [OpenCL][Docs] Update OpenCL 3.0 implementation status

2021-04-14 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-04-14T13:56:26+01:00
New Revision: 856c49d79c0d717fb3e9ff6deebfe740a4f752e2

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

LOG: [OpenCL][Docs] Update OpenCL 3.0 implementation status

Reviewed-By: Anastasia Stulova

Added: 


Modified: 
clang/docs/OpenCLSupport.rst

Removed: 




diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index 5b5ab2b1bec0..0d5774091fb6 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -380,7 +380,7 @@ implementation status.
 
+--+--+--+---+
 | Feature optionality  | Work group collective functions   
   | :part:`worked on`| https://reviews.llvm.org/D92004 
  |
 
+--+--+--+---+
-| New functionality| RGBA vector components
   | :none:`unclaimed`| 
  |
+| New functionality| RGBA vector components
   | :good:`done` | https://reviews.llvm.org/D99969 
  |
 
+--+--+--+---+
 | New functionality| Subgroup functions
   | :part:`worked on`| https://reviews.llvm.org/D92004 
  |
 
+--+--+--+---+



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


[PATCH] D97669: [clang][AVR] Add avr-libc/include to clang system include paths

2021-04-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia resigned from this revision.
Anastasia added a comment.

In D97669#2687419 , @benshi001 wrote:

> In D97669#2685698 , @Anastasia wrote:
>
>> In D97669#2678460 , @benshi001 
>> wrote:
>>
>>> In D97669#2676826 , @Anastasia 
>>> wrote:
>>>
 In D97669#2665865 , @benshi001 
 wrote:

> In D97669#2661560 , @Anastasia 
> wrote:
>
>> Is `stdio.h`  used by anything?
>
> No. `stdio.h` is not used. But if I do `#include `, then 
> `-I /usr/lib/avr/include` must be specified in the command line option. 
> While avr-gcc does not reqiures that.
>
> I would like to keep clang & avr-gcc in the behaviour.

 Ok, do you plan to use it later? Then perhaps you should be adding it in 
 the subsequent patches?
>>>
>>> No. No future pathes are needed. The avr-libc includes standard libc 
>>> (headers and libs) and avr specific headers and libs. This patch fixes all 
>>> of these issues. Both standard libc and avr platform specific libs can be 
>>> used without any explict command line option, just like avr-gcc does.
>>
>> Ok, so your patch is adding the following file
>>
>> `clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/include/stdio.h`
>>
>> But it doesn't seem to be used at present? If you don't need it anywhere it 
>> should not be added.
>
> No. The `stdio.h` is still needed even it is not referred by any code in 
> current patch. It works as a placeholder for the directory 
> `clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/include/`, and this 
> directory is needed in the test case `clang/test/Driver/avr-toolchain.c` of 
> current patch, and this directory can not exist without `stdio.h`.

Do you know why an empty directory is not sufficient?

Overall perhaps it makes more sense if someone with more experience on AVR 
reviews this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97669

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


[clang] 92aba5a - CPUDispatch- allow out of line member definitions

2021-04-14 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-04-14T06:19:49-07:00
New Revision: 92aba5ae49a6970c43bead0afd1e52c83fe44e6e

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

LOG: CPUDispatch- allow out of line member definitions

ICC permits this, and after some extensive testing it looks like we can
support this with very little trouble.  We intentionally don't choose to
do this with attribute-target (despite it likely working as well!)
  because GCC does not support that, and introducing said
  incompatibility doesn't seem worth it.

Added: 
clang/test/CodeGenCXX/attr-cpuspecific-outoflinedefs.cpp

Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/attr-cpuspecific.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 1d57d8e84849..73303b985f3f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9693,6 +9693,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
 (D.getCXXScopeSpec().getScopeRep()->isDependent() ||
  (!Previous.empty() && CurContext->isDependentContext( {
   // ignore these
+} else if (NewFD->isCPUDispatchMultiVersion() ||
+   NewFD->isCPUSpecificMultiVersion()) {
+  // ignore this, we allow the redeclaration behavior here to create 
new
+  // versions of the function.
 } else {
   // The user tried to provide an out-of-line definition for a
   // function that is a member of a class or namespace, but there

diff  --git a/clang/test/CodeGenCXX/attr-cpuspecific-outoflinedefs.cpp 
b/clang/test/CodeGenCXX/attr-cpuspecific-outoflinedefs.cpp
new file mode 100644
index ..a34a0b88e281
--- /dev/null
+++ b/clang/test/CodeGenCXX/attr-cpuspecific-outoflinedefs.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s 
--check-prefix=LINUX
+// RUN: %clang_cc1 -triple x86_64-windows-pc -fms-compatibility -emit-llvm -o 
- %s | FileCheck %s --check-prefix=WINDOWS
+
+struct OutOfLineDefs {
+  int foo(int);
+  int foo(int, int);
+  __attribute__((cpu_specific(atom))) int foo(int, int, int) { return 1; }
+};
+
+int __attribute__((cpu_specific(atom))) OutOfLineDefs::foo(int) {
+  return 1;
+}
+int __attribute__((cpu_specific(ivybridge))) OutOfLineDefs::foo(int) {
+  return 2;
+}
+int __attribute__((cpu_dispatch(ivybridge, atom))) OutOfLineDefs::foo(int) {
+}
+
+int __attribute__((cpu_specific(atom))) OutOfLineDefs::foo(int, int) {
+  return 1;
+}
+int __attribute__((cpu_specific(ivybridge))) OutOfLineDefs::foo(int, int) {
+  return 2;
+}
+int __attribute__((cpu_dispatch(ivybridge, atom)))
+OutOfLineDefs::foo(int, int) {
+}
+
+int __attribute__((cpu_specific(ivybridge))) OutOfLineDefs::foo(int, int, int) 
{
+  return 2;
+}
+int __attribute__((cpu_specific(sandybridge)))
+OutOfLineDefs::foo(int, int, int) {
+  return 3;
+}
+int __attribute__((cpu_dispatch(sandybridge, ivybridge, atom)))
+OutOfLineDefs::foo(int, int, int) {
+}
+
+// IFunc definitions, Linux only.
+// LINUX: @_ZN13OutOfLineDefs3fooEi = weak_odr alias i32 
(%struct.OutOfLineDefs*, i32), i32 (%struct.OutOfLineDefs*, i32)* 
@_ZN13OutOfLineDefs3fooEi.ifunc
+// LINUX: @_ZN13OutOfLineDefs3fooEii = weak_odr alias i32 
(%struct.OutOfLineDefs*, i32, i32), i32 (%struct.OutOfLineDefs*, i32, i32)* 
@_ZN13OutOfLineDefs3fooEii.ifunc
+// LINUX: @_ZN13OutOfLineDefs3fooEiii = weak_odr alias i32 
(%struct.OutOfLineDefs*, i32, i32, i32), i32 (%struct.OutOfLineDefs*, i32, i32, 
i32)* @_ZN13OutOfLineDefs3fooEiii.ifunc
+
+// LINUX: @_ZN13OutOfLineDefs3fooEi.ifunc = weak_odr ifunc i32 
(%struct.OutOfLineDefs*, i32), i32 (%struct.OutOfLineDefs*, i32)* ()* 
@_ZN13OutOfLineDefs3fooEi.resolver
+// LINUX: @_ZN13OutOfLineDefs3fooEii.ifunc = weak_odr ifunc i32 
(%struct.OutOfLineDefs*, i32, i32), i32 (%struct.OutOfLineDefs*, i32, i32)* ()* 
@_ZN13OutOfLineDefs3fooEii.resolver
+// LINUX: @_ZN13OutOfLineDefs3fooEiii.ifunc = weak_odr ifunc i32 
(%struct.OutOfLineDefs*, i32, i32, i32), i32 (%struct.OutOfLineDefs*, i32, i32, 
i32)* ()* @_ZN13OutOfLineDefs3fooEiii.resolver
+
+// Arity 1 version:
+// LINUX: define dso_local i32 @_ZN13OutOfLineDefs3fooEi.O
+// LINUX: define dso_local i32 @_ZN13OutOfLineDefs3fooEi.S
+// LINUX: define weak_odr i32 (%struct.OutOfLineDefs*, i32)* 
@_ZN13OutOfLineDefs3fooEi.resolver()
+// LINUX: ret i32 (%struct.OutOfLineDefs*, i32)* @_ZN13OutOfLineDefs3fooEi.S
+// LINUX: ret i32 (%struct.OutOfLineDefs*, i32)* @_ZN13OutOfLineDefs3fooEi.O
+// LINUX: call void @llvm.trap
+
+// WINDOWS: define dso_local i32 @"?foo@OutOfLineDefs@@QEAAHH@Z.O"
+// WINDOWS: define dso_local i32 @"?foo@OutOfLineDefs@@QEAAHH@Z.S"
+// WINDOWS: define weak_odr dso_local i32 
@"?foo@OutOfLineDefs@@QEAAHH@Z"(%struct

[PATCH] D91950: [clang-format] Add BreakBeforeInlineASMColon configuration

2021-04-14 Thread Anastasiia Lukianenko via Phabricator via cfe-commits
anastasiia_lukianenko updated this revision to Diff 337433.

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

https://reviews.llvm.org/D91950

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5069,6 +5069,24 @@
 format(Input, Style));
 }
 
+TEST_F(FormatTest, BreakBeforeInlineASMColon) {
+  FormatStyle Style = getLLVMStyle();
+
+  Style.BreakBeforeInlineASMColon = false;
+  verifyFormat("asm volatile(\"string\", : : val);", Style);
+  verifyFormat("asm volatile(\"string\", : val1 : val2);", Style);
+
+  Style.BreakBeforeInlineASMColon = true;
+  verifyFormat("asm volatile(\"string\",\n"
+   " :\n"
+   " : val);",
+   Style);
+  verifyFormat("asm volatile(\"string\",\n"
+   " : val1\n"
+   " : val2);",
+   Style);
+}
+
 TEST_F(FormatTest, BreakConstructorInitializersAfterColon) {
   FormatStyle Style = getLLVMStyle();
   Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3514,6 +3514,9 @@
   const FormatToken &Left = *Right.Previous;
   if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0)
 return true;
+  if (Line.startsWith(tok::kw_asm) && Right.is(TT_InlineASMColon) &&
+  Style.BreakBeforeInlineASMColon)
+return true;
 
   if (Style.isCSharp()) {
 if (Right.is(TT_CSharpNamedArgumentColon) ||
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -554,6 +554,9 @@
 Style.BreakInheritanceList == FormatStyle::BILS_BeforeColon)
   Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
 
+IO.mapOptional("BreakBeforeInlineASMColon",
+   Style.BreakBeforeInlineASMColon);
+
 IO.mapOptional("BreakBeforeTernaryOperators",
Style.BreakBeforeTernaryOperators);
 
@@ -940,6 +943,7 @@
   LLVMStyle.BinPackParameters = true;
   LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   LLVMStyle.BreakBeforeConceptDeclarations = true;
+  LLVMStyle.BreakBeforeInlineASMColon = false;
   LLVMStyle.BreakBeforeTernaryOperators = true;
   LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
   LLVMStyle.BraceWrapping = {/*AfterCaseLabel=*/false,
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1685,6 +1685,18 @@
   /// \endcode
   bool BreakBeforeConceptDeclarations;
 
+  /// If ``true``, colons in ASM parameters will be placed after line breaks.
+  /// \code
+  ///true:
+  ///asm volatile("string",
+  /// :
+  /// : val);
+  ///
+  ///false:
+  ///asm volatile("string", : : val);
+  /// \endcode
+  bool BreakBeforeInlineASMColon;
+
   /// If ``true``, ternary operators will be placed after line breaks.
   /// \code
   ///true:
@@ -3184,6 +3196,7 @@
BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
BreakBeforeBraces == R.BreakBeforeBraces &&
BreakBeforeConceptDeclarations == R.BreakBeforeConceptDeclarations &&
+   BreakBeforeInlineASMColon == R.BreakBeforeInlineASMColon &&
BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
BreakConstructorInitializers == R.BreakConstructorInitializers &&
CompactNamespaces == R.CompactNamespaces &&
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -1899,7 +1899,18 @@
   * ``BS_Custom`` (in configuration: ``Custom``)
 Configure each individual brace in `BraceWrapping`.
 
+**BreakBeforeInlineASMColon** (``bool``)
+  If ``true``, colons in ASM parameters will be placed after line breaks.
 
+  .. code-block:: c
+
+ true:
+  asm volatile("string",
+   :
+   : val);
+
+ false:
+  asm volatile("string", : : val);
 
 **BreakBeforeConceptDeclarations** (``bool``)
   If ``true``, concept will be placed on a new line.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-14 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 337441.
bader marked 5 inline comments as done.
bader added a comment.

Applied more comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenSYCL/address-space-conversions.cpp
  clang/test/CodeGenSYCL/address-space-deduction.cpp
  clang/test/SemaSYCL/address-space-conversions.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388593)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388590)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x71>();
+  correct<0x7FFFED>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: clang/test/SemaSYCL/address-space-conversions.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/address-space-conversions.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fsycl-is-device -verify -fsyntax-only %s
+
+void bar(int &Data) {}
+void bar2(int &Data) {}
+void bar(__attribute__((opencl_private)) int &Data) {}
+void foo(int *Data) {}
+void foo2(int *Data) {}
+void foo(__attribute__((opencl_private)) int *Data) {}
+void baz(__attribute__((opencl_private)) int *Data) {} // expected-note {{candidate function not viable: cannot pass pointer to generic address space as a pointer to address space '__private' in 1st argument}}
+
+template 
+void tmpl(T *t) {}
+
+void usages() {
+  __attribute__((opencl_global)) int *GLOB;
+  __attribute__((opencl_private)) int *PRIV;
+  __attribute__((opencl_local)) int *LOC;
+  int *NoAS;
+
+  GLOB = PRIV; // expected-error {{assigning '__private int *' to '__global int *' changes address space of pointer}}
+  GLOB = LOC; // expected-error {{assigning '__local int *' to '__global int *' changes address space of pointer}}
+  PRIV = static_cast<__attribute__((opencl_private)) int *>(GLOB); // expected-error {{static_cast from '__global int *' to '__private int *' is not allowed}}
+  PRIV = static_cast<__attribute__((opencl_private)) int *>(LOC); // expected-error {{static_cast from '__local int *' to '__private int *' is not allowed}}
+  NoAS = GLOB + PRIV; // expected-error {{invalid operands to binary expression ('__global int *' and '__private int *')}}
+  NoAS = GLOB + LOC; // expected-error {{invalid operands to binary expression ('__global int *' and '__local int *')}}
+  NoAS += GLOB; // expected-error {{invalid operands to binary expression ('int *' and '__global int *')}}
+
+  bar(*GLOB);
+  bar2(*GLOB);
+
+  bar(*PRIV);
+  bar2(*PRIV);
+
+  bar(*NoAS);
+  bar2(*NoAS);
+
+  bar(*LOC);
+  bar2(*LOC);
+
+  foo(GLOB);
+  foo2(GLOB);
+  foo(PRIV);
+  foo2(PRIV);
+  foo(NoAS);
+  foo2(NoAS);
+  foo(LOC);
+  foo2(LOC);
+
+  tmpl(GLOB);
+  tmpl(PRIV);
+  tmpl(NoAS);
+  tmpl(LOC);
+
+  // Implicit casts to named address space are disallowed
+  baz(NoAS); // expected-error {{no matching function for call to 'baz'}}
+  __attribute__((opencl_local)) int *l = NoAS; // expected-error {{cannot initialize a variable of type '__local int *' with an lvalue of type 'int *'}}
+
+  (void)static_cast(GLOB);
+  (void)static_cast(GLOB);
+  int *i = GLOB;
+  void *v = GLOB;
+  (void)i;
+  (void)v;
+}
Index: clang/test/CodeGenSYCL/address-space-deduction.cpp
===
--- /dev/null
+++ clang/test/CodeGenSYCL/address-space-deduction.cpp
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
+
+// CHECK:@_ZZ4testvE3foo = internal addrspace(1) constant i32 66, align 4
+// CHECK: @[[STR:[.a-zA-Z0-9_]+]] = private unnamed_a

[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-14 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:2379
   unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
-  if (TargetAS != 0)
+  if (TargetAS != 0 || Context.getASTContext().getLangOpts().SYCLIsDevice)
 ASString = "AS" + llvm::utostr(TargetAS);

Anastasia wrote:
> bader wrote:
> > Anastasia wrote:
> > > bader wrote:
> > > > Anastasia wrote:
> > > > > Any reason not to use OpenCL mangling? If you do then you might be 
> > > > > able to link against libraries compiled for OpenCL. Also you will get 
> > > > > more stable naming i.e. it would not differ from target to target. 
> > > > > Any reason not to use OpenCL mangling? If you do then you might be 
> > > > > able to link against libraries compiled for OpenCL. Also you will get 
> > > > > more stable naming i.e. it would not differ from target to target. 
> > > > 
> > > > I'm not sure I understand your suggestion. Could you elaborate on 
> > > > "OpenCL mangling", please?
> > > > 
> > > > Let me clarify the problem this change addresses. The test case 
> > > > covering it is located in 
> > > > `clang/test/CodeGenSYCL/address-space-parameter-conversions.cpp` lines 
> > > > 86-91.
> > > > 
> > > > ```
> > > > template 
> > > > void tmpl(T t) {}
> > > > 
> > > > int *NoAS;
> > > > __attribute__((opencl_private)) int *PRIV;
> > > > 
> > > > tmpl(PRIV);
> > > > // CHECK-DAG: [[PRIV_LOAD5:%[a-zA-Z0-9]+]] = load i32*, i32* 
> > > > addrspace(4)* [[PRIV]].ascast
> > > > // CHECK-DAG: call spir_func void [[PRIV_TMPL:@[a-zA-Z0-9_]+]](i32* 
> > > > [[PRIV_LOAD5]])
> > > > tmpl(NoAS);
> > > > // CHECK-DAG: [[NoAS_LOAD5:%[a-zA-Z0-9]+]] = load i32 addrspace(4)*, 
> > > > i32 addrspace(4)* addrspace(4)* [[NoAS]].ascast
> > > > // CHECK-DAG: call spir_func void [[GEN_TMPL:@[a-zA-Z0-9_]+]](i32 
> > > > addrspace(4)* [[NoAS_LOAD5]])
> > > > ```
> > > > Clang has separate code paths for mangling types w/ and w/o address 
> > > > space attributes (i.e. using `Default` address space).
> > > > 
> > > > Address space is not mangled if there is no AS attribute (`Default`) or 
> > > > if address space attribute is maps to `0` target address space. SPIR 
> > > > target maps `*_private` address space to `0`, which causes name 
> > > > conflict for the example above.
> > > > 
> > > > This change for SYCL compiler enables mangling for non-default address 
> > > > space attributes regardless of their mapping to target address space.
> > > It's just that all language address spaces are mangled with the source 
> > > spelling in Italium ABI right now, if you check the `else` statement. I 
> > > don't think it is part of the official spec yet but it might be better to 
> > > stick to the same pattern if possible.
> > > It's just that all language address spaces are mangled with the source 
> > > spelling in Italium ABI right now, if you check the `else` statement. I 
> > > don't think it is part of the official spec yet but it might be better to 
> > > stick to the same pattern if possible.
> > 
> > I would really love to avoid changes to the mangler (e.g. to be able to 
> > link binaries produced by different front-end like SYCL/OpenCL/CUDA), but I 
> > don't know the better way to address the issue 
> > Sorry, I don't get what do you suggest here. Could you clarify what exactly 
> > I should change, please?
> For now I am just trying to understand why you are not adopting similar 
> mangling scheme as for other language address spaces since it gives more 
> stable mangling irrespective from the target compiled for.
> 
> If you plan to link libraries from other frontends i.e. OpenCL or CUDA the 
> mangling you use is different from what they produce. Just have a look at the 
>  line 2470 that explains OpenCL mangling or line 2494 explaining CUDA 
> mangling. FYI similar scheme applies to other language address spaces, so the 
> `AS` was only really used for the address spaces that have no source 
> spelling i.e. no language semantics.
> For now I am just trying to understand why you are not adopting similar 
> mangling scheme as for other language address spaces since it gives more 
> stable mangling irrespective from the target compiled for.

According to my understanding this code is used for other language spaces. For 
instance, per comments at lines 2455-2457 it's used for OpenCL and CUDA address 
spaces.
Do you mean some other mangling scheme?

> If you plan to link libraries from other frontends i.e. OpenCL or CUDA the 
> mangling you use is different from what they produce. 

SYCL standard doesn't have such functionality. OpenCL C functions are not 
mangled (only built-ins), so there should be no problem to link with OpenCL C 
libraries. 
I know that mangling difference causes some problems for SYCL built-ins 
implementations on CUDA, but I don't know all the details. @Naghasan knows 
about these. @Naghasan, do you have suggestions to fix the problems caused by 
mangling?

> Jus

[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-14 Thread Greg Rodgers via Phabricator via cfe-commits
gregrodgers requested changes to this revision.
gregrodgers added a comment.
This revision now requires changes to proceed.

I have two serious concerns with this tool .  1.  It does not provide the 
infrastructure to identify runtime capabilities to satisfy requirements of a 
compiled image.   2.  It is not architecturally neutral or extensible to other 
architectures.  I have a different proposed tool called offload-arch .   Here 
is the help text for offload-arch.

grodgers@r4:/tmp/grodgers/git/aomp13/llvm-project/clang/tools/offload-arch/build$
 ./offload-arch -h

  offload-arch: Print offload architecture(s) for the current active system.
or lookup information about offload architectures
  
  Usage:
offload-arch [ Options ] [ Optional lookup-value ]
  
With no options, offload-arch prints a value for first offload architecture
found in current system.  This value can be used by various clang frontends.
For example, to compile for openmp offloading on current current system
one could invoke clang with the following command:
  
clang -fopenmp -openmp-targets=`offload-arch` foo.c
  
If an optional lookup-value is specified, offload-arch will
check if the value is either a valid offload-arch or a codename
and lookup requested additional information. For example,
this provides all information for offload-arch gfx906:
  
offload-arch gfx906 -v
  
Options:
-h  Print this help message
-a  Print values for all devices. Don't stop at first device found.
-c  Print codename
-n  Print numeric pci-id
-t  Print recommended offload triple.
-v  Verbose = -a -c -n -t
-l  Print long codename found in pci.ids file
-r  Print capabilities of current system to satisfy runtime requirements
of compiled offload images.  This option is used by the runtime to
choose correct image when multiple compiled images are availble.
  
The alias amdgpu-arch returns 1 if no amdgcn GPU is found.
The alias nvidia-arch returns 1 if no cuda GPU is found.
These aliases are useful to determine if architecture-specific tests
should be run. Or these aliases could be used to conditionally load
archecture-specific software.
  
  Copyright (c) 2021 ADVANCED MICRO DEVICES, INC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D97653: [clang-tidy] Fix RenamerClangTidy checks breaking lambda captures.

2021-04-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D97653#2681458 , @njames93 wrote:

> Use implicit capture instead of default capture.
>
> @aaron.ballman, Unfortunately the AST dump tests don't work as implicit 
> captures don't appear to show up in the textual representation.

Yeah, I was suggesting to add that as part of this patch so it'd be testable. 
We currently print something like `-DeclRefExpr  'int' lvalue Var 
0x55b0ddc7f808 'b' 'int'` and I think if we changed 
`TextNodeDumper::VisitDeclRefExpr()` to also print out 
`RefersToEnclosingVariableOrCapture` and `RefersToImplicitCapture` only when 
they're set, we could output something like: `-DeclRefExpr  'int' 
lvalue Var 0x55b0ddc7f808 'b' 'int' implicit_capture` or `-DeclRefExpr  
'int' lvalue Var 0x55b0ddc7f808 'b' 'int' explicit_capture`, which would be 
useful (in addition to making your changes testable). WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97653

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


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-14 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D99949#2688869 , @gregrodgers wrote:

> 1. It does not provide the infrastructure to identify runtime capabilities to 
> satisfy requirements of a compiled image.

I believe we only require a value for '-march=' to unblock running tests on CI 
machines. I'd guess you're referring to target id stuff where clang fills in 
reasonable defaults already.

In D99949#2688869 , @gregrodgers wrote:

> 2. It is not architecturally neutral or extensible to other architectures.

Yes. By design. Clang calling into some unrelated tool for nvptx seems fine, 
nvidia-smi may already suffice for that purpose.

If we want to do something clever about guessing whether the machine has an 
nvidia card or an amdgpu one, clang can call both this tool and the nvidia one, 
and check both return codes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D100480: Add flag for showing skipped headers in -H / --show-includes output

2021-04-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added reviewers: thakis, rnk.
Herald added subscribers: jansvoboda11, dang.
hans requested review of this revision.
Herald added a project: clang.

Consider the following set of files:

  a.cc:
  #include "a.h"
  
  a.h:
  #ifndef A_H
  #define A_H
  
  #include "b.h"
  #include "c.h"  // This gets "skipped".
  
  #endif
  
  b.h:
  #ifndef B_H
  #define B_H
  
  #include "c.h"
  
  #endif
  
  c.h:
  #ifndef C_H
  #define C_H
  
  void c();
  
  #endif

And the output of the -H option:

  $ clang -c -H a.cc
  . ./a.h
  .. ./b.h
  ... ./c.h

Note that the include of `c.h` in `a.h` is not shown in the output. (GCC does 
the same.) This is because of the include guard optimization: clang knows `c.h` 
is covered by an include guard which is already defined, so when it sees the 
include in `a.h`, it skips it. The same would have happened if `#pragma once` 
were used instead of include guards.

However, `a.h` *does* include `c.h`, and it may be useful to show that in the 
`-H` output. This patch adds a flag for doing that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100480

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/DependencyOutputOptions.h
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/test/Frontend/Inputs/test.h
  clang/test/Frontend/Inputs/test2.h
  clang/test/Frontend/print-header-includes.c

Index: clang/test/Frontend/print-header-includes.c
===
--- clang/test/Frontend/print-header-includes.c
+++ clang/test/Frontend/print-header-includes.c
@@ -6,6 +6,16 @@
 // CHECK-NOT: . {{.*noline.h}}
 // CHECK: . {{.*test.h}}
 // CHECK: .. {{.*test2.h}}
+// CHECK-NOT: .. {{.*test2.h}}
+
+// RUN: %clang_cc1 -I%S -isystem %S/Inputs/SystemHeaderPrefix \
+// RUN: -E -H -show-skipped-includes -o /dev/null %s 2> %t.stderr
+// RUN: FileCheck --check-prefix=SKIPPED < %t.stderr %s
+
+// SKIPPED-NOT: . {{.*noline.h}}
+// SKIPPED: . {{.*test.h}}
+// SKIPPED: .. {{.*test2.h}}
+// SKIPPED: .. {{.*test2.h}}
 
 // RUN: %clang_cc1 -I%S -include Inputs/test3.h -isystem %S/Inputs/SystemHeaderPrefix \
 // RUN: -E -H -sys-header-deps -o /dev/null %s 2> %t.stderr
Index: clang/test/Frontend/Inputs/test2.h
===
--- clang/test/Frontend/Inputs/test2.h
+++ clang/test/Frontend/Inputs/test2.h
@@ -1 +1,6 @@
+#ifndef TEST2_H
+#define TEST2_H
+
 int x;
+
+#endif
Index: clang/test/Frontend/Inputs/test.h
===
--- clang/test/Frontend/Inputs/test.h
+++ clang/test/Frontend/Inputs/test.h
@@ -1 +1,7 @@
+#ifndef TEST_H
+#define TEST_H
+
 #include "test2.h"
+#include "test2.h"
+
+#endif
Index: clang/lib/Frontend/HeaderIncludeGen.cpp
===
--- clang/lib/Frontend/HeaderIncludeGen.cpp
+++ clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -45,6 +45,9 @@
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override;
+
+  void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
+   SrcMgr::CharacteristicKind FileType) override;
 };
 }
 
@@ -181,3 +184,16 @@
 MSStyle);
   }
 }
+
+void HeaderIncludesCallback::FileSkipped(const FileEntryRef &SkippedFile, const
+ Token &FilenameTok,
+ SrcMgr::CharacteristicKind FileType) {
+  if (!DepOpts.ShowSkippedHeaderIncludes)
+return;
+
+  if (!DepOpts.IncludeSystemHeaders && isSystem(FileType))
+return;
+
+  PrintHeaderInfo(OutputFile, SkippedFile.getName(), ShowDepth,
+  CurrentIncludeDepth + 1, MSStyle);
+}
Index: clang/include/clang/Frontend/DependencyOutputOptions.h
===
--- clang/include/clang/Frontend/DependencyOutputOptions.h
+++ clang/include/clang/Frontend/DependencyOutputOptions.h
@@ -39,6 +39,10 @@
  /// problems.
   unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list
   unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
+  unsigned ShowSkippedHeaderIncludes : 1; ///< With ShowHeaderIncludes, show
+  /// also includes that were skipped
+  /// due to the "include guard
+  /// optimization" or #pragma once.
 
   /// Destination of cl.exe style /showIncludes info.
   ShowIncludesDestination ShowIncludesDest = ShowIncludesDestination::None;
@@ -75,7 +79,8 @@
 public:
   DependencyOutputOptions()
   : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
-AddMissingHeaderDeps(0), IncludeModuleFiles(0) {}
+AddMissingHeaderDeps(

[PATCH] D100471: [C++4OpenCL] Add extra diagnostics for kernel argument types

2021-04-14 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 337450.
olestrohm added a comment.

Added more exhaustive tests, as well as fixed the diagnostic to allow reference 
types.


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

https://reviews.llvm.org/D100471

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCLCXX/invalid-kernel.clcpp

Index: clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
===
--- clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
+++ clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
@@ -5,6 +5,7 @@
 };
 
 template 
+//expected-error@+1{{'T' cannot be used as the type of a kernel parameter}}
 kernel void templ(T par) { //expected-error{{kernel functions cannot be used in a template declaration, instantiation or specialization}}
 }
 
@@ -15,3 +16,51 @@
 kernel void foo(int); //expected-note{{previous declaration is here}}
 
 kernel void foo(float); //expected-error{{conflicting types for 'foo'}}
+
+kernel void int_v(int in);
+kernel void int_p(__global int *in);
+kernel void int_r(__global int &in);
+kernel void int_p_p(__global int *__global *in);
+kernel void int_p_r(__global int *__global &in);
+kernel void int_p_p_r(__global int *__global *__global &in);
+
+// expected-error@+1{{'__private atomic_int' (aka '__private _Atomic(int)') cannot be used as the type of a kernel parameter}}
+kernel void k_atomic_v(atomic_int in);
+kernel void k_atomic_p(__global atomic_int *in);
+kernel void k_atomic_r(__global atomic_int &in);
+
+kernel void k_pipe(read_only pipe int in, write_only pipe int out);
+kernel void k_sampler(sampler_t in);
+kernel void k_void(__global void *in);
+
+struct POD {
+  int a;
+  int b;
+};
+
+kernel void pod_v(POD in) {}
+kernel void pod_p(__global POD *in) {}
+kernel void pod_p_p(__global POD *__global *in) {}
+kernel void pod_r(__global POD &in) {}
+
+struct StandardLayout {
+  int a;
+  int b;
+  StandardLayout(int a, int b) : a(a), b(b) {}
+};
+
+kernel void standard_v(StandardLayout in) {} //expected-error{{'__private StandardLayout' cannot be used as the type of a kernel parameter}}
+kernel void standard_p(__global StandardLayout *in) {}
+kernel void standard_p_p(__global StandardLayout *__global *in) {}
+kernel void standard_r(__global StandardLayout &in) {}
+
+struct Trivial {
+  int a;
+private:
+  int b;
+};
+
+kernel void trivial_v(Trivial in) {} //expected-error{{'__private Trivial' cannot be used as the type of a kernel parameter}}
+kernel void trivial_p(__global Trivial *in) {} //expected-error{{'__global Trivial *__private' cannot be used as the type of a kernel parameter}}
+kernel void trivial_p_p(__global Trivial *__global *in) {} //expected-error{{'__global Trivial *__global *__private' cannot be used as the type of a kernel parameter}}
+kernel void trivial_r(__global Trivial &in) {} //expected-error{{'__global Trivial &__private' cannot be used as the type of a kernel parameter}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8648,7 +8648,7 @@
 }
 
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
-  if (PT->isPointerType()) {
+  if (PT->isPointerType() || PT->isReferenceType()) {
 QualType PointeeType = PT->getPointeeType();
 if (PointeeType.getAddressSpace() == LangAS::opencl_generic ||
 PointeeType.getAddressSpace() == LangAS::opencl_private ||
@@ -8665,6 +8665,15 @@
 
   return PtrPtrKernelParam;
 }
+
+// C++ for OpenCL v1.0 s2.4:
+// Moreover the types used in parameters of the kernel functions must be:
+// Standard layout types for pointer parameters. The same applies to
+// reference if an implementation supports them in kernel parameters.
+if (!PointeeType->isAtomicType() && !PointeeType->isVoidType() &&
+!PointeeType->isStandardLayoutType())
+  return InvalidKernelParam;
+
 return PtrKernelParam;
   }
 
@@ -8689,9 +8698,6 @@
   PT->isHalfType())
 return InvalidKernelParam;
 
-  if (PT->isRecordType())
-return RecordKernelParam;
-
   // Look into an array argument to check if it has a forbidden type.
   if (PT->isArrayType()) {
 const Type *UnderlyingTy = PT->getPointeeOrArrayElementType();
@@ -8701,6 +8707,16 @@
 return getOpenCLKernelParameterType(S, QualType(UnderlyingTy, 0));
   }
 
+  // C++ for OpenCL v1.0 s2.4:
+  // Moreover the types used in parameters of the kernel functions must be:
+  // Trivial and standard-layout types C++17 [basic.types] (plain old data
+  // types) for parameters passed by value;
+  if (!PT->isOpenCLSpecificType() && !PT.isPODType(S.Context))
+return InvalidKernelParam;
+
+  if (PT->isRecordType())
+return RecordKernelParam;
+
   return ValidKernelParam;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[PATCH] D100466: clang-format: [JS] merge import lines.

2021-04-14 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 337456.
mprobst added a comment.

address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100466

Files:
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/SortImportsTestJS.cpp

Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -319,6 +319,10 @@
  "\n"
  "X + Y + Z;\n");
 
+  // merge only, no resorting.
+  verifySort("import {A, B} from 'foo';\n", "import {A} from 'foo';\n"
+"import {B} from 'foo';");
+
   // empty imports
   verifySort("import {A} from 'foo';\n", "import {} from 'foo';\n"
  "import {A} from 'foo';");
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -87,6 +87,9 @@
   StringRef DefaultImport;
   // Symbols from `import {SymbolA, SymbolB, ...} from ...;`.
   SmallVector Symbols;
+  // Whether some symbols were merged into this one. Controls if the module
+  // reference needs re-formatting.
+  bool SymbolsMerged;
   // The source location just after { and just before } in the import.
   // Extracted eagerly to allow modification of Symbols later on.
   SourceLocation SymbolsStart, SymbolsEnd;
@@ -151,40 +154,7 @@
 });
 bool ReferencesInOrder = llvm::is_sorted(Indices);
 
-// Merge module references:
-// After sorting, find all references that import named symbols from the
-// same URL and merge their names. E.g.
-//   import {X} from 'a';
-//   import {Y} from 'a';
-// should be rewritten to:
-//   import {X, Y} from 'a';
-// Note: this removes merged imports from Indices, but not from References.
-// The loop below iterates Indices, so things work out.
-JsModuleReference *PreviousReference = &References[Indices[0]];
-auto *it = std::next(Indices.begin());
-bool ImportsMerged = false;
-while (it != std::end(Indices)) {
-  JsModuleReference *Reference = &References[*it];
-  // Skip:
-  //   import 'foo';
-  //   import * as foo from 'foo'; on either previous or this.
-  //   import Default from 'foo'; on either previous or this.
-  //   mismatching
-  if (Reference->Category == JsModuleReference::SIDE_EFFECT ||
-  !PreviousReference->Prefix.empty() || !Reference->Prefix.empty() ||
-  !PreviousReference->DefaultImport.empty() ||
-  !Reference->DefaultImport.empty() || Reference->Symbols.empty() ||
-  PreviousReference->URL != Reference->URL) {
-PreviousReference = Reference;
-++it;
-continue;
-  }
-  // Merge symbols from identical imports.
-  PreviousReference->Symbols.append(Reference->Symbols);
-  ImportsMerged = true;
-  // Remove the merged import.
-  it = Indices.erase(it);
-}
+mergeModuleReferences(References, Indices);
 
 std::string ReferencesText;
 bool SymbolsInOrder = true;
@@ -203,8 +173,7 @@
   ReferencesText += "\n";
   }
 }
-
-if (ReferencesInOrder && SymbolsInOrder && !ImportsMerged)
+if (ReferencesInOrder && SymbolsInOrder)
   return {Result, 0};
 
 SourceRange InsertionPoint = References[0].Range;
@@ -279,22 +248,61 @@
SM.getFileOffset(End) - SM.getFileOffset(Begin));
   }
 
+  // Merge module references.
+  // After sorting, find all references that import named symbols from the
+  // same URL and merge their names. E.g.
+  //   import {X} from 'a';
+  //   import {Y} from 'a';
+  // should be rewritten to:
+  //   import {X, Y} from 'a';
+  // Note: this modifies the passed in ``Indices`` vector (by removing no longer
+  // needed references), but not ``References``.
+  // ``JsModuleReference``s that get merged have the ``SymbolsMerged`` flag
+  // flipped to true.
+  void mergeModuleReferences(SmallVector &References,
+ SmallVector &Indices) {
+JsModuleReference *PreviousReference = &References[Indices[0]];
+auto *It = std::next(Indices.begin());
+while (It != std::end(Indices)) {
+  JsModuleReference *Reference = &References[*It];
+  // Skip:
+  //   import 'foo';
+  //   import * as foo from 'foo'; on either previous or this.
+  //   import Default from 'foo'; on either previous or this.
+  //   mismatching
+  if (Reference->Category == JsModuleReference::SIDE_EFFECT ||
+  !PreviousReference->Prefix.empty() || !Reference->Prefix.empty() ||
+  !PreviousReference->DefaultImport.empty() ||
+  !Reference->DefaultImport.empty() || Reference->Symb

[PATCH] D99501: ignore -flto= options recognized by GCC

2021-04-14 Thread Matthias Klose via Phabricator via cfe-commits
doko added a comment.

that's now https://reviews.llvm.org/D100484


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99501

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


[PATCH] D100466: clang-format: [JS] merge import lines.

2021-04-14 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked 3 inline comments as done.
mprobst added inline comments.



Comment at: clang/lib/Format/SortJavaScriptImports.cpp:92
+  // reference needs re-formatting.
+  bool SymbolsMerged;
   // The source location just after { and just before } in the import.

FYI I restructured the algorithm a bit here.



Comment at: clang/unittests/Format/SortImportsTestJS.cpp:333
+  // ignores default import
+  verifySort("import X from 'foo';\n"
+ "import {A} from 'foo';\n",

h-joo wrote:
> I'm a bit confused on what this is trying to test. Could you explain?
This makes sure we don't collapse `import * as foo` imports with `import {A}` 
style imports.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100466

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


[PATCH] D100480: Add flag for showing skipped headers in -H / --show-includes output

2021-04-14 Thread Hans Wennborg 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 rGf29dcbdde10c: Add flag for showing skipped headers in -H / 
--show-includes output (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100480

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/DependencyOutputOptions.h
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/test/Frontend/Inputs/test.h
  clang/test/Frontend/Inputs/test2.h
  clang/test/Frontend/print-header-includes.c

Index: clang/test/Frontend/print-header-includes.c
===
--- clang/test/Frontend/print-header-includes.c
+++ clang/test/Frontend/print-header-includes.c
@@ -6,6 +6,16 @@
 // CHECK-NOT: . {{.*noline.h}}
 // CHECK: . {{.*test.h}}
 // CHECK: .. {{.*test2.h}}
+// CHECK-NOT: .. {{.*test2.h}}
+
+// RUN: %clang_cc1 -I%S -isystem %S/Inputs/SystemHeaderPrefix \
+// RUN: -E -H -show-skipped-includes -o /dev/null %s 2> %t.stderr
+// RUN: FileCheck --check-prefix=SKIPPED < %t.stderr %s
+
+// SKIPPED-NOT: . {{.*noline.h}}
+// SKIPPED: . {{.*test.h}}
+// SKIPPED: .. {{.*test2.h}}
+// SKIPPED: .. {{.*test2.h}}
 
 // RUN: %clang_cc1 -I%S -include Inputs/test3.h -isystem %S/Inputs/SystemHeaderPrefix \
 // RUN: -E -H -sys-header-deps -o /dev/null %s 2> %t.stderr
Index: clang/test/Frontend/Inputs/test2.h
===
--- clang/test/Frontend/Inputs/test2.h
+++ clang/test/Frontend/Inputs/test2.h
@@ -1 +1,6 @@
+#ifndef TEST2_H
+#define TEST2_H
+
 int x;
+
+#endif
Index: clang/test/Frontend/Inputs/test.h
===
--- clang/test/Frontend/Inputs/test.h
+++ clang/test/Frontend/Inputs/test.h
@@ -1 +1,7 @@
+#ifndef TEST_H
+#define TEST_H
+
 #include "test2.h"
+#include "test2.h"
+
+#endif
Index: clang/lib/Frontend/HeaderIncludeGen.cpp
===
--- clang/lib/Frontend/HeaderIncludeGen.cpp
+++ clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -45,6 +45,9 @@
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override;
+
+  void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
+   SrcMgr::CharacteristicKind FileType) override;
 };
 }
 
@@ -181,3 +184,16 @@
 MSStyle);
   }
 }
+
+void HeaderIncludesCallback::FileSkipped(const FileEntryRef &SkippedFile, const
+ Token &FilenameTok,
+ SrcMgr::CharacteristicKind FileType) {
+  if (!DepOpts.ShowSkippedHeaderIncludes)
+return;
+
+  if (!DepOpts.IncludeSystemHeaders && isSystem(FileType))
+return;
+
+  PrintHeaderInfo(OutputFile, SkippedFile.getName(), ShowDepth,
+  CurrentIncludeDepth + 1, MSStyle);
+}
Index: clang/include/clang/Frontend/DependencyOutputOptions.h
===
--- clang/include/clang/Frontend/DependencyOutputOptions.h
+++ clang/include/clang/Frontend/DependencyOutputOptions.h
@@ -39,6 +39,10 @@
  /// problems.
   unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list
   unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
+  unsigned ShowSkippedHeaderIncludes : 1; ///< With ShowHeaderIncludes, show
+  /// also includes that were skipped
+  /// due to the "include guard
+  /// optimization" or #pragma once.
 
   /// Destination of cl.exe style /showIncludes info.
   ShowIncludesDestination ShowIncludesDest = ShowIncludesDestination::None;
@@ -75,7 +79,8 @@
 public:
   DependencyOutputOptions()
   : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
-AddMissingHeaderDeps(0), IncludeModuleFiles(0) {}
+AddMissingHeaderDeps(0), IncludeModuleFiles(0),
+ShowSkippedHeaderIncludes(0) {}
 };
 
 }  // end namespace clang
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4945,6 +4945,11 @@
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
+def show_skipped_includes : Flag<["-"], "show-skipped-includes">,
+  HelpText<"Show skipped includes in -H output.">,
+  DocBrief<[{#include files may be "skipped" due to include guard optimization
+ or #pragma once. This flag makes -H show also such includes.}]>,
+  Marshal

[clang] f29dcbd - Add flag for showing skipped headers in -H / --show-includes output

2021-04-14 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-04-14T17:01:51+02:00
New Revision: f29dcbdde10c86cfd89196fc2aa0e7f6ca3c9c4e

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

LOG: Add flag for showing skipped headers in -H / --show-includes output

Consider the following set of files:

  a.cc:
  #include "a.h"

  a.h:
  #ifndef A_H
  #define A_H

  #include "b.h"
  #include "c.h"  // This gets "skipped".

  #endif

  b.h:
  #ifndef B_H
  #define B_H

  #include "c.h"

  #endif

  c.h:
  #ifndef C_H
  #define C_H

  void c();

  #endif

And the output of the -H option:

  $ clang -c -H a.cc
  . ./a.h
  .. ./b.h
  ... ./c.h

Note that the include of c.h in a.h is not shown in the output (GCC does the
same). This is because of the include guard optimization: clang knows c.h is
covered by an include guard which is already defined, so when it sees the
include in a.h, it skips it. The same would have happened if #pragma once were
used instead of include guards.

However, a.h *does* include c.h, and it may be useful to show that in the -H
output. This patch adds a flag for doing that.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/DependencyOutputOptions.h
clang/lib/Frontend/HeaderIncludeGen.cpp
clang/test/Frontend/Inputs/test.h
clang/test/Frontend/Inputs/test2.h
clang/test/Frontend/print-header-includes.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 24bb3b8c34c7..9e15712eb2d5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4945,6 +4945,11 @@ def fdenormal_fp_math_f32_EQ : Joined<["-"], 
"fdenormal-fp-math-f32=">,
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
+def show_skipped_includes : Flag<["-"], "show-skipped-includes">,
+  HelpText<"Show skipped includes in -H output.">,
+  DocBrief<[{#include files may be "skipped" due to include guard optimization
+ or #pragma once. This flag makes -H show also such includes.}]>,
+  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;

diff  --git a/clang/include/clang/Frontend/DependencyOutputOptions.h 
b/clang/include/clang/Frontend/DependencyOutputOptions.h
index 433e3ede11c5..0c151935e842 100644
--- a/clang/include/clang/Frontend/DependencyOutputOptions.h
+++ b/clang/include/clang/Frontend/DependencyOutputOptions.h
@@ -39,6 +39,10 @@ class DependencyOutputOptions {
  /// problems.
   unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency 
list
   unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
+  unsigned ShowSkippedHeaderIncludes : 1; ///< With ShowHeaderIncludes, show
+  /// also includes that were skipped
+  /// due to the "include guard
+  /// optimization" or #pragma once.
 
   /// Destination of cl.exe style /showIncludes info.
   ShowIncludesDestination ShowIncludesDest = ShowIncludesDestination::None;
@@ -75,7 +79,8 @@ class DependencyOutputOptions {
 public:
   DependencyOutputOptions()
   : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
-AddMissingHeaderDeps(0), IncludeModuleFiles(0) {}
+AddMissingHeaderDeps(0), IncludeModuleFiles(0),
+ShowSkippedHeaderIncludes(0) {}
 };
 
 }  // end namespace clang

diff  --git a/clang/lib/Frontend/HeaderIncludeGen.cpp 
b/clang/lib/Frontend/HeaderIncludeGen.cpp
index df3f5345775a..1ee47d8d2480 100644
--- a/clang/lib/Frontend/HeaderIncludeGen.cpp
+++ b/clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -45,6 +45,9 @@ class HeaderIncludesCallback : public PPCallbacks {
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override;
+
+  void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
+   SrcMgr::CharacteristicKind FileType) override;
 };
 }
 
@@ -181,3 +184,16 @@ void HeaderIncludesCallback::FileChanged(SourceLocation 
Loc,
 MSStyle);
   }
 }
+
+void HeaderIncludesCallback::FileSkipped(const FileEntryRef &SkippedFile, const
+ Token &FilenameTok,
+ SrcMgr::CharacteristicKind FileType) {
+  if (!DepOpts.ShowSkippedHeaderIncludes)
+return;
+
+  if (!DepOpts.IncludeSystemHeaders && isSystem

[PATCH] D100466: clang-format: [JS] merge import lines.

2021-04-14 Thread Hana Joo via Phabricator via cfe-commits
h-joo accepted this revision.
h-joo added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100466

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


[clang] d45df0d - clang-format: [JS] merge import lines.

2021-04-14 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2021-04-14T17:20:07+02:00
New Revision: d45df0d29f7005d3c25357f3982002eaf339f875

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

LOG: clang-format: [JS] merge import lines.

Multiple lines importing from the same URL can be merged:

import {X} from 'a';
import {Y} from 'a';

Merge to:

import {X, Y} from 'a';

This change implements this merge operation. It takes care not to merge in
various corner case situations (default imports, star imports).

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

Added: 


Modified: 
clang/lib/Format/SortJavaScriptImports.cpp
clang/unittests/Format/SortImportsTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/SortJavaScriptImports.cpp 
b/clang/lib/Format/SortJavaScriptImports.cpp
index db2b65b088988..c1cf3de153256 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -83,8 +83,13 @@ struct JsModuleReference {
   // Prefix from "import * as prefix". Empty for symbol imports and `export *`.
   // Implies an empty names list.
   StringRef Prefix;
+  // Default import from "import DefaultName from '...';".
+  StringRef DefaultImport;
   // Symbols from `import {SymbolA, SymbolB, ...} from ...;`.
   SmallVector Symbols;
+  // The source location just after { and just before } in the import.
+  // Extracted eagerly to allow modification of Symbols later on.
+  SourceLocation SymbolsStart, SymbolsEnd;
   // Textual position of the import/export, including preceding and trailing
   // comments.
   SourceRange Range;
@@ -146,6 +151,41 @@ class JavaScriptImportSorter : public TokenAnalyzer {
 });
 bool ReferencesInOrder = llvm::is_sorted(Indices);
 
+// Merge module references:
+// After sorting, find all references that import named symbols from the
+// same URL and merge their names. E.g.
+//   import {X} from 'a';
+//   import {Y} from 'a';
+// should be rewritten to:
+//   import {X, Y} from 'a';
+// Note: this removes merged imports from Indices, but not from References.
+// The loop below iterates Indices, so things work out.
+JsModuleReference *PreviousReference = &References[Indices[0]];
+auto *it = std::next(Indices.begin());
+bool ImportsMerged = false;
+while (it != std::end(Indices)) {
+  JsModuleReference *Reference = &References[*it];
+  // Skip:
+  //   import 'foo';
+  //   import * as foo from 'foo'; on either previous or this.
+  //   import Default from 'foo'; on either previous or this.
+  //   mismatching
+  if (Reference->Category == JsModuleReference::SIDE_EFFECT ||
+  !PreviousReference->Prefix.empty() || !Reference->Prefix.empty() ||
+  !PreviousReference->DefaultImport.empty() ||
+  !Reference->DefaultImport.empty() || Reference->Symbols.empty() ||
+  PreviousReference->URL != Reference->URL) {
+PreviousReference = Reference;
+++it;
+continue;
+  }
+  // Merge symbols from identical imports.
+  PreviousReference->Symbols.append(Reference->Symbols);
+  ImportsMerged = true;
+  // Remove the merged import.
+  it = Indices.erase(it);
+}
+
 std::string ReferencesText;
 bool SymbolsInOrder = true;
 for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
@@ -164,7 +204,7 @@ class JavaScriptImportSorter : public TokenAnalyzer {
   }
 }
 
-if (ReferencesInOrder && SymbolsInOrder)
+if (ReferencesInOrder && SymbolsInOrder && !ImportsMerged)
   return {Result, 0};
 
 SourceRange InsertionPoint = References[0].Range;
@@ -245,20 +285,18 @@ class JavaScriptImportSorter : public TokenAnalyzer {
 // Sort the individual symbols within the import.
 // E.g. `import {b, a} from 'x';` -> `import {a, b} from 'x';`
 SmallVector Symbols = Reference.Symbols;
-llvm::stable_sort(
-Symbols, [&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) 
{
-  return LHS.Symbol.compare_lower(RHS.Symbol) < 0;
-});
-if (Symbols == Reference.Symbols) {
-  // No change in symbol order.
+if (Symbols.empty()) {
+  // No symbol imports, just emit the entire module reference.
   StringRef ReferenceStmt = getSourceText(Reference.Range);
   Buffer += ReferenceStmt;
   return false;
 }
+llvm::stable_sort(
+Symbols, [&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) 
{
+  return LHS.Symbol.compare_lower(RHS.Symbol) < 0;
+});
 // Stitch together the module reference start...
-SourceLocation SymbolsStart = Reference.Symbols.front().Range.getBegin();
-SourceLocation SymbolsEnd = Reference.Symbols.back().Range.getEnd();
-Buffer += getS

[clang] 4d195f1 - review comments

2021-04-14 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2021-04-14T17:20:08+02:00
New Revision: 4d195f1b4dd6e3978776d69f49840439933a2543

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

LOG: review comments

track symbol merge status in references to avoid excesive rewrites

Added: 


Modified: 
clang/lib/Format/SortJavaScriptImports.cpp
clang/unittests/Format/SortImportsTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/SortJavaScriptImports.cpp 
b/clang/lib/Format/SortJavaScriptImports.cpp
index c1cf3de15325..fdc2408ec1ec 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -87,6 +87,9 @@ struct JsModuleReference {
   StringRef DefaultImport;
   // Symbols from `import {SymbolA, SymbolB, ...} from ...;`.
   SmallVector Symbols;
+  // Whether some symbols were merged into this one. Controls if the module
+  // reference needs re-formatting.
+  bool SymbolsMerged;
   // The source location just after { and just before } in the import.
   // Extracted eagerly to allow modification of Symbols later on.
   SourceLocation SymbolsStart, SymbolsEnd;
@@ -151,40 +154,7 @@ class JavaScriptImportSorter : public TokenAnalyzer {
 });
 bool ReferencesInOrder = llvm::is_sorted(Indices);
 
-// Merge module references:
-// After sorting, find all references that import named symbols from the
-// same URL and merge their names. E.g.
-//   import {X} from 'a';
-//   import {Y} from 'a';
-// should be rewritten to:
-//   import {X, Y} from 'a';
-// Note: this removes merged imports from Indices, but not from References.
-// The loop below iterates Indices, so things work out.
-JsModuleReference *PreviousReference = &References[Indices[0]];
-auto *it = std::next(Indices.begin());
-bool ImportsMerged = false;
-while (it != std::end(Indices)) {
-  JsModuleReference *Reference = &References[*it];
-  // Skip:
-  //   import 'foo';
-  //   import * as foo from 'foo'; on either previous or this.
-  //   import Default from 'foo'; on either previous or this.
-  //   mismatching
-  if (Reference->Category == JsModuleReference::SIDE_EFFECT ||
-  !PreviousReference->Prefix.empty() || !Reference->Prefix.empty() ||
-  !PreviousReference->DefaultImport.empty() ||
-  !Reference->DefaultImport.empty() || Reference->Symbols.empty() ||
-  PreviousReference->URL != Reference->URL) {
-PreviousReference = Reference;
-++it;
-continue;
-  }
-  // Merge symbols from identical imports.
-  PreviousReference->Symbols.append(Reference->Symbols);
-  ImportsMerged = true;
-  // Remove the merged import.
-  it = Indices.erase(it);
-}
+mergeModuleReferences(References, Indices);
 
 std::string ReferencesText;
 bool SymbolsInOrder = true;
@@ -203,8 +173,7 @@ class JavaScriptImportSorter : public TokenAnalyzer {
   ReferencesText += "\n";
   }
 }
-
-if (ReferencesInOrder && SymbolsInOrder && !ImportsMerged)
+if (ReferencesInOrder && SymbolsInOrder)
   return {Result, 0};
 
 SourceRange InsertionPoint = References[0].Range;
@@ -279,22 +248,61 @@ class JavaScriptImportSorter : public TokenAnalyzer {
SM.getFileOffset(End) - 
SM.getFileOffset(Begin));
   }
 
+  // Merge module references.
+  // After sorting, find all references that import named symbols from the
+  // same URL and merge their names. E.g.
+  //   import {X} from 'a';
+  //   import {Y} from 'a';
+  // should be rewritten to:
+  //   import {X, Y} from 'a';
+  // Note: this modifies the passed in ``Indices`` vector (by removing no 
longer
+  // needed references), but not ``References``.
+  // ``JsModuleReference``s that get merged have the ``SymbolsMerged`` flag
+  // flipped to true.
+  void mergeModuleReferences(SmallVector &References,
+ SmallVector &Indices) {
+JsModuleReference *PreviousReference = &References[Indices[0]];
+auto *It = std::next(Indices.begin());
+while (It != std::end(Indices)) {
+  JsModuleReference *Reference = &References[*It];
+  // Skip:
+  //   import 'foo';
+  //   import * as foo from 'foo'; on either previous or this.
+  //   import Default from 'foo'; on either previous or this.
+  //   mismatching
+  if (Reference->Category == JsModuleReference::SIDE_EFFECT ||
+  !PreviousReference->Prefix.empty() || !Reference->Prefix.empty() ||
+  !PreviousReference->DefaultImport.empty() ||
+  !Reference->DefaultImport.empty() || Reference->Symbols.empty() ||
+  PreviousReference->URL != Reference->URL) {
+PreviousReference = Reference;
+++It;
+c

[PATCH] D100466: clang-format: [JS] merge import lines.

2021-04-14 Thread Martin Probst via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
mprobst marked an inline comment as done.
Closed by commit rGd45df0d29f70: clang-format: [JS] merge import lines. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D100466?vs=337456&id=337464#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100466

Files:
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/SortImportsTestJS.cpp

Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -307,6 +307,52 @@
  "import {A} from 'a';\n");
 }
 
+TEST_F(SortImportsTestJS, MergeImports) {
+  // basic operation
+  verifySort("import {X, Y} from 'a';\n"
+ "import {Z} from 'z';\n"
+ "\n"
+ "X + Y + Z;\n",
+ "import {X} from 'a';\n"
+ "import {Z} from 'z';\n"
+ "import {Y} from 'a';\n"
+ "\n"
+ "X + Y + Z;\n");
+
+  // empty imports
+  verifySort("import {A} from 'foo';\n", "import {} from 'foo';\n"
+ "import {A} from 'foo';");
+
+  // ignores import *
+  verifySort("import * as foo from 'foo';\n"
+ "import {A} from 'foo';\n",
+ "import   * as foo from 'foo';\n"
+ "import {A} from 'foo';\n");
+
+  // ignores default import
+  verifySort("import X from 'foo';\n"
+ "import {A} from 'foo';\n",
+ "importX from 'foo';\n"
+ "import {A} from 'foo';\n");
+
+  // keeps comments
+  // known issue: loses the 'also a' comment.
+  verifySort("// a\n"
+ "import {/* x */ X, /* y */ Y} from 'a';\n"
+ "// z\n"
+ "import {Z} from 'z';\n"
+ "\n"
+ "X + Y + Z;\n",
+ "// a\n"
+ "import {/* y */ Y} from 'a';\n"
+ "// z\n"
+ "import {Z} from 'z';\n"
+ "// also a\n"
+ "import {/* x */ X} from 'a';\n"
+ "\n"
+ "X + Y + Z;\n");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -83,8 +83,13 @@
   // Prefix from "import * as prefix". Empty for symbol imports and `export *`.
   // Implies an empty names list.
   StringRef Prefix;
+  // Default import from "import DefaultName from '...';".
+  StringRef DefaultImport;
   // Symbols from `import {SymbolA, SymbolB, ...} from ...;`.
   SmallVector Symbols;
+  // The source location just after { and just before } in the import.
+  // Extracted eagerly to allow modification of Symbols later on.
+  SourceLocation SymbolsStart, SymbolsEnd;
   // Textual position of the import/export, including preceding and trailing
   // comments.
   SourceRange Range;
@@ -146,6 +151,41 @@
 });
 bool ReferencesInOrder = llvm::is_sorted(Indices);
 
+// Merge module references:
+// After sorting, find all references that import named symbols from the
+// same URL and merge their names. E.g.
+//   import {X} from 'a';
+//   import {Y} from 'a';
+// should be rewritten to:
+//   import {X, Y} from 'a';
+// Note: this removes merged imports from Indices, but not from References.
+// The loop below iterates Indices, so things work out.
+JsModuleReference *PreviousReference = &References[Indices[0]];
+auto *it = std::next(Indices.begin());
+bool ImportsMerged = false;
+while (it != std::end(Indices)) {
+  JsModuleReference *Reference = &References[*it];
+  // Skip:
+  //   import 'foo';
+  //   import * as foo from 'foo'; on either previous or this.
+  //   import Default from 'foo'; on either previous or this.
+  //   mismatching
+  if (Reference->Category == JsModuleReference::SIDE_EFFECT ||
+  !PreviousReference->Prefix.empty() || !Reference->Prefix.empty() ||
+  !PreviousReference->DefaultImport.empty() ||
+  !Reference->DefaultImport.empty() || Reference->Symbols.empty() ||
+  PreviousReference->URL != Reference->URL) {
+PreviousReference = Reference;
+++it;
+continue;
+  }
+  // Merge symbols from identical imports.
+  PreviousReference->Symbols.append(Reference->Symbols);
+  ImportsMerged = true;
+  // Remove the merged import.
+  it = Indices.erase(it);
+}
+
 std::string ReferencesText;
 bool SymbolsInOrder = true;
 for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
@@ -164,7 +204,7 @@
   }
 }
 
-   

[PATCH] D100161: Redistribute energy for Corpus

2021-04-14 Thread taotao gu via Phabricator via cfe-commits
gtt1995 added a comment.

Hello.
Due to the time zone difference, I think our communication is a bit 
inefficient. Can we arrange a convenient time for you to focus on the 
discussion?
We use CST.
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100161

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


[PATCH] D100484: add test case for ignoring -flto=auto and -flto=jobserver

2021-04-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D100484

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


[PATCH] D99501: ignore -flto= options recognized by GCC

2021-04-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

Just approved the test case patch. Sorry I missed the lack of test on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99501

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


[PATCH] D100488: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

2021-04-14 Thread Jonathan Crowther via Phabricator via cfe-commits
Jonathan.Crowther created this revision.
Jonathan.Crowther added reviewers: abhina.sreeskantharajan, anirudhp, muiez, 
zibi, yusra.syeda, rnk, amccarth.
Herald added subscribers: wenlei, hiraditya.
Jonathan.Crowther requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Add the `IsText` argument to `GetFile` and `GetFileOrSTDIN` which will help 
z/OS distinguish between text and binary correctly. This is an extension to 
this patch 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100488

Files:
  clang/tools/driver/cc1as_main.cpp
  llvm/lib/AsmParser/Parser.cpp
  llvm/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/Testing/Support/SupportHelpers.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp

Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -343,7 +343,7 @@
   Triple TheTriple(TripleName);
 
   ErrorOr> BufferPtr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (std::error_code EC = BufferPtr.getError()) {
 WithColor::error(errs(), ProgName)
 << InputFilename << ": " << EC.message() << '\n';
Index: llvm/tools/llvm-ifs/llvm-ifs.cpp
===
--- llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -182,7 +182,7 @@
 static Expected> readInputFile(StringRef FilePath) {
   // Read in file.
   ErrorOr> BufOrError =
-  MemoryBuffer::getFileOrSTDIN(FilePath);
+  MemoryBuffer::getFileOrSTDIN(FilePath, /*IsText=*/true);
   if (!BufOrError)
 return createStringError(BufOrError.getError(), "Could not open `%s`",
  FilePath.data());
Index: llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
===
--- llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -334,7 +334,7 @@
 Expected
 InstructionBenchmark::readYaml(const LLVMState &State, StringRef Filename) {
   if (auto ExpectedMemoryBuffer =
-  errorOrToExpected(MemoryBuffer::getFile(Filename))) {
+  errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) {
 yaml::Input Yin(*ExpectedMemoryBuffer.get());
 YamlContext Context(State);
 InstructionBenchmark Benchmark;
@@ -351,7 +351,7 @@
 Expected>
 InstructionBenchmark::readYamls(const LLVMState &State, StringRef Filename) {
   if (auto ExpectedMemoryBuffer =
-  errorOrToExpected(MemoryBuffer::getFile(Filename))) {
+  errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) {
 yaml::Input Yin(*ExpectedMemoryBuffer.get());
 YamlContext Context(State);
 std::vector Benchmarks;
Index: llvm/lib/Testing/Support/SupportHelpers.cpp
===
--- llvm/lib/Testing/Support/SupportHelpers.cpp
+++ llvm/lib/Testing/Support/SupportHelpers.cpp
@@ -40,7 +40,7 @@
 
   EXPECT_TRUE(Found) << "Unit test source directory file does not exist.";
 
-  auto File = MemoryBuffer::getFile(InputFilePath);
+  auto File = MemoryBuffer::getFile(InputFilePath, /*IsText=*/true);
 
   EXPECT_TRUE(static_cast(File))
   << "Could not open unit test source directory file.";
Index: llvm/lib/ProfileData/SampleProfReader.cpp
===
--- llvm/lib/ProfileData/SampleProfReader.cpp
+++ llvm/lib/ProfileData/SampleProfReader.cpp
@@ -1575,7 +1575,7 @@
 /// \returns an error code indicating the status of the buffer.
 static ErrorOr>
 setupMemoryBuffer(const Twine &Filename) {
-  auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename);
+  auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
   if (std::error_code EC = BufferOrErr.getError())
 return EC;
   auto Buffer = std::move(BufferOrErr.get());
Index: llvm/lib/ProfileData/InstrProfReader.cpp
===
--- llvm/lib/ProfileData/InstrProfReader.cpp
+++ llvm/lib/ProfileData/InstrProfReader.cpp
@@ -41,7 +41,7 @@
 static Expected>
 setupMemoryBuffer(const Twine &Path) {
   ErrorOr> BufferOrErr =
-  MemoryBuffer::getFileOrSTDIN(Path);
+  MemoryBuffer::getFileOrSTDIN(Path, /*IsText=*/true);
   if (std::error_code EC = BufferOrErr.getError())
 return errorCodeToError(EC);
   return std::move(BufferOrErr.get());
Index: llvm/lib/CodeGen/MIRParser/MIRParser.cpp
===
--- llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ llvm/lib/CodeGen/MIRParser/MIRParser

[PATCH] D100368: [X86] Support some missing intrinsics

2021-04-14 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/avx512fintrin.h:9593
+/// locations starting at location \a base_addr at packed 32-bit integer 
indices
+/// stored in the lower half of \a vindex scaled by \a scale them in dst.
+///

"scale them in dst" doesn't make sense.



Comment at: clang/lib/Headers/avx512fintrin.h:9611
+/// starting at location \a base_addr at packed 32-bit integer indices stored 
in
+/// the lower half of \a vindex scaled by \a scale into dst using writemask
+/// \a mask (elements are copied from \a src when the corresponding mask bit is

Use of "dst" here doesn't make sense since it isn't a parameter name so 
shouldn't be abbreviated.



Comment at: clang/lib/Headers/avx512fintrin.h:9636
+/// at packed 32-bit integer indices stored in the lower half of \a vindex
+/// scaled by \a scale and stores them in dst.
+///

Same



Comment at: clang/lib/Headers/avx512fintrin.h:9654
+/// at packed 32-bit integer indices stored in the lower half of \a vindex
+/// scaled by \a scale and stores them in dst using writemask \a mask (elements
+/// are copied from \a src when the corresponding mask bit is not set).

Same



Comment at: clang/test/CodeGen/X86/avx512f-builtins.c:10853
+
+__m512i test_mm512_mask_i32logather_epi64(__m512i __v1_old, __mmask8 __mask, 
__m512i __index, void const *__addr) {
+  // CHECK-LABEL: @test_mm512_mask_i32logather_epi64

Any idea why _mm512_mask_i32loscatter_epi64 is documented as only being KNCI?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100368

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


[PATCH] D100161: Redistribute energy for Corpus

2021-04-14 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

At this point I am not convinced this patch will provide benefit for the 
default use case when `-entropic=1`.  I am hesitant to add complexity to the 
code for unsure benefit.

If you request a FuzzBench experiment 

 to get some data on this, and the results look good, then I'll be willing to 
invest more time into reviewing this patch.

Please CC me on the FuzzBench pull request, so I can make sure we are 
evaluating this properly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100161

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


[PATCH] D100492: [OpenCL] Change OpenCL builtin version encoding

2021-04-14 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: azabaznov.
svenvh added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

Instead of using a MinVersion and MaxVersion field, encode the version
of a builtin using a mask that aligns better with version handling in
OpenCLOptions.h.  In addition, this saves a field in the BuiltinTable.

This change allows a finer-grained control over the OpenCL versions in
which a builtin is available: instead of a range, we can now toggle
each version individually.

The fine-grained version control is not yet exposed on the TableGen
definitions side, as changes for OpenCL 3 feature optionality still
need to be defined and will affect how we want to expose these.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100492

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp


Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -339,10 +339,8 @@
   const bool IsConv : 1;
   // OpenCL extension(s) required for this overload.
   const unsigned short Extension;
-  // First OpenCL version in which this overload was introduced (e.g. CL20).
-  const unsigned short MinVersion;
-  // First OpenCL version in which this overload was removed (e.g. CL20).
-  const unsigned short MaxVersion;
+  // OpenCL versions in which this overload is available.
+  const unsigned short Versions;
 };
 
 )";
@@ -490,6 +488,29 @@
   OS << "};\n\n";
 }
 
+// Encode a range MinVersion..MaxVersion into a single bit mask that can be
+// checked against LangOpts using isOpenCLVersionContainedInMask().
+// This must be kept in sync with OpenCLVersionID in OpenCLOptions.h.
+// (Including OpenCLOptions.h here would be a layering violation.)
+static unsigned short EncodeVersions(unsigned int MinVersion,
+ unsigned int MaxVersion) {
+  unsigned short Encoded = 0;
+
+  // A maximum version of 0 means available in all later versions.
+  if (MaxVersion == 0) {
+MaxVersion = UINT_MAX;
+  }
+
+  unsigned VersionIDs[] = {100, 110, 120, 200, 300};
+  for (unsigned I = 0; I < sizeof(VersionIDs) / sizeof(VersionIDs[0]); I++) {
+if (VersionIDs[I] >= MinVersion && VersionIDs[I] < MaxVersion) {
+  Encoded |= 1 << I;
+}
+  }
+
+  return Encoded;
+}
+
 void BuiltinNameEmitter::EmitBuiltinTable() {
   unsigned Index = 0;
 
@@ -510,9 +531,10 @@
  << (Overload.first->getValueAsBit("IsConst")) << ", "
  << (Overload.first->getValueAsBit("IsConv")) << ", "
  << FunctionExtensionIndex[ExtName] << ", "
- << Overload.first->getValueAsDef("MinVersion")->getValueAsInt("ID")
- << ", "
- << Overload.first->getValueAsDef("MaxVersion")->getValueAsInt("ID")
+ << EncodeVersions(Overload.first->getValueAsDef("MinVersion")
+   ->getValueAsInt("ID"),
+   Overload.first->getValueAsDef("MaxVersion")
+   ->getValueAsInt("ID"))
  << " },\n";
   Index++;
 }
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -798,19 +798,16 @@
   // as argument.  Only meaningful for generic types, otherwise equals 1.
   unsigned GenTypeMaxCnt;
 
+  ASTContext &Context = S.Context;
+
   for (unsigned SignatureIndex = 0; SignatureIndex < Len; SignatureIndex++) {
 const OpenCLBuiltinStruct &OpenCLBuiltin =
 BuiltinTable[FctIndex + SignatureIndex];
-ASTContext &Context = S.Context;
 
-// Ignore this BIF if its version does not match the language options.
-unsigned OpenCLVersion = Context.getLangOpts().OpenCLVersion;
-if (Context.getLangOpts().OpenCLCPlusPlus)
-  OpenCLVersion = 200;
-if (OpenCLVersion < OpenCLBuiltin.MinVersion)
-  continue;
-if ((OpenCLBuiltin.MaxVersion != 0) &&
-(OpenCLVersion >= OpenCLBuiltin.MaxVersion))
+// Ignore this builtin function if it is not available in the currently
+// selected language version.
+if (!isOpenCLVersionContainedInMask(Context.getLangOpts(),
+OpenCLBuiltin.Versions))
   continue;
 
 // Ignore this builtin function if it carries an extension macro that is


Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -339,10 +339,8 @@
   const bool IsConv : 1;
   // OpenCL extension(s) required for this overload.
   const unsigned short Extension;
-  // First OpenCL version in which this o

[clang] af7ab81 - [WebAssembly] Use standard intrinsics for f32x4 and f64x2 ops

2021-04-14 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-04-14T09:19:27-07:00
New Revision: af7ab81ce3104418b4971b2398c1e028238ed90f

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

LOG: [WebAssembly] Use standard intrinsics for f32x4 and f64x2 ops

Now that these instructions are no longer prototypes, we do not need to be
careful about keeping them opt-in and can use the standard LLVM infrastructure
for them. This commit removes the bespoke intrinsics we were using to represent
these operations in favor of the corresponding target-independent intrinsics.
The clang builtins are preserved because there is no standard way to easily
represent these operations in C/C++.

For consistency with the scalar codegen in the Wasm backend, the intrinsic used
to represent {f32x4,f64x2}.nearest is @llvm.nearbyint even though
@llvm.roundeven better captures the semantics of the underlying Wasm
instruction. Replacing our use of @llvm.nearbyint with use of @llvm.roundeven is
left to a potential future patch.

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/CodeGen/WebAssembly/simd-unsupported.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 439b378306550..b9e3110da8345 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17136,19 +17136,19 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 switch (BuiltinID) {
 case WebAssembly::BI__builtin_wasm_ceil_f32x4:
 case WebAssembly::BI__builtin_wasm_ceil_f64x2:
-  IntNo = Intrinsic::wasm_ceil;
+  IntNo = Intrinsic::ceil;
   break;
 case WebAssembly::BI__builtin_wasm_floor_f32x4:
 case WebAssembly::BI__builtin_wasm_floor_f64x2:
-  IntNo = Intrinsic::wasm_floor;
+  IntNo = Intrinsic::floor;
   break;
 case WebAssembly::BI__builtin_wasm_trunc_f32x4:
 case WebAssembly::BI__builtin_wasm_trunc_f64x2:
-  IntNo = Intrinsic::wasm_trunc;
+  IntNo = Intrinsic::trunc;
   break;
 case WebAssembly::BI__builtin_wasm_nearest_f32x4:
 case WebAssembly::BI__builtin_wasm_nearest_f64x2:
-  IntNo = Intrinsic::wasm_nearest;
+  IntNo = Intrinsic::nearbyint;
   break;
 default:
   llvm_unreachable("unexpected builtin ID");

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index c27be6d909c08..7b7965c026e1a 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -792,49 +792,49 @@ f64x2 pmax_f64x2(f64x2 x, f64x2 y) {
 
 f32x4 ceil_f32x4(f32x4 x) {
   return __builtin_wasm_ceil_f32x4(x);
-  // WEBASSEMBLY: call <4 x float> @llvm.wasm.ceil.v4f32(<4 x float> %x)
+  // WEBASSEMBLY: call <4 x float> @llvm.ceil.v4f32(<4 x float> %x)
   // WEBASSEMBLY: ret
 }
 
 f32x4 floor_f32x4(f32x4 x) {
   return __builtin_wasm_floor_f32x4(x);
-  // WEBASSEMBLY: call <4 x float> @llvm.wasm.floor.v4f32(<4 x float> %x)
+  // WEBASSEMBLY: call <4 x float> @llvm.floor.v4f32(<4 x float> %x)
   // WEBASSEMBLY: ret
 }
 
 f32x4 trunc_f32x4(f32x4 x) {
   return __builtin_wasm_trunc_f32x4(x);
-  // WEBASSEMBLY: call <4 x float> @llvm.wasm.trunc.v4f32(<4 x float> %x)
+  // WEBASSEMBLY: call <4 x float> @llvm.trunc.v4f32(<4 x float> %x)
   // WEBASSEMBLY: ret
 }
 
 f32x4 nearest_f32x4(f32x4 x) {
   return __builtin_wasm_nearest_f32x4(x);
-  // WEBASSEMBLY: call <4 x float> @llvm.wasm.nearest.v4f32(<4 x float> %x)
+  // WEBASSEMBLY: call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %x)
   // WEBASSEMBLY: ret
 }
 
 f64x2 ceil_f64x2(f64x2 x) {
   return __builtin_wasm_ceil_f64x2(x);
-  // WEBASSEMBLY: call <2 x double> @llvm.wasm.ceil.v2f64(<2 x double> %x)
+  // WEBASSEMBLY: call <2 x double> @llvm.ceil.v2f64(<2 x double> %x)
   // WEBASSEMBLY: ret
 }
 
 f64x2 floor_f64x2(f64x2 x) {
   return __builtin_wasm_floor_f64x2(x);
-  // WEBASSEMBLY: call <2 x double> @llvm.wasm.floor.v2f64(<2 x double> %x)
+  // WEBASSEMBLY: call <2 x double> @llvm.floor.v2f64(<2 x double> %x)
   // WEBASSEMBLY: ret
 }
 
 f64x2 trunc_f64x2(f64x2 x) {
   return __builtin_wasm_trunc_f64x2(x);
-  // WEBASSEMBLY: call <2 x double> @llvm.wasm.trunc.v2f64(<2 x double> %x)
+  // WEBASSEMBLY: call <2 x double> @llvm.trunc.v2f64(<2 x double> %x)
   // WEBASSEMBLY: ret
 }
 
 f64x2 nearest_f64x2(f64x2 x) {
   return __builtin_wasm_nearest_f64x2(x);
-  // WEBASSEMBLY: call <2 x double> @llvm.wasm.nearest.v2f64(<2 x double> %x)
+  // WEBASSEMBLY: call <2 x double> @ll

[PATCH] D100411: [WebAssembly] Use standard intrinsics for f32x4 and f64x2 ops

2021-04-14 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf7ab81ce310: [WebAssembly] Use standard intrinsics for 
f32x4 and f64x2 ops (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100411

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/CodeGen/WebAssembly/simd-unsupported.ll

Index: llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
+++ llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
@@ -366,38 +366,6 @@
 ; 4 x f32
 ; ==
 
-; CHECK-LABEL: ceil_v4f32:
-; CHECK: f32.ceil
-declare <4 x float> @llvm.ceil.v4f32(<4 x float>)
-define <4 x float> @ceil_v4f32(<4 x float> %x) {
-  %v = call <4 x float> @llvm.ceil.v4f32(<4 x float> %x)
-  ret <4 x float> %v
-}
-
-; CHECK-LABEL: floor_v4f32:
-; CHECK: f32.floor
-declare <4 x float> @llvm.floor.v4f32(<4 x float>)
-define <4 x float> @floor_v4f32(<4 x float> %x) {
-  %v = call <4 x float> @llvm.floor.v4f32(<4 x float> %x)
-  ret <4 x float> %v
-}
-
-; CHECK-LABEL: trunc_v4f32:
-; CHECK: f32.trunc
-declare <4 x float> @llvm.trunc.v4f32(<4 x float>)
-define <4 x float> @trunc_v4f32(<4 x float> %x) {
-  %v = call <4 x float> @llvm.trunc.v4f32(<4 x float> %x)
-  ret <4 x float> %v
-}
-
-; CHECK-LABEL: nearbyint_v4f32:
-; CHECK: f32.nearest
-declare <4 x float> @llvm.nearbyint.v4f32(<4 x float>)
-define <4 x float> @nearbyint_v4f32(<4 x float> %x) {
-  %v = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %x)
-  ret <4 x float> %v
-}
-
 ; CHECK-LABEL: copysign_v4f32:
 ; CHECK: f32.copysign
 declare <4 x float> @llvm.copysign.v4f32(<4 x float>, <4 x float>)
@@ -498,38 +466,6 @@
 ; 2 x f64
 ; ==
 
-; CHECK-LABEL: ceil_v2f64:
-; CHECK: f64.ceil
-declare <2 x double> @llvm.ceil.v2f64(<2 x double>)
-define <2 x double> @ceil_v2f64(<2 x double> %x) {
-  %v = call <2 x double> @llvm.ceil.v2f64(<2 x double> %x)
-  ret <2 x double> %v
-}
-
-; CHECK-LABEL: floor_v2f64:
-; CHECK: f64.floor
-declare <2 x double> @llvm.floor.v2f64(<2 x double>)
-define <2 x double> @floor_v2f64(<2 x double> %x) {
-  %v = call <2 x double> @llvm.floor.v2f64(<2 x double> %x)
-  ret <2 x double> %v
-}
-
-; CHECK-LABEL: trunc_v2f64:
-; CHECK: f64.trunc
-declare <2 x double> @llvm.trunc.v2f64(<2 x double>)
-define <2 x double> @trunc_v2f64(<2 x double> %x) {
-  %v = call <2 x double> @llvm.trunc.v2f64(<2 x double> %x)
-  ret <2 x double> %v
-}
-
-; CHECK-LABEL: nearbyint_v2f64:
-; CHECK: f64.nearest
-declare <2 x double> @llvm.nearbyint.v2f64(<2 x double>)
-define <2 x double> @nearbyint_v2f64(<2 x double> %x) {
-  %v = call <2 x double> @llvm.nearbyint.v2f64(<2 x double> %x)
-  ret <2 x double> %v
-}
-
 ; CHECK-LABEL: copysign_v2f64:
 ; CHECK: f64.copysign
 declare <2 x double> @llvm.copysign.v2f64(<2 x double>, <2 x double>)
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -722,9 +722,9 @@
 ; CHECK-NEXT: .functype ceil_v4f32 (v128) -> (v128){{$}}
 ; CHECK-NEXT: f32x4.ceil $push[[R:[0-9]+]]=, $0{{$}}
 ; CHECK-NEXT: return $pop[[R]]{{$}}
-declare <4 x float> @llvm.wasm.ceil.v4f32(<4 x float>)
+declare <4 x float> @llvm.ceil.v4f32(<4 x float>)
 define <4 x float> @ceil_v4f32(<4 x float> %a) {
-  %v = call <4 x float> @llvm.wasm.ceil.v4f32(<4 x float> %a)
+  %v = call <4 x float> @llvm.ceil.v4f32(<4 x float> %a)
   ret <4 x float> %v
 }
 
@@ -732,9 +732,9 @@
 ; CHECK-NEXT: .functype floor_v4f32 (v128) -> (v128){{$}}
 ; CHECK-NEXT: f32x4.floor $push[[R:[0-9]+]]=, $0{{$}}
 ; CHECK-NEXT: return $pop[[R]]{{$}}
-declare <4 x float> @llvm.wasm.floor.v4f32(<4 x float>)
+declare <4 x float> @llvm.floor.v4f32(<4 x float>)
 define <4 x float> @floor_v4f32(<4 x float> %a) {
-  %v = call <4 x float> @llvm.wasm.floor.v4f32(<4 x float> %a)
+  %v = call <4 x float> @llvm.floor.v4f32(<4 x float> %a)
   ret <4 x float> %v
 }
 
@@ -742,9 +742,9 @@
 ; CHECK-NEXT: .functype trunc_v4f32 (v128) -> (v128){{$}}
 ; CHECK-NEXT: f32x4.trunc $push[[R:[0-9]+]]=, $0{{$}}
 ; CHECK-NEXT: return $pop[[R]]{{$}}
-declare <4 x float> @llvm.wasm.trunc.v4f32(<4 x float>)
+declare <4 x float> @llvm.trunc.v4f32(<4 x float>)
 define <4 x float> @trunc_v4f32(<4 x float> %a) {
-  %v = call <4 x float> @llvm.wasm.trunc.v4f32(<4 x float> %a)
+  %v = call <4 x float> @llvm.trunc.v4f32(<4 x float> %a)
   ret <4 x 

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

2021-04-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Well, one way to see things is that this patch only makes yet another step in a 
direction that we're already rather far in (in terms of CMake complexity). And 
as I said, I think the separation of `__config_site` in its own 
platform-specific directory makes a lot of sense. So don't consider yourself 
blocked on libc++.

I do have some questions regarding the driver side of things though. What 
platforms is this change going to impact on the Driver side? Fuchsia is 
self-explanatory, but what does the Gnu driver impact? Also, have you thought 
about using this scheme instead? Why did you opt for the scheme you selected?

  include/
c++/
  v1/

/
__config_site
/
__config_site


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89013

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


[clang] 2fe4909 - clang-format: fix undefined behavior.

2021-04-14 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2021-04-14T19:41:18+02:00
New Revision: 2fe4909748b5f14499e83b0647b7e9ddd0068a15

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

LOG: clang-format: fix undefined behavior.

The previous change failed to initialize the SymbolsMerged field.

Added: 


Modified: 
clang/lib/Format/SortJavaScriptImports.cpp

Removed: 




diff  --git a/clang/lib/Format/SortJavaScriptImports.cpp 
b/clang/lib/Format/SortJavaScriptImports.cpp
index fdc2408ec1ec..b7df1a5f1b53 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -89,7 +89,7 @@ struct JsModuleReference {
   SmallVector Symbols;
   // Whether some symbols were merged into this one. Controls if the module
   // reference needs re-formatting.
-  bool SymbolsMerged;
+  bool SymbolsMerged = false;
   // The source location just after { and just before } in the import.
   // Extracted eagerly to allow modification of Symbols later on.
   SourceLocation SymbolsStart, SymbolsEnd;



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


[clang] af7925b - [WebAssembly] Codegen for f64x2.convert_low_i32x4_{s, u}

2021-04-14 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-04-14T10:42:45-07:00
New Revision: af7925b4dd6519ebf0126ac8a18d791eb26968c9

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

LOG: [WebAssembly] Codegen for f64x2.convert_low_i32x4_{s,u}

Add a custom DAG combine and ISD opcode for detecting patterns like

  (uint_to_fp (extract_subvector ...))

before the extract_subvector is expanded to ensure that they will ultimately
lower to f64x2.convert_low_i32x4_{s,u} instructions. Since these instructions
are no longer prototypes and can now be produced via standard IR, this commit
also removes the target intrinsics and builtins that had been used to prototype
the instructions.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyISD.def
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-conversions.ll
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 3f8b050aabfd1..db8ec8ebeb302 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -196,8 +196,6 @@ TARGET_BUILTIN(__builtin_wasm_extend_high_s_i32x4_i64x2, 
"V2LLiV4i", "nc", "simd
 TARGET_BUILTIN(__builtin_wasm_extend_low_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_extend_high_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
 
-TARGET_BUILTIN(__builtin_wasm_convert_low_s_i32x4_f64x2, "V2dV4i", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_convert_low_u_i32x4_f64x2, "V2dV4Ui", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_demote_zero_f64x2_f32x4, "V4fV2d", "nc", 
"simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index b9e3110da8345..7871dfd65d53e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17500,23 +17500,6 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(IntNo);
 return Builder.CreateCall(Callee, Vec);
   }
-  case WebAssembly::BI__builtin_wasm_convert_low_s_i32x4_f64x2:
-  case WebAssembly::BI__builtin_wasm_convert_low_u_i32x4_f64x2: {
-Value *Vec = EmitScalarExpr(E->getArg(0));
-unsigned IntNo;
-switch (BuiltinID) {
-case WebAssembly::BI__builtin_wasm_convert_low_s_i32x4_f64x2:
-  IntNo = Intrinsic::wasm_convert_low_signed;
-  break;
-case WebAssembly::BI__builtin_wasm_convert_low_u_i32x4_f64x2:
-  IntNo = Intrinsic::wasm_convert_low_unsigned;
-  break;
-default:
-  llvm_unreachable("unexpected builtin ID");
-}
-Function *Callee = CGM.getIntrinsic(IntNo);
-return Builder.CreateCall(Callee, Vec);
-  }
   case WebAssembly::BI__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4:
   case WebAssembly::BI__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4: {
 Value *Vec = EmitScalarExpr(E->getArg(0));

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index 7b7965c026e1a..a5c6f4423c3b4 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -914,18 +914,6 @@ u64x2 extend_high_u_i32x4_i64x2(u32x4 x) {
   // WEBASSEMBLY: ret
 }
 
-f64x2 convert_low_s_i32x4_f64x2(i32x4 x) {
-  return __builtin_wasm_convert_low_s_i32x4_f64x2(x);
-  // WEBASSEMBLY: call <2 x double> @llvm.wasm.convert.low.signed(<4 x i32> %x)
-  // WEBASSEMBLY: ret
-}
-
-f64x2 convert_low_u_i32x4_f64x2(u32x4 x) {
-  return __builtin_wasm_convert_low_u_i32x4_f64x2(x);
-  // WEBASSEMBLY: call <2 x double> @llvm.wasm.convert.low.unsigned(<4 x i32> 
%x)
-  // WEBASSEMBLY: ret
-}
-
 i32x4 trunc_sat_zero_s_f64x2_i32x4(f64x2 x) {
   return __builtin_wasm_trunc_sat_zero_s_f64x2_i32x4(x);
   // WEBASSEMBLY: call <4 x i32> @llvm.wasm.trunc.sat.zero.signed(<2 x double> 
%x)

diff  --git a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td 
b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
index f4bdd07b81082..977647db92adf 100644
--- a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -275,12 +275,6 @@ def int_wasm_extadd_pairwise_unsigned :
 [IntrNoMem, IntrSpeculatable]>;
 
 // TODO: Remove these if possible if they are merg

[clang] 1c57172 - [libTooling] Add smart pointer support to the `access` Stencil

2021-04-14 Thread Shu-Chun Weng via cfe-commits

Author: Shu-Chun Weng
Date: 2021-04-14T10:45:59-07:00
New Revision: 1c5717225e89d4b266784f1a1fe482530bc4b6f2

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

LOG: [libTooling] Add smart pointer support to the `access` Stencil

This extends smart pointer support beyond the existing `maybeDeref` and
`maybeAddressOf`.

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

Added: 


Modified: 
clang/lib/Tooling/Transformer/Stencil.cpp
clang/unittests/Tooling/StencilTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Transformer/Stencil.cpp 
b/clang/lib/Tooling/Transformer/Stencil.cpp
index d46087e4b04bc..235473b691878 100644
--- a/clang/lib/Tooling/Transformer/Stencil.cpp
+++ b/clang/lib/Tooling/Transformer/Stencil.cpp
@@ -323,10 +323,23 @@ Error evalData(const AccessData &Data, const 
MatchFinder::MatchResult &Match,
 return llvm::make_error(errc::invalid_argument,
  "Id not bound: " + Data.BaseId);
   if (!E->isImplicitCXXThis()) {
-if (llvm::Optional S =
-E->getType()->isAnyPointerType()
-? tooling::buildArrow(*E, *Match.Context)
-: tooling::buildDot(*E, *Match.Context))
+llvm::Optional S;
+if (E->getType()->isAnyPointerType() ||
+isSmartPointerType(E->getType(), *Match.Context)) {
+  // Strip off any operator->. This can only occur inside an actual arrow
+  // member access, so we treat it as equivalent to an actual object
+  // expression.
+  if (const auto *OpCall = dyn_cast(E)) {
+if (OpCall->getOperator() == clang::OO_Arrow &&
+OpCall->getNumArgs() == 1) {
+  E = OpCall->getArg(0);
+}
+  }
+  S = tooling::buildArrow(*E, *Match.Context);
+} else {
+  S = tooling::buildDot(*E, *Match.Context);
+}
+if (S.hasValue())
   *Result += *S;
 else
   return llvm::make_error(

diff  --git a/clang/unittests/Tooling/StencilTest.cpp 
b/clang/unittests/Tooling/StencilTest.cpp
index 219339014..df05e6deeb577 100644
--- a/clang/unittests/Tooling/StencilTest.cpp
+++ b/clang/unittests/Tooling/StencilTest.cpp
@@ -392,6 +392,37 @@ TEST_F(StencilTest, AccessOpPointerDereference) {
   testExpr(Id, Snippet, access(Id, "field"), "x->field");
 }
 
+TEST_F(StencilTest, AccessOpSmartPointer) {
+  StringRef Snippet = R"cc(
+Smart x;
+x;
+  )cc";
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "x->field");
+}
+
+TEST_F(StencilTest, AccessOpSmartPointerDereference) {
+  StringRef Snippet = R"cc(
+Smart x;
+*x;
+  )cc";
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "(*x).field");
+}
+
+TEST_F(StencilTest, AccessOpSmartPointerMemberCall) {
+  StringRef Snippet = R"cc(
+Smart x;
+x->Field;
+  )cc";
+  StringRef Id = "id";
+  auto StmtMatch =
+  matchStmt(Snippet, memberExpr(hasObjectExpression(expr().bind(Id;
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT_EXPECTED(access(Id, "field")->eval(StmtMatch->Result),
+   HasValue("x->field"));
+}
+
 TEST_F(StencilTest, AccessOpExplicitThis) {
   using clang::ast_matchers::hasObjectExpression;
   using clang::ast_matchers::memberExpr;



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


[PATCH] D100425: [WebAssembly] Codegen for f64x2.convert_low_i32x4_{s,u}

2021-04-14 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf7925b4dd65: [WebAssembly] Codegen for 
f64x2.convert_low_i32x4_{s,u} (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100425

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-conversions.ll
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -843,26 +843,6 @@
   ret <2 x double> %v
 }
 
-; CHECK-LABEL: convert_low_signed_v2f64:
-; CHECK-NEXT: .functype convert_low_signed_v2f64 (v128) -> (v128){{$}}
-; CHECK-NEXT: f64x2.convert_low_i32x4_s $push[[R:[0-9]+]]=, $0{{$}}
-; CHECK-NEXT: return $pop[[R]]{{$}}
-declare <2 x double> @llvm.wasm.convert.low.signed(<4 x i32>)
-define <2 x double> @convert_low_signed_v2f64(<4 x i32> %a) {
-  %v = call <2 x double> @llvm.wasm.convert.low.signed(<4 x i32> %a)
-  ret <2 x double> %v
-}
-
-; CHECK-LABEL: convert_low_unsigned_v2f64:
-; CHECK-NEXT: .functype convert_low_unsigned_v2f64 (v128) -> (v128){{$}}
-; CHECK-NEXT: f64x2.convert_low_i32x4_u $push[[R:[0-9]+]]=, $0{{$}}
-; CHECK-NEXT: return $pop[[R]]{{$}}
-declare <2 x double> @llvm.wasm.convert.low.unsigned(<4 x i32>)
-define <2 x double> @convert_low_unsigned_v2f64(<4 x i32> %a) {
-  %v = call <2 x double> @llvm.wasm.convert.low.unsigned(<4 x i32> %a)
-  ret <2 x double> %v
-}
-
 ; CHECK-LABEL: promote_low_v2f64:
 ; CHECK-NEXT: .functype promote_low_v2f64 (v128) -> (v128){{$}}
 ; CHECK-NEXT: f64x2.promote_low_f32x4 $push[[R:[0-9]+]]=, $0{{$}}
Index: llvm/test/CodeGen/WebAssembly/simd-conversions.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-conversions.ll
+++ llvm/test/CodeGen/WebAssembly/simd-conversions.ll
@@ -81,3 +81,25 @@
   %a = fptoui <2 x double> %x to <2 x i64>
   ret <2 x i64> %a
 }
+
+; CHECK-LABEL: convert_low_s_v2f64:
+; NO-SIMD128-NOT: f64x2
+; SIMD128-NEXT: .functype convert_low_s_v2f64 (v128) -> (v128){{$}}
+; SIMD128-NEXT: f64x2.convert_low_i32x4_s $push[[R:[0-9]+]]=, $0
+; SIMD128-NEXT: return $pop[[R]]
+define <2 x double> @convert_low_s_v2f64(<4 x i32> %x) {
+  %v = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> 
+  %a = sitofp <2 x i32> %v to <2 x double>
+  ret <2 x double> %a
+}
+
+; CHECK-LABEL: convert_low_u_v2f64:
+; NO-SIMD128-NOT: f64x2
+; SIMD128-NEXT: .functype convert_low_u_v2f64 (v128) -> (v128){{$}}
+; SIMD128-NEXT: f64x2.convert_low_i32x4_u $push[[R:[0-9]+]]=, $0
+; SIMD128-NEXT: return $pop[[R]]
+define <2 x double> @convert_low_u_v2f64(<4 x i32> %x) {
+  %v = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> 
+  %a = uitofp <2 x i32> %v to <2 x double>
+  ret <2 x double> %a
+}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1091,16 +1091,21 @@
 defm "" : SIMDConvert;
 defm "" : SIMDConvert;
 
-// Integer to floating point: convert
-defm "" : SIMDConvert;
-defm "" : SIMDConvert;
-
 // Lower llvm.wasm.trunc.sat.* to saturating instructions
 def : Pat<(v4i32 (int_wasm_trunc_saturate_signed (v4f32 V128:$src))),
   (fp_to_sint_I32x4 $src)>;
 def : Pat<(v4i32 (int_wasm_trunc_saturate_unsigned (v4f32 V128:$src))),
   (fp_to_uint_I32x4 $src)>;
 
+// Integer to floating point: convert
+def convert_low_t : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVec<1>]>;
+def convert_low_s : SDNode<"WebAssemblyISD::CONVERT_LOW_S", convert_low_t>;
+def convert_low_u : SDNode<"WebAssemblyISD::CONVERT_LOW_U", convert_low_t>;
+defm "" : SIMDConvert;
+defm "" : SIMDConvert;
+defm "" : SIMDConvert;
+defm "" : SIMDConvert;
+
 // Extending operations
 def extend_t : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVec<1>]>;
 def extend_low_s : SDNode<"WebAssemblyISD::EXTEND_LOW_S", extend_t>;
@@ -1255,10 +1260,6 @@
   "trunc_sat_zero_f64x2_s", 0xfc>;
 defm "" : SIMDConvert;
-defm "" : SIMDConvert;
-defm "" : SIMDConvert;
 
 //===--===//
 // Saturating Rounding Q-Format Multiplication
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/Web

[PATCH] D100450: [libTooling] Add smart pointer support to the `access` Stencil

2021-04-14 Thread Shu-Chun Weng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c5717225e89: [libTooling] Add smart pointer support to the 
`access` Stencil (authored by scw).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100450

Files:
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp


Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -392,6 +392,37 @@
   testExpr(Id, Snippet, access(Id, "field"), "x->field");
 }
 
+TEST_F(StencilTest, AccessOpSmartPointer) {
+  StringRef Snippet = R"cc(
+Smart x;
+x;
+  )cc";
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "x->field");
+}
+
+TEST_F(StencilTest, AccessOpSmartPointerDereference) {
+  StringRef Snippet = R"cc(
+Smart x;
+*x;
+  )cc";
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "(*x).field");
+}
+
+TEST_F(StencilTest, AccessOpSmartPointerMemberCall) {
+  StringRef Snippet = R"cc(
+Smart x;
+x->Field;
+  )cc";
+  StringRef Id = "id";
+  auto StmtMatch =
+  matchStmt(Snippet, memberExpr(hasObjectExpression(expr().bind(Id;
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT_EXPECTED(access(Id, "field")->eval(StmtMatch->Result),
+   HasValue("x->field"));
+}
+
 TEST_F(StencilTest, AccessOpExplicitThis) {
   using clang::ast_matchers::hasObjectExpression;
   using clang::ast_matchers::memberExpr;
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -323,10 +323,23 @@
 return llvm::make_error(errc::invalid_argument,
  "Id not bound: " + Data.BaseId);
   if (!E->isImplicitCXXThis()) {
-if (llvm::Optional S =
-E->getType()->isAnyPointerType()
-? tooling::buildArrow(*E, *Match.Context)
-: tooling::buildDot(*E, *Match.Context))
+llvm::Optional S;
+if (E->getType()->isAnyPointerType() ||
+isSmartPointerType(E->getType(), *Match.Context)) {
+  // Strip off any operator->. This can only occur inside an actual arrow
+  // member access, so we treat it as equivalent to an actual object
+  // expression.
+  if (const auto *OpCall = dyn_cast(E)) {
+if (OpCall->getOperator() == clang::OO_Arrow &&
+OpCall->getNumArgs() == 1) {
+  E = OpCall->getArg(0);
+}
+  }
+  S = tooling::buildArrow(*E, *Match.Context);
+} else {
+  S = tooling::buildDot(*E, *Match.Context);
+}
+if (S.hasValue())
   *Result += *S;
 else
   return llvm::make_error(


Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -392,6 +392,37 @@
   testExpr(Id, Snippet, access(Id, "field"), "x->field");
 }
 
+TEST_F(StencilTest, AccessOpSmartPointer) {
+  StringRef Snippet = R"cc(
+Smart x;
+x;
+  )cc";
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "x->field");
+}
+
+TEST_F(StencilTest, AccessOpSmartPointerDereference) {
+  StringRef Snippet = R"cc(
+Smart x;
+*x;
+  )cc";
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "(*x).field");
+}
+
+TEST_F(StencilTest, AccessOpSmartPointerMemberCall) {
+  StringRef Snippet = R"cc(
+Smart x;
+x->Field;
+  )cc";
+  StringRef Id = "id";
+  auto StmtMatch =
+  matchStmt(Snippet, memberExpr(hasObjectExpression(expr().bind(Id;
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT_EXPECTED(access(Id, "field")->eval(StmtMatch->Result),
+   HasValue("x->field"));
+}
+
 TEST_F(StencilTest, AccessOpExplicitThis) {
   using clang::ast_matchers::hasObjectExpression;
   using clang::ast_matchers::memberExpr;
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -323,10 +323,23 @@
 return llvm::make_error(errc::invalid_argument,
  "Id not bound: " + Data.BaseId);
   if (!E->isImplicitCXXThis()) {
-if (llvm::Optional S =
-E->getType()->isAnyPointerType()
-? tooling::buildArrow(*E, *Match.Context)
-: tooling::buildDot(*E, *Match.Context))
+llvm::Optional S;
+if (E->getType()->isAnyPointerType() ||
+isSmartPointerType(E->getType(), *Match.Context)) {
+  // Strip off any operator->. This can only occur inside an actual arrow
+  // member access, so we treat it as eq

[PATCH] D100450: [libTooling] Add smart pointer support to the `access` Stencil

2021-04-14 Thread Shu-Chun Weng via Phabricator via cfe-commits
scw added inline comments.



Comment at: clang/unittests/Tooling/StencilTest.cpp:410
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "(*x).field");
+}

ymandel wrote:
> Hmm. Looks like we could use smart pointer support in tooling::buildAddressOf 
> as well.  If you're interested, the code is at
> clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp line 94
> but I understand if you want to stop here. :)
I don't think this particular output "(*x).field" is from `buildAddressOf`. 
Instead, it's in `buildDot` where `*x` is `x.operator*()` instead of 
`UO_Deref`. Yes, there's potential improvement but at least it's correct output 
comparing to this change which fixes "x->->field" so I'm leaving it along just 
adding the test case to highlight the potential.

As for `buildAddressOf`, we shouldn't change `&*x` to `x` when `x` is a smart 
pointer -- the types don't match and may result in ill-typed expressions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100450

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


[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-04-14 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

> FYI, I pushed the fix for the aarch64-coff issue now (D99572 
> , rGd5c5cf5ce8d921fc8c5e1b608c298a1ffa688d37 
> ) and 
> pushed another commit to remove the code for disabling the pass on aarch64 
> (rG57b259a852a6383880f5d0875d848420bb3c2945 
> ).

Thank you @mstorsjo!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[clang] c1554f3 - [clang][FileManager] Support empty file name in getVirtualFileRef for serialized diagnostics

2021-04-14 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2021-04-14T11:29:25-07:00
New Revision: c1554f32e3b3fafab64698fdb5b806b1bda4aa8a

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

LOG: [clang][FileManager] Support empty file name in getVirtualFileRef for 
serialized diagnostics

After https://reviews.llvm.org/D90484 libclang is unable to read a serialized 
diagnostic file
which contains a diagnostic which came from a file with an empty filename. The 
reason being is
that the serialized diagnostic reader is creating a virtual file for the "" 
filename, which now
fails after the changes in https://reviews.llvm.org/D90484. This patch restores 
the previous
behavior in getVirtualFileRef by allowing it to construct a file entry ref with 
an empty name by
pretending its name is "." so that the directory entry can be created.

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

Added: 
clang/test/Misc/serialized-diags-empty-filename.c

Modified: 
clang/lib/Basic/FileManager.cpp

Removed: 




diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 6e9d5d7fb4222..d39d7ba22643b 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -384,9 +384,12 @@ FileEntryRef FileManager::getVirtualFileRef(StringRef 
Filename, off_t Size,
 
   // Now that all ancestors of Filename are in the cache, the
   // following call is guaranteed to find the DirectoryEntry from the
-  // cache.
-  auto DirInfo = expectedToOptional(
-  getDirectoryFromFile(*this, Filename, /*CacheFailure=*/true));
+  // cache. A virtual file can also have an empty filename, that could come
+  // from a source location preprocessor directive with an empty filename as
+  // an example, so we need to pretend it has a name to ensure a valid 
directory
+  // entry can be returned.
+  auto DirInfo = expectedToOptional(getDirectoryFromFile(
+  *this, Filename.empty() ? "." : Filename, /*CacheFailure=*/true));
   assert(DirInfo &&
  "The directory of a virtual file should already be in the cache.");
 

diff  --git a/clang/test/Misc/serialized-diags-empty-filename.c 
b/clang/test/Misc/serialized-diags-empty-filename.c
new file mode 100644
index 0..e86108414273e
--- /dev/null
+++ b/clang/test/Misc/serialized-diags-empty-filename.c
@@ -0,0 +1,8 @@
+// RUN: rm -f %t.diag
+// RUN: not %clang -c %s --serialize-diagnostics %t.diag
+// RUN: c-index-test -read-diagnostics %t.diag 2>&1 | FileCheck %s
+
+# 1 "" 1
+void 1();
+
+// CHECK: :1:6: error:



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


[PATCH] D100428: [clang][FileManager] Support empty file name in getVirtualFileRef for serialized diagnostics

2021-04-14 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1554f32e3b3: [clang][FileManager] Support empty file name 
in getVirtualFileRef for… (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D100428?vs=337289&id=337507#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100428

Files:
  clang/lib/Basic/FileManager.cpp
  clang/test/Misc/serialized-diags-empty-filename.c


Index: clang/test/Misc/serialized-diags-empty-filename.c
===
--- /dev/null
+++ clang/test/Misc/serialized-diags-empty-filename.c
@@ -0,0 +1,8 @@
+// RUN: rm -f %t.diag
+// RUN: not %clang -c %s --serialize-diagnostics %t.diag
+// RUN: c-index-test -read-diagnostics %t.diag 2>&1 | FileCheck %s
+
+# 1 "" 1
+void 1();
+
+// CHECK: :1:6: error:
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -384,9 +384,12 @@
 
   // Now that all ancestors of Filename are in the cache, the
   // following call is guaranteed to find the DirectoryEntry from the
-  // cache.
-  auto DirInfo = expectedToOptional(
-  getDirectoryFromFile(*this, Filename, /*CacheFailure=*/true));
+  // cache. A virtual file can also have an empty filename, that could come
+  // from a source location preprocessor directive with an empty filename as
+  // an example, so we need to pretend it has a name to ensure a valid 
directory
+  // entry can be returned.
+  auto DirInfo = expectedToOptional(getDirectoryFromFile(
+  *this, Filename.empty() ? "." : Filename, /*CacheFailure=*/true));
   assert(DirInfo &&
  "The directory of a virtual file should already be in the cache.");
 


Index: clang/test/Misc/serialized-diags-empty-filename.c
===
--- /dev/null
+++ clang/test/Misc/serialized-diags-empty-filename.c
@@ -0,0 +1,8 @@
+// RUN: rm -f %t.diag
+// RUN: not %clang -c %s --serialize-diagnostics %t.diag
+// RUN: c-index-test -read-diagnostics %t.diag 2>&1 | FileCheck %s
+
+# 1 "" 1
+void 1();
+
+// CHECK: :1:6: error:
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -384,9 +384,12 @@
 
   // Now that all ancestors of Filename are in the cache, the
   // following call is guaranteed to find the DirectoryEntry from the
-  // cache.
-  auto DirInfo = expectedToOptional(
-  getDirectoryFromFile(*this, Filename, /*CacheFailure=*/true));
+  // cache. A virtual file can also have an empty filename, that could come
+  // from a source location preprocessor directive with an empty filename as
+  // an example, so we need to pretend it has a name to ensure a valid directory
+  // entry can be returned.
+  auto DirInfo = expectedToOptional(getDirectoryFromFile(
+  *this, Filename.empty() ? "." : Filename, /*CacheFailure=*/true));
   assert(DirInfo &&
  "The directory of a virtual file should already be in the cache.");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-04-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

As discussed offline, I think this is fine. This layout seems to be closest to 
what other compilers use.

@phosek said he would send out an RFC to make the multiarch layout become the 
default for all platforms. I'd be interested in using that on Darwin too (the 
only difference is that it would be `apple-` without the 
architecture, since we use universal binaries).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89013

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


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

2021-04-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Oh, and can you make sure the Runtimes build passes CI before shipping this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89013

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


[PATCH] D100468: [clang] [test] Share patterns in CodeGen/ms_abi_aarch64.c between cases. NFC.

2021-04-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100468

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


[PATCH] D100499: [AArch64] Neon Polynomial vadd Intrinsic Fix

2021-04-14 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic created this revision.
rsanthir.quic added reviewers: t.p.northover, DavidSpickett, labrinea, apazos.
Herald added subscribers: danielkiss, kristof.beyls.
rsanthir.quic requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The Neon vadd intrinsics were added to both the ARMSIMD and
AArch64SIMD Intrinsic maps. The intrinsics should only be supported
for AArch64, this patch corrects this by removing the mapping
from ARMSIMDIntrinsicMap that was added in https://reviews.llvm.org/D96825


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100499

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5458,10 +5458,7 @@
   NEONMAP2(vabdq_v, arm_neon_vabdu, arm_neon_vabds, Add1ArgType | 
UnsignedAlts),
   NEONMAP1(vabs_v, arm_neon_vabs, 0),
   NEONMAP1(vabsq_v, arm_neon_vabs, 0),
-  NEONMAP0(vadd_v),
   NEONMAP0(vaddhn_v),
-  NEONMAP0(vaddq_p128),
-  NEONMAP0(vaddq_v),
   NEONMAP1(vaesdq_v, arm_neon_aesd, 0),
   NEONMAP1(vaeseq_v, arm_neon_aese, 0),
   NEONMAP1(vaesimcq_v, arm_neon_aesimc, 0),


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5458,10 +5458,7 @@
   NEONMAP2(vabdq_v, arm_neon_vabdu, arm_neon_vabds, Add1ArgType | UnsignedAlts),
   NEONMAP1(vabs_v, arm_neon_vabs, 0),
   NEONMAP1(vabsq_v, arm_neon_vabs, 0),
-  NEONMAP0(vadd_v),
   NEONMAP0(vaddhn_v),
-  NEONMAP0(vaddq_p128),
-  NEONMAP0(vaddq_v),
   NEONMAP1(vaesdq_v, arm_neon_aesd, 0),
   NEONMAP1(vaeseq_v, arm_neon_aese, 0),
   NEONMAP1(vaesimcq_v, arm_neon_aesimc, 0),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100388: [BROKEN][clang] Try to fix thunk function types

2021-04-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/Basic/ABI.h:182
+  /// an ABI-specific comparator.
+  const CXXMethodDecl *BaseMethod;
+

Instead of the changes you made to `GlobalDecl`, I think this should be a 
`GlobalDecl` itself. Different function variants could have different 
signatures, so in principle at least, what we want to know is the function 
variant not the function declaration.



Comment at: clang/lib/AST/VTableBuilder.cpp:1155-1157
+  // Override it. Note that there may or may not be a thunk already.
+  VTableThunks.erase(Idx);
+  VTableThunks.insert({Idx, *TI});

Can you modify the thunk info in-place, instead of this erase + insert dance?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100388

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


[PATCH] D99079: [ARM][AArch64] Require appropriate features for crypto algorithms

2021-04-14 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.h:36
+  bool HasSHA3;
+  bool HasSM4;
   bool HasUnaligned;

Would it make sense to further differentiate SM3 and SM4? I see that we 
differentiate between the two in arm_neon.td ("ARM_FEATURE_SM3" & 
"ARM_FEATURE_SM4") but we don't include this differentiation as flags (only 
HasSM4, +sm4 etc)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99079

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


[PATCH] D100388: [BROKEN][clang] Try to fix thunk function types

2021-04-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/lib/AST/VTableBuilder.cpp:1155-1157
+  // Override it. Note that there may or may not be a thunk already.
+  VTableThunks.erase(Idx);
+  VTableThunks.insert({Idx, *TI});

rsmith wrote:
> Can you modify the thunk info in-place, instead of this erase + insert dance?
Absolutely. I had to change that because i needed to weed out all the places 
where `Thunk` is created.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100388

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


[PATCH] D100488: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

2021-04-14 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

Personally, I'm not a fan of boolean function parameters because of the inline 
comments necessary to make the call site understandable.  But it appears to be 
consistent with LLVM Coding Standards and other APIs, so this looks right to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100488

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


[PATCH] D100502: Allow lib64 in driver test

2021-04-14 Thread Troy Johnson via Phabricator via cfe-commits
troyj created this revision.
troyj added a reviewer: clang.
troyj added a project: clang.
troyj requested review of this revision.
Herald added a subscriber: cfe-commits.

The test clang/test/Driver/rocm-detect.hip does not consider that "lib" may be 
"lib64" instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100502

Files:
  clang/test/Driver/rocm-detect.hip


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -81,7 +81,7 @@
 
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
-// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib{{[0-9]+}}/clang/{{[0-9.]+}}
 // SPACK: ROCm installation search path: /opt/rocm
 // SPACK: InstalledDir: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -81,7 +81,7 @@
 
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
-// SPACK: ROCm installation search path: [[CLANG]]/{{(llvm/)?}}lib/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: [[CLANG]]/{{(llvm/)?}}lib{{[0-9]+}}/clang/{{[0-9.]+}}
 // SPACK: ROCm installation search path: /opt/rocm
 // SPACK: InstalledDir: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-14 Thread Greg Rodgers via Phabricator via cfe-commits
gregrodgers added a comment.

Dependence on hsa is not necessary.  The amdgpu and nvidia drivers both use PCI 
codes available in /sys .  We should use architecture independent methods as 
much as possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D100425: [WebAssembly] Codegen for f64x2.convert_low_i32x4_{s,u}

2021-04-14 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td:1104-1107
+defm "" : SIMDConvert;
+defm "" : SIMDConvert;
+defm "" : SIMDConvert;
+defm "" : SIMDConvert;

aheejin wrote:
> Not related to this CL, but we write encoding as decimals for some 
> instructions and hexadecimals in others?
I prefer hexadecimal because that's what all the SIMD documentation uses so 
it's easier to check for correctness, but for some reason I used to use 
decimal. I think I didn't realize hexadecimal was an option in .td files for a 
while. I would like to converge on using hexadecimal uniformly eventually.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100425

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


[clang] 6559ebd - [AST] Replace asserts with a condition

2021-04-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-04-14T21:14:05+01:00
New Revision: 6559ebd91b70f8d2ed82e19539ee09c5220159c2

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

LOG: [AST] Replace asserts with a condition

As was done for other locations in commit 54272e5b (NFC:
Replace asserts with if() in SourceLocation accessors, 2019-01-07).

Extracted from  https://reviews.llvm.org/D99231

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/TemplateBase.h

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index bb99ab1373ba5..bbf7ecf6712a3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2267,7 +2267,8 @@ class CXXCtorInitializer final {
 
   // For a pack expansion, returns the location of the ellipsis.
   SourceLocation getEllipsisLoc() const {
-assert(isPackExpansion() && "Initializer is not a pack expansion");
+if (!isPackExpansion())
+  return {};
 return MemberOrEllipsisLocation;
   }
 

diff  --git a/clang/include/clang/AST/TemplateBase.h 
b/clang/include/clang/AST/TemplateBase.h
index 1671637521e24..19f2cadc1f2b7 100644
--- a/clang/include/clang/AST/TemplateBase.h
+++ b/clang/include/clang/AST/TemplateBase.h
@@ -512,7 +512,8 @@ class TemplateArgumentLoc {
   }
 
   TypeSourceInfo *getTypeSourceInfo() const {
-assert(Argument.getKind() == TemplateArgument::Type);
+if (Argument.getKind() != TemplateArgument::Type)
+  return nullptr;
 return LocInfo.getAsTypeSourceInfo();
   }
 



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


[clang] d2bb3cb - Make test runnable on read-only file systems.

2021-04-14 Thread Sterling Augustine via cfe-commits

Author: Sterling Augustine
Date: 2021-04-14T13:29:51-07:00
New Revision: d2bb3cbbf8bc3a1b3d27c5a89e7cdd56bdca924f

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

LOG: Make test runnable on read-only file systems.

Added: 


Modified: 
clang/test/Misc/serialized-diags-empty-filename.c

Removed: 




diff  --git a/clang/test/Misc/serialized-diags-empty-filename.c 
b/clang/test/Misc/serialized-diags-empty-filename.c
index e86108414273e..32a9156e02151 100644
--- a/clang/test/Misc/serialized-diags-empty-filename.c
+++ b/clang/test/Misc/serialized-diags-empty-filename.c
@@ -1,5 +1,5 @@
 // RUN: rm -f %t.diag
-// RUN: not %clang -c %s --serialize-diagnostics %t.diag
+// RUN: not %clang -c %s --serialize-diagnostics %t.diag -o /dev/null
 // RUN: c-index-test -read-diagnostics %t.diag 2>&1 | FileCheck %s
 
 # 1 "" 1



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


[clang] f347f0e - [AST] Add introspection support for more base nodes

2021-04-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-04-14T21:31:23+01:00
New Revision: f347f0e0b869be4f9b97f26663cf8e4eac2c4868

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

LOG: [AST] Add introspection support for more base nodes

Fix the logic of detecting pseudo-virtual getBeginLoc etc on Stmt and
Decl subclasses.

Adjust the test infrastructure to filter out invalid source locations.
This makes the tests more clear about which nodes have which locations.

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

Added: 


Modified: 
clang/include/clang/Tooling/NodeIntrospection.h
clang/lib/Tooling/CMakeLists.txt
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
clang/unittests/Introspection/IntrospectionTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
index 3b40e68df24e7..28007c4468295 100644
--- a/clang/include/clang/Tooling/NodeIntrospection.h
+++ b/clang/include/clang/Tooling/NodeIntrospection.h
@@ -23,6 +23,10 @@ namespace clang {
 
 class Stmt;
 class Decl;
+class CXXCtorInitializer;
+class NestedNameSpecifierLoc;
+class TemplateArgumentLoc;
+class CXXBaseSpecifier;
 
 namespace tooling {
 
@@ -80,6 +84,10 @@ struct NodeLocationAccessors {
 namespace NodeIntrospection {
 NodeLocationAccessors GetLocations(clang::Stmt const *Object);
 NodeLocationAccessors GetLocations(clang::Decl const *Object);
+NodeLocationAccessors GetLocations(clang::CXXCtorInitializer const *Object);
+NodeLocationAccessors GetLocations(clang::NestedNameSpecifierLoc const *);
+NodeLocationAccessors GetLocations(clang::TemplateArgumentLoc const *);
+NodeLocationAccessors GetLocations(clang::CXXBaseSpecifier const *);
 NodeLocationAccessors GetLocations(clang::DynTypedNode const &Node);
 } // namespace NodeIntrospection
 } // namespace tooling

diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index ce7936a53671c..3598a44f13054 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -41,6 +41,22 @@ NodeLocationAccessors 
NodeIntrospection::GetLocations(clang::Stmt const *) {
 NodeLocationAccessors NodeIntrospection::GetLocations(clang::Decl const *) {
   return {};
 }
+NodeLocationAccessors NodeIntrospection::GetLocations(
+clang::CXXCtorInitializer const *) {
+  return {};
+}
+NodeLocationAccessors NodeIntrospection::GetLocations(
+clang::NestedNameSpecifierLoc const*) {
+  return {};
+}
+NodeLocationAccessors NodeIntrospection::GetLocations(
+clang::TemplateArgumentLoc const*) {
+  return {};
+}
+NodeLocationAccessors NodeIntrospection::GetLocations(
+clang::CXXBaseSpecifier const*) {
+  return {};
+}
 NodeLocationAccessors
 NodeIntrospection::GetLocations(clang::DynTypedNode const &) {
   return {};

diff  --git a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp 
b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
index d611261dd1a74..5121740cd7c3f 100644
--- a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
+++ b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
@@ -26,7 +26,11 @@ ASTSrcLocProcessor::ASTSrcLocProcessor(StringRef JsonPath)
   isDefinition(),
   isSameOrDerivedFrom(
   // TODO: Extend this with other clades
-  namedDecl(hasAnyName("clang::Stmt", "clang::Decl"))
+  namedDecl(hasAnyName("clang::Stmt", "clang::Decl",
+   "clang::CXXCtorInitializer",
+   "clang::NestedNameSpecifierLoc",
+   "clang::TemplateArgumentLoc",
+   "clang::CXXBaseSpecifier"))
   .bind("nodeClade")),
   optionally(isDerivedFrom(cxxRecordDecl().bind("derivedFrom"
   .bind("className"),
@@ -116,22 +120,30 @@ CaptureMethods(std::string TypeString, const 
clang::CXXRecordDecl *ASTClass,
  InnerMatcher...);
   };
 
-  auto BoundNodesVec =
-  match(findAll(publicAccessor(ofClass(equalsNode(ASTClass)),
-   returns(asString(TypeString)))
-.bind("classMethod")),
-*ASTClass, *Result.Context);
+  auto BoundNodesVec = match(
+  findAll(
+  publicAccessor(
+  ofClass(cxxRecordDecl(
+  equalsNode(ASTClass),
+  optionally(isDerivedFrom(
+  cxxRecordDecl(hasAnyName("clang::Stmt", "clang::Decl"))
+  .bind("stmtOrDeclBase"),
+  returns(asString(TypeString)))
+  .bind("classMethod")),
+  *ASTClass, *Result.Context);
 
   std::vector Methods;
   for (const auto &BN : BoundNode

[PATCH] D99231: [AST] Add introspection support for more base nodes

2021-04-14 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf347f0e0b869: [AST] Add introspection support for more base 
nodes (authored by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D99231?vs=336813&id=337537#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99231

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -30,7 +30,10 @@
 std::map
 FormatExpected(const MapType &Accessors) {
   std::map Result;
-  llvm::transform(Accessors,
+  llvm::transform(llvm::make_filter_range(Accessors,
+  [](const auto &Accessor) {
+return Accessor.first.isValid();
+  }),
   std::inserter(Result, Result.end()),
   [](const auto &Accessor) {
 return std::make_pair(
@@ -126,11 +129,9 @@
   UnorderedElementsAre(
   STRING_LOCATION_PAIR(MethodDecl, getBeginLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getBodyRBrace()),
-  STRING_LOCATION_PAIR(MethodDecl, getEllipsisLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getInnerLocStart()),
   STRING_LOCATION_PAIR(MethodDecl, getLocation()),
   STRING_LOCATION_PAIR(MethodDecl, getOuterLocStart()),
-  STRING_LOCATION_PAIR(MethodDecl, getPointOfInstantiation()),
   STRING_LOCATION_PAIR(MethodDecl, getTypeSpecEndLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getTypeSpecStartLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getEndLoc(;
@@ -145,3 +146,741 @@
   STRING_LOCATION_PAIR(MethodDecl, getReturnTypeSourceRange()),
   STRING_LOCATION_PAIR(MethodDecl, getSourceRange(;
 }
+
+TEST(Introspection, SourceLocations_NNS) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+namespace ns
+{
+  struct A {
+  void foo();
+};
+}
+void ns::A::foo() {}
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(nestedNameSpecifierLoc().bind("nns"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *NNS = BoundNodes[0].getNodeAs("nns");
+
+  auto Result = NodeIntrospection::GetLocations(NNS);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  EXPECT_THAT(
+  ExpectedLocations,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(NNS, getBeginLoc()),
+   STRING_LOCATION_PAIR(NNS, getEndLoc()),
+   STRING_LOCATION_PAIR(NNS, getLocalBeginLoc()),
+   STRING_LOCATION_PAIR(NNS, getLocalEndLoc(;
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(
+  ExpectedRanges,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(NNS, getLocalSourceRange()),
+   STRING_LOCATION_PAIR(NNS, getSourceRange(;
+}
+
+TEST(Introspection, SourceLocations_TA_Type) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+template
+  struct A {
+  void foo();
+};
+
+void foo()
+{
+  A a;
+}
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(templateArgumentLoc().bind("ta"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *TA = BoundNodes[0].getNodeAs("ta");
+
+  auto Result = NodeIntrospection::GetLocations(TA);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  EXPECT_THAT(ExpectedLocations,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(TA, getLocation(;
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(ExpectedRanges,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(TA, getSourceRange(;
+}
+
+TEST(Introspection, SourceLocations_TA_Decl) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+template
+void test2() {}
+void doNothing() {}
+void test() {
+test2();
+}
+)cpp",
+   "foo.cpp", std::make_share

[clang] 6a18cc2 - [WebAssembly] Codegen for i64x2.extend_{low,high}_i32x4_{s,u}

2021-04-14 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-04-14T13:43:09-07:00
New Revision: 6a18cc23efad410db48a3ccfc233d215de7d4cb9

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

LOG: [WebAssembly] Codegen for i64x2.extend_{low,high}_i32x4_{s,u}

Removes the builtins and intrinsics used to opt in to using these instructions
and replaces them with normal ISel patterns now that they are no longer
prototypes.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-extending.ll
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index db8ec8ebeb30..bc0c37a11207 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -191,11 +191,6 @@ TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, 
"V16UcV8UsV8Us", "nc", "simd
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4UiV4Ui", "nc", 
"simd128")
 
-TARGET_BUILTIN(__builtin_wasm_extend_low_s_i32x4_i64x2, "V2LLiV4i", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_extend_high_s_i32x4_i64x2, "V2LLiV4i", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_extend_low_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_extend_high_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
-
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_demote_zero_f64x2_f32x4, "V4fV2d", "nc", 
"simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7871dfd65d53..860492a281fe 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17475,31 +17475,6 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 CGM.getIntrinsic(IntNo, {ConvertType(E->getType()), Low->getType()});
 return Builder.CreateCall(Callee, {Low, High});
   }
-  case WebAssembly::BI__builtin_wasm_extend_low_s_i32x4_i64x2:
-  case WebAssembly::BI__builtin_wasm_extend_high_s_i32x4_i64x2:
-  case WebAssembly::BI__builtin_wasm_extend_low_u_i32x4_i64x2:
-  case WebAssembly::BI__builtin_wasm_extend_high_u_i32x4_i64x2: {
-Value *Vec = EmitScalarExpr(E->getArg(0));
-unsigned IntNo;
-switch (BuiltinID) {
-case WebAssembly::BI__builtin_wasm_extend_low_s_i32x4_i64x2:
-  IntNo = Intrinsic::wasm_extend_low_signed;
-  break;
-case WebAssembly::BI__builtin_wasm_extend_high_s_i32x4_i64x2:
-  IntNo = Intrinsic::wasm_extend_high_signed;
-  break;
-case WebAssembly::BI__builtin_wasm_extend_low_u_i32x4_i64x2:
-  IntNo = Intrinsic::wasm_extend_low_unsigned;
-  break;
-case WebAssembly::BI__builtin_wasm_extend_high_u_i32x4_i64x2:
-  IntNo = Intrinsic::wasm_extend_high_unsigned;
-  break;
-default:
-  llvm_unreachable("unexpected builtin ID");
-}
-Function *Callee = CGM.getIntrinsic(IntNo);
-return Builder.CreateCall(Callee, Vec);
-  }
   case WebAssembly::BI__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4:
   case WebAssembly::BI__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4: {
 Value *Vec = EmitScalarExpr(E->getArg(0));

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index a5c6f4423c3b..1a986f03dc49 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -890,30 +890,6 @@ u16x8 narrow_u_i16x8_i32x4(u32x4 low, u32x4 high) {
   // WEBASSEMBLY: ret
 }
 
-i64x2 extend_low_s_i32x4_i64x2(i32x4 x) {
-  return __builtin_wasm_extend_low_s_i32x4_i64x2(x);
-  // WEBASSEMBLY: call <2 x i64> @llvm.wasm.extend.low.signed(<4 x i32> %x)
-  // WEBASSEMBLY: ret
-}
-
-i64x2 extend_high_s_i32x4_i64x2(i32x4 x) {
-  return __builtin_wasm_extend_high_s_i32x4_i64x2(x);
-  // WEBASSEMBLY: call <2 x i64> @llvm.wasm.extend.high.signed(<4 x i32> %x)
-  // WEBASSEMBLY: ret
-}
-
-u64x2 extend_low_u_i32x4_i64x2(u32x4 x) {
-  return __builtin_wasm_extend_low_u_i32x4_i64x2(x);
-  // WEBASSEMBLY: call <2 x i64> @llvm.wasm.extend.low.unsigned(<4 x i32> %x)
-  // WEBASSEMBLY: ret
-}
-
-u64x2 extend_high_u_i32x4_i64x2(u32x4 x) {
-  return __builtin_wasm_extend_high_u_i32x4_i64x2(x);
-  // WEBASSEMBLY: call <2 x i6

  1   2   >