[clang-tools-extra] r358373 - [clangd] Reorder source files in CMakeLists

2019-04-15 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Mon Apr 15 00:21:17 2019
New Revision: 358373

URL: http://llvm.org/viewvc/llvm-project?rev=358373&view=rev
Log:
[clangd] Reorder source files in CMakeLists

Modified:
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt?rev=358373&r1=358372&r2=358373&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Mon Apr 15 00:21:17 
2019
@@ -13,7 +13,6 @@ include_directories(
 
 add_extra_unittest(ClangdTests
   Annotations.cpp
-  PrintASTTests.cpp
   BackgroundIndexTests.cpp
   CancellationTests.cpp
   ClangdTests.cpp
@@ -36,6 +35,7 @@ add_extra_unittest(ClangdTests
   IndexActionTests.cpp
   IndexTests.cpp
   JSONTransportTests.cpp
+  PrintASTTests.cpp
   QualityTests.cpp
   RIFFTests.cpp
   SelectionTests.cpp


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


r358375 - [clang-format] [PR41170] Break after return type ignored with certain comments positions

2019-04-15 Thread Paul Hoad via cfe-commits
Author: paulhoad
Date: Mon Apr 15 00:47:15 2019
New Revision: 358375

URL: http://llvm.org/viewvc/llvm-project?rev=358375&view=rev
Log:
[clang-format] [PR41170] Break after return type ignored with certain comments 
positions

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

The AlwaysBreakAfterReturn type setting can go wrong if the line ends with a 
comment
```
void foo() /* comment */
```
or

```
void foo() // comment
```

It will incorrectly see such functions as Declarations and not Definitions

The following code addresses this by looking for function which end with `; 
` rather than just `;` or ``

Reviewers: klimek, djasper, reuk, russellmcc, owenpan, sammccall
Reviewed By: owenpan
Subscribers: lebedev.ri, cfe-commits, sammccall
Tags: #clang
Differential Revision: https://reviews.llvm.org/D60363

Modified:
cfe/trunk/lib/Format/TokenAnnotator.h
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.h?rev=358375&r1=358374&r2=358375&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.h (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.h Mon Apr 15 00:47:15 2019
@@ -99,9 +99,17 @@ public:
   /// function declaration. Asserts MightBeFunctionDecl.
   bool mightBeFunctionDefinition() const {
 assert(MightBeFunctionDecl);
-// FIXME: Line.Last points to other characters than tok::semi
-// and tok::lbrace.
-return !Last->isOneOf(tok::semi, tok::comment);
+// Try to determine if the end of a stream of tokens is either the
+// Definition or the Declaration for a function. It does this by looking 
for
+// the ';' in foo(); and using that it ends with a ; to know this is the
+// Definition, however the line could end with
+//foo(); /* comment */
+// or
+//foo(); // comment
+// or
+//foo() // comment
+// endsWith() ignores the comment.
+return !endsWith(tok::semi);
   }
 
   /// \c true if this line starts a namespace definition.

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=358375&r1=358374&r2=358375&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Apr 15 00:47:15 2019
@@ -5768,6 +5768,26 @@ TEST_F(FormatTest, ReturnTypeBreakingSty
"  return a;\n"
"}\n",
Style);
+
+  Style = getGNUStyle();
+
+  // Test for comments at the end of function declarations.
+  verifyFormat("void\n"
+   "foo (int a, /*abc*/ int b) // def\n"
+   "{\n"
+   "}\n",
+   Style);
+
+  verifyFormat("void\n"
+   "foo (int a, /* abc */ int b) /* def */\n"
+   "{\n"
+   "}\n",
+   Style);
+
+  // Definitions that should not break after return type
+  verifyFormat("void foo (int a, int b); // def\n", Style);
+  verifyFormat("void foo (int a, int b); /* def */\n", Style);
+  verifyFormat("void foo (int a, int b);\n", Style);
 }
 
 TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) {


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


[PATCH] D60363: [clang-format] [PR41170] Break after return type ignored with certain comments positions

2019-04-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358375: [clang-format] [PR41170] Break after return type 
ignored with certain comments… (authored by paulhoad, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D60363?vs=195057&id=195099#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60363

Files:
  cfe/trunk/lib/Format/TokenAnnotator.h
  cfe/trunk/unittests/Format/FormatTest.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.h
===
--- cfe/trunk/lib/Format/TokenAnnotator.h
+++ cfe/trunk/lib/Format/TokenAnnotator.h
@@ -99,9 +99,17 @@
   /// function declaration. Asserts MightBeFunctionDecl.
   bool mightBeFunctionDefinition() const {
 assert(MightBeFunctionDecl);
-// FIXME: Line.Last points to other characters than tok::semi
-// and tok::lbrace.
-return !Last->isOneOf(tok::semi, tok::comment);
+// Try to determine if the end of a stream of tokens is either the
+// Definition or the Declaration for a function. It does this by looking 
for
+// the ';' in foo(); and using that it ends with a ; to know this is the
+// Definition, however the line could end with
+//foo(); /* comment */
+// or
+//foo(); // comment
+// or
+//foo() // comment
+// endsWith() ignores the comment.
+return !endsWith(tok::semi);
   }
 
   /// \c true if this line starts a namespace definition.
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -5768,6 +5768,26 @@
"  return a;\n"
"}\n",
Style);
+
+  Style = getGNUStyle();
+
+  // Test for comments at the end of function declarations.
+  verifyFormat("void\n"
+   "foo (int a, /*abc*/ int b) // def\n"
+   "{\n"
+   "}\n",
+   Style);
+
+  verifyFormat("void\n"
+   "foo (int a, /* abc */ int b) /* def */\n"
+   "{\n"
+   "}\n",
+   Style);
+
+  // Definitions that should not break after return type
+  verifyFormat("void foo (int a, int b); // def\n", Style);
+  verifyFormat("void foo (int a, int b); /* def */\n", Style);
+  verifyFormat("void foo (int a, int b);\n", Style);
 }
 
 TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) {


Index: cfe/trunk/lib/Format/TokenAnnotator.h
===
--- cfe/trunk/lib/Format/TokenAnnotator.h
+++ cfe/trunk/lib/Format/TokenAnnotator.h
@@ -99,9 +99,17 @@
   /// function declaration. Asserts MightBeFunctionDecl.
   bool mightBeFunctionDefinition() const {
 assert(MightBeFunctionDecl);
-// FIXME: Line.Last points to other characters than tok::semi
-// and tok::lbrace.
-return !Last->isOneOf(tok::semi, tok::comment);
+// Try to determine if the end of a stream of tokens is either the
+// Definition or the Declaration for a function. It does this by looking for
+// the ';' in foo(); and using that it ends with a ; to know this is the
+// Definition, however the line could end with
+//foo(); /* comment */
+// or
+//foo(); // comment
+// or
+//foo() // comment
+// endsWith() ignores the comment.
+return !endsWith(tok::semi);
   }
 
   /// \c true if this line starts a namespace definition.
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -5768,6 +5768,26 @@
"  return a;\n"
"}\n",
Style);
+
+  Style = getGNUStyle();
+
+  // Test for comments at the end of function declarations.
+  verifyFormat("void\n"
+   "foo (int a, /*abc*/ int b) // def\n"
+   "{\n"
+   "}\n",
+   Style);
+
+  verifyFormat("void\n"
+   "foo (int a, /* abc */ int b) /* def */\n"
+   "{\n"
+   "}\n",
+   Style);
+
+  // Definitions that should not break after return type
+  verifyFormat("void foo (int a, int b); // def\n", Style);
+  verifyFormat("void foo (int a, int b); /* def */\n", Style);
+  verifyFormat("void foo (int a, int b);\n", Style);
 }
 
 TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-15 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/test/SemaSYCL/device-attrubutes.cpp:8-11
+__attribute((sycl_kernel)) void foo();
+__attribute((sycl_device)) void foo1();
+[[clang::sycl_kernel]] void foo2();
+[[clang::sycl_device]] void foo3();

bader wrote:
> This duplicates clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp.
> Maybe it make sense to test case when both attributes are applied to the same 
> function.
From current documentation: sycl_kernel can be applied to function which can be 
directly called by the host and will be compiled for device, sycl_device 
applies to device functions which **cannot** be directly called by the host... 
I think if we want add this test case we need clarify how this case will be 
handled by the compiler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


r358378 - [Lookup] Invisible decls should not be ambiguous when renaming.

2019-04-15 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Apr 15 01:46:34 2019
New Revision: 358378

URL: http://llvm.org/viewvc/llvm-project?rev=358378&view=rev
Log:
[Lookup] Invisible decls should not be ambiguous when renaming.

Summary:
For example, a renamed type in a header file can conflict with declaration in
a random file that includes the header, but we should not consider the decl 
ambiguous if
it's not visible at the rename location. This improves consistency of generated 
replacements
when header file is included in different TUs.

Reviewers: hokein

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Tooling/Core/Lookup.h
cfe/trunk/lib/Tooling/Core/Lookup.cpp
cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
cfe/trunk/unittests/Tooling/LookupTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Core/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Lookup.h?rev=358378&r1=358377&r2=358378&view=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Lookup.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Lookup.h Mon Apr 15 01:46:34 2019
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_TOOLING_CORE_LOOKUP_H
 
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
 #include 
 
 namespace clang {
@@ -30,6 +31,7 @@ namespace tooling {
 /// This does not perform a full C++ lookup so ADL will not work.
 ///
 /// \param Use The nested name to be replaced.
+/// \param UseLoc The location of name to be replaced.
 /// \param UseContext The context in which the nested name is contained. This
 ///   will be used to minimize namespace qualifications.
 /// \param FromDecl The declaration to which the nested name points.
@@ -37,6 +39,7 @@ namespace tooling {
 ///  qualified including a leading "::".
 /// \returns The new name to be inserted in place of the current nested name.
 std::string replaceNestedName(const NestedNameSpecifier *Use,
+  SourceLocation UseLoc,
   const DeclContext *UseContext,
   const NamedDecl *FromDecl,
   StringRef ReplacementString);

Modified: cfe/trunk/lib/Tooling/Core/Lookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Lookup.cpp?rev=358378&r1=358377&r2=358378&view=diff
==
--- cfe/trunk/lib/Tooling/Core/Lookup.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Lookup.cpp Mon Apr 15 01:46:34 2019
@@ -14,6 +14,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/SmallVector.h"
 using namespace clang;
 using namespace clang::tooling;
@@ -123,7 +124,8 @@ static bool isFullyQualified(const Neste
 // FIXME: consider using namespaces.
 static std::string disambiguateSpellingInScope(StringRef Spelling,
StringRef QName,
-   const DeclContext &UseContext) {
+   const DeclContext &UseContext,
+   SourceLocation UseLoc) {
   assert(QName.startswith("::"));
   assert(QName.endswith(Spelling));
   if (Spelling.startswith("::"))
@@ -138,9 +140,10 @@ static std::string disambiguateSpellingI
   getAllNamedNamespaces(&UseContext);
   auto &AST = UseContext.getParentASTContext();
   StringRef TrimmedQName = QName.substr(2);
+  const auto &SM = UseContext.getParentASTContext().getSourceManager();
+  UseLoc = SM.getSpellingLoc(UseLoc);
 
-  auto IsAmbiguousSpelling = [&EnclosingNamespaces, &AST, &TrimmedQName](
- const llvm::StringRef CurSpelling) {
+  auto IsAmbiguousSpelling = [&](const llvm::StringRef CurSpelling) {
 if (CurSpelling.startswith("::"))
   return false;
 // Lookup the first component of Spelling in all enclosing namespaces
@@ -151,7 +154,13 @@ static std::string disambiguateSpellingI
   auto LookupRes = NS->lookup(DeclarationName(&AST.Idents.get(Head)));
   if (!LookupRes.empty()) {
 for (const NamedDecl *Res : LookupRes)
-  if (!TrimmedQName.startswith(Res->getQualifiedNameAsString()))
+  // If `Res` is not visible in `UseLoc`, we don't consider it
+  // ambiguous. For example, a reference in a header file should not be
+  // affected by a potentially ambiguous name in some file that 
includes
+  // the header.
+  if (!TrimmedQName.startswith(Res->getQualifiedNameAsString()) &&
+  SM.isBeforeInTranslationUnit(
+  SM.getSpellingLoc(Res->getLocation()), UseLoc))
 return true;
   }
 }
@@ -172,6 +181,7 @@ static s

[PATCH] D60257: [Lookup] Invisible decls should not be ambiguous when renaming.

2019-04-15 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC358378: [Lookup] Invisible decls should not be ambiguous 
when renaming. (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60257?vs=194841&id=195103#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D60257

Files:
  include/clang/Tooling/Core/Lookup.h
  lib/Tooling/Core/Lookup.cpp
  lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  unittests/Tooling/LookupTest.cpp

Index: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -542,8 +542,8 @@
 if (!llvm::isa(
 RenameInfo.Context->getDeclContext())) {
   ReplacedName = tooling::replaceNestedName(
-  RenameInfo.Specifier, RenameInfo.Context->getDeclContext(),
-  RenameInfo.FromDecl,
+  RenameInfo.Specifier, RenameInfo.Begin,
+  RenameInfo.Context->getDeclContext(), RenameInfo.FromDecl,
   NewName.startswith("::") ? NewName.str()
: ("::" + NewName).str());
 } else {
Index: lib/Tooling/Core/Lookup.cpp
===
--- lib/Tooling/Core/Lookup.cpp
+++ lib/Tooling/Core/Lookup.cpp
@@ -14,6 +14,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/SmallVector.h"
 using namespace clang;
 using namespace clang::tooling;
@@ -123,7 +124,8 @@
 // FIXME: consider using namespaces.
 static std::string disambiguateSpellingInScope(StringRef Spelling,
StringRef QName,
-   const DeclContext &UseContext) {
+   const DeclContext &UseContext,
+   SourceLocation UseLoc) {
   assert(QName.startswith("::"));
   assert(QName.endswith(Spelling));
   if (Spelling.startswith("::"))
@@ -138,9 +140,10 @@
   getAllNamedNamespaces(&UseContext);
   auto &AST = UseContext.getParentASTContext();
   StringRef TrimmedQName = QName.substr(2);
+  const auto &SM = UseContext.getParentASTContext().getSourceManager();
+  UseLoc = SM.getSpellingLoc(UseLoc);
 
-  auto IsAmbiguousSpelling = [&EnclosingNamespaces, &AST, &TrimmedQName](
- const llvm::StringRef CurSpelling) {
+  auto IsAmbiguousSpelling = [&](const llvm::StringRef CurSpelling) {
 if (CurSpelling.startswith("::"))
   return false;
 // Lookup the first component of Spelling in all enclosing namespaces
@@ -151,7 +154,13 @@
   auto LookupRes = NS->lookup(DeclarationName(&AST.Idents.get(Head)));
   if (!LookupRes.empty()) {
 for (const NamedDecl *Res : LookupRes)
-  if (!TrimmedQName.startswith(Res->getQualifiedNameAsString()))
+  // If `Res` is not visible in `UseLoc`, we don't consider it
+  // ambiguous. For example, a reference in a header file should not be
+  // affected by a potentially ambiguous name in some file that includes
+  // the header.
+  if (!TrimmedQName.startswith(Res->getQualifiedNameAsString()) &&
+  SM.isBeforeInTranslationUnit(
+  SM.getSpellingLoc(Res->getLocation()), UseLoc))
 return true;
   }
 }
@@ -172,6 +181,7 @@
 }
 
 std::string tooling::replaceNestedName(const NestedNameSpecifier *Use,
+   SourceLocation UseLoc,
const DeclContext *UseContext,
const NamedDecl *FromDecl,
StringRef ReplacementString) {
@@ -206,5 +216,6 @@
   StringRef Suggested = getBestNamespaceSubstr(UseContext, ReplacementString,
isFullyQualified(Use));
 
-  return disambiguateSpellingInScope(Suggested, ReplacementString, *UseContext);
+  return disambiguateSpellingInScope(Suggested, ReplacementString, *UseContext,
+ UseLoc);
 }
Index: unittests/Tooling/LookupTest.cpp
===
--- unittests/Tooling/LookupTest.cpp
+++ unittests/Tooling/LookupTest.cpp
@@ -44,8 +44,8 @@
 const auto *Callee = cast(Expr->getCallee()->IgnoreImplicit());
 const ValueDecl *FD = Callee->getDecl();
 return tooling::replaceNestedName(
-Callee->getQualifier(), Visitor.DeclStack.back()->getDeclContext(), FD,
-ReplacementString);
+Callee->getQualifier(), Callee->getLocation(),
+Visitor.DeclStack.back()->getDeclContext(), FD, ReplacementSt

[clang-tools-extra] r358383 - [clangd] Bump clangd-index version for TemplateArgument changes

2019-04-15 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Mon Apr 15 02:18:57 2019
New Revision: 358383

URL: http://llvm.org/viewvc/llvm-project?rev=358383&view=rev
Log:
[clangd] Bump clangd-index version for TemplateArgument changes

Modified:
clang-tools-extra/trunk/clangd/index/Serialization.cpp

Modified: clang-tools-extra/trunk/clangd/index/Serialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Serialization.cpp?rev=358383&r1=358382&r2=358383&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Mon Apr 15 02:18:57 
2019
@@ -370,7 +370,7 @@ readRefs(Reader &Data, llvm::ArrayRef readRIFF(llvm::StringRef Data) {
   auto RIFF = riff::readFile(Data);


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


[PATCH] D60607: [clangd] Wait for compile command in ASTWorker instead of ClangdServer

2019-04-15 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 195111.
ioeric added a comment.

- Only return compile command (instead of FileInputs) from AST worker.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60607

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Compiler.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -21,8 +21,6 @@
 namespace clangd {
 namespace {
 
-using ::testing::_;
-using ::testing::AllOf;
 using ::testing::AnyOf;
 using ::testing::Each;
 using ::testing::ElementsAre;
@@ -103,7 +101,7 @@
 TUSchedulerTests::DiagsCallbackKey;
 
 TEST_F(TUSchedulerTests, MissingFiles) {
-  TUScheduler S(getDefaultAsyncThreadsCount(),
+  TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true, /*ASTCallbacks=*/nullptr,
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -154,7 +152,7 @@
 // thread until we've scheduled them all.
 Notification Ready;
 TUScheduler S(
-getDefaultAsyncThreadsCount(),
+CDB, getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true, captureDiags(),
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -184,7 +182,7 @@
 TEST_F(TUSchedulerTests, Debounce) {
   std::atomic CallbackCount(0);
   {
-TUScheduler S(getDefaultAsyncThreadsCount(),
+TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true, captureDiags(),
   /*UpdateDebounce=*/std::chrono::seconds(1),
   ASTRetentionPolicy());
@@ -220,7 +218,7 @@
   {
 Notification InconsistentReadDone; // Must live longest.
 TUScheduler S(
-getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
+CDB, getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
 /*ASTCallbacks=*/nullptr,
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -277,7 +275,7 @@
   {
 Notification Proceed; // Ensure we schedule everything.
 TUScheduler S(
-getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
+CDB, getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
 /*ASTCallbacks=*/captureDiags(),
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -346,7 +344,7 @@
 
   // Run TUScheduler and collect some stats.
   {
-TUScheduler S(getDefaultAsyncThreadsCount(),
+TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true, captureDiags(),
   /*UpdateDebounce=*/std::chrono::milliseconds(50),
   ASTRetentionPolicy());
@@ -437,10 +435,11 @@
   std::atomic BuiltASTCounter(0);
   ASTRetentionPolicy Policy;
   Policy.MaxRetainedASTs = 2;
-  TUScheduler S(
-  /*AsyncThreadsCount=*/1, /*StorePreambleInMemory=*/true,
-  /*ASTCallbacks=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(), Policy);
+  TUScheduler S(CDB,
+/*AsyncThreadsCount=*/1, /*StorePreambleInMemory=*/true,
+/*ASTCallbacks=*/nullptr,
+/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+Policy);
 
   llvm::StringLiteral SourceContents = R"cpp(
 int* a;
@@ -487,11 +486,11 @@
 }
 
 TEST_F(TUSchedulerTests, EmptyPreamble) {
-  TUScheduler S(
-  /*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*/true,
-  /*ASTCallbacks=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
-  ASTRetentionPolicy());
+  TUScheduler S(CDB,
+/*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*/true,
+/*ASTCallbacks=*/nullptr,
+/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+ASTRetentionPolicy());
 
   auto Foo = testPath("foo.cpp");
   auto Header = testPath("foo.h");
@@ -532,11 +531,11 @@
 TEST_F(TUSchedulerTests, RunWaitsForPreamble) {
   // Testing strategy: we update the file and schedule a few preamble reads at
   // the same time. All reads should get the same non-null preamble.
-  TUScheduler S(
-  /*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*/true,
-  /*ASTCallbacks=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
-  ASTRetentionPolicy());
+  TUScheduler S(CDB,
+/*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*

[PATCH] D60485: [AArch64] Add support for MTE intrinsics

2019-04-15 Thread Javed Absar via Phabricator via cfe-commits
javed.absar updated this revision to Diff 195112.
javed.absar added a comment.

Tests merged as suggested.


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

https://reviews.llvm.org/D60485

Files:
  include/clang/Basic/BuiltinsAArch64.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/AArch64.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/arm_acle.h
  lib/Sema/SemaChecking.cpp
  test/CodeGen/arm64-mte.c
  test/Preprocessor/aarch64-target-features.c
  test/Sema/builtins-arm64-mte.c

Index: test/Sema/builtins-arm64-mte.c
===
--- /dev/null
+++ test/Sema/builtins-arm64-mte.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -fsyntax-only -verify
+// RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -x c++ -fsyntax-only -verify
+#include 
+#include 
+
+int  *create_tag1(int a, unsigned b) {
+  // expected-error@+1 {{first argument must be a pointer ('int' invalid)}}
+  return __arm_mte_create_random_tag(a,b);
+}
+
+int  *create_tag2(int *a, unsigned *b) {
+  // expected-error@+1 {{second argument must be an integer type ('unsigned int *' invalid)}}
+  return __arm_mte_create_random_tag(a,b);
+}
+
+int  *create_tag3(const int *a, unsigned b) {
+#ifdef __cplusplus
+  // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const int *'}}
+  return __arm_mte_create_random_tag(a,b);
+#else
+  // expected-warning@+1 {{returning 'const int *' from a function with result type 'int *' discards qualifiers}}
+  return __arm_mte_create_random_tag(a,b);
+#endif
+}
+
+int  *create_tag4(volatile int *a, unsigned b) {
+#ifdef __cplusplus
+  // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'volatile int *'}}
+  return __arm_mte_create_random_tag(a,b);
+#else
+  // expected-warning@+1 {{returning 'volatile int *' from a function with result type 'int *' discards qualifiers}}
+  return __arm_mte_create_random_tag(a,b);
+#endif
+}
+
+int  *increment_tag1(int *a, unsigned b) {
+  // expected-error@+1 {{argument to '__builtin_arm_addg' must be a constant integer}}
+  return __arm_mte_increment_tag(a,b);
+}
+
+int  *increment_tag2(int *a) {
+  // expected-error@+1 {{argument value 16 is outside the valid range [0, 15]}}
+  return __arm_mte_increment_tag(a,16);
+}
+
+int  *increment_tag3(int *a) {
+  // expected-error@+1 {{argument value -1 is outside the valid range [0, 15]}}
+  return __arm_mte_increment_tag(a,-1);
+}
+
+int  *increment_tag4(const int *a) {
+#ifdef __cplusplus
+  // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const int *'}}
+  return __arm_mte_increment_tag(a,5);
+#else
+  // expected-warning@+1 {{returning 'const int *' from a function with result type 'int *' discards qualifiers}}
+  return __arm_mte_increment_tag(a,5);
+#endif
+}
+
+int *increment_tag5(const volatile int *a) {
+#ifdef __cplusplus
+  // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const volatile int *'}}
+  return __arm_mte_increment_tag(a,5);
+#else
+  // expected-warning@+1 {{returning 'const volatile int *' from a function with result type 'int *' discards qualifiers}}
+  return __arm_mte_increment_tag(a,5);
+#endif
+}
+
+unsigned exclude_tag1(int *ptr, unsigned m) {
+   // expected-error@+1 {{first argument must be a pointer ('int' invalid)}}
+   return  __arm_mte_exclude_tag(*ptr, m);
+}
+
+unsigned exclude_tag2(int *ptr, int *m) {
+   // expected-error@+1 {{second argument must be an integer type ('int *' invalid)}}
+   return  __arm_mte_exclude_tag(ptr, m);
+}
+
+void get_tag1() {
+   // expected-error@+1 {{too few arguments to function call, expected 1, have 0}}
+   __arm_mte_get_tag();
+}
+
+int *get_tag2(int ptr) {
+   // expected-error@+1 {{first argument must be a pointer ('int' invalid)}}
+   return __arm_mte_get_tag(ptr);
+}
+
+int *get_tag3(const volatile int *ptr) {
+#ifdef __cplusplus
+  // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const volatile int *'}}
+  return __arm_mte_get_tag(ptr);
+#else
+  // expected-warning@+1 {{returning 'const volatile int *' from a function with result type 'int *' discards qualifiers}}
+  return __arm_mte_get_tag(ptr);
+#endif
+}
+
+void set_tag1() {
+   // expected-error@+1 {{too few arguments to function call, expected 1, have 0}}
+   __arm_mte_set_tag();
+}
+
+void set_tag2(int ptr) {
+   // expected-error@+1 {{first argument must be a pointer ('int' invalid)}}
+   __arm_mte_set_tag(ptr);
+}
+
+ptrdiff_t subtract_pointers1(int a, int *b) {
+  // expected-error@+1 {{first argument must be a null or a pointer ('int' invalid)}}
+  return __arm_mte_ptrdiff(a, b);
+}
+
+ptrdiff_t subtract_pointers2(int *a, int b) {
+  // expected-error@+1 {{second argument must be a null or a

[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-15 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: clang/test/SemaSYCL/device-attrubutes.cpp:8-11
+__attribute((sycl_kernel)) void foo();
+__attribute((sycl_device)) void foo1();
+[[clang::sycl_kernel]] void foo2();
+[[clang::sycl_device]] void foo3();

Fznamznon wrote:
> bader wrote:
> > This duplicates clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp.
> > Maybe it make sense to test case when both attributes are applied to the 
> > same function.
> From current documentation: sycl_kernel can be applied to function which can 
> be directly called by the host and will be compiled for device, sycl_device 
> applies to device functions which **cannot** be directly called by the 
> host... 
> I think if we want add this test case we need clarify how this case will be 
> handled by the compiler.
> From current documentation: sycl_kernel can be applied to function which can 
> be directly called by the host and will be compiled for device, sycl_device 
> applies to device functions which cannot be directly called by the host... 
> I think if we want add this test case we need clarify how this case will be 
> handled by the compiler.

I would expect `sycl_kernel` to supersede `sycl_device` attribute. Basically 
`sycl_kernel` include functionality of `sycl_device` attribute and provides 
additional host accessibility.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D60485: [AArch64] Add support for MTE intrinsics

2019-04-15 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9566
+def err_memtag_arg_null_or_pointer : Error<
+  "%0 argument must be a null or a pointer (%1 invalid)">;
+def err_memtag_any2arg_pointer : Error<

I think these diagnostics could do with a bit more context for consistency. 
They seem to take "MTE builtin" for granted, whereas most Clang messages 
mention what they're talking about.

I'm not saying "MTE builtin" is the best we can come up with, BTW, just that 
something more would be nice.



Comment at: lib/Headers/arm_acle.h:610-615
+#define __arm_mte_create_random_tag(__ptr, __mask)  __builtin_arm_irg(__ptr, 
__mask)
+#define __arm_mte_increment_tag(__ptr, __tag_offset)  
__builtin_arm_addg(__ptr, __tag_offset)
+#define __arm_mte_exclude_tag(__ptr, __excluded)  __builtin_arm_gmi(__ptr, 
__excluded)
+#define __arm_mte_get_tag(__ptr) __builtin_arm_ldg(__ptr)
+#define __arm_mte_set_tag(__ptr) __builtin_arm_stg(__ptr)
+#define __arm_mte_ptrdiff(__ptra, __ptrb) __builtin_arm_subp(__ptra, __ptrb)

Why are the builtin names so different from the ones exposed. GCC 
compatibility? LLVM?



Comment at: lib/Sema/SemaChecking.cpp:6113
+bool Sema::SemaBuiltinARMMemoryTaggingCall( unsigned BuiltinID, CallExpr 
*TheCall) {
+  bool IsMTEBuiltin = BuiltinID == AArch64::BI__builtin_arm_irg ||
+  BuiltinID == AArch64::BI__builtin_arm_addg ||

I think this will generate an unused variable warning in a non-asserts build.


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

https://reviews.llvm.org/D60485



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


[PATCH] D60607: [clangd] Wait for compile command in ASTWorker instead of ClangdServer

2019-04-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks, the change LG now. Only nits from my side!




Comment at: clangd/Compiler.h:19
 #include "../clang-tidy/ClangTidyOptions.h"
+#include "GlobalCompilationDatabase.h"
 #include "index/Index.h"

NIT: this looks unrelated to the actual change. Maybe revert?



Comment at: clangd/TUScheduler.cpp:224
 
+  std::shared_ptr getCurrentFileInputs() const;
+

Could you add a comment that this is private because `Inputs.FS` is not 
thread-safe and the client code should take care to not expose it via a public 
interface.



Comment at: clangd/TUScheduler.cpp:255
   mutable std::mutex Mutex;
+  /// Inputs, corresponding to the current state of AST.
+  std::shared_ptr FileInputs; /* GUARDED_BY(Mutex) 
*/

This comment is not true anymore, the `FileInputs` might be out-of-sync with 
the AST for short spans of time.
Maybe something like:
```
/// File inputs, currently being used by the worker.
/// Inputs are written and read by the worker thread, compile command can also 
be consumed by clients of ASTWorker.
```



Comment at: clangd/TUScheduler.cpp:343
+  auto Inputs = std::make_shared();
+  Inputs->CompileCommand = CDB.getFallbackCommand(FileName);
+  FileInputs = std::move(Inputs);

NIT:  maybe add a comment explaining why only `CompileCommand` is set and not 
the other fields?
Thinking of something like:
```
// Other fields are never read outside worker thread and the worker thread will 
initialize them before first use.
```



Comment at: clangd/TUScheduler.cpp:360
   auto Task = [=]() mutable {
+// Get the actual command as `Inputs` contains fallback command.
+// FIXME: some build systems like Bazel will take time to preparing

IIUC, The comment does not correspond to the latest version.
s/contains fallback command/does not have a command.



Comment at: clangd/TUScheduler.cpp:380
+  std::lock_guard Lock(Mutex);
+  FileInputs.reset(new ParseInputs(Inputs));
+}

NIT: maybe avoid using new?
```FileInputs = std::make_shared(Inputs)```

Feel free to keep as is too, I find the proposed style simpler to follow, but 
you could reasonably disagree.



Comment at: unittests/clangd/ClangdTests.cpp:1148
+  EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
+  // Identifier-based fallback completion doesn't know about "symbol" scope.
+  EXPECT_THAT(Res.Completions,

Not strictly related to this patch, but maybe we could add a flag to completion 
results to indicate if the completion happened via a fallback mode or not?

Would make the test code more straightforward and the tests like these would 
not rely on a particular implementation of the fallback mode (e.g. I can 
imagine the fallback mode learning about the scopes later on)



Comment at: unittests/clangd/CodeCompleteTests.cpp:1390
   Server.addDocument(FooCpp, Source.code(), WantDiagnostics::Yes);
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
   CodeCompleteResult Completions = cantFail(runCodeComplete(

Could you expand why we need this?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60607



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


[PATCH] D60485: [AArch64] Add support for MTE intrinsics

2019-04-15 Thread Javed Absar via Phabricator via cfe-commits
javed.absar marked 2 inline comments as done.
javed.absar added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9566
+def err_memtag_arg_null_or_pointer : Error<
+  "%0 argument must be a null or a pointer (%1 invalid)">;
+def err_memtag_any2arg_pointer : Error<

t.p.northover wrote:
> I think these diagnostics could do with a bit more context for consistency. 
> They seem to take "MTE builtin" for granted, whereas most Clang messages 
> mention what they're talking about.
> 
> I'm not saying "MTE builtin" is the best we can come up with, BTW, just that 
> something more would be nice.
I thought of doing that too , so can prefix these warnings with 'mte builtin' 
if that's what you meant. But the intrinsic called kind of names same thing 
(__arm_mte_..).



Comment at: lib/Headers/arm_acle.h:610-615
+#define __arm_mte_create_random_tag(__ptr, __mask)  __builtin_arm_irg(__ptr, 
__mask)
+#define __arm_mte_increment_tag(__ptr, __tag_offset)  
__builtin_arm_addg(__ptr, __tag_offset)
+#define __arm_mte_exclude_tag(__ptr, __excluded)  __builtin_arm_gmi(__ptr, 
__excluded)
+#define __arm_mte_get_tag(__ptr) __builtin_arm_ldg(__ptr)
+#define __arm_mte_set_tag(__ptr) __builtin_arm_stg(__ptr)
+#define __arm_mte_ptrdiff(__ptra, __ptrb) __builtin_arm_subp(__ptra, __ptrb)

t.p.northover wrote:
> Why are the builtin names so different from the ones exposed. GCC 
> compatibility? LLVM?
The builtin name (e.g. _mte_irg) is reflecting the instruction that implements 
the otherwise meaningful ACLE names  (mte_create_tag). Its just that the 
instruction names are sometimes cryptic (e.g. stg, ldg). I could change the 
names to __builtin_arm_create_tag etc and push the meaningful name -> insn 
level name to intrinsic level or further down but that would mean lots of name 
changes to current patch and tests. 


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

https://reviews.llvm.org/D60485



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


[PATCH] D58236: Make address space conversions a bit stricter.

2019-04-15 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

Well, it doesn't seem to me like there is consensus on prohibiting nested 
address space conversion like this.

I can simply redo the patch to only include the bugfix on implicit conversions 
and drop the nesting level checks.


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

https://reviews.llvm.org/D58236



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


r358393 - [MinGW] Remove some supefluous calls to MakeArgString. NFC.

2019-04-15 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon Apr 15 03:57:09 2019
New Revision: 358393

URL: http://llvm.org/viewvc/llvm-project?rev=358393&view=rev
Log:
[MinGW] Remove some supefluous calls to MakeArgString. NFC.

Modified:
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=358393&r1=358392&r2=358393&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Mon Apr 15 03:57:09 2019
@@ -252,16 +252,16 @@ void tools::MinGW::Linker::ConstructJob(
 ToolChain::FT_Shared));
 CmdArgs.push_back(
 TC.getCompilerRTArgString(Args, "asan_dynamic_runtime_thunk"));
-CmdArgs.push_back(Args.MakeArgString("--require-defined"));
-CmdArgs.push_back(Args.MakeArgString(TC.getArch() == llvm::Triple::x86
- ? "___asan_seh_interceptor"
- : "__asan_seh_interceptor"));
+CmdArgs.push_back("--require-defined");
+CmdArgs.push_back(TC.getArch() == llvm::Triple::x86
+  ? "___asan_seh_interceptor"
+  : "__asan_seh_interceptor");
 // Make sure the linker consider all object files from the dynamic
 // runtime thunk.
-CmdArgs.push_back(Args.MakeArgString("--whole-archive"));
-CmdArgs.push_back(Args.MakeArgString(
-TC.getCompilerRT(Args, "asan_dynamic_runtime_thunk")));
-CmdArgs.push_back(Args.MakeArgString("--no-whole-archive"));
+CmdArgs.push_back("--whole-archive");
+CmdArgs.push_back(
+TC.getCompilerRTArgString(Args, "asan_dynamic_runtime_thunk"));
+CmdArgs.push_back("--no-whole-archive");
   }
 
   TC.addProfileRTLibs(Args, CmdArgs);


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


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-15 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 195128.
Fznamznon added a comment.

Applied comments from @bader


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp
  clang/test/SemaSYCL/device-attributes.cpp

Index: clang/test/SemaSYCL/device-attributes.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/device-attributes.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -fsycl-is-device -verify %s
+
+[[clang::sycl_device]] int gv = 0;
+__attribute((sycl_device)) int gv1 = 0;
+[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to functions}}
+__attribute((sycl_kernel)) int gv3 = 0; // expected-warning {{'sycl_kernel' attribute only applies to functions}}
+
+__attribute((sycl_kernel)) __attribute((sycl_device)) void foo();
+[[clang::sycl_kernel]] [[clang::sycl_device]] void foo1();
+
+__attribute((sycl_kernel(1))) void foo(); // expected-error {{'sycl_kernel' attribute takes no arguments}}
+__attribute((sycl_device(1))) void foo1(); // expected-error {{'sycl_device' attribute takes no arguments}}
+[[clang::sycl_kernel(1)]] void foo2(); // expected-error {{'sycl_kernel' attribute takes no arguments}}
+[[clang::sycl_device(1)]] void foo3(); // expected-error {{'sycl_device' attribute takes no arguments}}
Index: clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -fsycl-is-device -verify %s
+// Now pretend that we're compiling a C++ file. There should be warnings.
+// RUN: %clang_cc1 -DEXPECT_WARNINGS -fsyntax-only -verify -x c++ %s
+
+#if not defined(__SYCL_DEVICE_ONLY__)
+// expected-warning@+8 {{'sycl_kernel' attribute ignored}}
+// expected-warning@+8 {{'sycl_device' attribute ignored}}
+// expected-warning@+8 {{'sycl_kernel' attribute ignored}}
+// expected-warning@+8 {{'sycl_device' attribute ignored}}
+#else
+// expected-no-diagnostics
+#endif
+
+__attribute((sycl_kernel)) void foo();
+__attribute((sycl_device)) void foo1();
+[[clang::sycl_kernel]] void foo2();
+[[clang::sycl_device]] void foo3();
+
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -124,6 +124,8 @@
 // CHECK-NEXT: ReturnTypestate (SubjectMatchRule_function, SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: ReturnsNonNull (SubjectMatchRule_objc_method, SubjectMatchRule_function)
 // CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function)
+// CHECK-NEXT: SYCLDevice (SubjectMatchRule_function, SubjectMatchRule_variable)
+// CHECK-NEXT: SYCLKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
 // CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
 // CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6755,6 +6755,12 @@
   case ParsedAttr::AT_Flatten:
 handleSimpleAttribute(S, D, AL);
 break;
+  case ParsedAttr::AT_SYCLDevice:
+handleSimpleAttribute(S, D, AL);
+break;
+  case ParsedAttr::AT_SYCLKernel:
+handleSimpleAttribute(S, D, AL);
+break;
   case ParsedAttr::AT_Format:
 handleFormatAttr(S, D, AL);
 break;
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -253,6 +253,50 @@
   }];
 }
 
+def SYCLDeviceDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The sycl_device attribute specifies function which is supposed to be compiled
+for the device and cannot be directly called by the host. Here is code example
+of the SYCL program, which demonstrates the need for this attribute:
+
+.. code-block:: c++
+
+  int foo(int x) { return ++x; }
+
+  using namespace cl::sycl;
+  queue Q;
+  buffer a(range<1>{1024});
+  Q.submit([&](handler& cgh) {
+auto A = a.get_access(cgh);
+cgh.parallel_for(range<1>{1024}, [=](id<1> index) {
+  A[index] = index[0] * 2 + index[1] + foo(42);
+});
+  }
+
+Code is passed to parallel_for is called "kernel function" and defines some
+entry poi

[PATCH] D60685: [clangd] Dont index Symbols with invalid source location

2019-04-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ioeric, 
ilya-biryukov.
Herald added a project: clang.

After rL358098  clangd started to index 
redecls of implicit symbols, but
sometimes these decls lack the source location information which results in
undefined behaviors in clangd.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60685

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp


Index: clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
===
--- clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
+++ clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
@@ -1241,6 +1241,14 @@
   EXPECT_THAT(Symbols, Contains(QName("printf")));
 }
 
+TEST_F(SymbolCollectorTest, InvalidSourceLoc) {
+  const char *Header = R"(
+  void operator delete(void*)
+__attribute__((__externally_visible__));)";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -302,7 +302,7 @@
   if (D->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None)
 D = CanonicalDecls.try_emplace(D, ASTNode.OrigD).first->second;
   const NamedDecl *ND = dyn_cast(D);
-  if (!ND)
+  if (!ND || ND->getLocation().isInvalid())
 return true;
 
   // Mark D as referenced if this is a reference coming from the main file.
@@ -540,6 +540,7 @@
   S.SymInfo = index::getSymbolInfo(&ND);
   std::string FileURI;
   auto Loc = findNameLoc(&ND);
+  assert(Loc.isValid() && "Invalid source location for NamedDecl");
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM, SM.getFileID(Loc), Opts, &FilesToIndexCache);
   if (auto DeclLoc =


Index: clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
===
--- clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
+++ clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
@@ -1241,6 +1241,14 @@
   EXPECT_THAT(Symbols, Contains(QName("printf")));
 }
 
+TEST_F(SymbolCollectorTest, InvalidSourceLoc) {
+  const char *Header = R"(
+  void operator delete(void*)
+__attribute__((__externally_visible__));)";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -302,7 +302,7 @@
   if (D->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None)
 D = CanonicalDecls.try_emplace(D, ASTNode.OrigD).first->second;
   const NamedDecl *ND = dyn_cast(D);
-  if (!ND)
+  if (!ND || ND->getLocation().isInvalid())
 return true;
 
   // Mark D as referenced if this is a reference coming from the main file.
@@ -540,6 +540,7 @@
   S.SymInfo = index::getSymbolInfo(&ND);
   std::string FileURI;
   auto Loc = findNameLoc(&ND);
+  assert(Loc.isValid() && "Invalid source location for NamedDecl");
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM, SM.getFileID(Loc), Opts, &FilesToIndexCache);
   if (auto DeclLoc =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-15 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.

LGTM. One minor comment.




Comment at: clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp:3
+// Now pretend that we're compiling a C++ file. There should be warnings.
+// RUN: %clang_cc1 -DEXPECT_WARNINGS -fsyntax-only -verify -x c++ %s
+

No need to pass "EXPECT_WARNINGS" define.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D60674: [X86] Restore the pavg intrinsics.

2019-04-15 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM - there's too many different optimizations and canonicalizations that can 
occur on such a pattern to be able to match all of the permutations.

We can probably add some InstCombine optimizations (e.g. where the avg can't 
overflow etc.) and keep the existing DAG matching.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60674



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


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-15 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 195134.
Fznamznon added a comment.

Applied comment from @bader.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp
  clang/test/SemaSYCL/device-attributes.cpp

Index: clang/test/SemaSYCL/device-attributes.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/device-attributes.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -fsycl-is-device -verify %s
+
+[[clang::sycl_device]] int gv = 0;
+__attribute((sycl_device)) int gv1 = 0;
+[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to functions}}
+__attribute((sycl_kernel)) int gv3 = 0; // expected-warning {{'sycl_kernel' attribute only applies to functions}}
+
+__attribute((sycl_kernel)) __attribute((sycl_device)) void foo();
+[[clang::sycl_kernel]] [[clang::sycl_device]] void foo1();
+
+__attribute((sycl_kernel(1))) void foo(); // expected-error {{'sycl_kernel' attribute takes no arguments}}
+__attribute((sycl_device(1))) void foo1(); // expected-error {{'sycl_device' attribute takes no arguments}}
+[[clang::sycl_kernel(1)]] void foo2(); // expected-error {{'sycl_kernel' attribute takes no arguments}}
+[[clang::sycl_device(1)]] void foo3(); // expected-error {{'sycl_device' attribute takes no arguments}}
Index: clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -fsycl-is-device -verify %s
+// Now pretend that we're compiling a C++ file. There should be warnings.
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
+
+#if not defined(__SYCL_DEVICE_ONLY__)
+// expected-warning@+8 {{'sycl_kernel' attribute ignored}}
+// expected-warning@+8 {{'sycl_device' attribute ignored}}
+// expected-warning@+8 {{'sycl_kernel' attribute ignored}}
+// expected-warning@+8 {{'sycl_device' attribute ignored}}
+#else
+// expected-no-diagnostics
+#endif
+
+__attribute((sycl_kernel)) void foo();
+__attribute((sycl_device)) void foo1();
+[[clang::sycl_kernel]] void foo2();
+[[clang::sycl_device]] void foo3();
+
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -124,6 +124,8 @@
 // CHECK-NEXT: ReturnTypestate (SubjectMatchRule_function, SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: ReturnsNonNull (SubjectMatchRule_objc_method, SubjectMatchRule_function)
 // CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function)
+// CHECK-NEXT: SYCLDevice (SubjectMatchRule_function, SubjectMatchRule_variable)
+// CHECK-NEXT: SYCLKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
 // CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
 // CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6755,6 +6755,12 @@
   case ParsedAttr::AT_Flatten:
 handleSimpleAttribute(S, D, AL);
 break;
+  case ParsedAttr::AT_SYCLDevice:
+handleSimpleAttribute(S, D, AL);
+break;
+  case ParsedAttr::AT_SYCLKernel:
+handleSimpleAttribute(S, D, AL);
+break;
   case ParsedAttr::AT_Format:
 handleFormatAttr(S, D, AL);
 break;
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -253,6 +253,50 @@
   }];
 }
 
+def SYCLDeviceDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The sycl_device attribute specifies function which is supposed to be compiled
+for the device and cannot be directly called by the host. Here is code example
+of the SYCL program, which demonstrates the need for this attribute:
+
+.. code-block:: c++
+
+  int foo(int x) { return ++x; }
+
+  using namespace cl::sycl;
+  queue Q;
+  buffer a(range<1>{1024});
+  Q.submit([&](handler& cgh) {
+auto A = a.get_access(cgh);
+cgh.parallel_for(range<1>{1024}, [=](id<1> index) {
+  A[index] = index[0] * 2 + index[1] + foo(42);
+});
+  }
+
+Code is passed to parallel_for is called "kernel function" and defines some
+entry point to device code 

[PATCH] D60687: [clangd] Check file path of declaring header when deciding whether to insert include.

2019-04-15 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Previously, we would use include spelling of the declaring header to check
whether the inserted header is the same as the main file. This doesn't help 
because
we only have file path of the main file.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D60687

Files:
  clangd/CodeComplete.cpp
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/IncludeFixer.cpp
  unittests/clangd/HeadersTests.cpp

Index: unittests/clangd/HeadersTests.cpp
===
--- unittests/clangd/HeadersTests.cpp
+++ unittests/clangd/HeadersTests.cpp
@@ -93,11 +93,10 @@
  &Clang->getPreprocessor().getHeaderSearchInfo());
 for (const auto &Inc : Inclusions)
   Inserter.addExisting(Inc);
-auto Declaring = ToHeaderFile(Original);
 auto Inserted = ToHeaderFile(Preferred);
-if (!Inserter.shouldInsertInclude(Declaring, Inserted))
+if (!Inserter.shouldInsertInclude(Original, Inserted))
   return "";
-std::string Path = Inserter.calculateIncludePath(Declaring, Inserted);
+std::string Path = Inserter.calculateIncludePath(Inserted);
 Action.EndSourceFile();
 return Path;
   }
@@ -258,16 +257,15 @@
/*BuildDir=*/"", /*HeaderSearchInfo=*/nullptr);
 
   auto HeaderPath = testPath("sub/bar.h");
-  auto Declaring = HeaderFile{HeaderPath, /*Verbatim=*/false};
   auto Inserting = HeaderFile{HeaderPath, /*Verbatim=*/false};
   auto Verbatim = HeaderFile{"", /*Verbatim=*/true};
 
-  EXPECT_EQ(Inserter.calculateIncludePath(Declaring, Inserting),
+  EXPECT_EQ(Inserter.calculateIncludePath(Inserting),
 "\"" + HeaderPath + "\"");
-  EXPECT_EQ(Inserter.shouldInsertInclude(Declaring, Inserting), false);
+  EXPECT_EQ(Inserter.shouldInsertInclude(HeaderPath, Inserting), false);
 
-  EXPECT_EQ(Inserter.calculateIncludePath(Declaring, Verbatim), "");
-  EXPECT_EQ(Inserter.shouldInsertInclude(Declaring, Verbatim), true);
+  EXPECT_EQ(Inserter.calculateIncludePath(Verbatim), "");
+  EXPECT_EQ(Inserter.shouldInsertInclude(HeaderPath, Verbatim), true);
 }
 
 } // namespace
Index: clangd/IncludeFixer.cpp
===
--- clangd/IncludeFixer.cpp
+++ clangd/IncludeFixer.cpp
@@ -142,15 +142,17 @@
 std::vector IncludeFixer::fixesForSymbols(const SymbolSlab &Syms) const {
   auto Inserted = [&](const Symbol &Sym, llvm::StringRef Header)
   -> llvm::Expected> {
-auto ResolvedDeclaring =
-toHeaderFile(Sym.CanonicalDeclaration.FileURI, File);
+auto DeclaringURI = URI::parse(Sym.CanonicalDeclaration.FileURI);
+if (!DeclaringURI)
+  return DeclaringURI.takeError();
+auto ResolvedDeclaring = URI::resolve(*DeclaringURI, File);
 if (!ResolvedDeclaring)
   return ResolvedDeclaring.takeError();
 auto ResolvedInserted = toHeaderFile(Header, File);
 if (!ResolvedInserted)
   return ResolvedInserted.takeError();
 return std::make_pair(
-Inserter->calculateIncludePath(*ResolvedDeclaring, *ResolvedInserted),
+Inserter->calculateIncludePath(*ResolvedInserted),
 Inserter->shouldInsertInclude(*ResolvedDeclaring, *ResolvedInserted));
   };
 
@@ -173,8 +175,8 @@
 {std::move(*Edit)}});
 }
   } else {
-vlog("Failed to calculate include insertion for {0} into {1}: {2}",
- File, Inc, ToInclude.takeError());
+vlog("Failed to calculate include insertion for {0} into {1}: {2}", Inc,
+ File, ToInclude.takeError());
   }
 }
   }
Index: clangd/Headers.h
===
--- clangd/Headers.h
+++ clangd/Headers.h
@@ -137,25 +137,22 @@
   ///   in \p Inclusions (including those included via different paths).
   ///   - \p DeclaringHeader or \p InsertedHeader is the same as \p File.
   ///
-  /// \param DeclaringHeader is the original header corresponding to \p
+  /// \param DeclaringHeader is path of the original header corresponding to \p
   /// InsertedHeader e.g. the header that declares a symbol.
   /// \param InsertedHeader The preferred header to be inserted. This could be
   /// the same as DeclaringHeader but must be provided.
-  bool shouldInsertInclude(const HeaderFile &DeclaringHeader,
+  bool shouldInsertInclude(PathRef DeclaringHeader,
const HeaderFile &InsertedHeader) const;
 
   /// Determines the preferred way to #include a file, taking into account the
   /// search path. Usually this will prefer a shorter representation like
   /// 'Foo/Bar.h' over a longer one like 'Baz/include/Foo/Bar.h'.
   ///
-  /// \param DeclaringHeader is the original header corresponding to \p
-  /// InsertedHeader e.g. the header that declares a symbol.
   /// 

[PATCH] D60607: [clangd] Wait for compile command in ASTWorker instead of ClangdServer

2019-04-15 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: unittests/clangd/ClangdTests.cpp:1148
+  EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
+  // Identifier-based fallback completion doesn't know about "symbol" scope.
+  EXPECT_THAT(Res.Completions,

ilya-biryukov wrote:
> Not strictly related to this patch, but maybe we could add a flag to 
> completion results to indicate if the completion happened via a fallback mode 
> or not?
> 
> Would make the test code more straightforward and the tests like these would 
> not rely on a particular implementation of the fallback mode (e.g. I can 
> imagine the fallback mode learning about the scopes later on)
We are setting the context to `Recovery` and make fallback as part of 
`Recovery`. Do you we should distinguish fallback mode from `Recovery`?



Comment at: unittests/clangd/CodeCompleteTests.cpp:1390
   Server.addDocument(FooCpp, Source.code(), WantDiagnostics::Yes);
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
   CodeCompleteResult Completions = cantFail(runCodeComplete(

ilya-biryukov wrote:
> Could you expand why we need this?
Added a comment.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60607



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


[PATCH] D60607: [clangd] Wait for compile command in ASTWorker instead of ClangdServer

2019-04-15 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 195137.
ioeric marked 9 inline comments as done.
ioeric added a comment.

- address comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60607

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Compiler.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -21,8 +21,6 @@
 namespace clangd {
 namespace {
 
-using ::testing::_;
-using ::testing::AllOf;
 using ::testing::AnyOf;
 using ::testing::Each;
 using ::testing::ElementsAre;
@@ -103,7 +101,7 @@
 TUSchedulerTests::DiagsCallbackKey;
 
 TEST_F(TUSchedulerTests, MissingFiles) {
-  TUScheduler S(getDefaultAsyncThreadsCount(),
+  TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true, /*ASTCallbacks=*/nullptr,
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -154,7 +152,7 @@
 // thread until we've scheduled them all.
 Notification Ready;
 TUScheduler S(
-getDefaultAsyncThreadsCount(),
+CDB, getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true, captureDiags(),
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -184,7 +182,7 @@
 TEST_F(TUSchedulerTests, Debounce) {
   std::atomic CallbackCount(0);
   {
-TUScheduler S(getDefaultAsyncThreadsCount(),
+TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true, captureDiags(),
   /*UpdateDebounce=*/std::chrono::seconds(1),
   ASTRetentionPolicy());
@@ -220,7 +218,7 @@
   {
 Notification InconsistentReadDone; // Must live longest.
 TUScheduler S(
-getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
+CDB, getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
 /*ASTCallbacks=*/nullptr,
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -277,7 +275,7 @@
   {
 Notification Proceed; // Ensure we schedule everything.
 TUScheduler S(
-getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
+CDB, getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
 /*ASTCallbacks=*/captureDiags(),
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -346,7 +344,7 @@
 
   // Run TUScheduler and collect some stats.
   {
-TUScheduler S(getDefaultAsyncThreadsCount(),
+TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true, captureDiags(),
   /*UpdateDebounce=*/std::chrono::milliseconds(50),
   ASTRetentionPolicy());
@@ -437,10 +435,11 @@
   std::atomic BuiltASTCounter(0);
   ASTRetentionPolicy Policy;
   Policy.MaxRetainedASTs = 2;
-  TUScheduler S(
-  /*AsyncThreadsCount=*/1, /*StorePreambleInMemory=*/true,
-  /*ASTCallbacks=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(), Policy);
+  TUScheduler S(CDB,
+/*AsyncThreadsCount=*/1, /*StorePreambleInMemory=*/true,
+/*ASTCallbacks=*/nullptr,
+/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+Policy);
 
   llvm::StringLiteral SourceContents = R"cpp(
 int* a;
@@ -487,11 +486,11 @@
 }
 
 TEST_F(TUSchedulerTests, EmptyPreamble) {
-  TUScheduler S(
-  /*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*/true,
-  /*ASTCallbacks=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
-  ASTRetentionPolicy());
+  TUScheduler S(CDB,
+/*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*/true,
+/*ASTCallbacks=*/nullptr,
+/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+ASTRetentionPolicy());
 
   auto Foo = testPath("foo.cpp");
   auto Header = testPath("foo.h");
@@ -532,11 +531,11 @@
 TEST_F(TUSchedulerTests, RunWaitsForPreamble) {
   // Testing strategy: we update the file and schedule a few preamble reads at
   // the same time. All reads should get the same non-null preamble.
-  TUScheduler S(
-  /*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*/true,
-  /*ASTCallbacks=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
-  ASTRetentionPolicy());
+  TUScheduler S(CDB,
+/*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*/true,
+   

[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:80
+// \endcode
+struct TextChange {
+  // The (bound) id of the node whose source will be replaced.  This id should

ymandel wrote:
> ilya-biryukov wrote:
> > ymandel wrote:
> > > ilya-biryukov wrote:
> > > > `MatchChange` or something similar might be a better name.
> > > > This actually tries to change the matched AST node to a textual 
> > > > replacement.
> > > I chose this to contrast with an AST change.  The idea being that we're 
> > > specifying a replacement relative to source code locations (informed by 
> > > the ast). If we later, say, integrate with your library I could imagine 
> > > specifying changes to AST nodes.  But, maybe I'm overthinking... If we're 
> > > going to drop "text", what about "source?" be clearer than "text"? E.g, 
> > > `SourceChange` or (my preference) `SourceEdit`?
> > The reasons I find `TextChange` confusing is because I immediately think of 
> > something super-simple (a range of text + the replaced text), and I 
> > definitely don't think of the AST.
> > 
> > `SourceChange` and `SourceEdit` does not cause this confusion for me 
> > personally, so both look ok. Although they do look pretty similar.
> > Also, it's not actually a final edit, rather a description of it. So 
> > something like `EditDescription` could work too.
> Right, I'm now tending way from the whole focus on text/source/etc. I agree 
> with your point that this is operating at the AST level, especially in light 
> of the discussion below on applyRewriteRule.  Given that these are all 
> anchored by an AST node, let's go with `ASTEdit`, unless that will conflict 
> with the library that you're developing?
> 
> I agree that "Description" is more apt, but I feel like this is (somewhat) 
> implicit in the fact that its a struct versus a function (which would 
> actually be carrying out the action). I'm also afraid that "EditDescription" 
> will read like an action, which may be a bit confusing (although the casing 
> should help distinguish).
`ASTEdit` seems like a proper name here, LG!



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:87
+  TextGenerator Replacement;
+  TextGenerator Explanation;
+};

ymandel wrote:
> ilya-biryukov wrote:
> > ymandel wrote:
> > > ilya-biryukov wrote:
> > > > I would've expected explanation to be the trait of the rewrite rule, 
> > > > since all changes have to be applied.
> > > > What's the reasoning behind having it at the level of separate changes? 
> > > > How would this explanation be used? For debugging purposes or 
> > > > displaying that to the user?
> > > I think that for most cases, one explanation sufficies for the whole 
> > > transformation. However, there are some tidies that emit multiple 
> > > diagnoses (for example if changing before a declaration and a 
> > > definition).   Would it help if I clarify in the comments?
> > Yeah, absolutely! Please document what it's used for and that would clear 
> > that up for me.
> > I actually thing that explaining every part of the transformation is 
> > probably too complicated, so most of the time you would want to have an 
> > explanation for the `RewriteRule`, not for each individual change.
> > 
> > The other challenge that I see is show to display these explanations to the 
> > user, i.e. how should the clients combine these explanations in order to 
> > get the full one? Should the `RewriteRule` have an explanation of the full 
> > transformation too?
> I've revised the comments, changed the name to "Note" and put "Explanation" 
> back into RewriteRule.
> 
> As for how to display these, I imagine an interface like clang tidy's fixit 
> hints.  The Explanation (if any) will be associated with the span of the 
> entire match.  The Notes will be associated with the target node span of each 
> annotated change.  WDYT?
Do we really need the AST information to expose the edits to the users?
IIUC, clang-tidy uses the information from textual replacements to render the 
changes produced by the fix-its today.

I guess it might be useful to add extra notes to clang-tidy warnings that have 
corresponding fix-its, but is the transformers library the right layer to 
produce those? 
I haven't seen the proposed glue to clang-tidy yet, maybe that would make more 
sense when I see it.

One of the other reasons I ask this is that it seems that without `Note` we 
don't strictly `ASTEditBuilder`, we could replace
```
change("ref").to("something"); // without nodepart
change("ref", NodePart::Member).to("something");
```
with
```
change("ref", "something")
change("ref", NodePart::Member, "something");
```
That would remove the boilerplate of the builder, simplifying the code a bit.

That trick would be hard to pull if we have a `Note` field inside, we'll need 
more overloads and having note and replacement after each other might be 
confusing (

[PATCH] D60607: [clangd] Wait for compile command in ASTWorker instead of ClangdServer

2019-04-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM! See the NITs, specifically about `runAddDocument` - those definitely look 
worth fixing.




Comment at: unittests/clangd/ClangdTests.cpp:1148
+  EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
+  // Identifier-based fallback completion doesn't know about "symbol" scope.
+  EXPECT_THAT(Res.Completions,

ioeric wrote:
> ilya-biryukov wrote:
> > Not strictly related to this patch, but maybe we could add a flag to 
> > completion results to indicate if the completion happened via a fallback 
> > mode or not?
> > 
> > Would make the test code more straightforward and the tests like these 
> > would not rely on a particular implementation of the fallback mode (e.g. I 
> > can imagine the fallback mode learning about the scopes later on)
> We are setting the context to `Recovery` and make fallback as part of 
> `Recovery`. Do you we should distinguish fallback mode from `Recovery`?
Ah, `Recovery` looks good enough if we check the same location twice and second 
should be non-recovery.

Maybe keep **only** the `Context == Recovery` check? Checking for particular 
results only seems to make test less focused. 



Comment at: unittests/clangd/ClangdTests.cpp:1113
+getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override {
+  CanReturnCommand.wait();
+  auto FileName = llvm::sys::path::filename(File);

Ah, we should really have a wait-with-timeout for these use-cases.
It's sad that we'll block indefinitely in the old implementation at this point. 
Having a failing test is much better than the one that never finishes.

No need to do anything in this patch, though, that requires a change to 
`Threading.h` that is best done separately anyway.



Comment at: unittests/clangd/CodeCompleteTests.cpp:1392
+  // code completion.
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
   CodeCompleteResult Completions = cantFail(runCodeComplete(

Same here: could you use `runAddDocument`?



Comment at: unittests/clangd/CodeCompleteTests.cpp:1390
   Server.addDocument(FooCpp, Source.code(), WantDiagnostics::Yes);
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
   CodeCompleteResult Completions = cantFail(runCodeComplete(

ioeric wrote:
> ilya-biryukov wrote:
> > Could you expand why we need this?
> Added a comment.
Ah, thanks! Could we instead use a sync helper here to keep the code a bit 
simpler (won't need a comment too)?
```
runAddDocument(Server, ...);
```


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60607



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


[PATCH] D60689: [clangd] Fallback to OrigD when SLoc is invalid

2019-04-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
kadircet added a project: clang.

Some implicit/built-in decls lack the source location
information. Fallback to OrigD that we've seen in the source code
instead of the canonical one in those cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60689

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp


Index: clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
===
--- clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
+++ clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
@@ -1241,6 +1241,14 @@
   EXPECT_THAT(Symbols, Contains(QName("printf")));
 }
 
+TEST_F(SymbolCollectorTest, InvalidSourceLoc) {
+  const char *Header = R"(
+  void operator delete(void*)
+__attribute__((__externally_visible__));)";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, Contains(QName("operator delete")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -285,6 +285,11 @@
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
   assert(CompletionAllocator && CompletionTUInfo);
   assert(ASTNode.OrigD);
+  // Indexing API puts cannonical decl into D, which might not have a valid
+  // source location for implicit/built-in decls. Fallback to original decl in
+  // such cases.
+  if (D->getLocation().isInvalid())
+D = ASTNode.OrigD;
   // If OrigD is an declaration associated with a friend declaration and it's
   // not a definition, skip it. Note that OrigD is the occurrence that the
   // collector is currently visiting.
@@ -540,6 +545,7 @@
   S.SymInfo = index::getSymbolInfo(&ND);
   std::string FileURI;
   auto Loc = findNameLoc(&ND);
+  assert(Loc.isValid() && "Invalid source location for NamedDecl");
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM, SM.getFileID(Loc), Opts, &FilesToIndexCache);
   if (auto DeclLoc =


Index: clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
===
--- clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
+++ clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
@@ -1241,6 +1241,14 @@
   EXPECT_THAT(Symbols, Contains(QName("printf")));
 }
 
+TEST_F(SymbolCollectorTest, InvalidSourceLoc) {
+  const char *Header = R"(
+  void operator delete(void*)
+__attribute__((__externally_visible__));)";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, Contains(QName("operator delete")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -285,6 +285,11 @@
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
   assert(CompletionAllocator && CompletionTUInfo);
   assert(ASTNode.OrigD);
+  // Indexing API puts cannonical decl into D, which might not have a valid
+  // source location for implicit/built-in decls. Fallback to original decl in
+  // such cases.
+  if (D->getLocation().isInvalid())
+D = ASTNode.OrigD;
   // If OrigD is an declaration associated with a friend declaration and it's
   // not a definition, skip it. Note that OrigD is the occurrence that the
   // collector is currently visiting.
@@ -540,6 +545,7 @@
   S.SymInfo = index::getSymbolInfo(&ND);
   std::string FileURI;
   auto Loc = findNameLoc(&ND);
+  assert(Loc.isValid() && "Invalid source location for NamedDecl");
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM, SM.getFileID(Loc), Opts, &FilesToIndexCache);
   if (auto DeclLoc =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60607: [clangd] Wait for compile command in ASTWorker instead of ClangdServer

2019-04-15 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 195139.
ioeric marked 5 inline comments as done.
ioeric added a comment.

- use sync runAddDocument in test


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60607

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Compiler.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -21,8 +21,6 @@
 namespace clangd {
 namespace {
 
-using ::testing::_;
-using ::testing::AllOf;
 using ::testing::AnyOf;
 using ::testing::Each;
 using ::testing::ElementsAre;
@@ -103,7 +101,7 @@
 TUSchedulerTests::DiagsCallbackKey;
 
 TEST_F(TUSchedulerTests, MissingFiles) {
-  TUScheduler S(getDefaultAsyncThreadsCount(),
+  TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true, /*ASTCallbacks=*/nullptr,
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -154,7 +152,7 @@
 // thread until we've scheduled them all.
 Notification Ready;
 TUScheduler S(
-getDefaultAsyncThreadsCount(),
+CDB, getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true, captureDiags(),
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -184,7 +182,7 @@
 TEST_F(TUSchedulerTests, Debounce) {
   std::atomic CallbackCount(0);
   {
-TUScheduler S(getDefaultAsyncThreadsCount(),
+TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true, captureDiags(),
   /*UpdateDebounce=*/std::chrono::seconds(1),
   ASTRetentionPolicy());
@@ -220,7 +218,7 @@
   {
 Notification InconsistentReadDone; // Must live longest.
 TUScheduler S(
-getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
+CDB, getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
 /*ASTCallbacks=*/nullptr,
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -277,7 +275,7 @@
   {
 Notification Proceed; // Ensure we schedule everything.
 TUScheduler S(
-getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
+CDB, getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
 /*ASTCallbacks=*/captureDiags(),
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -346,7 +344,7 @@
 
   // Run TUScheduler and collect some stats.
   {
-TUScheduler S(getDefaultAsyncThreadsCount(),
+TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true, captureDiags(),
   /*UpdateDebounce=*/std::chrono::milliseconds(50),
   ASTRetentionPolicy());
@@ -437,10 +435,11 @@
   std::atomic BuiltASTCounter(0);
   ASTRetentionPolicy Policy;
   Policy.MaxRetainedASTs = 2;
-  TUScheduler S(
-  /*AsyncThreadsCount=*/1, /*StorePreambleInMemory=*/true,
-  /*ASTCallbacks=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(), Policy);
+  TUScheduler S(CDB,
+/*AsyncThreadsCount=*/1, /*StorePreambleInMemory=*/true,
+/*ASTCallbacks=*/nullptr,
+/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+Policy);
 
   llvm::StringLiteral SourceContents = R"cpp(
 int* a;
@@ -487,11 +486,11 @@
 }
 
 TEST_F(TUSchedulerTests, EmptyPreamble) {
-  TUScheduler S(
-  /*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*/true,
-  /*ASTCallbacks=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
-  ASTRetentionPolicy());
+  TUScheduler S(CDB,
+/*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*/true,
+/*ASTCallbacks=*/nullptr,
+/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+ASTRetentionPolicy());
 
   auto Foo = testPath("foo.cpp");
   auto Header = testPath("foo.h");
@@ -532,11 +531,11 @@
 TEST_F(TUSchedulerTests, RunWaitsForPreamble) {
   // Testing strategy: we update the file and schedule a few preamble reads at
   // the same time. All reads should get the same non-null preamble.
-  TUScheduler S(
-  /*AsyncThreadsCount=*/4, /*StorePreambleInMemory=*/true,
-  /*ASTCallbacks=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
-  ASTRetentionPolicy());
+  TUScheduler S(CDB,
+/*AsyncThreadsCount=*/4, /*StorePreambleInMemo

[clang-tools-extra] r358400 - [clangd] Wait for compile command in ASTWorker instead of ClangdServer

2019-04-15 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Apr 15 05:32:28 2019
New Revision: 358400

URL: http://llvm.org/viewvc/llvm-project?rev=358400&view=rev
Log:
[clangd] Wait for compile command in ASTWorker instead of ClangdServer

Summary:
This makes addDocument non-blocking and would also allow code completion
(in fallback mode) to run when worker waits for the compile command.

Reviewers: sammccall, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: javed.absar, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/Compiler.h
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/TUScheduler.cpp
clang-tools-extra/trunk/clangd/TUScheduler.h
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=358400&r1=358399&r2=358400&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Apr 15 05:32:28 2019
@@ -109,7 +109,7 @@ ClangdServer::ClangdServer(const GlobalC
const FileSystemProvider &FSProvider,
DiagnosticsConsumer &DiagConsumer,
const Options &Opts)
-: CDB(CDB), FSProvider(FSProvider),
+: FSProvider(FSProvider),
   DynamicIdx(Opts.BuildDynamicSymbolIndex
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
@@ -121,7 +121,7 @@ ClangdServer::ClangdServer(const GlobalC
   // is parsed.
   // FIXME(ioeric): this can be slow and we may be able to index on less
   // critical paths.
-  WorkScheduler(Opts.AsyncThreadsCount, Opts.StorePreamblesInMemory,
+  WorkScheduler(CDB, Opts.AsyncThreadsCount, Opts.StorePreamblesInMemory,
 llvm::make_unique(DynamicIdx.get(),
 DiagConsumer),
 Opts.UpdateDebounce, Opts.RetentionPolicy) {
@@ -155,12 +155,8 @@ void ClangdServer::addDocument(PathRef F
 Opts.ClangTidyOpts = ClangTidyOptProvider->getOptions(File);
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
 
-  // FIXME: some build systems like Bazel will take time to preparing
-  // environment to build the file, it would be nice if we could emit a
-  // "PreparingBuild" status to inform users, it is non-trivial given the
-  // current implementation.
+  // Compile command is set asynchronously during update, as it can be slow.
   ParseInputs Inputs;
-  Inputs.CompileCommand = getCompileCommand(File);
   Inputs.FS = FSProvider.getFileSystem();
   Inputs.Contents = Contents;
   Inputs.Opts = std::move(Opts);
@@ -543,14 +539,6 @@ void ClangdServer::typeHierarchy(PathRef
   WorkScheduler.runWithAST("Type Hierarchy", File, Bind(Action, 
std::move(CB)));
 }
 
-tooling::CompileCommand ClangdServer::getCompileCommand(PathRef File) {
-  trace::Span Span("GetCompileCommand");
-  llvm::Optional C = CDB.getCompileCommand(File);
-  if (!C) // FIXME: Suppress diagnostics? Let the user know?
-C = CDB.getFallbackCommand(File);
-  return std::move(*C);
-}
-
 void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams &Params) {
   // FIXME: Do nothing for now. This will be used for indexing and potentially
   // invalidating other caches.

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=358400&r1=358399&r2=358400&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon Apr 15 05:32:28 2019
@@ -266,9 +266,6 @@ private:
   formatCode(llvm::StringRef Code, PathRef File,
  ArrayRef Ranges);
 
-  tooling::CompileCommand getCompileCommand(PathRef File);
-
-  const GlobalCompilationDatabase &CDB;
   const FileSystemProvider &FSProvider;
 
   Path ResourceDir;

Modified: clang-tools-extra/trunk/clangd/Compiler.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Compiler.h?rev=358400&r1=358399&r2=358400&view=diff
==
--- clang-tools-extra/trunk/clangd/Compiler.h (original)
+++ clang-tools-extra/trunk/clangd/Compiler.h Mon Apr 15 05:32:28 2019
@@ -16,9 +16,9 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H
 
 #include "../clang-tidy/Clan

[PATCH] D60607: [clangd] Wait for compile command in ASTWorker instead of ClangdServer

2019-04-15 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE358400: [clangd] Wait for compile command in ASTWorker 
instead of ClangdServer (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60607?vs=195139&id=195141#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60607

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Compiler.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -1099,6 +1099,64 @@
 Field(&CodeCompletion::Scope, "ns::";
 }
 
+TEST_F(ClangdVFSTest, FallbackWhenWaitingForCompileCommand) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  // Returns compile command only when notified.
+  class DelayedCompilationDatabase : public GlobalCompilationDatabase {
+  public:
+DelayedCompilationDatabase(Notification &CanReturnCommand)
+: CanReturnCommand(CanReturnCommand) {}
+
+llvm::Optional
+getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override {
+  // FIXME: make this timeout and fail instead of waiting forever in case
+  // something goes wrong.
+  CanReturnCommand.wait();
+  auto FileName = llvm::sys::path::filename(File);
+  std::vector CommandLine = {"clangd", "-ffreestanding", File};
+  return {tooling::CompileCommand(llvm::sys::path::parent_path(File),
+  FileName, std::move(CommandLine), "")};
+}
+
+std::vector ExtraClangFlags;
+
+  private:
+Notification &CanReturnCommand;
+  };
+
+  Notification CanReturnCommand;
+  DelayedCompilationDatabase CDB(CanReturnCommand);
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto FooCpp = testPath("foo.cpp");
+  Annotations Code(R"cpp(
+namespace ns { int xyz; }
+using namespace ns;
+int main() {
+   xy^
+})cpp");
+  FS.Files[FooCpp] = FooCpp;
+  Server.addDocument(FooCpp, Code.code());
+
+  // Sleep for some time to make sure code completion is not run because update
+  // hasn't been scheduled.
+  std::this_thread::sleep_for(std::chrono::milliseconds(10));
+  auto Opts = clangd::CodeCompleteOptions();
+  Opts.AllowFallback = true;
+
+  auto Res = cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts));
+  EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
+
+  CanReturnCommand.notify();
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Code.point(),
+   clangd::CodeCompleteOptions()))
+  .Completions,
+  ElementsAre(AllOf(Field(&CodeCompletion::Name, "xyz"),
+Field(&CodeCompletion::Scope, "ns::";
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -21,8 +21,6 @@
 namespace clangd {
 namespace {
 
-using ::testing::_;
-using ::testing::AllOf;
 using ::testing::AnyOf;
 using ::testing::Each;
 using ::testing::ElementsAre;
@@ -103,7 +101,7 @@
 TUSchedulerTests::DiagsCallbackKey;
 
 TEST_F(TUSchedulerTests, MissingFiles) {
-  TUScheduler S(getDefaultAsyncThreadsCount(),
+  TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true, /*ASTCallbacks=*/nullptr,
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -154,7 +152,7 @@
 // thread until we've scheduled them all.
 Notification Ready;
 TUScheduler S(
-getDefaultAsyncThreadsCount(),
+CDB, getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true, captureDiags(),
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
@@ -184,7 +182,7 @@
 TEST_F(TUSchedulerTests, Debounce) {
   std::atomic CallbackCount(0);
   {
-TUScheduler S(getDefaultAsyncThreadsCount(),
+TUScheduler S(CDB, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true, captureDiags(),
   /*UpdateDebounce=*/std::chrono::seconds(1),
   ASTRetentionPolicy());
@@ -220,7 +218,7 @@
   {
 Notification InconsistentReadDone; // Must live longest.
 TUScheduler S(
-getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
+CDB, getDefaultAsyncThreadsCount(

[PATCH] D60485: [AArch64] Add support for MTE intrinsics

2019-04-15 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9566
+def err_memtag_arg_null_or_pointer : Error<
+  "%0 argument must be a null or a pointer (%1 invalid)">;
+def err_memtag_any2arg_pointer : Error<

javed.absar wrote:
> t.p.northover wrote:
> > I think these diagnostics could do with a bit more context for consistency. 
> > They seem to take "MTE builtin" for granted, whereas most Clang messages 
> > mention what they're talking about.
> > 
> > I'm not saying "MTE builtin" is the best we can come up with, BTW, just 
> > that something more would be nice.
> I thought of doing that too , so can prefix these warnings with 'mte builtin' 
> if that's what you meant. But the intrinsic called kind of names same thing 
> (__arm_mte_..).
"Builtin" or even "function" (fixed up to be grammatical) would suffice if you 
don't like the repetition.



Comment at: lib/Headers/arm_acle.h:610-615
+#define __arm_mte_create_random_tag(__ptr, __mask)  __builtin_arm_irg(__ptr, 
__mask)
+#define __arm_mte_increment_tag(__ptr, __tag_offset)  
__builtin_arm_addg(__ptr, __tag_offset)
+#define __arm_mte_exclude_tag(__ptr, __excluded)  __builtin_arm_gmi(__ptr, 
__excluded)
+#define __arm_mte_get_tag(__ptr) __builtin_arm_ldg(__ptr)
+#define __arm_mte_set_tag(__ptr) __builtin_arm_stg(__ptr)
+#define __arm_mte_ptrdiff(__ptra, __ptrb) __builtin_arm_subp(__ptra, __ptrb)

javed.absar wrote:
> t.p.northover wrote:
> > Why are the builtin names so different from the ones exposed. GCC 
> > compatibility? LLVM?
> The builtin name (e.g. _mte_irg) is reflecting the instruction that 
> implements the otherwise meaningful ACLE names  (mte_create_tag). Its just 
> that the instruction names are sometimes cryptic (e.g. stg, ldg). I could 
> change the names to __builtin_arm_create_tag etc and push the meaningful name 
> -> insn level name to intrinsic level or further down but that would mean 
> lots of name changes to current patch and tests. 
OK, sounds reasonable to leave it as is then.



Comment at: lib/Sema/SemaChecking.cpp:6112
+/// SemaBuiltinARMMemoryTaggingCall - Handle calls of memory tagging extensions
+bool Sema::SemaBuiltinARMMemoryTaggingCall( unsigned BuiltinID, CallExpr 
*TheCall) {
+  bool IsMTEBuiltin = BuiltinID == AArch64::BI__builtin_arm_irg ||

Stray space here between '(' and 'unsigned', BTW.


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

https://reviews.llvm.org/D60485



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


[PATCH] D51905: Front-end of the implementation of the interleaving algorithm

2019-04-15 Thread Zhaomo Yang via Phabricator via cfe-commits
zhaomo updated this revision to Diff 195148.
zhaomo marked 7 inline comments as done.
zhaomo added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fixed bugs in the previous patch.


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

https://reviews.llvm.org/D51905

Files:
  clang/include/clang/AST/VTableBuilder.h
  clang/include/clang/Basic/ABI.h
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/AST/VTableBuilder.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/tbaa-for-vptr.cpp
  clang/test/CodeGenCXX/alignment.cpp
  clang/test/CodeGenCXX/arm.cpp
  clang/test/CodeGenCXX/cfi-cross-dso.cpp
  clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
  clang/test/CodeGenCXX/constructor-init.cpp
  clang/test/CodeGenCXX/delete.cpp
  clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
  clang/test/CodeGenCXX/interleaving-member-function-pointers.cpp
  clang/test/CodeGenCXX/interleaving-virtual-base.cpp
  clang/test/CodeGenCXX/interleaving-virtual-calls.cpp
  clang/test/CodeGenCXX/ubsan-vtable-checks.cpp
  clang/test/CodeGenCXX/virtual-base-cast.cpp
  compiler-rt/test/cfi/CMakeLists.txt
  compiler-rt/test/cfi/anon-namespace.cpp
  compiler-rt/test/cfi/cross-dso/lit.local.cfg
  compiler-rt/test/cfi/icall/lit.local.cfg
  compiler-rt/test/cfi/lit.cfg
  compiler-rt/test/cfi/lit.site.cfg.in
  compiler-rt/test/cfi/mfcall.cpp
  compiler-rt/test/cfi/multiple-inheritance.cpp
  compiler-rt/test/cfi/simple-fail.cpp
  compiler-rt/test/cfi/vdtor.cpp
  compiler-rt/test/lit.common.configured.in

Index: compiler-rt/test/lit.common.configured.in
===
--- compiler-rt/test/lit.common.configured.in
+++ compiler-rt/test/lit.common.configured.in
@@ -36,6 +36,7 @@
 set_default("use_thinlto", False)
 set_default("use_lto", config.use_thinlto)
 set_default("use_newpm", False)
+set_default("use_interleaving", False)
 set_default("android", @ANDROID_PYBOOL@)
 set_default("android_ndk_version", @ANDROID_NDK_VERSION@)
 set_default("android_serial", "@ANDROID_SERIAL_FOR_TESTING@")
Index: compiler-rt/test/cfi/vdtor.cpp
===
--- compiler-rt/test/cfi/vdtor.cpp
+++ compiler-rt/test/cfi/vdtor.cpp
@@ -14,7 +14,7 @@
 // RUN: %run %t5 2>&1 | FileCheck --check-prefix=NCFI %s
 
 // RUN: %clangxx_cfi_diag -o %t6 %s
-// RUN: %run %t6 2>&1 | FileCheck --check-prefix=CFI-DIAG %s
+// RUN: %interleave_diag %run %t6 2>&1 | FileCheck --check-prefix=CFI-DIAG %s
 
 // Tests that the CFI enforcement also applies to virtual destructor calls made
 // via 'delete'.
Index: compiler-rt/test/cfi/simple-fail.cpp
===
--- compiler-rt/test/cfi/simple-fail.cpp
+++ compiler-rt/test/cfi/simple-fail.cpp
@@ -47,12 +47,12 @@
 // RUN: %expect_crash %run %t16 2>&1 | FileCheck --check-prefix=CFI %s
 
 // RUN: %clangxx_cfi_diag -o %t17 %s
-// RUN: %run %t17 2>&1 | FileCheck --check-prefix=CFI-DIAG %s
+// RUN: %interleave_diag %run %t17 2>&1 | FileCheck --check-prefix=CFI-DIAG %s
 
 // RUN: %clangxx -o %t18 %s
 // RUN: %run %t18 2>&1 | FileCheck --check-prefix=NCFI %s
 
-// RUN: %clangxx_cfi -DCHECK_NO_SANITIZE_CFI -o %t19 %s
+// RUN: %clangxx_cfi_no_interleaving -DCHECK_NO_SANITIZE_CFI -o %t19 %s
 // RUN: %run %t19 2>&1 | FileCheck --check-prefix=NCFI %s
 
 // Tests that the CFI mechanism crashes the program when making a virtual call
@@ -95,6 +95,7 @@
   // CFI-DIAG-NEXT: note: vtable is of type '{{(struct )?}}A'
   ((B *)a)->f(); // UB here
 
+  // INTERLEAVING-NCFI-NOT: {{^2$}}
   // CFI-NOT: {{^2$}}
   // NCFI: {{^2$}}
   fprintf(stderr, "2\n");
Index: compiler-rt/test/cfi/multiple-inheritance.cpp
===
--- compiler-rt/test/cfi/multiple-inheritance.cpp
+++ compiler-rt/test/cfi/multiple-inheritance.cpp
@@ -19,8 +19,8 @@
 // RUN: %run %t5 x 2>&1 | FileCheck --check-prefix=NCFI %s
 
 // RUN: %clangxx_cfi_diag -o %t6 %s
-// RUN: %run %t6 2>&1 | FileCheck --check-prefix=CFI-DIAG2 %s
-// RUN: %run %t6 x 2>&1 | FileCheck --check-prefix=CFI-DIAG1 %s
+// RUN: %interleave_diag %run %t6 2>&1 | FileCheck --check-prefix=CFI-DIAG2 %s
+// RUN: %interleave_diag %run %t6 x 2>&1 | FileCheck --check-prefix=CFI-DIAG1 %s
 
 // Tests that the CFI mechanism is sensitive to multiple inheritance and only
 // permits calls via virtual tables for the correct base class.
Index: compiler-rt/test/cfi/mfcall.cpp
===
--- compiler-rt/test/cfi/mfcall.cpp
+++ compiler-rt/test/cfi/mfc

[PATCH] D60697: [ARM] Allow "-march=foo+fp" to vary with foo.

2019-04-15 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, samparker, SjoerdMeijer.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls, 
javed.absar.
Herald added projects: clang, LLVM.

Now, when clang processes an argument of the form "-march=foo+x+y+z",
then instead of calling getArchExtFeature() for each of the extension
names "x", "y", "z" and appending the returned string to its list of
low-level subtarget features, it will call appendArchExtFeatures()
which does the appending itself.

The difference is that appendArchExtFeatures can add _more_ than one
low-level feature name to the output feature list if it has to, and
also, it gets told some information about what base architecture and
CPU the extension is going to go with, which means that "+fp" can now
mean something different for different CPUs. Namely, "+fp" now selects
whatever the _default_ FPU is for the selected CPU and/or
architecture, as defined in the ARM_ARCH or ARM_CPU_NAME macros in
ARMTargetParser.def.

On the clang side, I adjust DecodeARMFeatures to call the new
appendArchExtFeatures function in place of getArchExtFeature. This
means DecodeARMFeatures needs to be passed a CPU name and an ArchKind,
which meant changing its call sites to make those available, and also
sawing getLLVMArchSuffixForARM in half so that you can get an ArchKind
enum value out of it instead of a string.

Also, I add support here for the extension name "+fp.dp", which will
automatically look through the FPU list for something that looks just
like the default FPU except for also supporting double precision.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60697

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Support/ARMTargetParser.cpp

Index: llvm/lib/Support/ARMTargetParser.cpp
===
--- llvm/lib/Support/ARMTargetParser.cpp
+++ llvm/lib/Support/ARMTargetParser.cpp
@@ -473,22 +473,68 @@
   return StringRef();
 }
 
-StringRef ARM::getArchExtFeature(StringRef ArchExt) {
-  if (ArchExt.startswith("no")) {
-StringRef ArchExtBase(ArchExt.substr(2));
-for (const auto AE : ARCHExtNames) {
-  if (AE.NegFeature && ArchExtBase == AE.getName())
-return StringRef(AE.NegFeature);
-}
+static bool wasNegated(StringRef &Name) {
+  if (Name.startswith("no")) {
+Name = Name.substr(2);
+return true;
   }
+  return false;
+}
+
+StringRef ARM::getArchExtFeature(StringRef ArchExt) {
+  bool Negated = wasNegated(ArchExt);
   for (const auto AE : ARCHExtNames) {
 if (AE.Feature && ArchExt == AE.getName())
-  return StringRef(AE.Feature);
+  return StringRef(Negated ? AE.NegFeature : AE.Feature);
   }
 
   return StringRef();
 }
 
+bool ARM::appendArchExtFeatures(
+  StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
+  std::vector &Features) {
+  StringRef StandardFeature = getArchExtFeature(ArchExt);
+  if (!StandardFeature.empty()) {
+Features.push_back(StandardFeature);
+return true;
+  }
+
+  bool Negated = wasNegated(ArchExt);
+  if (ArchExt == "fp" || ArchExt == "fp.dp") {
+unsigned FPUKind;
+if (Negated) {
+  FPUKind = ARM::FK_NONE;
+} else {
+  FPUKind = getDefaultFPU(CPU, AK);
+  if (FPUKind == ARM::FK_NONE)
+return false;
+  if (ArchExt == "fp.dp") {
+// Enable a double-precision-capable FPU in cases where the
+// default one is single-precision only.
+const FPUName &DefaultFPU = FPUNames[FPUKind];
+if (DefaultFPU.Restriction != FPURestriction::SP_D16)
+  return false;// meaningless for this arch
+
+FPUKind = ARM::FK_INVALID;
+for (const FPUName &CandidateFPU : FPUNames) {
+  if (CandidateFPU.FPUVer == DefaultFPU.FPUVer &&
+  CandidateFPU.NeonSupport == DefaultFPU.NeonSupport &&
+  CandidateFPU.Restriction == FPURestriction::D16) {
+FPUKind = CandidateFPU.ID;
+break;
+  }
+}
+  }
+}
+if (FPUKind == ARM::FK_INVALID)
+  return false;
+return ARM::getFPUFeatures(FPUKind, Features);
+  }
+
+  return false;
+}
+
 StringRef ARM::getHWDivName(unsigned HWDivKind) {
   for (const auto D : HWDivNames) {
 if (HWDivKind == D.ID)
Index: llvm/include/llvm/Support/ARMTargetParser.h
===
--- llvm/include/llvm/Support/ARMTargetParser.h
+++ llvm/include/llvm/Support/ARMTargetParser.h
@@ -233,6 +233,8 @@
 StringRef getSubArch(ArchKind AK);
 StringRef getArchExtName(unsigned ArchExtKind);
 StringRef getArchExtFeature(StringRef ArchExt);
+bool appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
+   std::vector &Features);
 StringRef getHWDivName(unsigned HWDivKind);
 
 // Information by Name
Index: clang/lib/Driver

[PATCH] D60699: [ARM] add CLI support for 8.1-M and MVE.

2019-04-15 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, samparker, SjoerdMeijer.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

Given the existing infrastructure in LLVM side for +fp and +fp.dp,
this is more or less trivial, needing only one tiny source change and
a couple of tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60699

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Driver/armv8.1m.main.c
  clang/test/Driver/armv8.1m.main.s

Index: clang/test/Driver/armv8.1m.main.s
===
--- /dev/null
+++ clang/test/Driver/armv8.1m.main.s
@@ -0,0 +1,65 @@
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8-m.main %s 2>%t
+# RUN:  FileCheck --check-prefix=ERROR-V8M < %t %s
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main %s 2>%t
+# RUN:  FileCheck --check-prefix=ERROR-V81M < %t %s
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+dsp %s 2>%t
+# RUN:  FileCheck --check-prefix=ERROR-V81M_DSP < %t %s
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+fp %s 2>%t
+# RUN:  FileCheck --check-prefix=ERROR-V81M_FP < %t %s
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+fp.dp %s 2>%t
+# RUN:  FileCheck --check-prefix=ERROR-V81M_FPDP < %t %s
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+mve %s 2>%t
+# RUN:  FileCheck --check-prefix=ERROR-V81M_MVE < %t %s
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+mve+fp %s 2>%t
+# RUN:  FileCheck --check-prefix=ERROR-V81M_MVE_FP < %t %s
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+mve.fp %s 2>%t
+# RUN:  FileCheck --check-prefix=ERROR-V81M_MVEFP < %t %s
+# RUN: %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+mve.fp+fp.dp %s
+
+.syntax unified
+.thumb
+.text
+
+csinc r0, r1, r2, eq
+# ERROR-V8M: :[[@LINE-1]]:1: error
+
+qadd r0, r1, r2
+# ERROR-V8M: :[[@LINE-1]]:1: error
+# ERROR-V81M: :[[@LINE-2]]:1: error
+# ERROR-V81M_FP: :[[@LINE-3]]:1: error
+# ERROR-V81M_FPDP: :[[@LINE-4]]:1: error
+
+vadd.f16 s0, s1, s2
+# ERROR-V8M: :[[@LINE-1]]:1: error
+# ERROR-V81M: :[[@LINE-2]]:1: error
+# ERROR-V81M_DSP: :[[@LINE-3]]:1: error
+# ERROR-V81M_MVE: :[[@LINE-4]]:1: error
+
+vabs.f32 s0, s1
+# ERROR-V8M: :[[@LINE-1]]:1: error
+# ERROR-V81M: :[[@LINE-2]]:1: error
+# ERROR-V81M_DSP: :[[@LINE-3]]:1: error
+# ERROR-V81M_MVE: :[[@LINE-4]]:1: error
+
+vcmp.f64 d0,d1
+# ERROR-V8M: :[[@LINE-1]]:1: error
+# ERROR-V81M: :[[@LINE-2]]:1: error
+# ERROR-V81M_DSP: :[[@LINE-3]]:1: error
+# ERROR-V81M_FP: :[[@LINE-4]]:1: error
+# ERROR-V81M_MVE: :[[@LINE-5]]:1: error
+# ERROR-V81M_MVE_FP: :[[@LINE-6]]:1: error
+# ERROR-V81M_MVEFP: :[[@LINE-7]]:1: error
+
+asrl r0, r1, r2
+# ERROR-V8M: :[[@LINE-1]]:1: error
+# ERROR-V81M: :[[@LINE-2]]:1: error
+# ERROR-V81M_DSP: :[[@LINE-3]]:1: error
+# ERROR-V81M_FP: :[[@LINE-4]]:1: error
+# ERROR-V81M_FPDP: :[[@LINE-5]]:1: error
+
+vcadd.i8 q0, q1, q2, #90
+# ERROR-V8M: :[[@LINE-1]]:1: error
+# ERROR-V81M: :[[@LINE-2]]:1: error
+# ERROR-V81M_DSP: :[[@LINE-3]]:1: error
+# ERROR-V81M_FP: :[[@LINE-4]]:1: error
+# ERROR-V81M_FPDP: :[[@LINE-5]]:1: error
Index: clang/test/Driver/armv8.1m.main.c
===
--- /dev/null
+++ clang/test/Driver/armv8.1m.main.c
@@ -0,0 +1,34 @@
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+dsp  -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-DSP < %t %s
+// CHECK-DSP: "-target-feature" "+dsp"
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+fp  -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FP < %t %s
+// CHECK-FP: "-target-feature" "+fp-armv8"
+// CHECK-FP-NOT: "-target-feature" "+fp64"
+// CHECK-FP-NOT: "-target-feature" "+d32"
+// CHECK-FP: "-target-feature" "+fullfp16"
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+fp.dp  -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FPDP < %t %s
+// CHECK-FPDP: "-target-feature" "+fp-armv8"
+// CHECK-FPDP: "-target-feature" "+fullfp16"
+// CHECK-FPDP: "-target-feature" "+fp64"
+// CHECK-FPDP-NOT: "-target-feature" "+d32"
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve  -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MVE < %t %s
+// CHECK-MVE: "-target-feature" "+mve"
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp  -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MVEFP < %t %s
+// CHECK-MVEFP: "-target-feature" "+mve.fp"
+// CHECK-MVEFP-NOT: "-target-feature" "+fp64"
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp+fp.dp  -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MVEFP_DP < %t %s
+// CHECK-MVEFP_DP: "-target-feature" "+mve.fp"
+// CHECK-MVEFP_DP: "-target-feature" "+fp64"
+
+// RUN: %clang -target arm-arm-none-eabi -marc

[PATCH] D51905: Front-end of the implementation of the interleaving algorithm

2019-04-15 Thread Zhaomo Yang via Phabricator via cfe-commits
zhaomo added a comment.

Addressed @rsmith's comments.




Comment at: clang/include/clang/Driver/CC1Options.td:356-357
+HelpText<"Enable VTable interleaving">;
+def disable_vtable_interleaving : Flag<["-"], "disable-vtable-interleaving">,
+HelpText<"Disable VTable interleaving">;
 
//===--===//

rsmith wrote:
> We usually only expose the non-default flag in `-cc1`, so that there are no 
> ordering concerns and we can determine whether a feature is enabled with just 
> `hasArg`. Also, `-fvtable-interleaving` would seem like a more natural flag 
> name to me.
Changed it in the latest patch. 



Comment at: clang/include/clang/Frontend/CodeGenOptions.h:274
+  /// the interleaving layout is decided.
+  bool EnableVTableInterleaving;
+

rsmith wrote:
> `Enable` here seems redundant. Is thee a reason to declare this explicitly 
> rather than adding it to CodeGenOptions.def?
Changed it in the latest patch.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:973-976
+// The name of a offset global variable has the format "__[type
+// id]$[offset]".
+std::string Name =
+"__" + RD->getNameAsString() + "$" + std::to_string(Offset);

rsmith wrote:
> The `__`s here are atypical. If you want a name that can't collide with a 
> name generated by the frontend, putting a period in it is the usual strategy. 
> Also, a name prefix that indicates what this global is for would make the IR 
> more readable and make this less likely to collide with other things. Maybe 
> `clang.vtable.index..` or similar?
> 
> Also, there's no guarantee that `RD->getNameAsString()` produces something 
> unique within the translation unit, so you'll need to make sure that name 
> collisions are handled somehow (I *think* `GlobalVariable` already deals with 
> this for you, but I'm not sure... however, I think its strategy is to add a 
> number to the end of the mangling, which will lead to some quite peculiar 
> results given that you already have a number there). It might be easier to 
> base the name of this symbol on the mangled name of the class; then you could 
> give the global variable the same linkage as the class, which might save your 
> interleaving pass a little bit of work later on as the duplicates will 
> already have been combined -- but that's up to you, and I don't have enough 
> of the big picture here to give you advice.
The encoding of the name of such a global variable is just for debugging 
purposes. The back-end pass does not care about the name. Instead, it relies on 
the metadata associated with the global variable, and the metadata does not 
rely on `RD->getNameAsString() `. Also, the back-end pass does not care how 
many global variables associated with the same metadata.

I did not know that it is using periods is a convention in LLVM. I changed the 
name to `clang.vtable.offset..`.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:987
+  }
+  return llvm::ConstantExpr::getPtrToInt(OffsetGV, OffsetType);
+}

rsmith wrote:
> Representing this offset as a `ptrtoint` on a global variable seems really 
> strange. Is there really no better way to model this in IR? (I mean, if not, 
> then carry on as you are, but this seems like a hack.)
The global variable we create for each referenced vtable offset is actually a 
zero-length array, and we use the address of the array as the placeholder for a 
referenced vtable offset. I was told that this is a common trick used in LLVM. 

@pcc: Peter, would you provide more information here? 



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:1767
 
+  bool InBounds = shouldInterleaveVTables(VTableClass) ? false : true;
   return llvm::ConstantExpr::getGetElementPtr(VTable->getValueType(), VTable,

rsmith wrote:
> zhaomo wrote:
> > pcc wrote:
> > > Remind me why this needs to be here? (And the explanation needs to be in 
> > > a comment.)
> > The calculation of address point is essentially base_vtable_addr + offset, 
> > where offset is from the indices of gep.
> > In the interleaving pass, we replace base_vtable_addr with 
> > (addr_point_in_interleaved_layout - offset).
> > 
> > The LLVM language reference says that the base address of a inbounds gep 
> > must be an in bound address of the object. The new base address 
> > addr_point_in_interleaved_layout - offset, however, may not be an in bound 
> > address.
> I still find the need for this confusing. Suppose we have:
> 
> ```
> struct A { virtual void f(); };
> struct B { virtual void g(); virtual void h(); };
> struct C : A, B {};
> ```
> 
> such that `C` has a naive vtable containing 7 elements {{offset, typeid, 
> &A::f}, {offset, typeid, &B::f, &B::h}}, with address point indexes (0, 2) 
> and (1, 2). Here we emit a `gep inbounds @vtable, 0, 1, 2` to get the B-in-C 
> vtable. 

r358402 - clang-format vs plugin: Visual Studio 2019 support

2019-04-15 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Apr 15 06:02:03 2019
New Revision: 358402

URL: http://llvm.org/viewvc/llvm-project?rev=358402&view=rev
Log:
clang-format vs plugin: Visual Studio 2019 support

Modified:
cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in

Modified: cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in?rev=358402&r1=358401&r2=358402&view=diff
==
--- cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in (original)
+++ cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in Mon Apr 15 
06:02:03 2019
@@ -8,7 +8,7 @@
 license.txt
   
   
-
+
   
   
 


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


[PATCH] D60709: [ARM] Support inline assembler constraints for MVE.

2019-04-15 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, samparker, SjoerdMeijer.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls, 
eraman, javed.absar.
Herald added projects: clang, LLVM.

"To" selects an odd-numbered GPR, and "Te" an even one. There are some
8.1-M instructions that have one too few bits in their register fields
and require registers of particular parity, without necessarily using
a consecutive even/odd pair.

Also, the constraint letter "t" should select an MVE q-register, when
MVE is present. This didn't need any source changes, but some extra
tests have been added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60709

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/CodeGen/arm-asm.c
  llvm/docs/LangRef.rst
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/test/CodeGen/ARM/inlineasm-error-t-toofewregs-mve.ll
  llvm/test/CodeGen/ARM/inlineasm-mve.ll
  llvm/test/CodeGen/ARM/inlineasm.ll

Index: llvm/test/CodeGen/ARM/inlineasm.ll
===
--- llvm/test/CodeGen/ARM/inlineasm.ll
+++ llvm/test/CodeGen/ARM/inlineasm.ll
@@ -48,3 +48,27 @@
 	%0 = tail call <4 x float> asm "vadd.f32 $0, $1, $2", "=t,t,t"(<4 x float> %a, <4 x float> %b)
 	ret <4 x float> %0
 }
+
+define i32 @even-GPR-constraint() {
+entry:
+	; CHECK-LABEL: even-GPR-constraint
+	; CHECK: add [[REG:r1*[0, 2, 4, 6, 8]]], [[REG]], #1
+	; CHECK: add [[REG:r1*[0, 2, 4, 6, 8]]], [[REG]], #2
+	; CHECK: add [[REG:r1*[0, 2, 4, 6, 8]]], [[REG]], #3
+	; CHECK: add [[REG:r1*[0, 2, 4, 6, 8]]], [[REG]], #4
+	%0 = tail call { i32, i32, i32, i32 } asm "add $0, #1\0Aadd $1, #2\0Aadd $2, #3\0Aadd $3, #4\0A", "=^Te,=^Te,=^Te,=^Te,0,1,2,3"(i32 0, i32 0, i32 0, i32 0)
+	%asmresult = extractvalue { i32, i32, i32, i32 } %0, 0
+	ret i32 %asmresult
+}
+
+define i32 @odd-GPR-constraint() {
+entry:
+	; CHECK-LABEL: odd-GPR-constraint
+	; CHECK: add [[REG:r1*[1, 3, 5, 7, 9]]], [[REG]], #1
+	; CHECK: add [[REG:r1*[1, 3, 5, 7, 9]]], [[REG]], #2
+	; CHECK: add [[REG:r1*[1, 3, 5, 7, 9]]], [[REG]], #3
+	; CHECK: add [[REG:r1*[1, 3, 5, 7, 9]]], [[REG]], #4
+	%0 = tail call { i32, i32, i32, i32 } asm "add $0, #1\0Aadd $1, #2\0Aadd $2, #3\0Aadd $3, #4\0A", "=^To,=^To,=^To,=^To,0,1,2,3"(i32 0, i32 0, i32 0, i32 0)
+	%asmresult = extractvalue { i32, i32, i32, i32 } %0, 0
+	ret i32 %asmresult
+}
Index: llvm/test/CodeGen/ARM/inlineasm-mve.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/inlineasm-mve.ll
@@ -0,0 +1,48 @@
+; RUN: llc -mtriple=armv8.1-m-eabi -mattr=+mve %s -o - | FileCheck %s
+
+define i32 @test1(i32 %tmp54) {
+	%tmp56 = tail call i32 asm "uxtb16 $0,$1", "=r,r"( i32 %tmp54 )
+	ret i32 %tmp56
+}
+
+define void @test2() {
+	tail call void asm sideeffect "/* number: ${0:c} */", "i"( i32 1 )
+	ret void
+}
+
+define <4 x i32> @mve-t-constraint-128bit(<4 x i32>, <4 x i32>) {
+; CHECK-LABEL: mve-t-constraint-128bit
+; CHECK: vadd.i32 q{{[0-7]}}, q{{[0-7]}}, q{{[0-7]}}
+  %ret = tail call <4 x i32>
+ asm "vadd.i32 $0, $1, $2", "=t,t,t"
+ (<4 x i32> %0, <4 x i32> %1)
+  ret <4 x i32> %ret
+}
+
+define i32 @even-GPR-constraint() {
+entry:
+	; CHECK-LABEL: even-GPR-constraint
+	; CHECK: add [[REG:r1*[0, 2, 4, 6, 8]]], [[REG]], #1
+	; CHECK: add [[REG:r1*[0, 2, 4, 6, 8]]], [[REG]], #2
+	; CHECK: add [[REG:r1*[0, 2, 4, 6, 8]]], [[REG]], #3
+	; CHECK: add [[REG:r1*[0, 2, 4, 6, 8]]], [[REG]], #4
+	%0 = tail call { i32, i32, i32, i32 }
+ asm "add $0, #1\0Aadd $1, #2\0Aadd $2, #3\0Aadd $3, #4\0A", "=^Te,=^Te,=^Te,=^Te,0,1,2,3"
+ (i32 0, i32 0, i32 0, i32 0)
+	%asmresult = extractvalue { i32, i32, i32, i32 } %0, 0
+	ret i32 %asmresult
+}
+
+define i32 @odd-GPR-constraint() {
+entry:
+	; CHECK-LABEL: odd-GPR-constraint
+	; CHECK: add [[REG:r1*[1, 3, 5, 7, 9]]], [[REG]], #1
+	; CHECK: add [[REG:r1*[1, 3, 5, 7, 9]]], [[REG]], #2
+	; CHECK: add [[REG:r1*[1, 3, 5, 7, 9]]], [[REG]], #3
+	; CHECK: add [[REG:r1*[1, 3, 5, 7, 9]]], [[REG]], #4
+	%0 = tail call { i32, i32, i32, i32 }
+ asm "add $0, #1\0Aadd $1, #2\0Aadd $2, #3\0Aadd $3, #4\0A", "=^To,=^To,=^To,=^To,0,1,2,3"
+ (i32 0, i32 0, i32 0, i32 0)
+	%asmresult = extractvalue { i32, i32, i32, i32 } %0, 0
+	ret i32 %asmresult
+}
Index: llvm/test/CodeGen/ARM/inlineasm-error-t-toofewregs-mve.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/inlineasm-error-t-toofewregs-mve.ll
@@ -0,0 +1,14 @@
+; RUN: not llc -mtriple=armv8.1-m-eabi -mattr=+mve %s -o /dev/null 2>&1 | FileCheck %s
+
+; CHECK: inline assembly requires more registers than available
+define <4 x i32> @t-constraint-i32-vectors-too-few-regs(<4 x i32> %a, <4 x i32> %b) {
+entry:
+	%0 = tail call { <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>,
+ <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32> }
+   asm "

[PATCH] D60710: [ARM] Add ACLE feature macros for MVE.

2019-04-15 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, samparker, SjoerdMeijer.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

If MVE is present at all, then the macro __ARM_FEATURE_MVE is defined
to a value which has bit 0 set for integer MVE, and bit 1 set for
floating-point MVE.

(Floating-point MVE implies integer MVE, so if this macro is defined
at all then it will be set to 1 or 3, never 2.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60710

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h


Index: clang/lib/Basic/Targets/ARM.h
===
--- clang/lib/Basic/Targets/ARM.h
+++ clang/lib/Basic/Targets/ARM.h
@@ -33,6 +33,11 @@
 FPARMV8 = (1 << 4)
   };
 
+  enum MVEMode {
+  MVE_INT = (1 << 0),
+  MVE_FP  = (1 << 1)
+  };
+
   // Possible HWDiv features.
   enum HWDivMode { HWDivThumb = (1 << 0), HWDivARM = (1 << 1) };
 
@@ -56,6 +61,7 @@
   unsigned ArchVersion;
 
   unsigned FPU : 5;
+  unsigned MVE : 2;
 
   unsigned IsAAPCS : 1;
   unsigned HWDiv : 2;
@@ -100,6 +106,8 @@
   bool isThumb() const;
   bool supportsThumb() const;
   bool supportsThumb2() const;
+  bool hasMVE() const;
+  bool hasMVEFloat() const;
 
   StringRef getCPUAttr() const;
   StringRef getCPUProfile() const;
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -146,6 +146,14 @@
   }
 }
 
+bool ARMTargetInfo::hasMVE() const {
+  return ArchKind == llvm::ARM::ArchKind::ARMV8_1MMainline && MVE != 0;
+}
+
+bool ARMTargetInfo::hasMVEFloat() const {
+  return hasMVE() && (MVE & MVE_FP);
+}
+
 bool ARMTargetInfo::isThumb() const {
   return ArchISA == llvm::ARM::ISAKind::THUMB;
 }
@@ -443,6 +451,13 @@
   HasLegalHalfType = true;
 } else if (Feature == "+dotprod") {
   DotProd = true;
+} else if (Feature == "+mve") {
+  DSP = 1;
+  MVE |= MVE_INT;
+} else if (Feature == "+mve.fp") {
+  DSP = 1;
+  MVE |= MVE_INT | MVE_FP;
+  HW_FP |= HW_FP_SP | HW_FP_HP;
 }
   }
 
@@ -493,6 +508,7 @@
   .Case("vfp", FPU && !SoftFloat)
   .Case("hwdiv", HWDiv & HWDivThumb)
   .Case("hwdiv-arm", HWDiv & HWDivARM)
+  .Case("mve", hasMVE())
   .Default(false);
 }
 
@@ -708,6 +724,10 @@
 "0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP));
   }
 
+  if (hasMVE()) {
+Builder.defineMacro("__ARM_FEATURE_MVE", hasMVEFloat() ? "3" : "1");
+  }
+
   Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
   Twine(Opts.WCharSize ? Opts.WCharSize : 4));
 


Index: clang/lib/Basic/Targets/ARM.h
===
--- clang/lib/Basic/Targets/ARM.h
+++ clang/lib/Basic/Targets/ARM.h
@@ -33,6 +33,11 @@
 FPARMV8 = (1 << 4)
   };
 
+  enum MVEMode {
+  MVE_INT = (1 << 0),
+  MVE_FP  = (1 << 1)
+  };
+
   // Possible HWDiv features.
   enum HWDivMode { HWDivThumb = (1 << 0), HWDivARM = (1 << 1) };
 
@@ -56,6 +61,7 @@
   unsigned ArchVersion;
 
   unsigned FPU : 5;
+  unsigned MVE : 2;
 
   unsigned IsAAPCS : 1;
   unsigned HWDiv : 2;
@@ -100,6 +106,8 @@
   bool isThumb() const;
   bool supportsThumb() const;
   bool supportsThumb2() const;
+  bool hasMVE() const;
+  bool hasMVEFloat() const;
 
   StringRef getCPUAttr() const;
   StringRef getCPUProfile() const;
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -146,6 +146,14 @@
   }
 }
 
+bool ARMTargetInfo::hasMVE() const {
+  return ArchKind == llvm::ARM::ArchKind::ARMV8_1MMainline && MVE != 0;
+}
+
+bool ARMTargetInfo::hasMVEFloat() const {
+  return hasMVE() && (MVE & MVE_FP);
+}
+
 bool ARMTargetInfo::isThumb() const {
   return ArchISA == llvm::ARM::ISAKind::THUMB;
 }
@@ -443,6 +451,13 @@
   HasLegalHalfType = true;
 } else if (Feature == "+dotprod") {
   DotProd = true;
+} else if (Feature == "+mve") {
+  DSP = 1;
+  MVE |= MVE_INT;
+} else if (Feature == "+mve.fp") {
+  DSP = 1;
+  MVE |= MVE_INT | MVE_FP;
+  HW_FP |= HW_FP_SP | HW_FP_HP;
 }
   }
 
@@ -493,6 +508,7 @@
   .Case("vfp", FPU && !SoftFloat)
   .Case("hwdiv", HWDiv & HWDivThumb)
   .Case("hwdiv-arm", HWDiv & HWDivARM)
+  .Case("mve", hasMVE())
   .Default(false);
 }
 
@@ -708,6 +724,10 @@
 "0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP));
   }
 
+  if (hasMVE()) {
+Builder.defineMacro("__ARM_FEATURE_MVE", hasMVEFloat() ? "3" : "1");
+  }
+
   Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
   Twine(Opts.WCharSize ? Opts.WCharSize : 4));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-

[PATCH] D60709: [ARM] Support inline assembler constraints for MVE.

2019-04-15 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

Is this coordinated with GCC?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60709



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


[PATCH] D60710: [ARM] Add ACLE feature macros for MVE.

2019-04-15 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

Could you add some tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60710



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


[PATCH] D60699: [ARM] add CLI support for 8.1-M and MVE.

2019-04-15 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/test/Driver/armv8.1m.main.c:1
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+dsp  -### %s 2> 
%t
+// RUN: FileCheck --check-prefix=CHECK-DSP < %t %s

It doesn't really matter, I guess, but we don't need a temp file and can pipe 
the output directly to FileCheck?



Comment at: clang/test/Driver/armv8.1m.main.c:3
+// RUN: FileCheck --check-prefix=CHECK-DSP < %t %s
+// CHECK-DSP: "-target-feature" "+dsp"
+

Do we also want to check that just:

  -march=armv8.1-m

doesn't enable DSP (and other non-mandatory extensions)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60699



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


[PATCH] D60570: [Sema] Add more tests for the behavior of argument-dependent name lookup

2019-04-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked 2 inline comments as done.
riccibruno added a comment.

(I have numbered your examples to make the discussion easier, and moved to a 
non-inline comment to have more space)

  foo(ft_t);  // OK: ADL considers N::foo (nobody but GCC implements 
this) #1
  foo(vt_t);  // Error: ADL does not consider N::foo #2
  foo(ft_t);  // Error: ADL does not consider N::foo #3
  foo(vt_t);  // Error: ADL does not consider N::foo #4
  
  foo(ft_nt);  // Error: ADL does not consider N::foo #5
  foo(vt_nt);  // Error: ADL does not consider N::foo #6
  foo(vt_nt);  // Error: ADL does not consider N::foo #7
  
  foo(ft_tt);  // OK: ADL considers N::foo (nobody but GCC implements 
this) #8
  foo(vt_tt);  // Error: ADL does not consider N::foo #9
  foo(ft_tt);  // OK: ADL considers N::foo (nobody but GCC implements 
this) #10
  
  foo( (ft_t) );  // OK??: ADL considers N::foo (nobody but GCC 
implements this) #11
  foo( &ft_t  );  // OK??: ADL considers N::foo (nobody but GCC 
implements this) #12
  foo( (ft_tt) );  // OK??: ADL considers N::foo (nobody but GCC 
implements this) #13
  foo( &ft_tt  );  // OK??: ADL considers N::foo (nobody but GCC 
implements this) #14
  foo( (ft_tt) );  // OK??: ADL considers N::foo (nobody but GCC 
implements this) #15
  foo( &ft_tt  );  // OK??: ADL considers N::foo (nobody but GCC 
implements this) #16

I am sympathetic to your concerns about having consistent rules for ADL in 
these examples. However I am not sure that the conclusion here is to ban them.

First I believe that the examples #11-#16 are just variations of the previous 
examples because of [over.over]p1: `The overloaded function name can be 
preceded by the & operator. [...]`.

The examples involving a variable template are currently not supported, but it 
may be just because it is omitted from the list of ADL rules ? It might be 
worth filing an issue asking for clarification about this case. WDYT ? (In 
general I have noticed that variable templates are rarely mentioned in the 
standard).

The examples #3, #4 are a consequence of the fact that builtin types have no 
associated namespaces and classes. But this is something that is consistent; 
just use a class type instead if ADL is intended to be used. Similarly the 
examples #5. #6, and #7 are consistent; for now, don't rely on ADL with NTTPs 
(similarly perhaps this case should also be included in the ADL rules since 
C++20 will allow class types as NTTPs ? I did not see any discussion about this 
issue in P0732r2.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D60570



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


[PATCH] D60665: [Sema] ADL: Template arguments in a template-id naming a set of overloaded functions (part of CWG 997)

2019-04-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

For information we are discussing in D60570  
whether it is actually a good idea to implement this rule.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60665



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


[PATCH] D59425: Explicitly Craft a Path to Compiler-RT Builtins on Bare Metal Targets

2019-04-15 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi marked an inline comment as done.
CodaFi added inline comments.



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:173
+  }
+
+  // Builds of compiler-rt on bare-metal targets are specialized by specific

phosek wrote:
> Would it be possible to support the [per-target runtimes directory 
> layout](https://github.com/llvm/llvm-project/blob/master/clang/lib/Driver/ToolChain.cpp#L391)
>  as well?
Does that make sense in the context of bare metal triples?  My understanding of 
the layout of the resource directory for these targets is hazy, but I was under 
the impression that each target architecture having its own namespaced copy of 
compiler-rt in `/lib` *is* how we do per-target runtimes.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59425



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


[PATCH] D60691: [ARM] Replace fp-only-sp and d16 with fp64 and d32.

2019-04-15 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

I like the direction of this change, and the details look correct too.

The one thing I wonder about is whether we should be upgrading .bc files too 
(or otherwise support fp-only-sp in legacy inputs). I think it's a specialized 
enough feature that there won't be much older IR being mixed in, but can't be 
sure there's none. Anyone else got any views?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60691



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


r358409 - [clang] Aligned allocation is actually supported in macosx 10.13

2019-04-15 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Mon Apr 15 07:14:45 2019
New Revision: 358409

URL: http://llvm.org/viewvc/llvm-project?rev=358409&view=rev
Log:
[clang] Aligned allocation is actually supported in macosx 10.13

Summary:
In r350649, I changed aligned allocation from being available starting
in macosx10.13 to macosx10.14. However, aligned allocation is indeed
available starting with macosx10.13, my investigation had been based
on the wrong libc++abi dylib.

This means that Clang before the fix will be more stringent when it
comes to aligned allocation -- it will not allow it when back-deploying
to macosx 10.13, when it would actually be safe to do so.

Note that a companion change will be coming to fix the libc++ tests.

Reviewers: ahatanak

Subscribers: jkorous, dexonsmith, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/AlignedAllocation.h
cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp

Modified: cfe/trunk/include/clang/Basic/AlignedAllocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AlignedAllocation.h?rev=358409&r1=358408&r2=358409&view=diff
==
--- cfe/trunk/include/clang/Basic/AlignedAllocation.h (original)
+++ cfe/trunk/include/clang/Basic/AlignedAllocation.h Mon Apr 15 07:14:45 2019
@@ -26,8 +26,8 @@ inline llvm::VersionTuple alignedAllocMi
   default:
 break;
   case llvm::Triple::Darwin:
-  case llvm::Triple::MacOSX: // Earliest supporting version is 10.14.
-return llvm::VersionTuple(10U, 14U);
+  case llvm::Triple::MacOSX: // Earliest supporting version is 10.13.
+return llvm::VersionTuple(10U, 13U);
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0.
 return llvm::VersionTuple(11U);

Modified: cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp?rev=358409&r1=358408&r2=358409&view=diff
==
--- cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp (original)
+++ cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp Mon Apr 15 
07:14:45 2019
@@ -1,4 +1,4 @@
-// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.12 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=UNAVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios10 -c -### %s 2>&1 \
@@ -24,7 +24,7 @@
 //
 // UNAVAILABLE: "-faligned-alloc-unavailable"
 
-// RUN: %clang -target x86_64-apple-macosx10.14 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios11 -c -### %s 2>&1 \
@@ -54,10 +54,10 @@
 // Check that passing -faligned-allocation or -fno-aligned-allocation stops the
 // driver from passing -faligned-alloc-unavailable to cc1.
 //
-// RUN: %clang -target x86_64-apple-macosx10.13 -faligned-allocation -c -### 
%s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.12 -faligned-allocation -c -### 
%s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
-// RUN: %clang -target x86_64-apple-macosx10.13 -fno-aligned-allocation -c 
-### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.12 -fno-aligned-allocation -c 
-### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 
 // AVAILABLE-NOT: "-faligned-alloc-unavailable"

Modified: cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp?rev=358409&r1=358408&r2=358409&view=diff
==
--- cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp (original)
+++ cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp Mon Apr 15 
07:14:45 2019
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-io

[PATCH] D60697: [ARM] Allow "-march=foo+fp" to vary with foo.

2019-04-15 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

This needs some tests. I'm also not quite sure when you'd use bare "+fp", if 
it's the default anyway.




Comment at: llvm/lib/Support/ARMTargetParser.cpp:476
 
-StringRef ARM::getArchExtFeature(StringRef ArchExt) {
-  if (ArchExt.startswith("no")) {
-StringRef ArchExtBase(ArchExt.substr(2));
-for (const auto AE : ARCHExtNames) {
-  if (AE.NegFeature && ArchExtBase == AE.getName())
-return StringRef(AE.NegFeature);
-}
+static bool wasNegated(StringRef &Name) {
+  if (Name.startswith("no")) {

I think `isNegated` is probably more in line with existing naming.



Comment at: llvm/lib/Support/ARMTargetParser.cpp:504-507
+  if (ArchExt == "fp" || ArchExt == "fp.dp") {
+unsigned FPUKind;
+if (Negated) {
+  FPUKind = ARM::FK_NONE;

Doesn't this mean `+nofp.dp` disables all floats? That seems surprising 
behaviour to me, but I can't find any existing tests covering it.



Comment at: llvm/lib/Support/ARMTargetParser.cpp:516-517
+const FPUName &DefaultFPU = FPUNames[FPUKind];
+if (DefaultFPU.Restriction != FPURestriction::SP_D16)
+  return false;// meaningless for this arch
+

Doesn't this silently disable the FPU entirely if we decide "fp.dp" is useless? 
That seems unlikely to be what a user wants, especially without a diagnostic.

Could you also expand on the comment a bit more. I had to look up exactly what 
FPURestrictions existed to get this, and I'm not even 100% sure I'm right now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60697



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


[PATCH] D60626: [clang] Aligned allocation is actually supported in macosx 10.13

2019-04-15 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358409: [clang] Aligned allocation is actually supported in 
macosx 10.13 (authored by ldionne, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60626?vs=194922&id=195178#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60626

Files:
  cfe/trunk/include/clang/Basic/AlignedAllocation.h
  cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
  cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp


Index: cfe/trunk/include/clang/Basic/AlignedAllocation.h
===
--- cfe/trunk/include/clang/Basic/AlignedAllocation.h
+++ cfe/trunk/include/clang/Basic/AlignedAllocation.h
@@ -26,8 +26,8 @@
   default:
 break;
   case llvm::Triple::Darwin:
-  case llvm::Triple::MacOSX: // Earliest supporting version is 10.14.
-return llvm::VersionTuple(10U, 14U);
+  case llvm::Triple::MacOSX: // Earliest supporting version is 10.13.
+return llvm::VersionTuple(10U, 13U);
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0.
 return llvm::VersionTuple(11U);
Index: cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
===
--- cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
+++ cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.12 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=UNAVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios10 -c -### %s 2>&1 \
@@ -24,7 +24,7 @@
 //
 // UNAVAILABLE: "-faligned-alloc-unavailable"
 
-// RUN: %clang -target x86_64-apple-macosx10.14 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios11 -c -### %s 2>&1 \
@@ -54,10 +54,10 @@
 // Check that passing -faligned-allocation or -fno-aligned-allocation stops the
 // driver from passing -faligned-alloc-unavailable to cc1.
 //
-// RUN: %clang -target x86_64-apple-macosx10.13 -faligned-allocation -c -### 
%s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.12 -faligned-allocation -c -### 
%s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
-// RUN: %clang -target x86_64-apple-macosx10.13 -fno-aligned-allocation -c 
-### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.12 -fno-aligned-allocation -c 
-### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 
 // AVAILABLE-NOT: "-faligned-alloc-unavailable"
Index: cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
@@ -117,8 +117,8 @@
 // expected-error@-13 {{aligned allocation function of type 'void *(unsigned 
long, enum std::align_val_t)' is only available on watchOS 4 or newer}}}
 // expected-error@-14 {{aligned deallocation function of type 'void (void *, 
enum std::align_val_t) noexcept' is only available on watchOS 4 or newer}}}
 #else
-// expected-error@-16 {{aligned allocation function of type 'void *(unsigned 
long, enum std::align_val_t)' is only available on macOS 10.14 or newer}}}
-// expected-error@-17 {{aligned deallocation function of type 'void (void *, 
enum std::align_val_t) noexcept' is only available on macOS 10.14 or newer}}}
+// expected-error@-16 {{aligned allocation function of type 'void *(unsigned 
long, enum std::align_val_t)' is only available on macOS 10.13 or newer}}}
+// expected-e

[PATCH] D60699: [ARM] add CLI support for 8.1-M and MVE.

2019-04-15 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a comment.
This revision is now accepted and ready to land.

This looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60699



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


[PATCH] D60626: [clang] Aligned allocation is actually supported in macosx 10.13

2019-04-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Just as a note to someone that might get here through CI failures: I expect 
this will break back-deployment CIs for libc++ that use recent Clangs (because 
the XFAILs in libc++ won't be correct anymore). I have a patch ready to address 
that but I want to see exactly how the CIs fail before I apply the patch.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60626



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


[PATCH] D60709: [ARM] Support inline assembler constraints for MVE.

2019-04-15 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

Yes, it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60709



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


[clang-tools-extra] r358413 - [clangd] Fallback to OrigD when SLoc is invalid

2019-04-15 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Mon Apr 15 07:38:46 2019
New Revision: 358413

URL: http://llvm.org/viewvc/llvm-project?rev=358413&view=rev
Log:
[clangd] Fallback to OrigD when SLoc is invalid

Summary:
Some implicit/built-in decls lack the source location
information. Fallback to OrigD that we've seen in the source code
instead of the canonical one in those cases.

Reviewers: sammccall

Subscribers: cfe-commits, arphaman, jkorous, MaskRay, ioeric, ilya-biryukov

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=358413&r1=358412&r2=358413&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Mon Apr 15 
07:38:46 2019
@@ -285,6 +285,11 @@ bool SymbolCollector::handleDeclOccurenc
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
   assert(CompletionAllocator && CompletionTUInfo);
   assert(ASTNode.OrigD);
+  // Indexing API puts cannonical decl into D, which might not have a valid
+  // source location for implicit/built-in decls. Fallback to original decl in
+  // such cases.
+  if (D->getLocation().isInvalid())
+D = ASTNode.OrigD;
   // If OrigD is an declaration associated with a friend declaration and it's
   // not a definition, skip it. Note that OrigD is the occurrence that the
   // collector is currently visiting.
@@ -540,6 +545,7 @@ const Symbol *SymbolCollector::addDeclar
   S.SymInfo = index::getSymbolInfo(&ND);
   std::string FileURI;
   auto Loc = findNameLoc(&ND);
+  assert(Loc.isValid() && "Invalid source location for NamedDecl");
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM, SM.getFileID(Loc), Opts, &FilesToIndexCache);
   if (auto DeclLoc =

Modified: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp?rev=358413&r1=358412&r2=358413&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp Mon Apr 
15 07:38:46 2019
@@ -1241,6 +1241,14 @@ TEST_F(SymbolCollectorTest, CBuiltins) {
   EXPECT_THAT(Symbols, Contains(QName("printf")));
 }
 
+TEST_F(SymbolCollectorTest, InvalidSourceLoc) {
+  const char *Header = R"(
+  void operator delete(void*)
+__attribute__((__externally_visible__));)";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, Contains(QName("operator delete")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


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


[PATCH] D60689: [clangd] Fallback to OrigD when SLoc is invalid

2019-04-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE358413: [clangd] Fallback to OrigD when SLoc is invalid 
(authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60689?vs=195140&id=195179#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60689

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp


Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -285,6 +285,11 @@
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
   assert(CompletionAllocator && CompletionTUInfo);
   assert(ASTNode.OrigD);
+  // Indexing API puts cannonical decl into D, which might not have a valid
+  // source location for implicit/built-in decls. Fallback to original decl in
+  // such cases.
+  if (D->getLocation().isInvalid())
+D = ASTNode.OrigD;
   // If OrigD is an declaration associated with a friend declaration and it's
   // not a definition, skip it. Note that OrigD is the occurrence that the
   // collector is currently visiting.
@@ -540,6 +545,7 @@
   S.SymInfo = index::getSymbolInfo(&ND);
   std::string FileURI;
   auto Loc = findNameLoc(&ND);
+  assert(Loc.isValid() && "Invalid source location for NamedDecl");
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM, SM.getFileID(Loc), Opts, &FilesToIndexCache);
   if (auto DeclLoc =
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -1241,6 +1241,14 @@
   EXPECT_THAT(Symbols, Contains(QName("printf")));
 }
 
+TEST_F(SymbolCollectorTest, InvalidSourceLoc) {
+  const char *Header = R"(
+  void operator delete(void*)
+__attribute__((__externally_visible__));)";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, Contains(QName("operator delete")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -285,6 +285,11 @@
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
   assert(CompletionAllocator && CompletionTUInfo);
   assert(ASTNode.OrigD);
+  // Indexing API puts cannonical decl into D, which might not have a valid
+  // source location for implicit/built-in decls. Fallback to original decl in
+  // such cases.
+  if (D->getLocation().isInvalid())
+D = ASTNode.OrigD;
   // If OrigD is an declaration associated with a friend declaration and it's
   // not a definition, skip it. Note that OrigD is the occurrence that the
   // collector is currently visiting.
@@ -540,6 +545,7 @@
   S.SymInfo = index::getSymbolInfo(&ND);
   std::string FileURI;
   auto Loc = findNameLoc(&ND);
+  assert(Loc.isValid() && "Invalid source location for NamedDecl");
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM, SM.getFileID(Loc), Opts, &FilesToIndexCache);
   if (auto DeclLoc =
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -1241,6 +1241,14 @@
   EXPECT_THAT(Symbols, Contains(QName("printf")));
 }
 
+TEST_F(SymbolCollectorTest, InvalidSourceLoc) {
+  const char *Header = R"(
+  void operator delete(void*)
+__attribute__((__externally_visible__));)";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, Contains(QName("operator delete")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r358414 - Revert r358337: "[CommandLineParser] Add DefaultOption flag"

2019-04-15 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Apr 15 07:43:50 2019
New Revision: 358414

URL: http://llvm.org/viewvc/llvm-project?rev=358414&view=rev
Log:
Revert r358337: "[CommandLineParser] Add DefaultOption flag"

The change causes test failures under asan. Reverting to unbreak our
integrate.

Modified:
cfe/trunk/lib/Tooling/CommonOptionsParser.cpp

Modified: cfe/trunk/lib/Tooling/CommonOptionsParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CommonOptionsParser.cpp?rev=358414&r1=358413&r2=358414&view=diff
==
--- cfe/trunk/lib/Tooling/CommonOptionsParser.cpp (original)
+++ cfe/trunk/lib/Tooling/CommonOptionsParser.cpp Mon Apr 15 07:43:50 2019
@@ -83,6 +83,8 @@ std::vector ArgumentsAdj
 llvm::Error CommonOptionsParser::init(
 int &argc, const char **argv, cl::OptionCategory &Category,
 llvm::cl::NumOccurrencesFlag OccurrencesFlag, const char *Overview) {
+  static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden,
+cl::sub(*cl::AllSubCommands));
 
   static cl::opt BuildPath("p", cl::desc("Build path"),
 cl::Optional, cl::cat(Category),


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


[PATCH] D59932: [clang-tidy] **Prototype**: Add fix description to clang-tidy checks.

2019-04-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Thanks! The change looks good now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59932



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


[PATCH] D60709: [ARM] Support inline assembler constraints for MVE.

2019-04-15 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a comment.
This revision is now accepted and ready to land.

Excellent, looks good to me then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60709



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195185.
gtbercea added a comment.

- Address comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare void @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,30 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+namespace {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.
+  OMP_REQ_NONE= 0x000,
+  /// reverse_offload clause.
+  OMP_REQ_REVERSE_OFFLOAD = 0x001,

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195186.
gtbercea added a comment.

- Remove atomic flags.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare void @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,24 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+namespace {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.
+  OMP_REQ_NONE= 0x000,
+  /// reverse_offload clause.
+  OMP_REQ_REVERSE_OFFLOAD = 0x0

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8970
+if (Clause->getClauseKind() == OMPC_unified_shared_memory)
+  CGM.getOpenMPRuntime().HasRequiresUnifiedSharedMemory = true;
+  }

You can do `break;` here, no need for further analysis



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:9050
+CGF.StartFunction(GlobalDecl(), C.VoidTy, RequiresRegFn, FI, {});
+int64_t Flags = OMP_REQ_NONE;
+//TODO: check for other requires clauses.

Change the type from `int64_t` to `OpenMPOffloadingRequiresDirFlags`



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8978
+if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
+  CGM.getOpenMPRuntime().HasRequiresUnifiedSharedMemory = true;
+  break;

ABataev wrote:
> Just `HasRequiresUnifiedSharedMemory = true;`
Not done



Comment at: lib/CodeGen/CGOpenMPRuntime.h:641
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+

AlexEichenberger wrote:
> Don't you need a bool for each characteristics? Your intention is to have one 
> bit vector for each characteristics that matter to the compiler?
> 
> Also, it is my belief that you need to record 2 states: 
> unmaterialized (meaning I have not processed any target yet, so I should 
> record any requires as they arrive)
> finalized (I am processing a target, so the state is now fixed)
> 
> you need this in case you have an input like this:
> 
> declare target
> int x
> end declare target
> 
> requires unified memory
> 
> which is illegal
What about this comment?



Comment at: lib/CodeGen/CGOpenMPRuntime.h:1438
+  /// requires directives was used in the current module.
+  virtual llvm::Function *emitRequiresDirectiveRegFun();
+

ABataev wrote:
> Why do you need this vertual funtion? I think static local is going to be 
> enough
Can you make it `const` member function?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D58033: Add option for emitting dbg info for call sites

2019-04-15 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195188.
djtodoro edited the summary of this revision.
djtodoro added a comment.

-Rebase
-Add all_call_sites flag in the case of GNU extensions


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

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_emit_param_entry_values_cc1);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3396,6 +3396,10 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  // Enable param entry values functionlaity.
+  if (Args.hasArg(options::OPT_emit_param_entry_values))
+CmdArgs.push_back("-emit-param-entry-values-cc1");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableParamEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -916,6 +916,10 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+def emit_param_entry_values : Joined<["-"], "femit-param-entry-values">,
+   Group,
+   Flags<[CC1Option]>,
+   HelpText<"Enables debug info about call site and call 
site parameters">;
 def fforce_enable_int128 : Flag<["-"], "fforce-enable-int128">,
   Group, Flags<[CC1Option]>,
   HelpText<"Enable support for int128_t type">;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -359,6 +359,9 @@
 def flto_visibility_public_std:
 Flag<["-"], "flto-visibility-public-std">,
 HelpText<"Use public LTO visibility for classes in std and stdext 
namespaces">;
+def emit_param_entry_values_cc1:
+Flag<["-"], "emit-param-entry-values-cc1">,
+HelpText<"Enables debug info about call site and call site parameters">;
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableParamEntryValues, 1, 0) ///< Emit any call site dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_emit_param_entry_

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195190.
gtbercea added a comment.

- Fix type.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare void @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,24 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+namespace {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.
+  OMP_REQ_NONE= 0x000,
+  /// reverse_offload clause.
+  OMP_REQ_REVERSE_OFFLOAD = 0x001,
+  /// 

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-04-15 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195192.
djtodoro added a comment.

-Rebase
-Use `ExprMutationAnalyzer` for parameter's modification check


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

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4532,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableParamEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for(auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = dyn_cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4532,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableParamEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for(auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = dyn_cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195195.
gtbercea added a comment.

- Add break.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare void @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,24 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+namespace {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.
+  OMP_REQ_NONE= 0x000,
+  /// reverse_offload clause.
+  OMP_REQ_REVERSE_OFFLOAD = 0x001,
+  ///

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked 2 inline comments as done.
gtbercea added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:1438
+  /// requires directives was used in the current module.
+  virtual llvm::Function *emitRequiresDirectiveRegFun();
+

ABataev wrote:
> ABataev wrote:
> > Why do you need this vertual funtion? I think static local is going to be 
> > enough
> Can you make it `const` member function?
Cannot add that due to createRuntimeFunction not being const.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked 2 inline comments as done.
gtbercea added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8978
+if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
+  CGM.getOpenMPRuntime().HasRequiresUnifiedSharedMemory = true;
+  break;

ABataev wrote:
> ABataev wrote:
> > Just `HasRequiresUnifiedSharedMemory = true;`
> Not done
Ah I misunderstood your initial comment. I thought you were complaining about 
the break being in there.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8978
+if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
+  CGM.getOpenMPRuntime().HasRequiresUnifiedSharedMemory = true;
+  break;

gtbercea wrote:
> ABataev wrote:
> > ABataev wrote:
> > > Just `HasRequiresUnifiedSharedMemory = true;`
> > Not done
> Ah I misunderstood your initial comment. I thought you were complaining about 
> the break being in there.
Because the member is non-static I have to provide the CGM.getOpenMPRuntime() 
part.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D58043: Add experimental options for call site related dbg info

2019-04-15 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195198.
djtodoro retitled this revision from "Add option for emitting 
DW_OP_entry_values" to "Add experimental options for call site related dbg 
info".
djtodoro edited the summary of this revision.

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

https://reviews.llvm.org/D58043

Files:
  lib/Driver/ToolChains/Clang.cpp


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3397,8 +3397,15 @@
 CmdArgs.push_back("-dwarf-explicit-import");
 
   // Enable param entry values functionlaity.
-  if (Args.hasArg(options::OPT_emit_param_entry_values))
+  if (Args.hasArg(options::OPT_emit_param_entry_values) &&
+  areOptimizationsEnabled(Args)) {
 CmdArgs.push_back("-emit-param-entry-values-cc1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-entry-values=1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-call-site-info=1");
+
+  }
 
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3397,8 +3397,15 @@
 CmdArgs.push_back("-dwarf-explicit-import");
 
   // Enable param entry values functionlaity.
-  if (Args.hasArg(options::OPT_emit_param_entry_values))
+  if (Args.hasArg(options::OPT_emit_param_entry_values) &&
+  areOptimizationsEnabled(Args)) {
 CmdArgs.push_back("-emit-param-entry-values-cc1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-entry-values=1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-call-site-info=1");
+
+  }
 
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195200.
gtbercea added a comment.

- Remove const.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare void @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -383,7 +383,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const override;
+  void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) override;
 
   /// Returns default address space for the constant firstprivates, __constant__
   /// address space by default.
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4942,7 +4942,7 @@
 /// Check to see if target architecture supports unified addressing which is
 /// a restriction for OpenMP requires clause "unified_shared_memory".
 void CGOpenMPRuntimeNVPTX::checkArchForUnifiedAddressing(
-const OMPRequiresDecl *D) const {
+const OMPRequiresDecl *D) {
   for (const OMPClause *Clause : D->clauselists()) {
 if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
   switch (getCudaArch(CGM)) {
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   ///

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8978
+if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
+  CGM.getOpenMPRuntime().HasRequiresUnifiedSharedMemory = true;
+  break;

gtbercea wrote:
> gtbercea wrote:
> > ABataev wrote:
> > > ABataev wrote:
> > > > Just `HasRequiresUnifiedSharedMemory = true;`
> > > Not done
> > Ah I misunderstood your initial comment. I thought you were complaining 
> > about the break being in there.
> Because the member is non-static I have to provide the CGM.getOpenMPRuntime() 
> part.
Because the member function is non-static and the member data is non-static, 
you can just use `HasRequiresUnifiedSharedMemory = true;`



Comment at: test/OpenMP/openmp_offload_registration.cpp:38
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void

Add a test where the unified memory flag is used


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: test/OpenMP/openmp_offload_registration.cpp:38
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void

ABataev wrote:
> Add a test where the unified memory flag is used
Agreed. More test will be coming anyway. There are a lot of regression tests 
which need to be updated.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 195201.
ymandel marked 10 inline comments as done.
ymandel added a comment.

Clarified comments for `translateEdits` function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60408

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -13,36 +13,11 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-namespace clang {
-namespace tooling {
-namespace {
-using ast_matchers::anyOf;
-using ast_matchers::argumentCountIs;
-using ast_matchers::callee;
-using ast_matchers::callExpr;
-using ast_matchers::cxxMemberCallExpr;
-using ast_matchers::cxxMethodDecl;
-using ast_matchers::cxxRecordDecl;
-using ast_matchers::declRefExpr;
-using ast_matchers::expr;
-using ast_matchers::functionDecl;
-using ast_matchers::hasAnyName;
-using ast_matchers::hasArgument;
-using ast_matchers::hasDeclaration;
-using ast_matchers::hasElse;
-using ast_matchers::hasName;
-using ast_matchers::hasType;
-using ast_matchers::ifStmt;
-using ast_matchers::member;
-using ast_matchers::memberExpr;
-using ast_matchers::namedDecl;
-using ast_matchers::on;
-using ast_matchers::pointsTo;
-using ast_matchers::to;
-using ast_matchers::unless;
-
-using llvm::StringRef;
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
 
+namespace {
 constexpr char KHeaderContents[] = R"cc(
   struct string {
 string(const char*);
@@ -59,6 +34,9 @@
 PCFProto& GetProto();
   };
   }  // namespace proto
+  class Logger {};
+  void operator<<(Logger& l, string msg);
+  Logger& log(int level);
 )cc";
 
 static ast_matchers::internal::Matcher
@@ -141,18 +119,16 @@
 static RewriteRule ruleStrlenSize() {
   StringRef StringExpr = "strexpr";
   auto StringType = namedDecl(hasAnyName("::basic_string", "::string"));
-  return buildRule(
- callExpr(
- callee(functionDecl(hasName("strlen"))),
- hasArgument(0, cxxMemberCallExpr(
-on(expr(hasType(isOrPointsTo(StringType)))
-   .bind(StringExpr)),
-callee(cxxMethodDecl(hasName("c_str")))
-  // Specify the intended type explicitly, because the matcher "type" of
-  // `callExpr()` is `Stmt`, not `Expr`.
-  .as()
-  .replaceWith("REPLACED")
-  .because("Use size() method directly on string.");
+  auto R = makeRule(
+  callExpr(callee(functionDecl(hasName("strlen"))),
+   hasArgument(0, cxxMemberCallExpr(
+  on(expr(hasType(isOrPointsTo(StringType)))
+ .bind(StringExpr)),
+  callee(cxxMethodDecl(hasName("c_str")),
+  changeRoot()
+  .to("REPLACED"));
+  R.Explanation = text("Use size() method directly on string.");
+  return R;
 }
 
 TEST_F(TransformerTest, StrlenSize) {
@@ -181,15 +157,12 @@
 // Tests replacing an expression.
 TEST_F(TransformerTest, Flag) {
   StringRef Flag = "flag";
-  RewriteRule Rule =
-  buildRule(
-  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(hasName(
-"proto::ProtoCommandLineFlag"
-   .bind(Flag)),
-unless(callee(cxxMethodDecl(hasName("GetProto"))
-  .change(Flag)
-  .replaceWith("EXPR")
-  .because("Use GetProto() to access proto fields.");
+  RewriteRule Rule = makeRule(
+  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(
+hasName("proto::ProtoCommandLineFlag"
+   .bind(Flag)),
+unless(callee(cxxMethodDecl(hasName("GetProto"),
+  change(Flag).to("EXPR"));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -207,9 +180,9 @@
 
 TEST_F(TransformerTest, NodePartNameNamedDecl) {
   StringRef Fun = "fun";
-  RewriteRule Rule = buildRule(functionDecl(hasName("bad")).bind(Fun))
- .change(Fun, NodePart::Name)
- .replaceWith("good");
+  RewriteRule Rule =
+  makeRule(functionDecl(hasName("bad")).bind(Fun),
+   change(Fun, NodePart::Name).to("good"));
 
   std::string Input = R"cc(
 int bad(int x);
@@ -240,9 +213,8 @@
   )cc";
 
   StringRef Ref = "ref";
-  testRule(buildRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref))
-   .change(Ref, NodePart::Name)
-   .replaceWith("good"),
+  testRule(makeRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref),
+

[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:87
+  TextGenerator Replacement;
+  TextGenerator Explanation;
+};

ilya-biryukov wrote:
> ymandel wrote:
> > ilya-biryukov wrote:
> > > ymandel wrote:
> > > > ilya-biryukov wrote:
> > > > > I would've expected explanation to be the trait of the rewrite rule, 
> > > > > since all changes have to be applied.
> > > > > What's the reasoning behind having it at the level of separate 
> > > > > changes? How would this explanation be used? For debugging purposes 
> > > > > or displaying that to the user?
> > > > I think that for most cases, one explanation sufficies for the whole 
> > > > transformation. However, there are some tidies that emit multiple 
> > > > diagnoses (for example if changing before a declaration and a 
> > > > definition).   Would it help if I clarify in the comments?
> > > Yeah, absolutely! Please document what it's used for and that would clear 
> > > that up for me.
> > > I actually thing that explaining every part of the transformation is 
> > > probably too complicated, so most of the time you would want to have an 
> > > explanation for the `RewriteRule`, not for each individual change.
> > > 
> > > The other challenge that I see is show to display these explanations to 
> > > the user, i.e. how should the clients combine these explanations in order 
> > > to get the full one? Should the `RewriteRule` have an explanation of the 
> > > full transformation too?
> > I've revised the comments, changed the name to "Note" and put "Explanation" 
> > back into RewriteRule.
> > 
> > As for how to display these, I imagine an interface like clang tidy's fixit 
> > hints.  The Explanation (if any) will be associated with the span of the 
> > entire match.  The Notes will be associated with the target node span of 
> > each annotated change.  WDYT?
> Do we really need the AST information to expose the edits to the users?
> IIUC, clang-tidy uses the information from textual replacements to render the 
> changes produced by the fix-its today.
> 
> I guess it might be useful to add extra notes to clang-tidy warnings that 
> have corresponding fix-its, but is the transformers library the right layer 
> to produce those? 
> I haven't seen the proposed glue to clang-tidy yet, maybe that would make 
> more sense when I see it.
> 
> One of the other reasons I ask this is that it seems that without `Note` we 
> don't strictly `ASTEditBuilder`, we could replace
> ```
> change("ref").to("something"); // without nodepart
> change("ref", NodePart::Member).to("something");
> ```
> with
> ```
> change("ref", "something")
> change("ref", NodePart::Member, "something");
> ```
> That would remove the boilerplate of the builder, simplifying the code a bit.
> 
> That trick would be hard to pull if we have a `Note` field inside, we'll need 
> more overloads and having note and replacement after each other might be 
> confusing (they have the same type, might be hard to read without the guiding 
> `.to()` and `.because()`)
Breaking this explicitly into two questions:
1. Do Notes belong here?
2. Can we drop the builder?

1. Do Notes belong here?
I think so.  When users provide a diagnostic, they are specifying its location. 
So, we don't quite need the AST but we do need location info.  The diagnostic 
generator does take information from the replacements themselves, but that's 
not alone. For example: clang-tidy/readability/ConstReturnTypeCheck.cpp:104.  
That demos both the diagnostic construction and multiple diagnostics in a 
single tidy result.

Given that, i think that RewriteRules are the appropriate place. The goal is 
that they be self contained, so I think the explanations should be bundled with 
the description of that actual change.  An example approach to merging with 
clang tidy is here: 
https://github.com/ymand/llvm-project/blob/transformer/clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp
 (although that's based on a somewhat different version of the Transformer 
library; it should make clear what I have in mind).

2. Do we need the builder?
No, despite my opinion that notes belong.  Given the explanation on 
RewriteRule, I think notes will be used only rarely (like in the example 
clang-tidy above; but that's not standard practice).  So, we can provide the 
two overloads of `change` that you mention and then let users assign the note 
directly in those rare cases they need it. then, we can drop the builder.

So, I propose keeping the note but dropping the builder. WDYT?



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:204
+applyRewriteRule(const ast_matchers::MatchFinder::MatchResult &Result,
+ llvm::ArrayRef Changes);
 

ilya-biryukov wrote:
> ymandel wrote:
> > ilya-biryukov wrote:
> > > Why would we change the interface here? Rewrite rule seemed like a 
> > > perfect input to this function
> > Good

[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.



> Our current approach is to add an attribute, which SYCL runtime will use to 
> mark code passed to `cl::sycl::handler::parallel_for` as "kernel functions". 
> Obviously runtime library can't mark `foo` as "device" code - this is a 
> compiler job: to traverse all symbols accessible from kernel functions and 
> add them to the "device part" of the code.
> 
> Here is a link to the code in the SYCL runtime using `sycl_kernel` attribute: 
> https://github.com/intel/llvm/blob/sycl/sycl/include/CL/sycl/handler.hpp#L267
> 
> I'm quite sure something similar should happen for other "single source" 
> programming models like OpenMP/CUDA, except these attributes are exposed to 
> the user and there is a specific requirement on attributes/pragma/keyword 
> names.

Just to understand how this will work. I would imagine you can have a device 
function definition preceding its use. When the function is being parsed it's 
not known yet whether it will be called from the device or not, so it won't be 
possible to set the language mode correctly and hence provide the right 
diagnostics. So is the plan to launch a separate parsing phase then just to 
extract the call graph and annotate the device functions?

> NOTE2: @Anastasia, https://reviews.llvm.org/D60454 makes impossible to 
> replace `sycl_kernel` attribute with `__kernel` attribute. I mean we still 
> can enable it for SYCL extension, but we will need SYCL specific 
> customization in this case as we apply `kernel` attribute to a template 
> function.

Ok, my question is whether you are planning to duplicate the same logic as for 
OpenCL kernel which doesn't really seem like an ideal design choice. Is this 
the only difference then we can simply add an extra check for SYCL compilation 
mode in this template handling case. The overall interaction between OpenCL and 
SYCL implementation is still a very big unknown to me so it's not very easy to 
judge about the implementations details...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda reopened this revision.
hintonda added a comment.
This revision is now accepted and ready to land.

Reopen to track fix after buildbot failure and revert -- r358414.

http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190415/644037.html


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59746



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


[PATCH] D60719: Fixing freestanding for memcpy.

2019-04-15 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60719

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5464,6 +5464,14 @@
   }
 }
 
+static bool IsForceInlineLibc(const SelectionDAG &DAG) {
+  const Module *M = DAG.getMachineFunction().getFunction().getParent();
+  if (auto *MD = mdconst::extract_or_null(
+  M->getModuleFlag("force-inline-libc")))
+return MD->getZExtValue();
+  return false;
+}
+
 /// Lower the call to the specified intrinsic function. If we want to emit this
 /// as a call to a named external function, return the name. Otherwise, lower 
it
 /// and return null.
@@ -5537,10 +5545,11 @@
 unsigned Align = MinAlign(DstAlign, SrcAlign);
 bool isVol = MCI.isVolatile();
 bool isTC = I.isTailCall() && isInTailCallPosition(&I, DAG.getTarget());
+bool IsAlwaysInline = IsForceInlineLibc(DAG);
 // FIXME: Support passing different dest/src alignments to the memcpy DAG
 // node.
 SDValue MC = DAG.getMemcpy(getRoot(), sdl, Op1, Op2, Op3, Align, isVol,
-   false, isTC,
+   IsAlwaysInline, isTC,
MachinePointerInfo(I.getArgOperand(0)),
MachinePointerInfo(I.getArgOperand(1)));
 updateDAGForMaybeTailCall(MC);
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6090,6 +6090,9 @@
   // beyond the given memory regions. But fixing this isn't easy, and most
   // people don't care.
 
+  assert(MF->getFunction().getParent()->getModuleFlag("force-inline-libc") ==
+ nullptr);
+
   // Emit a library call.
   TargetLowering::ArgListTy Args;
   TargetLowering::ArgListEntry Entry;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -596,6 +596,10 @@
   if (!getCodeGenOpts().RecordCommandLine.empty())
 EmitCommandLineMetadata();
 
+  if (LangOpts.Freestanding) {
+getModule().addModuleFlag(llvm::Module::Override, "force-inline-libc", 1);
+  }
+
   EmitTargetMetadata();
 }
 


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5464,6 +5464,14 @@
   }
 }
 
+static bool IsForceInlineLibc(const SelectionDAG &DAG) {
+  const Module *M = DAG.getMachineFunction().getFunction().getParent();
+  if (auto *MD = mdconst::extract_or_null(
+  M->getModuleFlag("force-inline-libc")))
+return MD->getZExtValue();
+  return false;
+}
+
 /// Lower the call to the specified intrinsic function. If we want to emit this
 /// as a call to a named external function, return the name. Otherwise, lower it
 /// and return null.
@@ -5537,10 +5545,11 @@
 unsigned Align = MinAlign(DstAlign, SrcAlign);
 bool isVol = MCI.isVolatile();
 bool isTC = I.isTailCall() && isInTailCallPosition(&I, DAG.getTarget());
+bool IsAlwaysInline = IsForceInlineLibc(DAG);
 // FIXME: Support passing different dest/src alignments to the memcpy DAG
 // node.
 SDValue MC = DAG.getMemcpy(getRoot(), sdl, Op1, Op2, Op3, Align, isVol,
-   false, isTC,
+   IsAlwaysInline, isTC,
MachinePointerInfo(I.getArgOperand(0)),
MachinePointerInfo(I.getArgOperand(1)));
 updateDAGForMaybeTailCall(MC);
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6090,6 +6090,9 @@
   // beyond the given memory regions. But fixing this isn't easy, and most
   // people don't care.
 
+  assert(MF->getFunction().getParent()->getModuleFlag("force-inline-libc") ==
+ nullptr);
+
   // Emit a library call.
   TargetLowering::ArgListTy Args;
   TargetLowering::ArgListEntry Entry;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModu

Re: r358402 - clang-format vs plugin: Visual Studio 2019 support

2019-04-15 Thread Nico Weber via cfe-commits
Nice! Is adding compat to
https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain&ssr=false#overview
equally easy?

On Mon, Apr 15, 2019 at 9:01 AM Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hans
> Date: Mon Apr 15 06:02:03 2019
> New Revision: 358402
>
> URL: http://llvm.org/viewvc/llvm-project?rev=358402&view=rev
> Log:
> clang-format vs plugin: Visual Studio 2019 support
>
> Modified:
> cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in
>
> Modified: cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in?rev=358402&r1=358401&r2=358402&view=diff
>
> ==
> --- cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in
> (original)
> +++ cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in Mon
> Apr 15 06:02:03 2019
> @@ -8,7 +8,7 @@
>  license.txt
>
>
> -
> +
>
>
>   DisplayName="Visual Studio MPF" />
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60233: [clang-scan-deps] initial outline of the tool that runs preprocessor to find dependencies over a JSON compilation database

2019-04-15 Thread Tom Rix via Phabricator via cfe-commits
trixirt added a comment.

A comment by whisperity in the origin WIP did not seem to be addressed.
Have you looked at IWYU 
https://github.com/include-what-you-use/include-what-you-use ?
The end goals of clang-scan-deps and iwyu seem similar so their implementation 
problems would also be similar.
The iwyu problems doc is 
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYUIsDifficult.md


Repository:
  rC Clang

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

https://reviews.llvm.org/D60233



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


[PATCH] D60721: [ARM] Check codegen of v8.2a intrinsics

2019-04-15 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio created this revision.
dnsampaio added reviewers: olista01, miyuki.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.
dnsampaio added a parent revision: D60720: [ARM] Add v4f16 and v8f16 types to 
the CallingConv.
ostannard requested changes to this revision.
ostannard added a comment.
This revision now requires changes to proceed.

Clang tests should just cover the C->IR translation, and not depend on the LLVM 
backends. This should instead be an IR->asm test in the LLVM repository.


This patch adds a assembly check for the
ARM v8.2-A intrinsics.


Repository:
  rC Clang

https://reviews.llvm.org/D60721

Files:
  test/CodeGen/arm-v8.2a-neon-intrinsics.c
  test/CodeGen/arm-v8.2a-neon-intrinsics.c.asm

Index: test/CodeGen/arm-v8.2a-neon-intrinsics.c.asm
===
--- /dev/null
+++ test/CodeGen/arm-v8.2a-neon-intrinsics.c.asm
@@ -0,0 +1,1000 @@
+// CHECK-LABEL: test_vabs_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vabs.f16	d16, d16
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vabsq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vabs.f16	q8, q8
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vceqz_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vceq.f16	d16, d16, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vceqzq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vceq.f16	q8, q8, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcgez_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcge.f16	d16, d16, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcgezq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcge.f16	q8, q8, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcgtz_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcgt.f16	d16, d16, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcgtzq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcgt.f16	q8, q8, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vclez_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcle.f16	d16, d16, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vclezq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcle.f16	q8, q8, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcltz_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vclt.f16	d16, d16, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcltzq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vclt.f16	q8, q8, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvt_f16_s16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.f16.s16	d16, d16
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvtq_f16_s16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.f16.s16	q8, q8
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvt_f16_u16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.f16.u16	d16, d16
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvtq_f16_u16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.f16.u16	q8, q8
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvt_s16_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.s16.f16	d16, d16
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvtq_s16_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.s16.f16	q8, q8
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvt_u16_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.u16.f16	d16, d16
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvtq_u1

[PATCH] D60721: [ARM] Check codegen of v8.2a intrinsics

2019-04-15 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard requested changes to this revision.
ostannard added a comment.
This revision now requires changes to proceed.

Clang tests should just cover the C->IR translation, and not depend on the LLVM 
backends. This should instead be an IR->asm test in the LLVM repository.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60721



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


[PATCH] D59919: [Attributor] Deduce "returned" argument attribute

2019-04-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.



Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:495
+  virtual size_t getNumReturnValues() const override {
+return isValidState() ? ReturnedValues.size() : -1;
+  }

This should probably call `llvm_unreachable` with a message instead of 
returning -1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59919



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


[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 195217.
hintonda added a comment.

- Original patch, r358337, that was reverted.
- Make sure to clear DefaultOptions on reset.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746

Files:
  clang/lib/Tooling/CommonOptionsParser.cpp
  llvm/docs/CommandLine.rst
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -620,6 +620,68 @@
   }
 }
 
+TEST(CommandLineTest, DefaultOptions) {
+  cl::ResetCommandLineParser();
+
+  StackOption Bar("bar", cl::sub(*cl::AllSubCommands),
+   cl::DefaultOption);
+  StackOption Bar_Alias(
+  "b", cl::desc("Alias for -bar"), cl::aliasopt(Bar), cl::DefaultOption);
+
+  StackOption Foo("foo", cl::init(false), cl::sub(*cl::AllSubCommands),
+cl::DefaultOption);
+  StackOption Foo_Alias("f", cl::desc("Alias for -foo"),
+ cl::aliasopt(Foo), cl::DefaultOption);
+
+  StackSubCommand SC1("sc1", "First Subcommand");
+  // Override "-b" and change type in sc1 SubCommand.
+  StackOption SC1_B("b", cl::sub(SC1), cl::init(false));
+  StackSubCommand SC2("sc2", "Second subcommand");
+  // Override "-foo" and change type in sc2 SubCommand.  Note that this does not
+  // affect "-f" alias, which continues to work correctly.
+  StackOption SC2_Foo("foo", cl::sub(SC2));
+
+  const char *args0[] = {"prog", "-b", "args0 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args0) / sizeof(char *), args0,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args0 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args1[] = {"prog", "sc1", "-b", "-bar", "args1 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args1) / sizeof(char *), args1,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args1 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_TRUE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc1", S->getName());
+}
+  }
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args2[] = {"prog", "sc2", "-b", "args2 bar string",
+ "-f", "-foo", "foo string"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args2) / sizeof(char *), args2,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args2 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo == "foo string");
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc2", S->getName());
+}
+  }
+  cl::ResetCommandLineParser();
+}
+
 TEST(CommandLineTest, ArgumentLimit) {
   std::string args(32 * 4096, 'a');
   EXPECT_FALSE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args.data()));
Index: llvm/tools/llvm-opt-report/OptReport.cpp
===
--- llvm/tools/llvm-opt-report/OptReport.cpp
+++ llvm/tools/llvm-opt-report/OptReport.cpp
@@ -36,8 +36,6 @@
 using namespace llvm;
 using namespace llvm::yaml;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
-
 // Mark all our options with this category, everything else (except for -version
 // and -help) will be hidden.
 static cl::OptionCategory
@@ -440,11 +438,6 @@
   "A tool to generate an optimization report from YAML optimization"
   " record files.\n");
 
-  if (Help) {
-cl::PrintHelpMessage();
-return 0;
-  }
-
   LocationInfoTy LocationInfo;
   if (!readLocationInfo(LocationInfo))
 return 1;
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -98,6 +98,11 @@
   // This collects additional help to be printed.
   std::vector MoreHelp;
 
+  // This collects Options added with the cl::DefaultOption flag. Since they can
+  // be overridden, they are not added to the appropriate SubCommands until
+  // ParseCommandLineOptions actually runs.
+  SmallVector DefaultOptions;
+
   // This collects the different option categories that have been registered.
   SmallPtrSet RegisteredOptionCategories;
 
@@ -146,6 +151,11 @@
   void addOption(Option *O, SubCommand *SC) {
 bool HadErrors = false;
 if (O->hasArgStr()) {
+  // If it's a DefaultOption, check to make sure it isn't already there.
+  if (O->isDefa

[PATCH] D58236: Make address space conversions a bit stricter.

2019-04-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D58236#1466263 , @ebevhan wrote:

> Well, it doesn't seem to me like there is consensus on prohibiting nested 
> address space conversion like this.
>
> I can simply redo the patch to only include the bugfix on implicit 
> conversions and drop the nesting level checks.


I thought the conclusion is:

- Explicit conversions allowed for nested pointers with a warning.
- Implicit conversions are disallowed for nested pointers with an error.

Do you not see it this way?


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

https://reviews.llvm.org/D58236



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


[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 195218.
hintonda added a comment.

- Add new test back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746

Files:
  clang/lib/Tooling/CommonOptionsParser.cpp
  llvm/docs/CommandLine.rst
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/test/Support/check-default-options.txt
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -620,6 +620,68 @@
   }
 }
 
+TEST(CommandLineTest, DefaultOptions) {
+  cl::ResetCommandLineParser();
+
+  StackOption Bar("bar", cl::sub(*cl::AllSubCommands),
+   cl::DefaultOption);
+  StackOption Bar_Alias(
+  "b", cl::desc("Alias for -bar"), cl::aliasopt(Bar), cl::DefaultOption);
+
+  StackOption Foo("foo", cl::init(false), cl::sub(*cl::AllSubCommands),
+cl::DefaultOption);
+  StackOption Foo_Alias("f", cl::desc("Alias for -foo"),
+ cl::aliasopt(Foo), cl::DefaultOption);
+
+  StackSubCommand SC1("sc1", "First Subcommand");
+  // Override "-b" and change type in sc1 SubCommand.
+  StackOption SC1_B("b", cl::sub(SC1), cl::init(false));
+  StackSubCommand SC2("sc2", "Second subcommand");
+  // Override "-foo" and change type in sc2 SubCommand.  Note that this does not
+  // affect "-f" alias, which continues to work correctly.
+  StackOption SC2_Foo("foo", cl::sub(SC2));
+
+  const char *args0[] = {"prog", "-b", "args0 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args0) / sizeof(char *), args0,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args0 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args1[] = {"prog", "sc1", "-b", "-bar", "args1 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args1) / sizeof(char *), args1,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args1 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_TRUE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc1", S->getName());
+}
+  }
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args2[] = {"prog", "sc2", "-b", "args2 bar string",
+ "-f", "-foo", "foo string"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args2) / sizeof(char *), args2,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args2 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo == "foo string");
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc2", S->getName());
+}
+  }
+  cl::ResetCommandLineParser();
+}
+
 TEST(CommandLineTest, ArgumentLimit) {
   std::string args(32 * 4096, 'a');
   EXPECT_FALSE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args.data()));
Index: llvm/tools/llvm-opt-report/OptReport.cpp
===
--- llvm/tools/llvm-opt-report/OptReport.cpp
+++ llvm/tools/llvm-opt-report/OptReport.cpp
@@ -36,8 +36,6 @@
 using namespace llvm;
 using namespace llvm::yaml;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
-
 // Mark all our options with this category, everything else (except for -version
 // and -help) will be hidden.
 static cl::OptionCategory
@@ -440,11 +438,6 @@
   "A tool to generate an optimization report from YAML optimization"
   " record files.\n");
 
-  if (Help) {
-cl::PrintHelpMessage();
-return 0;
-  }
-
   LocationInfoTy LocationInfo;
   if (!readLocationInfo(LocationInfo))
 return 1;
Index: llvm/test/Support/check-default-options.txt
===
--- /dev/null
+++ llvm/test/Support/check-default-options.txt
@@ -0,0 +1,18 @@
+# RUN: llvm-objdump -help-hidden %t | FileCheck --check-prefix=CHECK-OBJDUMP %s
+# RUN: llvm-readobj -help-hidden %t | FileCheck --check-prefix=CHECK-READOBJ %s
+# RUN: llvm-tblgen -help-hidden %t | FileCheck --check-prefix=CHECK-TBLGEN %s
+# RUN: llvm-opt-report -help-hidden %t | FileCheck --check-prefix=CHECK-OPT-RPT %s
+# RUN: llvm-dwarfdump -help-hidden %t | FileCheck --check-prefix=CHECK-DWARF %s
+# RUN: llvm-dwarfdump -h %t | FileCheck --check-prefix=CHECK-DWARF-H %s
+
+
+# CHECK-OBJDUMP: -h  - Alias for --section-headers
+# CHECK-READOBJ: -h  - Alias for --file-headers
+# CHECK-TBLGEN:  -h  - Alias for -help
+# CHECK-OPT-RPT: -h  - Alias for -help
+# CHECK-DWARF:   -h  - A

r358427 - [X86] Restore the pavg intrinsics.

2019-04-15 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Apr 15 10:17:35 2019
New Revision: 358427

URL: http://llvm.org/viewvc/llvm-project?rev=358427&view=rev
Log:
[X86] Restore the pavg intrinsics.

The pattern we replaced these with may be too hard to match as demonstrated by
PR41496 and PR41316.

This patch restores the intrinsics and then we can start focusing
on the optimizing the intrinsics.

I've mostly reverted the original patch that removed them. Though I modified
the avx512 intrinsics to not have masking built in.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx2intrin.h
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/test/CodeGen/avx2-builtins.c
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=358427&r1=358426&r2=358427&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Apr 15 10:17:35 2019
@@ -263,6 +263,8 @@ TARGET_BUILTIN(__builtin_ia32_paddusw128
 TARGET_BUILTIN(__builtin_ia32_psubusb128, "V16cV16cV16c", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psubusw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmulhw128, "V8sV8sV8s", "ncV:128:", "sse2")
+TARGET_BUILTIN(__builtin_ia32_pavgb128, "V16cV16cV16c", "ncV:128:", "sse2")
+TARGET_BUILTIN(__builtin_ia32_pavgw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmaxub128, "V16cV16cV16c", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmaxsw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pminub128, "V16cV16cV16c", "ncV:128:", "sse2")
@@ -574,6 +576,8 @@ TARGET_BUILTIN(__builtin_ia32_paddusw256
 TARGET_BUILTIN(__builtin_ia32_psubusb256, "V32cV32cV32c", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psubusw256, "V16sV16sV16s", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_palignr256, "V32cV32cV32cIi", "ncV:256:", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pavgb256, "V32cV32cV32c", "ncV:256:", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pavgw256, "V16sV16sV16s", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_pblendvb256, "V32cV32cV32cV32c", "ncV:256:", 
"avx2")
 TARGET_BUILTIN(__builtin_ia32_pblendw256, "V16sV16sV16sIi", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_phaddw256, "V16sV16sV16s", "ncV:256:", "avx2")
@@ -1053,6 +1057,8 @@ TARGET_BUILTIN(__builtin_ia32_paddsb512,
 TARGET_BUILTIN(__builtin_ia32_paddsw512, "V32sV32sV32s", "ncV:512:", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddusb512, "V64cV64cV64c", "ncV:512:", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddusw512, "V32sV32sV32s", "ncV:512:", 
"avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pavgb512, "V64cV64cV64c", "ncV:512:", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pavgw512, "V32sV32sV32s", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxsb512, "V64cV64cV64c", "ncV:512:", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxsw512, "V32sV32sV32s", "ncV:512:", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxub512, "V64cV64cV64c", "ncV:512:", 
"avx512bw")

Modified: cfe/trunk/lib/Headers/avx2intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx2intrin.h?rev=358427&r1=358426&r2=358427&view=diff
==
--- cfe/trunk/lib/Headers/avx2intrin.h (original)
+++ cfe/trunk/lib/Headers/avx2intrin.h Mon Apr 15 10:17:35 2019
@@ -132,21 +132,13 @@ _mm256_andnot_si256(__m256i __a, __m256i
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_avg_epu8(__m256i __a, __m256i __b)
 {
-  typedef unsigned short __v32hu __attribute__((__vector_size__(64)));
-  return (__m256i)__builtin_convertvector(
-   ((__builtin_convertvector((__v32qu)__a, __v32hu) +
- __builtin_convertvector((__v32qu)__b, __v32hu)) + 1)
- >> 1, __v32qu);
+  return (__m256i)__builtin_ia32_pavgb256((__v32qi)__a, (__v32qi)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_avg_epu16(__m256i __a, __m256i __b)
 {
-  typedef unsigned int __v16su __attribute__((__vector_size__(64)));
-  return (__m256i)__builtin_convertvector(
-   ((__builtin_convertvector((__v16hu)__a, __v16su) +
- __builtin_convertvector((__v16hu)__b, __v16su)) + 1)
- >> 1, __v16hu);
+  return (__m256i)__builtin_ia32_pavgw256((__v16hi)__a, (__v16hi)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS256

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=358427&r1=358426&r2=358427&view=diff
=

r358428 - [CommandLineParser] Add DefaultOption flag

2019-04-15 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Mon Apr 15 10:18:10 2019
New Revision: 358428

URL: http://llvm.org/viewvc/llvm-project?rev=358428&view=rev
Log:
[CommandLineParser] Add DefaultOption flag

Summary: Add DefaultOption flag to CommandLineParser which provides a
default option or alias, but allows users to override it for some
other purpose as needed.

Also, add `-h` as a default alias to `-help`, which can be seamlessly
overridden by applications like llvm-objdump and llvm-readobj which
use `-h` as an alias for other options.

(relanding after revert, r358414)
Added DefaultOptions.clear() to reset().

Reviewers: alexfh, klimek

Reviewed By: klimek

Subscribers: kristina, MaskRay, mehdi_amini, inglorion, dexonsmith, hiraditya, 
llvm-commits, jhenderson, arphaman, cfe-commits

Tags: #clang, #llvm

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

Modified:
cfe/trunk/lib/Tooling/CommonOptionsParser.cpp

Modified: cfe/trunk/lib/Tooling/CommonOptionsParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CommonOptionsParser.cpp?rev=358428&r1=358427&r2=358428&view=diff
==
--- cfe/trunk/lib/Tooling/CommonOptionsParser.cpp (original)
+++ cfe/trunk/lib/Tooling/CommonOptionsParser.cpp Mon Apr 15 10:18:10 2019
@@ -83,8 +83,6 @@ std::vector ArgumentsAdj
 llvm::Error CommonOptionsParser::init(
 int &argc, const char **argv, cl::OptionCategory &Category,
 llvm::cl::NumOccurrencesFlag OccurrencesFlag, const char *Overview) {
-  static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden,
-cl::sub(*cl::AllSubCommands));
 
   static cl::opt BuildPath("p", cl::desc("Build path"),
 cl::Optional, cl::cat(Category),


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


[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358428: [CommandLineParser] Add DefaultOption flag (authored 
by dhinton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59746?vs=195218&id=195220#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59746

Files:
  cfe/trunk/lib/Tooling/CommonOptionsParser.cpp
  llvm/trunk/docs/CommandLine.rst
  llvm/trunk/include/llvm/Support/CommandLine.h
  llvm/trunk/lib/Support/CommandLine.cpp
  llvm/trunk/test/Support/check-default-options.txt
  llvm/trunk/tools/llvm-opt-report/OptReport.cpp
  llvm/trunk/unittests/Support/CommandLineTest.cpp

Index: llvm/trunk/lib/Support/CommandLine.cpp
===
--- llvm/trunk/lib/Support/CommandLine.cpp
+++ llvm/trunk/lib/Support/CommandLine.cpp
@@ -98,6 +98,11 @@
   // This collects additional help to be printed.
   std::vector MoreHelp;
 
+  // This collects Options added with the cl::DefaultOption flag. Since they can
+  // be overridden, they are not added to the appropriate SubCommands until
+  // ParseCommandLineOptions actually runs.
+  SmallVector DefaultOptions;
+
   // This collects the different option categories that have been registered.
   SmallPtrSet RegisteredOptionCategories;
 
@@ -146,6 +151,11 @@
   void addOption(Option *O, SubCommand *SC) {
 bool HadErrors = false;
 if (O->hasArgStr()) {
+  // If it's a DefaultOption, check to make sure it isn't already there.
+  if (O->isDefaultOption() &&
+  SC->OptionsMap.find(O->ArgStr) != SC->OptionsMap.end())
+return;
+
   // Add argument to the argument map!
   if (!SC->OptionsMap.insert(std::make_pair(O->ArgStr, O)).second) {
 errs() << ProgramName << ": CommandLine Error: Option '" << O->ArgStr
@@ -185,7 +195,12 @@
 }
   }
 
-  void addOption(Option *O) {
+  void addOption(Option *O, bool ProcessDefaultOption = false) {
+if (!ProcessDefaultOption && O->isDefaultOption()) {
+  DefaultOptions.push_back(O);
+  return;
+}
+
 if (O->Subs.empty()) {
   addOption(O, &*TopLevelSubCommand);
 } else {
@@ -201,8 +216,12 @@
   OptionNames.push_back(O->ArgStr);
 
 SubCommand &Sub = *SC;
-for (auto Name : OptionNames)
-  Sub.OptionsMap.erase(Name);
+auto End = Sub.OptionsMap.end();
+for (auto Name : OptionNames) {
+  auto I = Sub.OptionsMap.find(Name);
+  if (I != End && I->getValue() == O)
+Sub.OptionsMap.erase(I);
+  }
 
 if (O->getFormattingFlag() == cl::Positional)
   for (auto Opt = Sub.PositionalOpts.begin();
@@ -266,8 +285,13 @@
 if (O->Subs.empty())
   updateArgStr(O, NewName, &*TopLevelSubCommand);
 else {
-  for (auto SC : O->Subs)
-updateArgStr(O, NewName, SC);
+  if (O->isInAllSubCommands()) {
+for (auto SC : RegisteredSubCommands)
+  updateArgStr(O, NewName, SC);
+  } else {
+for (auto SC : O->Subs)
+  updateArgStr(O, NewName, SC);
+  }
 }
   }
 
@@ -331,6 +355,8 @@
 AllSubCommands->reset();
 registerSubCommand(&*TopLevelSubCommand);
 registerSubCommand(&*AllSubCommands);
+
+DefaultOptions.clear();
   }
 
 private:
@@ -366,6 +392,13 @@
   ArgStr = S;
 }
 
+void Option::reset() {
+  NumOccurrences = 0;
+  setDefault();
+  if (isDefaultOption())
+removeArgument();
+}
+
 // Initialise the general option category.
 OptionCategory llvm::cl::GeneralCategory("General options");
 
@@ -1167,6 +1200,10 @@
   auto &SinkOpts = ChosenSubCommand->SinkOpts;
   auto &OptionsMap = ChosenSubCommand->OptionsMap;
 
+  for (auto O: DefaultOptions) {
+addOption(O, true);
+  }
+
   if (ConsumeAfterOpt) {
 assert(PositionalOpts.size() > 0 &&
"Cannot specify cl::ConsumeAfter without a positional argument!");
@@ -2146,6 +2183,9 @@
 cl::location(WrappedNormalPrinter), cl::ValueDisallowed,
 cl::cat(GenericCategory), cl::sub(*AllSubCommands));
 
+static cl::alias HOpA("h", cl::desc("Alias for -help"), cl::aliasopt(HOp),
+  cl::DefaultOption);
+
 static cl::opt>
 HHOp("help-hidden", cl::desc("Display all available options"),
  cl::location(WrappedHiddenPrinter), cl::Hidden, cl::ValueDisallowed,
Index: llvm/trunk/unittests/Support/CommandLineTest.cpp
===
--- llvm/trunk/unittests/Support/CommandLineTest.cpp
+++ llvm/trunk/unittests/Support/CommandLineTest.cpp
@@ -620,6 +620,68 @@
   }
 }
 
+TEST(CommandLineTest, DefaultOptions) {
+  cl::ResetCommandLineParser();
+
+  StackOption Bar("bar", cl::sub(*cl::AllSubCommands),
+   cl::DefaultOption);
+  StackOption Bar_Alias(
+  "b", cl::desc("Alias for -bar"), cl::aliasopt(Bar), cl::DefaultOption);
+
+  StackOption Foo("foo", cl::init(false), cl::sub(*cl::AllSubCommands),
+ 

[PATCH] D60674: [X86] Restore the pavg intrinsics.

2019-04-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358427: [X86] Restore the pavg intrinsics. (authored by 
ctopper, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60674?vs=195090&id=195219#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60674

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/lib/Headers/avx2intrin.h
  cfe/trunk/lib/Headers/avx512bwintrin.h
  cfe/trunk/lib/Headers/emmintrin.h
  cfe/trunk/test/CodeGen/avx2-builtins.c
  cfe/trunk/test/CodeGen/avx512bw-builtins.c
  cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
  cfe/trunk/test/CodeGen/sse2-builtins.c
  llvm/trunk/include/llvm/IR/IntrinsicsX86.td
  llvm/trunk/lib/IR/AutoUpgrade.cpp
  llvm/trunk/lib/Target/X86/X86IntrinsicsInfo.h
  llvm/trunk/test/CodeGen/X86/avx2-intrinsics-fast-isel.ll
  llvm/trunk/test/CodeGen/X86/avx2-intrinsics-x86-upgrade.ll
  llvm/trunk/test/CodeGen/X86/avx2-intrinsics-x86.ll
  llvm/trunk/test/CodeGen/X86/avx512bw-intrinsics.ll
  llvm/trunk/test/CodeGen/X86/avx512bwvl-intrinsics.ll
  llvm/trunk/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll
  llvm/trunk/test/CodeGen/X86/sse2-intrinsics-x86-upgrade.ll
  llvm/trunk/test/CodeGen/X86/sse2-intrinsics-x86.ll

Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -263,6 +263,8 @@
 TARGET_BUILTIN(__builtin_ia32_psubusb128, "V16cV16cV16c", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psubusw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmulhw128, "V8sV8sV8s", "ncV:128:", "sse2")
+TARGET_BUILTIN(__builtin_ia32_pavgb128, "V16cV16cV16c", "ncV:128:", "sse2")
+TARGET_BUILTIN(__builtin_ia32_pavgw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmaxub128, "V16cV16cV16c", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmaxsw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pminub128, "V16cV16cV16c", "ncV:128:", "sse2")
@@ -574,6 +576,8 @@
 TARGET_BUILTIN(__builtin_ia32_psubusb256, "V32cV32cV32c", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psubusw256, "V16sV16sV16s", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_palignr256, "V32cV32cV32cIi", "ncV:256:", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pavgb256, "V32cV32cV32c", "ncV:256:", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pavgw256, "V16sV16sV16s", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_pblendvb256, "V32cV32cV32cV32c", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_pblendw256, "V16sV16sV16sIi", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_phaddw256, "V16sV16sV16s", "ncV:256:", "avx2")
@@ -1053,6 +1057,8 @@
 TARGET_BUILTIN(__builtin_ia32_paddsw512, "V32sV32sV32s", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddusb512, "V64cV64cV64c", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddusw512, "V32sV32sV32s", "ncV:512:", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pavgb512, "V64cV64cV64c", "ncV:512:", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pavgw512, "V32sV32sV32s", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxsb512, "V64cV64cV64c", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxsw512, "V32sV32sV32s", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxub512, "V64cV64cV64c", "ncV:512:", "avx512bw")
Index: cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
+++ cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
@@ -1179,101 +1179,49 @@
 }
 __m128i test_mm_mask_avg_epu8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_avg_epu8
-  // CHECK-NOT: @llvm.x86.sse2.pavg.b
-  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
-  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
-  // CHECK: add <16 x i16> %{{.*}}, %{{.*}}
-  // CHECK: add <16 x i16> %{{.*}}, 
-  // CHECK: lshr <16 x i16> %{{.*}}, 
-  // CHECK: trunc <16 x i16> %{{.*}} to <16 x i8>
+  // CHECK: @llvm.x86.sse2.pavg.b
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
   return _mm_mask_avg_epu8(__W,__U,__A,__B); 
 }
 __m128i test_mm_maskz_avg_epu8(__mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_maskz_avg_epu8
-  // CHECK-NOT: @llvm.x86.sse2.pavg.b
-  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
-  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
-  // CHECK: add <16 x i16> %{{.*}}, %{{.*}}
-  // CHECK: add <16 x i16> %{{.*}}, 
-  // CHECK: lshr <16 x i16> %{{.*}}, 
-  // CHECK: trunc <16 x i16> %{{.*}} to <16 x i8>
-  // CHECK: store <2 x i64> zeroinitializer
+  // CHECK: @llvm.x86.sse2.pavg.b
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
   return _mm_maskz_avg_epu8(__U,__A,__B); 
 }
 __m256i test_mm256_m

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-04-15 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: test/CodeGen/x86_32-m64-darwin.c:1
+// RUN: %clang_cc1 -w -fblocks -triple i386-apple-darwin9 -target-cpu yonah 
-target-feature +mmx -emit-llvm -O2 -o - %s | FileCheck %s
+

You should be able to merge all of these triples into the same test file, each 
with their own RUN: line, you will need to add a FileCheck prefix, something 
like:
```
| FileCheck %s --check-prefixes=CHECK,DARWIN
| FileCheck %s --check-prefixes=CHECK,IAMCU
| FileCheck %s --check-prefixes=CHECK,LINUX
| FileCheck %s --check-prefixes=CHECK,WIN32
```


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

https://reviews.llvm.org/D59744



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


[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

A few quick responses, will take a closer look again tomorrow.




Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:87
+  TextGenerator Replacement;
+  TextGenerator Explanation;
+};

ymandel wrote:
> ilya-biryukov wrote:
> > ymandel wrote:
> > > ilya-biryukov wrote:
> > > > ymandel wrote:
> > > > > ilya-biryukov wrote:
> > > > > > I would've expected explanation to be the trait of the rewrite 
> > > > > > rule, since all changes have to be applied.
> > > > > > What's the reasoning behind having it at the level of separate 
> > > > > > changes? How would this explanation be used? For debugging purposes 
> > > > > > or displaying that to the user?
> > > > > I think that for most cases, one explanation sufficies for the whole 
> > > > > transformation. However, there are some tidies that emit multiple 
> > > > > diagnoses (for example if changing before a declaration and a 
> > > > > definition).   Would it help if I clarify in the comments?
> > > > Yeah, absolutely! Please document what it's used for and that would 
> > > > clear that up for me.
> > > > I actually thing that explaining every part of the transformation is 
> > > > probably too complicated, so most of the time you would want to have an 
> > > > explanation for the `RewriteRule`, not for each individual change.
> > > > 
> > > > The other challenge that I see is show to display these explanations to 
> > > > the user, i.e. how should the clients combine these explanations in 
> > > > order to get the full one? Should the `RewriteRule` have an explanation 
> > > > of the full transformation too?
> > > I've revised the comments, changed the name to "Note" and put 
> > > "Explanation" back into RewriteRule.
> > > 
> > > As for how to display these, I imagine an interface like clang tidy's 
> > > fixit hints.  The Explanation (if any) will be associated with the span 
> > > of the entire match.  The Notes will be associated with the target node 
> > > span of each annotated change.  WDYT?
> > Do we really need the AST information to expose the edits to the users?
> > IIUC, clang-tidy uses the information from textual replacements to render 
> > the changes produced by the fix-its today.
> > 
> > I guess it might be useful to add extra notes to clang-tidy warnings that 
> > have corresponding fix-its, but is the transformers library the right layer 
> > to produce those? 
> > I haven't seen the proposed glue to clang-tidy yet, maybe that would make 
> > more sense when I see it.
> > 
> > One of the other reasons I ask this is that it seems that without `Note` we 
> > don't strictly `ASTEditBuilder`, we could replace
> > ```
> > change("ref").to("something"); // without nodepart
> > change("ref", NodePart::Member).to("something");
> > ```
> > with
> > ```
> > change("ref", "something")
> > change("ref", NodePart::Member, "something");
> > ```
> > That would remove the boilerplate of the builder, simplifying the code a 
> > bit.
> > 
> > That trick would be hard to pull if we have a `Note` field inside, we'll 
> > need more overloads and having note and replacement after each other might 
> > be confusing (they have the same type, might be hard to read without the 
> > guiding `.to()` and `.because()`)
> Breaking this explicitly into two questions:
> 1. Do Notes belong here?
> 2. Can we drop the builder?
> 
> 1. Do Notes belong here?
> I think so.  When users provide a diagnostic, they are specifying its 
> location. So, we don't quite need the AST but we do need location info.  The 
> diagnostic generator does take information from the replacements themselves, 
> but that's not alone. For example: 
> clang-tidy/readability/ConstReturnTypeCheck.cpp:104.  That demos both the 
> diagnostic construction and multiple diagnostics in a single tidy result.
> 
> Given that, i think that RewriteRules are the appropriate place. The goal is 
> that they be self contained, so I think the explanations should be bundled 
> with the description of that actual change.  An example approach to merging 
> with clang tidy is here: 
> https://github.com/ymand/llvm-project/blob/transformer/clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp
>  (although that's based on a somewhat different version of the Transformer 
> library; it should make clear what I have in mind).
> 
> 2. Do we need the builder?
> No, despite my opinion that notes belong.  Given the explanation on 
> RewriteRule, I think notes will be used only rarely (like in the example 
> clang-tidy above; but that's not standard practice).  So, we can provide the 
> two overloads of `change` that you mention and then let users assign the note 
> directly in those rare cases they need it. then, we can drop the builder.
> 
> So, I propose keeping the note but dropping the builder. WDYT?
Thanks for pointing out how this usage in clang-tidy. Seems to be the only way 
to put it into clang-tidy (and there are good reasons for that, e.g.

[PATCH] D60726: Fixed -Wconversion-null warning in GCC.

2019-04-15 Thread Denis Bakhvalov via Phabricator via cfe-commits
dendibakh created this revision.
dendibakh added a reviewer: reuk.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GCC -Wconversion-null warning appeared after 
9a63380260860b657b72f07c4f0e61e382ab934a.
There was a similar problem already in the past:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20131230/096230.html


Repository:
  rC Clang

https://reviews.llvm.org/D60726

Files:
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11393,6 +11393,7 @@
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
@@ -11566,12 +11567,6 @@
   CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatements);
 
-  Style.SpaceAfterLogicalNot = false;
-  CHECK_PARSE("SpaceAfterLogicalNot: true", SpaceAfterLogicalNot,
-  true);
-  CHECK_PARSE("SpaceAfterLogicalNot: false", SpaceAfterLogicalNot,
-  false);
-
   Style.ColumnLimit = 123;
   FormatStyle BaseStyle = getLLVMStyle();
   CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11393,6 +11393,7 @@
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
@@ -11566,12 +11567,6 @@
   CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatements);
 
-  Style.SpaceAfterLogicalNot = false;
-  CHECK_PARSE("SpaceAfterLogicalNot: true", SpaceAfterLogicalNot,
-  true);
-  CHECK_PARSE("SpaceAfterLogicalNot: false", SpaceAfterLogicalNot,
-  false);
-
   Style.ColumnLimit = 123;
   FormatStyle BaseStyle = getLLVMStyle();
   CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60233: [clang-scan-deps] initial outline of the tool that runs preprocessor to find dependencies over a JSON compilation database

2019-04-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D60233#1467092 , @trixirt wrote:

> A comment by whisperity in the origin WIP did not seem to be addressed.
>  Have you looked at IWYU 
> https://github.com/include-what-you-use/include-what-you-use ?
>  The end goals of clang-scan-deps and iwyu seem similar so their 
> implementation problems would also be similar.
>  The iwyu problems doc is 
> https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYUIsDifficult.md


IWYU doesn't seem related to me.  My understanding is:

- IWYU checks that semantic dependencies between source files is reflected by 
the file dependencies (e.g., semantic dependencies should have matching 
`#include`s).
- `clang-scan-deps` discovers the transitive file dependencies of a TU.

IIUC, IWYU's implementation challenges are related to mapping/discovering 
semantic dependencies between source files, which is something that 
`clang-scan-deps` doesn't care about at all.  Can you clarify what link you see?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60233



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


[PATCH] D60728: [clang] [test] Add a (xfailing) test for PR41027

2019-04-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, joerg, hans, rsmith.

Add a test for tracking PR41027 (8.0 regression breaking assembly code
relying on __builtin_constant_p() to identify compile-time constants).
Mark it as expected to fail everywhere.


https://reviews.llvm.org/D60728

Files:
  clang/test/Sema/pr41027.c


Index: clang/test/Sema/pr41027.c
===
--- /dev/null
+++ clang/test/Sema/pr41027.c
@@ -0,0 +1,9 @@
+// XFAIL: *
+// RUN: %clang_cc1 -triple x86_64 -fsyntax-only %s
+inline void pr41027(unsigned a, unsigned b) {
+  if (__builtin_constant_p(a)) {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "n"(a));
+  } else {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "d"(a));
+  }
+}


Index: clang/test/Sema/pr41027.c
===
--- /dev/null
+++ clang/test/Sema/pr41027.c
@@ -0,0 +1,9 @@
+// XFAIL: *
+// RUN: %clang_cc1 -triple x86_64 -fsyntax-only %s
+inline void pr41027(unsigned a, unsigned b) {
+  if (__builtin_constant_p(a)) {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "n"(a));
+  } else {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "d"(a));
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r358435 - [X86] Improve avx512-kconstraints-att_inline_asm.c to not be easily defeated by deadcode elimination. Improve CHECK lines to check IR types used. NFC

2019-04-15 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Apr 15 11:39:36 2019
New Revision: 358435

URL: http://llvm.org/viewvc/llvm-project?rev=358435&view=rev
Log:
[X86] Improve avx512-kconstraints-att_inline_asm.c to not be easily defeated by 
deadcode elimination. Improve CHECK lines to check IR types used. NFC

I plan to use this as the basis for backend IR test cases. We currently crash 
hard for using 32 or 64 bit mask registers without avx512bw.

Modified:
cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c

Modified: cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c?rev=358435&r1=358434&r2=358435&view=diff
==
--- cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c (original)
+++ cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c Mon Apr 15 
11:39:36 2019
@@ -1,59 +1,77 @@
-// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-cpu 
skylake-avx512 -emit-llvm -o - -Wall -Werror |opt -instnamer -S |FileCheck %s
+// RUN: %clang_cc1 %s -O0 -ffreestanding -triple=x86_64-apple-darwin 
-target-cpu skylake-avx512 -emit-llvm -o - -Wall -Werror |opt -instnamer -S 
|FileCheck %s
 // This test checks validity of att\gcc style inline assmebly for avx512 k and 
Yk constraints.
 // Also checks mask register allows flexible type (size <= 64 bit)
 
-void mask_Yk_i8(char msk){ 
-//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
- asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
-   ://output
-   : "Yk" (msk));   //inputs
-}
-
-void mask_Yk_i16(short msk){
-//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
- asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
-   ://output
-   :  "Yk" (msk));  //inputs
-}
-
-void mask_Yk_i32(int msk){
-//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
-asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
-   ://output
-   :  "Yk" (msk));   //inputs
-}
+#include 
 
-void mask_Yk_i64(long long msk){
-//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
- asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
-   ://output
-   :  "Yk" (msk));   //inputs
-}
-
-void k_wise_op_i8(char msk_dst,char msk_src1,char msk_src2){
-//CHECK: kandw\09$2, $1, $0
- asm ("kandw\t%2, %1, %0"
+__m512i mask_Yk_i8(char msk, __m512i x, __m512i y){
+// CHECK: <8 x i64> asm "vpaddq\09$3, $2, $0 {$1}", 
"=x,^Yk,x,x,~{dirflag},~{fpsr},~{flags}"(i8 %{{.*}}, <8 x i64> %{{.*}}, <8 x 
i64> %{{.*}})
+  __m512i dst;
+  asm ("vpaddq\t%3, %2, %0 %{%1%}"
+   : "=x" (dst)  //output
+   : "Yk" (msk), "x" (x), "x" (y));   //inputs
+  return dst;
+}
+
+__m512i mask_Yk_i16(short msk, __m512i x, __m512i y){
+// CHECK: <8 x i64> asm "vpaddd\09$3, $2, $0 {$1}", 
"=x,^Yk,x,x,~{dirflag},~{fpsr},~{flags}"(i16 %{{.*}}, <8 x i64> %{{.*}}, <8 x 
i64> %{{.*}})
+  __m512i dst;
+  asm ("vpaddd\t%3, %2, %0 %{%1%}"
+   : "=x" (dst)  //output
+   : "Yk" (msk), "x" (x), "x" (y));   //inputs
+  return dst;
+}
+
+__m512i mask_Yk_i32(int msk, __m512i x, __m512i y){
+// CHECK: <8 x i64> asm "vpaddw\09$3, $2, $0 {$1}", 
"=x,^Yk,x,x,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, <8 x i64> %{{.*}}, <8 x 
i64> %{{.*}})
+  __m512i dst;
+  asm ("vpaddw\t%3, %2, %0 %{%1%}"
+   : "=x" (dst)  //output
+   : "Yk" (msk), "x" (x), "x" (y));   //inputs
+  return dst;
+}
+
+__m512i mask_Yk_i64(long long msk, __m512i x, __m512i y){
+// CHECK: <8 x i64> asm "vpaddb\09$3, $2, $0 {$1}", 
"=x,^Yk,x,x,~{dirflag},~{fpsr},~{flags}"(i64 %{{.*}}, <8 x i64> %{{.*}}, <8 x 
i64> %{{.*}})
+  __m512i dst;
+  asm ("vpaddb\t%3, %2, %0 %{%1%}"
+   : "=x" (dst)  //output
+   : "Yk" (msk), "x" (x), "x" (y));   //inputs
+  return dst;
+}
+
+char k_wise_op_i8(char msk_src1,char msk_src2){
+//CHECK: i8 asm "kandb\09$2, $1, $0", "=k,k,k,~{dirflag},~{fpsr},~{flags}"(i8 
%{{.*}}, i8 %{{.*}})
+  char msk_dst;
+  asm ("kandb\t%2, %1, %0"
: "=k" (msk_dst)
: "k" (msk_src1), "k" (msk_src2));
+  return msk_dst;
 }
 
-void k_wise_op_i16(short msk_dst, short msk_src1, short msk_src2){
-//CHECK: kandw\09$2, $1, $0
+short k_wise_op_i16(short msk_src1, short msk_src2){
+//CHECK: i16 asm "kandw\09$2, $1, $0", 
"=k,k,k,~{dirflag},~{fpsr},~{flags}"(i16 %{{.*}}, i16 %{{.*}})
+  short msk_dst;
   asm ("kandw\t%2, %1, %0"
: "=k" (msk_dst)
: "k" (msk_src1), "k" (msk_src2));
+  return msk_dst;
 }
 
-void k_wise_op_i32(int msk_dst, int msk_src1, int msk_src2){
-//CHECK: kandw\09$2, $1, $0
-  asm ("kandw\t%2, %1, %0"
+int k_wise_op_i32(int msk_src1, int msk_src2){
+//CHECK: i32 asm "kandd\09$2, $1, $0", 
"=k,k,k,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i32 %{{.*}})
+  int msk_dst;
+  asm ("kandd\t%2, %1, %0"
: "=k" (msk_dst)
: "k" (msk_src1), "k" (msk_src2));
+  return msk_dst;
 }
 
-void k_wise_op_i64(long long msk_dst, long long msk_src1, long long msk_src2

[PATCH] D59264: [Driver] Support compiler-rt crtbegin.o/crtend.o for Linux

2019-04-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

@MaskRay can you review this again now that there's just a single `crtbegin.o` 
and `crtend.o` version?


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

https://reviews.llvm.org/D59264



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


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

In D60455#1464324 , @Fznamznon wrote:

> Applied comments from @aaron.ballman and @keryell
>
> - Introduced a C++11 and C2x style spelling in the clang namespace. I didn't 
> find path to add two namespaces to attribute (like [[clang::sycl::device]]) 
> so [[clang::sycl_device]] spelling is added.
> - Since both attributes have spellings and possible can be used as some 
> "standard" outlining in Clang/LLVM I added documetation.
> - Added more test cases.
> - As @bader mentioned sycl_device can be used to mark functions, which are 
> called from the different translation units so I added simple handling of 
> this attribute in Sema.


I'm confused -- I thought @bader also said "...SYCL is not supposed to expose 
any non-standard extensions to a user." -- these attributes are not standards 
based (WG21 and WG14 have nothing to say about them), so are these attributes 
considered "non-standard extensions" or not?

I'm still wondering what the actual semantics are for the attribute. Right now, 
these are being parsed and ignored -- are there future plans here?




Comment at: clang/include/clang/Basic/Attr.td:1000
+def SYCLDevice : InheritableAttr {
+  let Spellings = [GNU<"sycl_device">];
+  let Subjects = SubjectList<[Function, Var]>;

aaron.ballman wrote:
> keryell wrote:
> > Fznamznon wrote:
> > > aaron.ballman wrote:
> > > > Is there a reason to not also introduce a C++11 and C2x style spelling 
> > > > in the `clang` namespace? e.g., `[[clang::sycl_device]]`
> > > I don't think that it makes sense because these attributes not for public 
> > > consumption. These attributes is needed to separate code which is 
> > > supposed to be offloaded from regular host code. I think SYCLDevice 
> > > attribute actually doesn't need a spelling because it will be added only 
> > > implicitly by compiler.
> > 
> > If we go towards this direction, `[[clang::sycl::device]]` or 
> > `[[clang::sycl::kernel]]` look more compatible with the concept of name 
> > space.
> > While not a public interface, if we have a kind of "standard" outlining in 
> > Clang/LLVM, some people might want to use it in some other contexts too.
> If these are only being added implicitly by the compiler, then they should 
> not be given any `Spelling`. See `AlignMac68k` for an example.
I'm still confused -- are these created implicitly or are they spelled out by 
the user explicitly? Right now, it looks like they're spelled out explicitly, 
but I was under the impression they are only intended to be created implicitly 
by the compiler.

If they are expected to be explicitly specified by the user, the spelling 
should be using `Clang<>` instead of using `GNU<>`, `C2x<>`, and `CXX11<>` 
explicitly.

> If we go towards this direction, [[clang::sycl::device]] or 
> [[clang::sycl::kernel]] look more compatible with the concept of name space.

Attribute namespaces do not work that way. There is the vendor namespace and 
then the attribute name.



Comment at: clang/include/clang/Basic/AttrDocs.td:259
+  let Content = [{
+The sycl_device attribute specifies function which is supposed to be compiled
+for the device and cannot be directly called by the host. Here is code example

specifies function which is -> specifies that a function is

Also, please put backticks around `sycl_device`.



Comment at: clang/include/clang/Basic/AttrDocs.td:260
+The sycl_device attribute specifies function which is supposed to be compiled
+for the device and cannot be directly called by the host. Here is code example
+of the SYCL program, which demonstrates the need for this attribute:

is code example -> is a code example



Comment at: clang/include/clang/Basic/AttrDocs.td:261
+for the device and cannot be directly called by the host. Here is code example
+of the SYCL program, which demonstrates the need for this attribute:
+

the SYCL program, which -> a SYLC program that

(Note, I also removed the comma.)



Comment at: clang/include/clang/Basic/AttrDocs.td:277
+
+Code is passed to parallel_for is called "kernel function" and defines some
+entry point to device code i.e. will be called by host in run time. Compiler

Code -> Do you mean the lambda? If so, perhaps "The lambda that is passed to 
the `parallel_for`" (add backticks around parallel_for too, please).

is called "kernel function" -> is called a "kernel function"



Comment at: clang/include/clang/Basic/AttrDocs.td:286
+help.
+  }];
+}

I'm still not entirely certain how I would know what to mark and how. From the 
description, it sounds like whoever authors `parallel_for` needs to do this 
marking, or it somehow happens automatically?

(I'll do another edi

[PATCH] D60726: Fixed -Wconversion-null warning in GCC.

2019-04-15 Thread Reuben Thomas via Phabricator via cfe-commits
reuk accepted this revision.
reuk added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D60726



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


[PATCH] D60726: Fixed -Wconversion-null warning in GCC.

2019-04-15 Thread Denis Bakhvalov via Phabricator via cfe-commits
dendibakh added a comment.

@reuk , can you please commit this patch on my behalf?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60726



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


r358437 - Revert "[clang] Aligned allocation is actually supported in macosx 10.13"

2019-04-15 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Mon Apr 15 12:08:52 2019
New Revision: 358437

URL: http://llvm.org/viewvc/llvm-project?rev=358437&view=rev
Log:
Revert "[clang] Aligned allocation is actually supported in macosx 10.13"

This reverts r358409, which I think broke the bots in compiler-rt.
Since I'm having trouble reproducing the failure, I'm reverting this
until I can investigate locally.

Modified:
cfe/trunk/include/clang/Basic/AlignedAllocation.h
cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp

Modified: cfe/trunk/include/clang/Basic/AlignedAllocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AlignedAllocation.h?rev=358437&r1=358436&r2=358437&view=diff
==
--- cfe/trunk/include/clang/Basic/AlignedAllocation.h (original)
+++ cfe/trunk/include/clang/Basic/AlignedAllocation.h Mon Apr 15 12:08:52 2019
@@ -26,8 +26,8 @@ inline llvm::VersionTuple alignedAllocMi
   default:
 break;
   case llvm::Triple::Darwin:
-  case llvm::Triple::MacOSX: // Earliest supporting version is 10.13.
-return llvm::VersionTuple(10U, 13U);
+  case llvm::Triple::MacOSX: // Earliest supporting version is 10.14.
+return llvm::VersionTuple(10U, 14U);
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0.
 return llvm::VersionTuple(11U);

Modified: cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp?rev=358437&r1=358436&r2=358437&view=diff
==
--- cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp (original)
+++ cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp Mon Apr 15 
12:08:52 2019
@@ -1,4 +1,4 @@
-// RUN: %clang -target x86_64-apple-macosx10.12 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=UNAVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios10 -c -### %s 2>&1 \
@@ -24,7 +24,7 @@
 //
 // UNAVAILABLE: "-faligned-alloc-unavailable"
 
-// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.14 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios11 -c -### %s 2>&1 \
@@ -54,10 +54,10 @@
 // Check that passing -faligned-allocation or -fno-aligned-allocation stops the
 // driver from passing -faligned-alloc-unavailable to cc1.
 //
-// RUN: %clang -target x86_64-apple-macosx10.12 -faligned-allocation -c -### 
%s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -faligned-allocation -c -### 
%s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
-// RUN: %clang -target x86_64-apple-macosx10.12 -fno-aligned-allocation -c 
-### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -fno-aligned-allocation -c 
-### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 
 // AVAILABLE-NOT: "-faligned-alloc-unavailable"

Modified: cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp?rev=358437&r1=358436&r2=358437&view=diff
==
--- cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp (original)
+++ cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp Mon Apr 15 
12:08:52 2019
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
@@ -117,8 +117,8 @@ void testOveralignedCheckOS() {
 // expected-error@-13 {{aligned allocation function of type 'void *(unsigned 
long, enum std::align_val_t)' is only available on watchOS 4 or newer}}}
 // expected-error@-14 {{aligned deallocation function of type 'void (void *, 
enum std::align_

[PATCH] D60663: Time profiler: small fixes and optimizations

2019-04-15 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev added a comment.

In D60663#1465721 , @lebedev.ri wrote:

> Looks good ignoring the json bits.
>
> Re license:
>
> > https://reviews.llvm.org/D58675
> >  This is the first part of time tracing system, I have splitted them cause 
> > this part is mostly written by Aras Pranckevicius except of several minor 
> > fixes concerning formatting.
>
> So i can't and won't claim any legal knowledge, but it maybe would be good 
> for him to at least comment here, that he is ok with this?


I've communicated to Aras by mail, he is ok with new license header:

> "Sure! I started my branch before the LLVM license change. The new one is 
> fine."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60663



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


[PATCH] D60626: [clang] Aligned allocation is actually supported in macosx 10.13

2019-04-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Reverted in r358437 because of unforeseen CI failures. The failures I was 
expecting are in libc++, not in compiler-rt. I'll investigate locally and 
re-apply.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60626



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


[PATCH] D60663: Time profiler: small fixes and optimizations

2019-04-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Ok, LG, thank you!




Comment at: llvm/lib/Support/TimeProfiler.cpp:30
+cl::desc(
+"Minimum time granularity (in microsecons) traced by time profiler"),
+cl::init(500));

microsecon*d*s



Comment at: llvm/lib/Support/TimeProfiler.cpp:70-71
+
+  Entry(time_point &&S, DurationType &&D, std::string &&N,
+std::string &&Dt)
+  : Start(std::move(S)), Duration(std::move(D)), Name(std::move(N)),

I *think* `&&` are not needed.



Comment at: llvm/lib/Support/TimeProfiler.cpp:92
+// Only include sections longer than TimeTraceGranularity.
+if (duration_cast(E.Duration).count() > TimeTraceGranularity)
   Entries.emplace_back(E);

This will only track events that are **longer** than `TimeTraceGranularity`, 
which i think conflicts
with the `"Minimum time granularity (in microseconds) traced by time profiler"`
So either `>=` or reword the description a bit?



Comment at: llvm/lib/Support/TimeProfiler.cpp:156-157
 
-  std::vector Stack;
-  std::vector Entries;
+  SmallVector Stack;
+  SmallVector Entries;
   StringMap CountAndTotalPerName;

Since `TimeTraceProfiler` will be always heap-allocated (so stack usage is not 
a concern)
i think this is safe, and maybe even bump it a bit, depending on the values you 
see in average profiles?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60663



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


[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-04-15 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.



  ; ModuleID = 'arch_static_branch.bc'
  source_filename = "arch/x86/entry/vsyscall/vsyscall_64.c"
  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  target triple = "x86_64-grtev4-linux-gnu"
  
  %struct.atomic_t = type { i32 }
  %struct.jump_entry = type { i64, i64, i64 }
  %struct.tracepoint_func = type { i8*, i8*, i32 }
  %struct.static_key = type { %struct.atomic_t, %union.anon }
  %union.anon = type { i64 }
  
  @__tracepoint_emulate_vsyscall = external hidden global { i8*, { 
%struct.atomic_t, { %struct.jump_entry* } }, i32 ()*, void ()*, 
%struct.tracepoint_func* }, section "__tracepoints", align 8
  
  ; Function Attrs: alwaysinline noredzone nounwind sspstrong
  define zeroext i1 @arch_static_branch(%struct.static_key* nocapture readnone 
%key, i1 zeroext %branch) {
  entry:
callbr void asm sideeffect "1:.byte 0x0f,0x1f,0x44,0x00,0\0A\09.pushsection 
__jump_table,  \22aw\22 \0A\09 .balign 8 \0A\09 .quad 1b, ${2:l}, ${0:c} + 
${1:c} \0A\09.popsection \0A\09", 
"i,i,X,~{dirflag},~{fpsr},~{flags}"(%struct.static_key* bitcast (i32* 
getelementptr inbounds ({ i8*, { %struct.atomic_t, { %struct.jump_entry* } }, 
i32 ()*, void ()*, %struct.tracepoint_func* }, { i8*, { %struct.atomic_t, { 
%struct.j
  ump_entry* } }, i32 ()*, void ()*, %struct.tracepoint_func* }* 
@__tracepoint_emulate_vsyscall, i64 0, i32 1, i32 0, i32 0) to 
%struct.static_key*), i1 false, i8* blockaddress(@arch_static_branch, %return))
to label %asm.fallthrough [label %return]
  
  asm.fallthrough:  ; preds = %entry
call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"()
br label %return
  
  return:   ; preds = %asm.fallthrough, 
%entry
%retval.0 = phi i1 [ false, %asm.fallthrough ], [ true, %entry ]
ret i1 %retval.0
  }


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

https://reviews.llvm.org/D56571



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


  1   2   >