[clang-tools-extra] e326f52 - [clangd] Fix the incomplete template specialization in findTarget.

2020-02-21 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-02-21T09:42:02+01:00
New Revision: e326f52430419af1ca5aed635168672fbaab5654

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

LOG: [clangd] Fix the incomplete template specialization in findTarget.

Summary:
FindTarget doesn't report the TemplatePattern for incomplete
specialization.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 685079f0ebe8..4528e2a77164 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -31,6 +31,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
@@ -139,7 +140,14 @@ const Type *getPointeeType(const Type *T) {
 
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-return CRD->getTemplateInstantiationPattern();
+if (const auto *Result = CRD->getTemplateInstantiationPattern())
+  return Result;
+// getTemplateInstantiationPattern returns null if the Specialization is
+// incomplete (e.g. the type didn't need to be complete), fall back to the
+// primary template.
+if (CRD->getTemplateSpecializationKind() == TSK_Undeclared)
+  if (const auto *Spec = dyn_cast(CRD))
+return Spec->getSpecializedTemplate()->getTemplatedDecl();
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 return FD->getTemplateInstantiationPattern();
   } else if (auto *VD = dyn_cast(D)) {

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index fa091b2a2503..5cf94b6ff6b0 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -309,6 +309,16 @@ TEST_F(TargetDeclTest, ClassTemplate) {
{"template<> class Foo<42>", Rel::TemplateInstantiation},
{"class Foo", Rel::TemplatePattern});
 
+  Code = R"cpp(
+template class Foo {};
+// The "Foo" SpecializationDecl is incomplete, there is no
+// instantiation happening.
+void func([[Foo]] *);
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc",
+   {"class Foo", Rel::TemplatePattern},
+   {"template<> class Foo", Rel::TemplateInstantiation});
+
   Code = R"cpp(
 // Explicit specialization.
 template class Foo{};

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 31c965087547..27b717b0e1c2 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -954,6 +954,12 @@ TEST(FindReferences, WithinAST) {
class [[Fo^o]] {};
void func([[Foo]]);
   )cpp",
+
+  R"cpp(
+   template 
+   class [[Foo]] {};
+   void func([[Fo^o]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);



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


[PATCH] D74900: [clangd] Fix the incomplete template specialization in findTarget.

2020-02-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 245800.
hokein added a comment.

Fxi the tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74900

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -954,6 +954,12 @@
class [[Fo^o]] {};
void func([[Foo]]);
   )cpp",
+
+  R"cpp(
+   template 
+   class [[Foo]] {};
+   void func([[Fo^o]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -309,6 +309,16 @@
{"template<> class Foo<42>", Rel::TemplateInstantiation},
{"class Foo", Rel::TemplatePattern});
 
+  Code = R"cpp(
+template class Foo {};
+// The "Foo" SpecializationDecl is incomplete, there is no
+// instantiation happening.
+void func([[Foo]] *);
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc",
+   {"class Foo", Rel::TemplatePattern},
+   {"template<> class Foo", Rel::TemplateInstantiation});
+
   Code = R"cpp(
 // Explicit specialization.
 template class Foo{};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -31,6 +31,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
@@ -139,7 +140,14 @@
 
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-return CRD->getTemplateInstantiationPattern();
+if (const auto *Result = CRD->getTemplateInstantiationPattern())
+  return Result;
+// getTemplateInstantiationPattern returns null if the Specialization is
+// incomplete (e.g. the type didn't need to be complete), fall back to the
+// primary template.
+if (CRD->getTemplateSpecializationKind() == TSK_Undeclared)
+  if (const auto *Spec = dyn_cast(CRD))
+return Spec->getSpecializedTemplate()->getTemplatedDecl();
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 return FD->getTemplateInstantiationPattern();
   } else if (auto *VD = dyn_cast(D)) {


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -954,6 +954,12 @@
class [[Fo^o]] {};
void func([[Foo]]);
   )cpp",
+
+  R"cpp(
+   template 
+   class [[Foo]] {};
+   void func([[Fo^o]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -309,6 +309,16 @@
{"template<> class Foo<42>", Rel::TemplateInstantiation},
{"class Foo", Rel::TemplatePattern});
 
+  Code = R"cpp(
+template class Foo {};
+// The "Foo" SpecializationDecl is incomplete, there is no
+// instantiation happening.
+void func([[Foo]] *);
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc",
+   {"class Foo", Rel::TemplatePattern},
+   {"template<> class Foo", Rel::TemplateInstantiation});
+
   Code = R"cpp(
 // Explicit specialization.
 template class Foo{};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -31,6 +31,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
@@ -139,7 +140,14 @@
 
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-return CRD->getTemplateInstantiationPattern();
+if (const auto *Result = CRD->getT

[PATCH] D74900: [clangd] Fix the incomplete template specialization in findTarget.

2020-02-21 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe326f5243041: [clangd] Fix the incomplete template 
specialization in findTarget. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D74900?vs=245800&id=245801#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74900

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -954,6 +954,12 @@
class [[Fo^o]] {};
void func([[Foo]]);
   )cpp",
+
+  R"cpp(
+   template 
+   class [[Foo]] {};
+   void func([[Fo^o]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -310,6 +310,16 @@
{"class Foo", Rel::TemplatePattern});
 
   Code = R"cpp(
+template class Foo {};
+// The "Foo" SpecializationDecl is incomplete, there is no
+// instantiation happening.
+void func([[Foo]] *);
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc",
+   {"class Foo", Rel::TemplatePattern},
+   {"template<> class Foo", Rel::TemplateInstantiation});
+
+  Code = R"cpp(
 // Explicit specialization.
 template class Foo{};
 template<> class Foo<42>{};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -31,6 +31,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
@@ -139,7 +140,14 @@
 
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-return CRD->getTemplateInstantiationPattern();
+if (const auto *Result = CRD->getTemplateInstantiationPattern())
+  return Result;
+// getTemplateInstantiationPattern returns null if the Specialization is
+// incomplete (e.g. the type didn't need to be complete), fall back to the
+// primary template.
+if (CRD->getTemplateSpecializationKind() == TSK_Undeclared)
+  if (const auto *Spec = dyn_cast(CRD))
+return Spec->getSpecializedTemplate()->getTemplatedDecl();
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 return FD->getTemplateInstantiationPattern();
   } else if (auto *VD = dyn_cast(D)) {


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -954,6 +954,12 @@
class [[Fo^o]] {};
void func([[Foo]]);
   )cpp",
+
+  R"cpp(
+   template 
+   class [[Foo]] {};
+   void func([[Fo^o]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -310,6 +310,16 @@
{"class Foo", Rel::TemplatePattern});
 
   Code = R"cpp(
+template class Foo {};
+// The "Foo" SpecializationDecl is incomplete, there is no
+// instantiation happening.
+void func([[Foo]] *);
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc",
+   {"class Foo", Rel::TemplatePattern},
+   {"template<> class Foo", Rel::TemplateInstantiation});
+
+  Code = R"cpp(
 // Explicit specialization.
 template class Foo{};
 template<> class Foo<42>{};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -31,6 +31,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
@@ -139,7 +140,14 @@
 
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl 

[clang-tools-extra] bc49819 - [clangd] Allow renaming class templates in cross-file rename.

2020-02-21 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-02-21T09:57:10+01:00
New Revision: bc498198b5559829d8f7138db01b0f51afefe2a7

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

LOG: [clangd] Allow renaming class templates in cross-file rename.

Summary:
It was disabled because we don't handle explicit template
specialization well (due to the index limitation).

renaming templates is normal in practic, rather than disabling it, this patch
allows to rename them though it is not perfect (just a known limitation).

Context: https://github.com/clangd/clangd/issues/280

Reviewers: kbobyrev

Reviewed By: kbobyrev

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index c5dd09b99508..02e355ecf164 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -184,13 +184,6 @@ llvm::Optional renameable(const NamedDecl 
&RenameDecl,
   if (!Index)
 return ReasonToReject::NoIndexProvided;
 
-  // Blacklist symbols that are not supported yet in cross-file mode due to the
-  // limitations of our index.
-  // FIXME: Renaming templates requires to rename all related specializations,
-  // our index doesn't have this information.
-  if (RenameDecl.getDescribedTemplate())
-return ReasonToReject::UnsupportedSymbol;
-
   // FIXME: Renaming virtual methods requires to rename all overridens in
   // subclasses, our index doesn't have this information.
   // Note: Within-file rename does support this through the AST.

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 3561ff6438f7..aa08be484ea3 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -887,6 +887,23 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
 }
   )cpp",
   },
+  {
+  // class templates.
+  R"cpp(
+template 
+class [[Foo]] {};
+// FIXME: explicit template specilizations are not supported due the
+// clangd index limitations.
+template <>
+class Foo {};
+  )cpp",
+  R"cpp(
+#include "foo.h"
+void func() {
+  [[F^oo]] foo;
+}
+  )cpp",
+  },
   {
   // class methods.
   R"cpp(



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


[PATCH] D74709: [clangd] Allow renaming class templates in cross-file rename.

2020-02-21 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc498198b555: [clangd] Allow renaming class templates in 
cross-file rename. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D74709?vs=244953&id=245802#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74709

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -888,6 +888,23 @@
   )cpp",
   },
   {
+  // class templates.
+  R"cpp(
+template 
+class [[Foo]] {};
+// FIXME: explicit template specilizations are not supported due the
+// clangd index limitations.
+template <>
+class Foo {};
+  )cpp",
+  R"cpp(
+#include "foo.h"
+void func() {
+  [[F^oo]] foo;
+}
+  )cpp",
+  },
+  {
   // class methods.
   R"cpp(
 class Foo {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -184,13 +184,6 @@
   if (!Index)
 return ReasonToReject::NoIndexProvided;
 
-  // Blacklist symbols that are not supported yet in cross-file mode due to the
-  // limitations of our index.
-  // FIXME: Renaming templates requires to rename all related specializations,
-  // our index doesn't have this information.
-  if (RenameDecl.getDescribedTemplate())
-return ReasonToReject::UnsupportedSymbol;
-
   // FIXME: Renaming virtual methods requires to rename all overridens in
   // subclasses, our index doesn't have this information.
   // Note: Within-file rename does support this through the AST.


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -888,6 +888,23 @@
   )cpp",
   },
   {
+  // class templates.
+  R"cpp(
+template 
+class [[Foo]] {};
+// FIXME: explicit template specilizations are not supported due the
+// clangd index limitations.
+template <>
+class Foo {};
+  )cpp",
+  R"cpp(
+#include "foo.h"
+void func() {
+  [[F^oo]] foo;
+}
+  )cpp",
+  },
+  {
   // class methods.
   R"cpp(
 class Foo {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -184,13 +184,6 @@
   if (!Index)
 return ReasonToReject::NoIndexProvided;
 
-  // Blacklist symbols that are not supported yet in cross-file mode due to the
-  // limitations of our index.
-  // FIXME: Renaming templates requires to rename all related specializations,
-  // our index doesn't have this information.
-  if (RenameDecl.getDescribedTemplate())
-return ReasonToReject::UnsupportedSymbol;
-
   // FIXME: Renaming virtual methods requires to rename all overridens in
   // subclasses, our index doesn't have this information.
   // Note: Within-file rename does support this through the AST.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 245805.
serge-sans-paille added a comment.

Add a configure feature test to filter out tests that depend on platform 
linker, as hinted by @MaskRay


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c
  clang/test/lit.site.cfg.py.in


Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -46,5 +46,8 @@
 import lit.llvm
 lit.llvm.initialize(lit_config, config)
 
+if not "@CLANG_DEFAULT_LINKER@":
+config.available_features('platform-linker')
+
 # Let the main config do the real work.
 lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/lit.cfg.py")
Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -1,8 +1,13 @@
 // A basic clang -cc1 command-line, and simple environment check.
+// REQUIRES: platform-linker
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck 
-check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
+// Test interaction with -fuse-ld=lld, if lld is available.
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 
2>&1 | FileCheck -check-prefix=LLD %s
+// LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
+
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
 
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -1,8 +1,13 @@
 // A basic clang -cc1 command-line, and simple environment check.
+// REQUIRES: platform-linker
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck 
-check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
 
+// Test interaction with -fuse-ld=lld, if lld is available.
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 
2>&1 | FileCheck -check-prefix=LLD %s
+// LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
+
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
 
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -142,7 +142,7 @@
 CmdArgs.push_back("elf32lriscv");
   }
 
-  std::string Linker = getToolChain().GetProgramPath(getShortName());
+  std::string Linker = getToolChain().GetLinkerPath();
 
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);


Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -46,5 +46,8 @@
 import lit.llvm
 lit.llvm.initialize(lit_config, config)
 
+if not "@CLANG_DEFAULT_LINKER@":
+config.available_features('platform-linker')
+
 # Let the main config do the real work.
 lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/lit.cfg.py")
Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -1,8 +1,13 @@
 // A basic clang -cc1 command-line, and simple environment check.
+// REQUIRES: platform-linker
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
+// Test interaction with -fuse-ld=lld, if lld is available.
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
+
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
 
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -1,8 +1,13 @@
 // A basic clang -cc1 command-line, and simple environment check.
+// REQUIRES: platform-linker
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple"

[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:70
 size_t UTF8Length = llvm::countLeadingOnes(C);
-// 0xxx is ASCII, handled above. 10xxx is a trailing byte, invalid here.
-// 1xxx is not valid UTF-8 at all. Assert because it's probably our 
bug.
-assert((UTF8Length >= 2 && UTF8Length <= 4) &&
-   "Invalid UTF-8, or transcoding bug?");
 I += UTF8Length; // Skip over all trailing bytes.
+// 0xxx is ASCII, handled above. 10xxx is a trailing byte, invalid here.

can we also move this into valid case, and only increment by one on the 
invalid(extended ascii) case ?

as we are trying to recover from extended ascii, and they are 1 byte in length, 
not multiple.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:71
 I += UTF8Length; // Skip over all trailing bytes.
-// A codepoint takes two UTF-16 code unit if it's astral (outside BMP).
-// Astral codepoints are encoded as 4 bytes in UTF-8 (0xxx ...)
-if (CB(UTF8Length, UTF8Length == 4 ? 2 : 1))
-  return true;
+// 0xxx is ASCII, handled above. 10xxx is a trailing byte, invalid here.
+// 1xxx is not valid UTF-8 at all. Log it because it's probably our 
bug.

could you re-arrange this part into

```
if (LLVM_LIKELY(UTF8Length >= 2 && UTF8Length <=4)) {
  // A codepoint takes two UTF-16 code unit if it's astral (outside BMP).
  // Astral codepoints are encoded as 4 bytes in UTF-8 (0xxx ...)
  if (CB(UTF8Length, UTF8Length >> 1))
return true;
  continue;
}

vlog("File contains invalid UTF-8, or transcoding bug? UTF8Length = {0}, string 
= {1}", UTF8Length, U8);
// If UTF8 length is 1, treat as one UTF8, if above 4, treat as one UTF16
if (CB(UTF8Length, UTF8Length == 1 ? 1 : 2))
   return true;
```



Comment at: clang-tools-extra/clangd/SourceCode.cpp:74
+if(UTF8Length == 1 || UTF8Length > 4) {
+  vlog("File contains invalid UTF-8, or transcoding bug? UTF8Length = {0}, 
string = {1}", UTF8Length, U8);
+  // If UTF8 length is 1, treat as one UTF8, if above 4, treat as one UTF16

instead of printing the string, it would be better to print hex representation 
of current character, you can check `llvm::utohexstr`



Comment at: clang-tools-extra/clangd/SourceCode.cpp:75
+  vlog("File contains invalid UTF-8, or transcoding bug? UTF8Length = {0}, 
string = {1}", UTF8Length, U8);
+  // If UTF8 length is 1, treat as one UTF8, if above 4, treat as one UTF16
+  if (CB(UTF8Length, UTF8Length == 1 ? 1 : 2))

we are already in a bad shape here, instead of making it more fluctuating can 
we always `CB(1, 1)`?

As long as you don't have any special reasoning for it.



Comment at: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp:64
+  // Invalid UTF16
+  const char invalidUTF16[6] = {
+  static_cast(0xFF), static_cast(0xFF), 
static_cast(0xFF),

 I believe in addition to being invalidutf16, this is also extended ascii 
(representing multiple `ÿ`s).

if we want clangd to work for extended ascii. I suppose the length should 
rather be 5 instead, as in utf-8 case. Since all of these bytes are 
representing a different character.


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

https://reviews.llvm.org/D74731



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

also could you clang-format your changes


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

https://reviews.llvm.org/D74731



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


[PATCH] D74934: [Clang interpreter] Rename Block.{h,cpp} to AllocatedBlock.{h,cpp}

2020-02-21 Thread Nandor Licker via Phabricator via cfe-commits
nand added a comment.

Was wondering if ```InterpBlock``` might be a more suitable name?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74934



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


[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-02-21 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a comment.

I find this phrasing pretty confusing. How about the following:

> This indicates that objects accessed via pointer values based on the argument 
> or return value are not **modified**, during the execution of the function, 
> via pointer values not based on the argument or return value. The attribute 
> on a return value also has additional semantics [...]

Does this exactly capture your intended meaning? If yes, can we please use that 
instead because it seems much clearer at least to me. If not, can you give an 
example for why it is different?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Let's go that way then. @xur I leave it to you to add the appropriate warning 
at least on the clang side? Feel free to just use the code from 
https://reviews.llvm.org/D74871?id=245594.


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

https://reviews.llvm.org/D74878



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


[PATCH] D74912: [AArch64][SVE] Add SVE2 intrinsics for bit permutation & table lookup

2020-02-21 Thread Andrzej Warzynski via Phabricator via cfe-commits
andwar added a comment.

Cheers for working on this @kmclaughlin!




Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:2035
+
+def int_aarch64_sve_bdep_x : AdvSIMD_2VectorArg_Intrinsic;
+def int_aarch64_sve_bext_x : AdvSIMD_2VectorArg_Intrinsic;

What does `_x` mean here?



Comment at: llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp:1222
+  unsigned Opc) {
+  SDLoc dl(N);
+  EVT VT = N->getValueType(0);

`DL` ;-)



Comment at: llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp:3592
+  if (VT == MVT::nxv16i8) {
+SelectTableSVE2(Node, 2, AArch64::TBL__B);
+return;

`NumVecs` seems be always 2 in this patch. Will we need this to work for other 
values in the future too?

[Nit] `2` is a bit of a magic number here. What about `2` -> `/*NumVecs=*/2`



Comment at: llvm/test/CodeGen/AArch64/sve2-intrinsics-bit-permutation.ll:1
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2,+sve2-bitperm 
-asm-verbose=0 < %s | FileCheck %s
+

AFAIK, `-asm-verbose=0` is not currently needed here (and you don't use it in 
the other test). There are 2 options:

* Leave `-asm-verbose=0` (guarantees that there are no comments in assembly) 
and additionally decorate every function that you define with `nounwind` 
(guarantees that no CFI directives are added). This way you can safely replace 
every instance of `CHECK`  with `CHECK-NEXT`.
* Remove `-asm-verbose=0` and leave things as they are.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74912



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


[PATCH] D74470: Seperated DIBasicType DIFlags to DIBTFlags.

2020-02-21 Thread Chirag Patel via Phabricator via cfe-commits
Chirag updated this revision to Diff 245809.
Chirag added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Moved five of the DIFlags to DISPFlags. (updated few clang testcases)
DIFlagExplicit -> DISPFlagExplicit
DIFlagPrototyped -> DISPFlagPrototyped
DIFlagNoReturn -> DISPFlagNoReturn
DIFlagThunk -> DISPFlagThunk
DIFlagAllCallsDescribed -> DISPFlagAllCallsDescribed

Note: currently llvm ir parser still needs the DIFlags, once the llvm ir format 
gets updated(with all the relevant testcases) the entries from 
DebugInfoFlags.def will be removed and moveDItoSP should only be used for 
bitcode read and C-API.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74470

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
  clang/test/CodeGenCXX/debug-info-access.cpp
  clang/test/CodeGenCXX/debug-info-cxx1y.cpp
  clang/test/CodeGenCXX/debug-info-decl-nested.cpp
  clang/test/CodeGenCXX/debug-info-deleted.cpp
  clang/test/CodeGenCXX/debug-info-ms-abi.cpp
  clang/test/CodeGenCXX/debug-info-noreturn.cpp
  clang/test/CodeGenCXX/debug-info-qualifiers.cpp
  clang/test/CodeGenCXX/debug-info-thunk.cpp
  clang/test/CodeGenObjC/debug-info-category.m
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/Assembler/debug-info.ll
  llvm/test/Assembler/disubprogram.ll
  llvm/test/Bitcode/DIBasicType.ll
  llvm/test/Bitcode/DIBasicType.ll.bc
  llvm/test/Bitcode/DISubprogram-v5.ll
  llvm/test/DebugInfo/COFF/thunk.ll
  llvm/unittests/IR/MetadataTest.cpp

Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -1202,9 +1202,8 @@
 typedef MetadataTest DIBasicTypeTest;
 
 TEST_F(DIBasicTypeTest, get) {
-  auto *N =
-  DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33, 26, 7,
-DINode::FlagZero);
+  auto *N = DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
+ 26, 7, DIBasicType::BTFlagZero);
   EXPECT_EQ(dwarf::DW_TAG_base_type, N->getTag());
   EXPECT_EQ("special", N->getName());
   EXPECT_EQ(33u, N->getSizeInBits());
@@ -1213,31 +1212,31 @@
   EXPECT_EQ(0u, N->getLine());
   EXPECT_EQ(DINode::FlagZero, N->getFlags());
   EXPECT_EQ(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
-26, 7, DINode::FlagZero));
+26, 7, DIBasicType::BTFlagZero));
 
   EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_unspecified_type,
-"special", 33, 26, 7, DINode::FlagZero));
-  EXPECT_NE(N,
-DIBasicType::get(Context, dwarf::DW_TAG_base_type, "s", 33, 26, 7,
-  DINode::FlagZero));
+"special", 33, 26, 7, DIBasicType::BTFlagZero));
+  EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "s", 33, 26,
+7, DIBasicType::BTFlagZero));
   EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 32,
-26, 7, DINode::FlagZero));
+26, 7, DIBasicType::BTFlagZero));
   EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
-25, 7, DINode::FlagZero));
+25, 7, DIBasicType::BTFlagZero));
   EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
-26, 6, DINode::FlagZero));
+26, 6, DIBasicType::BTFlagZero));
   EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
-26, 7, DINode::FlagBigEndian));
+26, 7, DIBasicType::BTFlagBigEndian));
   EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
-26, 7, DINode::FlagLittleEndian));
+26, 7, DIBasicType::BTFlagLittleEndian));
 
   TempDIBasicType Temp = N->clone();
   EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
 }
 
 TEST_F(DIBasicTypeTest, getWithLargeValues) {
-  auto *N = DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special",
- UINT64_MAX, UINT32_MAX - 1, 7, DINode::FlagZero);
+  auto *N =
+  DIBasic

[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-02-21 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added a comment.

I agree with @aqjune that stating clearly the definition of object in this 
context.
See this example in the C spec:

  For example, the second call of f in g has undefined behavior because each of 
d[1] through d[49] is accessed through both p and q.
  
  void g(void) {
  extern int d[100];
  f(50, d + 50, d); // valid
  f(50, d + 1, d); // undefined behavior
  }

Restrict just guarantees that accesses are to disjoint memory locations, not 
that they point at different objects (in the sense of they were allocated 
separately).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D62961: [AST] Add new Type queries for sizeless types

2020-02-21 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm updated this revision to Diff 245812.
rsandifo-arm added a comment.

Update to latest master.  Defer making sizeless types
incomplete until D62962 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62961

Files:
  clang/include/clang/AST/CanonicalType.h
  clang/include/clang/AST/Type.h
  clang/lib/AST/Type.cpp
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/SizelessTypesTest.cpp

Index: clang/unittests/AST/SizelessTypesTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/SizelessTypesTest.cpp
@@ -0,0 +1,81 @@
+//===- unittests/AST/SizelessTypesTest.cpp --- Sizeless type tests ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains tests for clang::Type queries related to sizeless types.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Type.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+struct SizelessTypeTester : public ::testing::Test {
+  // Declare an incomplete structure type.
+  std::unique_ptr AST =
+tooling::buildASTFromCodeWithArgs("struct foo;",
+  {"-target", "aarch64-linux-gnu"});
+  ASTContext &Ctx = AST->getASTContext();
+  TranslationUnitDecl &TU = *Ctx.getTranslationUnitDecl();
+  TypeDecl *Foo = cast(TU.lookup(&Ctx.Idents.get("foo")).front());
+  const Type *FooTy = Foo->getTypeForDecl();
+};
+
+TEST_F(SizelessTypeTester, TestSizeless) {
+  ASSERT_TRUE(Ctx.SveInt8Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveInt16Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveInt32Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveInt64Ty->isSizelessType());
+
+  ASSERT_TRUE(Ctx.SveUint8Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveUint16Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveUint32Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveUint64Ty->isSizelessType());
+
+  ASSERT_TRUE(Ctx.SveFloat16Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveFloat32Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveFloat64Ty->isSizelessType());
+
+  ASSERT_TRUE(Ctx.SveBoolTy->isSizelessType());
+
+  ASSERT_FALSE(Ctx.VoidTy->isSizelessType());
+  ASSERT_FALSE(Ctx.PseudoObjectTy->isSizelessType());
+  ASSERT_FALSE(FooTy->isSizelessType());
+
+  ASSERT_FALSE(Ctx.getPointerType(Ctx.SveBoolTy)->isSizelessType());
+  ASSERT_FALSE(Ctx.getLValueReferenceType(Ctx.SveBoolTy)->isSizelessType());
+  ASSERT_FALSE(Ctx.getRValueReferenceType(Ctx.SveBoolTy)->isSizelessType());
+}
+
+TEST_F(SizelessTypeTester, TestIndefinite) {
+  ASSERT_FALSE(Ctx.SveInt8Ty->isIndefiniteType());
+  ASSERT_FALSE(Ctx.SveInt16Ty->isIndefiniteType());
+  ASSERT_FALSE(Ctx.SveInt32Ty->isIndefiniteType());
+  ASSERT_FALSE(Ctx.SveInt64Ty->isIndefiniteType());
+
+  ASSERT_FALSE(Ctx.SveUint8Ty->isIndefiniteType());
+  ASSERT_FALSE(Ctx.SveUint16Ty->isIndefiniteType());
+  ASSERT_FALSE(Ctx.SveUint32Ty->isIndefiniteType());
+  ASSERT_FALSE(Ctx.SveUint64Ty->isIndefiniteType());
+
+  ASSERT_FALSE(Ctx.SveFloat16Ty->isIndefiniteType());
+  ASSERT_FALSE(Ctx.SveFloat32Ty->isIndefiniteType());
+  ASSERT_FALSE(Ctx.SveFloat64Ty->isIndefiniteType());
+
+  ASSERT_FALSE(Ctx.SveBoolTy->isIndefiniteType());
+
+  ASSERT_TRUE(Ctx.VoidTy->isIndefiniteType());
+  ASSERT_FALSE(Ctx.PseudoObjectTy->isIndefiniteType());
+  ASSERT_TRUE(FooTy->isIndefiniteType());
+
+  ASSERT_FALSE(Ctx.getPointerType(Ctx.SveBoolTy)->isIndefiniteType());
+  ASSERT_FALSE(Ctx.getLValueReferenceType(Ctx.SveBoolTy)->isIndefiniteType());
+  ASSERT_FALSE(Ctx.getRValueReferenceType(Ctx.SveBoolTy)->isIndefiniteType());
+}
Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -29,6 +29,7 @@
   NamedDeclPrinterTest.cpp
   OMPStructuredBlockTest.cpp
   RecursiveASTVisitorTest.cpp
+  SizelessTypesTest.cpp
   SourceLocationTest.cpp
   StmtPrinterTest.cpp
   StructuralEquivalenceTest.cpp
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2109,10 +2109,10 @@
   return !isa(CanonicalType);
 }
 
-/// isIncompleteType - Return true if this is an incomplete type (C99 6.2.5p1)
-/// - a type that can describe objects, but which lacks information needed to
-/// determine its size.
-bool Type::isIncompleteType(NamedDecl **Def) const {
+/// isIndefiniteType - Return true if this is an indefinite type - a type that
+/// can describe objects, but lacks information needed to construct them.
+/// For

[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-21 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:407
+// FIXME Add detailed diagnostic.
+std::string Msg = "Function argument constraint is not satisfied";
+auto R = std::make_unique(BT, Msg, N);

StringRef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D74953: [profile] Don't dump counters when forking and don't reset when calling exec** functions

2020-02-21 Thread calixte via Phabricator via cfe-commits
calixte created this revision.
calixte added a reviewer: marco-c.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, hiraditya.
Herald added projects: clang, Sanitizers, LLVM.

There is no need to write out gcdas when forking because we can just reset the 
counters in the parent process.
Let say a counter is N before the fork, then fork and this counter is set to 0 
in the child process.
In the parent process, the counter is incremented by P and in the child process 
it's incremented by C.
When dump is ran at exit, parent process will dump N+P for the given counter 
and the child process will dump 0+C, so when the gcdas are merged the resulting 
counter will be N+P+C.
About exec** functions, since the current process is replaced by an another one 
there is no need to reset the counters but just write out the gcdas since the 
counters are definitely lost.
To avoid to have lists in a bad state, we just lock them during the fork and 
the flush (if called explicitely) and lock them when an element is added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74953

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/lib/profile/GCDAProfiling.c
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Index: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -115,7 +115,8 @@
   // list.
   Function *
   insertCounterWriteout(ArrayRef>);
-  Function *insertFlush(ArrayRef>);
+  Function *insertReset(ArrayRef>);
+  Function *insertFlush(Function *ResetF);
 
   void AddFlushBeforeForkAndExec();
 
@@ -631,35 +632,66 @@
 }
 
 void GCOVProfiler::AddFlushBeforeForkAndExec() {
-  SmallVector ForkAndExecs;
+  SmallVector, 2> ForkAndExecs;
   for (auto &F : M->functions()) {
 auto *TLI = &GetTLI(F);
 for (auto &I : instructions(F)) {
   if (CallInst *CI = dyn_cast(&I)) {
 if (Function *Callee = CI->getCalledFunction()) {
   LibFunc LF;
-  if (TLI->getLibFunc(*Callee, LF) &&
-  (LF == LibFunc_fork || LF == LibFunc_execl ||
-   LF == LibFunc_execle || LF == LibFunc_execlp ||
-   LF == LibFunc_execv || LF == LibFunc_execvp ||
-   LF == LibFunc_execve || LF == LibFunc_execvpe ||
-   LF == LibFunc_execvP)) {
-ForkAndExecs.push_back(&I);
+  if (TLI->getLibFunc(*Callee, LF)) {
+if (LF == LibFunc_fork) {
+#if !defined(_WIN32)
+  ForkAndExecs.push_back({true, CI});
+#endif
+} else if (LF == LibFunc_execl || LF == LibFunc_execle ||
+   LF == LibFunc_execlp || LF == LibFunc_execv ||
+   LF == LibFunc_execvp || LF == LibFunc_execve ||
+   LF == LibFunc_execvpe || LF == LibFunc_execvP) {
+  ForkAndExecs.push_back({false, CI});
+}
   }
 }
   }
 }
   }
 
-  // We need to split the block after the fork/exec call
-  // because else the counters for the lines after will be
-  // the same as before the call.
-  for (auto I : ForkAndExecs) {
-IRBuilder<> Builder(I);
-FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
-FunctionCallee GCOVFlush = M->getOrInsertFunction("__gcov_flush", FTy);
-Builder.CreateCall(GCOVFlush);
-I->getParent()->splitBasicBlock(I);
+  for (auto F : ForkAndExecs) {
+IRBuilder<> Builder(F.second);
+BasicBlock *Parent = F.second->getParent();
+auto NextInst = ++F.second->getIterator();
+
+if (F.first) {
+  // We've a fork so just reset the counters in the child process
+  FunctionType *FTy = FunctionType::get(Builder.getInt32Ty(), {}, false);
+  FunctionCallee GCOVFork = M->getOrInsertFunction("__gcov_fork", FTy);
+  F.second->setCalledFunction(GCOVFork);
+  if (NextInst != Parent->end()) {
+// We split just after the fork to have a counter for the lines after
+// Anyway there's a bug:
+// void foo() { fork(); }
+// void bar() { foo(); blah(); }
+// then "blah();" will be called 2 times but showed as 1
+// because "blah()" belongs to the same block as "foo();"
+Parent->splitBasicBlock(NextInst);
+
+// back() is a br instruction with a debug location
+// equals to the one from NextAfterFork
+// So to avoid to have two debug locs on two blocks just change it
+DebugLoc Loc = F.second->getDebugLoc();
+Parent->back().setDebugLoc(Loc);
+  }
+} else {
+  // Since the process is replaced by a new one we need to write out gcdas
+  // No need to reset the counters since there'll be lost after the exec**
+  FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
+  FunctionCallee WriteoutF =
+  M->getOrInsertFunction("llvm_writeout_files

[PATCH] D74953: [profile] Don't dump counters when forking and don't reset when calling exec** functions

2020-02-21 Thread Marco Castelluccio via Phabricator via cfe-commits
marco-c added a comment.

Also, as we discussed, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93623#c5 
regarding exec.




Comment at: compiler-rt/lib/profile/GCDAProfiling.c:665
+  gcov_lock();
+  // Avoid a concurrent modification of the lists during the fork
+  pid = fork();

Could you expand the comment explaining a situation where this could fail if we 
didn't lock?



Comment at: compiler-rt/lib/profile/GCDAProfiling.c:671
+pid_t child_pid = getpid();
+if (child_pid != parent_pid) {
+  // The pid changed so we've a fork

Nit: do we need this check or can we just use the earlier one on pid == 0?



Comment at: compiler-rt/lib/profile/GCDAProfiling.c:675
+  // No need to lock here since we just forked and cannot have any other
+  // threads.
+  struct fn_node *curr = reset_fn_list.head;

What if we have a thread in another process making modifications to the list?



Comment at: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp:635
 void GCOVProfiler::AddFlushBeforeForkAndExec() {
-  SmallVector ForkAndExecs;
+  SmallVector, 2> ForkAndExecs;
   for (auto &F : M->functions()) {

Since we are now mostly doing different things on forks and execs, we could 
remove this vector and just do the operations directly instead of adding to the 
vec.



Comment at: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp:671
+// We split just after the fork to have a counter for the lines after
+// Anyway there's a bug:
+// void foo() { fork(); }

Isn't this bug fixed by splitting the block?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74953



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

> Proposing a fix to extend the ascii handling code to take extended ascii as 
> well.

Please reduce the scope of this patch to not crashing on invalid utf-8.

Handling other encodings is in principle possible, but requires more work and a 
more precise understanding of what we're trying to do.
(In particular, "extended ascii" doesn't have a precise meaning)




Comment at: clang-tools-extra/clangd/SourceCode.cpp:74
+if(UTF8Length == 1 || UTF8Length > 4) {
+  vlog("File contains invalid UTF-8, or transcoding bug? UTF8Length = {0}, 
string = {1}", UTF8Length, U8);
+  // If UTF8 length is 1, treat as one UTF8, if above 4, treat as one UTF16

kadircet wrote:
> instead of printing the string, it would be better to print hex 
> representation of current character, you can check `llvm::utohexstr`
Printing UTF8length isn't useful here., and I don't think current character is 
enough as it may not be where the error is (e.g. in the 10xxx case).

I'd suggest llvm::toHex(U8) and printing the offset I. Printing the bytes is 
better than the text as we know we're misinterpreting the bytes!

(In practice, these strings are parts of a single line, so it shouldn't be too 
long)



Comment at: clang-tools-extra/clangd/SourceCode.cpp:74
+if(UTF8Length == 1 || UTF8Length > 4) {
+  vlog("File contains invalid UTF-8, or transcoding bug? UTF8Length = {0}, 
string = {1}", UTF8Length, U8);
+  // If UTF8 length is 1, treat as one UTF8, if above 4, treat as one UTF16

sammccall wrote:
> kadircet wrote:
> > instead of printing the string, it would be better to print hex 
> > representation of current character, you can check `llvm::utohexstr`
> Printing UTF8length isn't useful here., and I don't think current character 
> is enough as it may not be where the error is (e.g. in the 10xxx case).
> 
> I'd suggest llvm::toHex(U8) and printing the offset I. Printing the bytes is 
> better than the text as we know we're misinterpreting the bytes!
> 
> (In practice, these strings are parts of a single line, so it shouldn't be 
> too long)
also I think you want to set a flag and vlog only the first time around the 
loop.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:75
+  vlog("File contains invalid UTF-8, or transcoding bug? UTF8Length = {0}, 
string = {1}", UTF8Length, U8);
+  // If UTF8 length is 1, treat as one UTF8, if above 4, treat as one UTF16
+  if (CB(UTF8Length, UTF8Length == 1 ? 1 : 2))

kadircet wrote:
> we are already in a bad shape here, instead of making it more fluctuating can 
> we always `CB(1, 1)`?
> 
> As long as you don't have any special reasoning for it.
Yeah, this isn't a principled recovery strategy, so CB(1, 1) is the way to go I 
think. 
With a comment indicating that we're not returning anything  really useful, 
like "// Treat this byte as a character, for lack of better options".
(And CB(2, 1) seems silly if you think this text is actually ISO-8859-x - 
that's a single-byte encoding!)

If we really wanted to do something principled, we could validate the UTF-8 
first (llvm::isUTF8 in JSON.h, though it's missing some cases), and if it 
fails, invoke CB(1, 1) for each character under the assumption that it's 
ISO-8859-x so one-byte per char and all chars are in BMP. But I'd urge against 
it, I don't think this will actually end up working reliably end-to-end.



Comment at: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp:60
   EXPECT_EQ(lspLength("😂"), 2UL);
+  // Extended ASCII
+  const char extendedASCIIStr[2] = {static_cast(160U), '\0'};

"Extended ASCII" is vague and misleading. Please call these something like 
"Invalid UTF-8" or "ISO-8859-x misinterpreted as UTF-8" or so



Comment at: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp:62
+  const char extendedASCIIStr[2] = {static_cast(160U), '\0'};
+  EXPECT_EQ(lspLength(extendedASCIIStr), 1UL);
+  // Invalid UTF16

I don't think we should be asserting the exact values here, it's garbage and 
depends on implementation details.

The most important thing is to call it and verify it doesn't crash.
We could assert that 0 <= lspLength <= strlen, which lspLength generally obeys 
(for all encodings)



Comment at: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp:64
+  // Invalid UTF16
+  const char invalidUTF16[6] = {
+  static_cast(0xFF), static_cast(0xFF), 
static_cast(0xFF),

kadircet wrote:
>  I believe in addition to being invalidutf16, this is also extended ascii 
> (representing multiple `ÿ`s).
> 
> if we want clangd to work for extended ascii. I suppose the length should 
> rather be 5 instead, as in utf-8 case. Since all of these bytes are 
> representing a different character.
I'm just really confused by this test case - we never interpret or convert it 
to UTF-16 so why

[PATCH] D74953: [profile] Don't dump counters when forking and don't reset when calling exec** functions

2020-02-21 Thread calixte via Phabricator via cfe-commits
calixte updated this revision to Diff 245837.
calixte added a comment.

If exec** fails we need to reset the counters since they've have dumped just 
before to avoid to count them twice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74953

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/lib/profile/GCDAProfiling.c
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Index: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -115,7 +115,8 @@
   // list.
   Function *
   insertCounterWriteout(ArrayRef>);
-  Function *insertFlush(ArrayRef>);
+  Function *insertReset(ArrayRef>);
+  Function *insertFlush(Function *ResetF);
 
   void AddFlushBeforeForkAndExec();
 
@@ -631,35 +632,74 @@
 }
 
 void GCOVProfiler::AddFlushBeforeForkAndExec() {
-  SmallVector ForkAndExecs;
+  SmallVector, 2> ForkAndExecs;
   for (auto &F : M->functions()) {
 auto *TLI = &GetTLI(F);
 for (auto &I : instructions(F)) {
   if (CallInst *CI = dyn_cast(&I)) {
 if (Function *Callee = CI->getCalledFunction()) {
   LibFunc LF;
-  if (TLI->getLibFunc(*Callee, LF) &&
-  (LF == LibFunc_fork || LF == LibFunc_execl ||
-   LF == LibFunc_execle || LF == LibFunc_execlp ||
-   LF == LibFunc_execv || LF == LibFunc_execvp ||
-   LF == LibFunc_execve || LF == LibFunc_execvpe ||
-   LF == LibFunc_execvP)) {
-ForkAndExecs.push_back(&I);
+  if (TLI->getLibFunc(*Callee, LF)) {
+if (LF == LibFunc_fork) {
+#if !defined(_WIN32)
+  ForkAndExecs.push_back({true, CI});
+#endif
+} else if (LF == LibFunc_execl || LF == LibFunc_execle ||
+   LF == LibFunc_execlp || LF == LibFunc_execv ||
+   LF == LibFunc_execvp || LF == LibFunc_execve ||
+   LF == LibFunc_execvpe || LF == LibFunc_execvP) {
+  ForkAndExecs.push_back({false, CI});
+}
   }
 }
   }
 }
   }
 
-  // We need to split the block after the fork/exec call
-  // because else the counters for the lines after will be
-  // the same as before the call.
-  for (auto I : ForkAndExecs) {
-IRBuilder<> Builder(I);
-FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
-FunctionCallee GCOVFlush = M->getOrInsertFunction("__gcov_flush", FTy);
-Builder.CreateCall(GCOVFlush);
-I->getParent()->splitBasicBlock(I);
+  for (auto F : ForkAndExecs) {
+IRBuilder<> Builder(F.second);
+BasicBlock *Parent = F.second->getParent();
+auto NextInst = ++F.second->getIterator();
+
+if (F.first) {
+  // We've a fork so just reset the counters in the child process
+  FunctionType *FTy = FunctionType::get(Builder.getInt32Ty(), {}, false);
+  FunctionCallee GCOVFork = M->getOrInsertFunction("__gcov_fork", FTy);
+  F.second->setCalledFunction(GCOVFork);
+  if (NextInst != Parent->end()) {
+// We split just after the fork to have a counter for the lines after
+// Anyway there's a bug:
+// void foo() { fork(); }
+// void bar() { foo(); blah(); }
+// then "blah();" will be called 2 times but showed as 1
+// because "blah()" belongs to the same block as "foo();"
+Parent->splitBasicBlock(NextInst);
+
+// back() is a br instruction with a debug location
+// equals to the one from NextAfterFork
+// So to avoid to have two debug locs on two blocks just change it
+DebugLoc Loc = F.second->getDebugLoc();
+Parent->back().setDebugLoc(Loc);
+  }
+} else {
+  // Since the process is replaced by a new one we need to write out gcdas
+  // No need to reset the counters since there'll be lost after the exec**
+  FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
+  FunctionCallee WriteoutF =
+  M->getOrInsertFunction("llvm_writeout_files", FTy);
+  Builder.CreateCall(WriteoutF);
+  if (NextInst != Parent->end()) {
+DebugLoc Loc = F.second->getDebugLoc();
+Builder.SetInsertPoint(&*NextInst);
+// If the exec** fails we must reset the counters since they've been
+// dumped
+FunctionCallee ResetF =
+M->getOrInsertFunction("llvm_reset_counters", FTy);
+Builder.CreateCall(ResetF)->setDebugLoc(Loc);
+Parent->splitBasicBlock(NextInst);
+Parent->back().setDebugLoc(Loc);
+  }
+}
   }
 }
 
@@ -851,7 +891,8 @@
 }
 
 Function *WriteoutF = insertCounterWriteout(CountersBySP);
-Function *FlushF = insertFlush(CountersBySP);
+Function *ResetF = insertReset(CountersBySP);
+Function *FlushF = insertFlush(ResetF

[PATCH] D74912: [AArch64][SVE] Add SVE2 intrinsics for bit permutation & table lookup

2020-02-21 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 245835.
kmclaughlin added a comment.

- Removed NumVecs parameter from SelectTableSVE2 as the value is always the 
same (2)
- Removed unnecessary -asm-verbose=0 from the RUN line of 
sve2-intrinsics-bit-permutation.ll


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

https://reviews.llvm.org/D74912

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-bit-permutation.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-perm-tb.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-perm-tb.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-perm-tb.ll
@@ -0,0 +1,167 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; TBL2
+;
+
+define  @tbl2_b( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_b:
+; CHECK: tbl z0.b, { z0.b, z1.b }, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv16i8( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @tbl2_h( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_h:
+; CHECK: tbl z0.h, { z0.h, z1.h }, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv8i16( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @tbl2_s( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_s:
+; CHECK: tbl z0.s, { z0.s, z1.s }, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv4i32( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @tbl2_d( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_d:
+; CHECK: tbl z0.d, { z0.d, z1.d }, z2.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv2i64( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @tbl2_fh( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_fh:
+; CHECK: tbl z0.h, { z0.h, z1.h }, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv8f16( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @tbl2_fs( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_fs:
+; CHECK: tbl z0.s, { z0.s, z1.s }, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv4f32( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+define  @tbl2_fd( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_fd:
+; CHECK: tbl z0.d, { z0.d, z1.d }, z2.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv2f64( %a,
+%b,
+%c)
+  ret  %out
+}
+
+;
+; TBX
+;
+
+define  @tbx_b( %a,  %b,  %c) {
+; CHECK-LABEL: tbx_b:
+; CHECK: tbx z0.b, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbx.nxv16i8( %a,
+%b,
+%c)
+  ret  %out
+}
+
+define  @tbx_h( %a,  %b,  %c) {
+; CHECK-LABEL: tbx_h:
+; CHECK: tbx z0.h, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbx.nxv8i16( %a,
+%b,
+%c)
+  ret  %out
+}
+
+define  @ftbx_h( %a,  %b,  %c) {
+; CHECK-LABEL: ftbx_h:
+; CHECK: tbx z0.h, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbx.nxv8f16( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @tbx_s( %a,  %b,  %c) {
+; CHECK-LABEL: tbx_s:
+; CHECK: tbx z0.s, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbx.nxv4i32( %a,
+%b,
+%c)
+  ret  %out
+}
+
+define  @ftbx_s( %a,  %b,  %c) {
+; CHECK-LABEL: ftbx_s:
+; CHECK: tbx z0.s, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbx.nxv4f32( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @tbx_d( %a,  %b,  %c) {
+; CHECK-LABEL: tbx_d:
+; CHECK: tbx z0.d, z1.d, z2.d
+; CHECK-NEXT: ret
+  %out

[PATCH] D74961: [clangd] Make global rename file limit adjustable

2020-02-21 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74961

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -715,7 +715,8 @@
   auto AST = TU.build();
   llvm::StringRef NewName = "newName";
   auto Results = rename({MainCode.point(), NewName, AST, MainFilePath,
- Index.get(), /*CrossFile=*/true, GetDirtyBuffer});
+ Index.get(), /*CrossFile=*/true,
+ /*GlobalRenameFileLimit=*/50, GetDirtyBuffer});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   EXPECT_THAT(
   applyEdits(std::move(*Results)),
@@ -731,7 +732,8 @@
   TU.AdditionalFiles["bar.cc"] = std::string(BarCode.code());
   AST = TU.build();
   Results = rename({MainCode.point(), NewName, AST, MainFilePath, Index.get(),
-/*CrossFile=*/true, GetDirtyBuffer});
+/*CrossFile=*/true, /*GlobalRenameFileLimit=*/50,
+GetDirtyBuffer});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   EXPECT_THAT(
   applyEdits(std::move(*Results)),
@@ -762,7 +764,8 @@
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
   Results = rename({MainCode.point(), NewName, AST, MainFilePath, &PIndex,
-/*CrossFile=*/true, GetDirtyBuffer});
+/*CrossFile=*/true, /*GlobalRenameFileLimit=*/50,
+GetDirtyBuffer});
   EXPECT_FALSE(Results);
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("too many occurrences"));
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -402,6 +402,14 @@
 init(false),
 };
 
+opt GlobalRenameFileLimit{
+"global-rename-file-limit",
+cat(Features),
+desc("Renaming symbol that appears in more files will fail"),
+init(50),
+Hidden,
+};
+
 /// Supports a test URI scheme with relaxed constraints for lit tests.
 /// The path in a test URI will be combined with a platform-specific fake
 /// directory to form an absolute path. For example, test:///a.cpp is resolved
@@ -601,6 +609,7 @@
   }
 
   ClangdServer::Options Opts;
+  Opts.GlobalRenameFileLimit = GlobalRenameFileLimit;
   switch (PCHStorage) {
   case PCHStorageFlag::Memory:
 Opts.StorePreamblesInMemory = true;
Index: clang-tools-extra/clangd/refactor/Rename.h
===
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -36,6 +36,7 @@
   const SymbolIndex *Index = nullptr;
 
   bool AllowCrossFile = false;
+  const unsigned GlobalRenameFileLimit = 50;
   // When set, used by the rename to get file content for all rename-related
   // files.
   // If there is no corresponding dirty buffer, we will use the file content
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -315,7 +315,8 @@
 // grouped by the absolute file path.
 llvm::Expected>>
 findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
-   llvm::StringRef MainFile, const SymbolIndex &Index) {
+   llvm::StringRef MainFile, const SymbolIndex &Index,
+   const unsigned GlobalRenameFileLimit) {
   trace::Span Tracer("FindOccurrencesOutsideFile");
   RefsRequest RQuest;
   RQuest.IDs.insert(*getSymbolID(&RenameDecl));
@@ -330,10 +331,8 @@
 
   // Absolute file path => rename occurrences in that file.
   llvm::StringMap> AffectedFiles;
-  // FIXME: Make the limit customizable.
-  static constexpr size_t MaxLimitFiles = 50;
   bool HasMore = Index.refs(RQuest, [&](const Ref &R) {
-if (AffectedFiles.size() > MaxLimitFiles)
+if (AffectedFiles.size() > GlobalRenameFileLimit)
   return;
 if ((R.Kind & RefKind::Spelled) == RefKind::Unknown)
   return;
@@ -343,10 +342,10 @@
 }
   });
 
-  if (AffectedFiles.size() > MaxLimitFiles)
+  if (AffectedFiles.size() > GlobalRenameFileLimit)
 return llvm::make_error(
 llvm::formatv("The number of affected files 

[PATCH] D74962: [clang][Tooling] Add a way to tokenize a FileRange

2020-02-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74962

Files:
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -153,11 +153,17 @@
 }
   }
 
-  /// Add a new file, run syntax::tokenize() on it and return the results.
+  /// Add a new file, run syntax::tokenize() on the range if any, run it on the
+  /// whole file otherwise and return the results.
   std::vector tokenize(llvm::StringRef Text) {
+llvm::Annotations Annot(Text);
+auto FID = SourceMgr->createFileID(
+llvm::MemoryBuffer::getMemBufferCopy(Annot.code()));
 // FIXME: pass proper LangOptions.
+if (Annot.ranges().empty())
+  return syntax::tokenize(FID, *SourceMgr, LangOptions());
 return syntax::tokenize(
-SourceMgr->createFileID(llvm::MemoryBuffer::getMemBufferCopy(Text)),
+syntax::FileRange(FID, Annot.range().Begin, Annot.range().End),
 *SourceMgr, LangOptions());
   }
 
@@ -258,6 +264,16 @@
   ElementsAre(Kind(tok::kw_int),
   AllOf(HasText("a"), Kind(tok::identifier)),
   Kind(tok::semi)));
+  EXPECT_THAT(tokenize("int [[main() {]]}"),
+  ElementsAre(AllOf(HasText("main"), Kind(tok::identifier)),
+  Kind(tok::l_paren), Kind(tok::r_paren),
+  Kind(tok::l_brace)));
+  // First token is partially parsed, last token is fully included even though
+  // only a part of it is contained in the range.
+  EXPECT_THAT(tokenize("int m[[ain() {ret]]urn 0;}"),
+  ElementsAre(AllOf(HasText("ain"), Kind(tok::identifier)),
+  Kind(tok::l_paren), Kind(tok::r_paren),
+  Kind(tok::l_brace), Kind(tok::kw_return)));
 }
 
 TEST_F(TokenCollectorTest, Basic) {
Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -67,7 +67,8 @@
   auto F = First.range(SM);
   auto L = Last.range(SM);
   assert(F.file() == L.file() && "tokens from different files");
-  assert((F == L || F.endOffset() <= L.beginOffset()) && "wrong order of tokens");
+  assert((F == L || F.endOffset() <= L.beginOffset()) &&
+ "wrong order of tokens");
   return FileRange(F.file(), F.beginOffset(), L.endOffset());
 }
 
@@ -307,7 +308,8 @@
   return Expansions;
 }
 
-std::vector syntax::tokenize(FileID FID, const SourceManager &SM,
+std::vector syntax::tokenize(const FileRange &FR,
+const SourceManager &SM,
 const LangOptions &LO) {
   std::vector Tokens;
   IdentifierTable Identifiers(LO);
@@ -322,10 +324,15 @@
 Tokens.push_back(syntax::Token(T));
   };
 
-  Lexer L(FID, SM.getBuffer(FID), SM, LO);
+  auto SrcBuffer = SM.getBufferData(FR.file());
+  Lexer L(SM.getLocForStartOfFile(FR.file()), LO, SrcBuffer.data(),
+  SrcBuffer.data() + FR.beginOffset(),
+  // We can't make BufEnd point to FR.endOffset, as Lexer requires a
+  // null terminated buffer.
+  SrcBuffer.data() + SrcBuffer.size());
 
   clang::Token T;
-  while (!L.LexFromRawLexer(T))
+  while (!L.LexFromRawLexer(T) && L.getCurrentBufferOffset() < FR.endOffset())
 AddToken(T);
   // 'eof' is only the last token if the input is null-terminated. Never store
   // it, for consistency.
@@ -334,6 +341,13 @@
   return Tokens;
 }
 
+std::vector syntax::tokenize(FileID FID, const SourceManager &SM,
+const LangOptions &LO) {
+  return tokenize(syntax::FileRange(SM, SM.getLocForStartOfFile(FID),
+SM.getLocForEndOfFile(FID)),
+  SM, LO);
+}
+
 /// Records information reqired to construct mappings for the token buffer that
 /// we are collecting.
 class TokenCollector::CollectPPExpansions : public PPCallbacks {
Index: clang/include/clang/Tooling/Syntax/Tokens.h
===
--- clang/include/clang/Tooling/Syntax/Tokens.h
+++ clang/include/clang/Tooling/Syntax/Tokens.h
@@ -339,6 +339,12 @@
 /// The result will *not* have a 'eof' token at the end.
 std::vector tokenize(FileID FID, const SourceManager &SM,
 const LangOptions &LO);
+/// Similar to one above, instead of whole file tokenizes a part of it. Note
+/// that, the first token might be incomplete if FR.startOffset is not at the
+/// beginning of a token, and 

[PATCH] D74953: [profile] Don't dump counters when forking and don't reset when calling exec** functions

2020-02-21 Thread calixte via Phabricator via cfe-commits
calixte updated this revision to Diff 245843.
calixte marked 4 inline comments as done.
calixte added a comment.

Add more comments to explain why we need to lock around the fork


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74953

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/lib/profile/GCDAProfiling.c
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Index: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -115,7 +115,8 @@
   // list.
   Function *
   insertCounterWriteout(ArrayRef>);
-  Function *insertFlush(ArrayRef>);
+  Function *insertReset(ArrayRef>);
+  Function *insertFlush(Function *ResetF);
 
   void AddFlushBeforeForkAndExec();
 
@@ -631,35 +632,74 @@
 }
 
 void GCOVProfiler::AddFlushBeforeForkAndExec() {
-  SmallVector ForkAndExecs;
+  SmallVector, 2> ForkAndExecs;
   for (auto &F : M->functions()) {
 auto *TLI = &GetTLI(F);
 for (auto &I : instructions(F)) {
   if (CallInst *CI = dyn_cast(&I)) {
 if (Function *Callee = CI->getCalledFunction()) {
   LibFunc LF;
-  if (TLI->getLibFunc(*Callee, LF) &&
-  (LF == LibFunc_fork || LF == LibFunc_execl ||
-   LF == LibFunc_execle || LF == LibFunc_execlp ||
-   LF == LibFunc_execv || LF == LibFunc_execvp ||
-   LF == LibFunc_execve || LF == LibFunc_execvpe ||
-   LF == LibFunc_execvP)) {
-ForkAndExecs.push_back(&I);
+  if (TLI->getLibFunc(*Callee, LF)) {
+if (LF == LibFunc_fork) {
+#if !defined(_WIN32)
+  ForkAndExecs.push_back({true, CI});
+#endif
+} else if (LF == LibFunc_execl || LF == LibFunc_execle ||
+   LF == LibFunc_execlp || LF == LibFunc_execv ||
+   LF == LibFunc_execvp || LF == LibFunc_execve ||
+   LF == LibFunc_execvpe || LF == LibFunc_execvP) {
+  ForkAndExecs.push_back({false, CI});
+}
   }
 }
   }
 }
   }
 
-  // We need to split the block after the fork/exec call
-  // because else the counters for the lines after will be
-  // the same as before the call.
-  for (auto I : ForkAndExecs) {
-IRBuilder<> Builder(I);
-FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
-FunctionCallee GCOVFlush = M->getOrInsertFunction("__gcov_flush", FTy);
-Builder.CreateCall(GCOVFlush);
-I->getParent()->splitBasicBlock(I);
+  for (auto F : ForkAndExecs) {
+IRBuilder<> Builder(F.second);
+BasicBlock *Parent = F.second->getParent();
+auto NextInst = ++F.second->getIterator();
+
+if (F.first) {
+  // We've a fork so just reset the counters in the child process
+  FunctionType *FTy = FunctionType::get(Builder.getInt32Ty(), {}, false);
+  FunctionCallee GCOVFork = M->getOrInsertFunction("__gcov_fork", FTy);
+  F.second->setCalledFunction(GCOVFork);
+  if (NextInst != Parent->end()) {
+// We split just after the fork to have a counter for the lines after
+// Anyway there's a bug:
+// void foo() { fork(); }
+// void bar() { foo(); blah(); }
+// then "blah();" will be called 2 times but showed as 1
+// because "blah()" belongs to the same block as "foo();"
+Parent->splitBasicBlock(NextInst);
+
+// back() is a br instruction with a debug location
+// equals to the one from NextAfterFork
+// So to avoid to have two debug locs on two blocks just change it
+DebugLoc Loc = F.second->getDebugLoc();
+Parent->back().setDebugLoc(Loc);
+  }
+} else {
+  // Since the process is replaced by a new one we need to write out gcdas
+  // No need to reset the counters since there'll be lost after the exec**
+  FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
+  FunctionCallee WriteoutF =
+  M->getOrInsertFunction("llvm_writeout_files", FTy);
+  Builder.CreateCall(WriteoutF);
+  if (NextInst != Parent->end()) {
+DebugLoc Loc = F.second->getDebugLoc();
+Builder.SetInsertPoint(&*NextInst);
+// If the exec** fails we must reset the counters since they've been
+// dumped
+FunctionCallee ResetF =
+M->getOrInsertFunction("llvm_reset_counters", FTy);
+Builder.CreateCall(ResetF)->setDebugLoc(Loc);
+Parent->splitBasicBlock(NextInst);
+Parent->back().setDebugLoc(Loc);
+  }
+}
   }
 }
 
@@ -851,7 +891,8 @@
 }
 
 Function *WriteoutF = insertCounterWriteout(CountersBySP);
-Function *FlushF = insertFlush(CountersBySP);
+Function *ResetF = insertReset(CountersBySP);
+Function *FlushF = insertFlush(ResetF);
 
   

[PATCH] D74953: [profile] Don't dump counters when forking and don't reset when calling exec** functions

2020-02-21 Thread calixte via Phabricator via cfe-commits
calixte added inline comments.



Comment at: compiler-rt/lib/profile/GCDAProfiling.c:671
+pid_t child_pid = getpid();
+if (child_pid != parent_pid) {
+  // The pid changed so we've a fork

marco-c wrote:
> Nit: do we need this check or can we just use the earlier one on pid == 0?
I added this check to be sure we had a true fork in case of someone wrote its 
own fork function.



Comment at: compiler-rt/lib/profile/GCDAProfiling.c:675
+  // No need to lock here since we just forked and cannot have any other
+  // threads.
+  struct fn_node *curr = reset_fn_list.head;

marco-c wrote:
> What if we have a thread in another process making modifications to the list?
When forking, only the thread in the parent process is copied so in the child 
process we've only one thread.
When forking, the parent and the child process share the same memory until some 
change (Copy-on-Write), so even if in the parent process a list is changed then 
the memory will be copied before the change and then the child process will 
have an unchanged list. 



Comment at: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp:635
 void GCOVProfiler::AddFlushBeforeForkAndExec() {
-  SmallVector ForkAndExecs;
+  SmallVector, 2> ForkAndExecs;
   for (auto &F : M->functions()) {

marco-c wrote:
> Since we are now mostly doing different things on forks and execs, we could 
> remove this vector and just do the operations directly instead of adding to 
> the vec.
If we make the insertions of new code in the second for loop, we'll invalidate 
the iterator used in this loop. 



Comment at: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp:671
+// We split just after the fork to have a counter for the lines after
+// Anyway there's a bug:
+// void foo() { fork(); }

marco-c wrote:
> Isn't this bug fixed by splitting the block?
With the example shew here, the split is in foo but not in bar, blah() should 
be in another block


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74953



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


[PATCH] D74829: [clang-rename] Add the USR of incomplete decl to the USRSet.

2020-02-21 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

Yeah, it works in Clang-Rename due to additional steps in the renaming process. 
Testing only Clangd's rename is sufficient here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74829



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


[PATCH] D74015: [AIX][Frontend] C++ ABI customizations for AIX boilerplate

2020-02-21 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 245844.
Xiangling_L marked an inline comment as done.
Xiangling_L added a comment.

Update the comment about ABI description;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74015

Files:
  clang/include/clang/Basic/TargetCXXABI.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- /dev/null
+++ clang/test/CodeGen/static-init.cpp
@@ -0,0 +1,12 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
+// RUN: 2>&1 | FileCheck %s
+
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
+// RUN: 2>&1 | FileCheck %s
+
+struct test {
+  test();
+  ~test();
+} t;
+
+// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -516,6 +516,16 @@
   }
   bool canCallMismatchedFunctionType() const override { return false; }
 };
+
+class XLCXXABI final : public ItaniumCXXABI {
+public:
+  explicit XLCXXABI(CodeGen::CodeGenModule &CGM)
+  : ItaniumCXXABI(CGM) {}
+
+  void registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,
+  llvm::FunctionCallee dtor,
+  llvm::Constant *addr) override;
+};
 }
 
 CodeGen::CGCXXABI *CodeGen::CreateItaniumCXXABI(CodeGenModule &CGM) {
@@ -546,6 +556,9 @@
   case TargetCXXABI::WebAssembly:
 return new WebAssemblyCXXABI(CGM);
 
+  case TargetCXXABI::XL:
+return new XLCXXABI(CGM);
+
   case TargetCXXABI::GenericItanium:
 if (CGM.getContext().getTargetInfo().getTriple().getArch()
 == llvm::Triple::le32) {
@@ -4407,3 +4420,11 @@
 NormalCleanup, cast(CGF.CurrentFuncletPad));
   ItaniumCXXABI::emitBeginCatch(CGF, C);
 }
+
+/// Register a global destructor as best as we know how.
+void XLCXXABI::registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,
+  llvm::FunctionCallee dtor,
+  llvm::Constant *addr) {
+  llvm::report_fatal_error("Static initialization has not been implemented on"
+   " XL ABI yet.");
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -83,6 +83,7 @@
   case TargetCXXABI::GenericMIPS:
   case TargetCXXABI::GenericItanium:
   case TargetCXXABI::WebAssembly:
+  case TargetCXXABI::XL:
 return CreateItaniumCXXABI(CGM);
   case TargetCXXABI::Microsoft:
 return CreateMicrosoftCXXABI(CGM);
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -706,6 +706,8 @@
 public:
   AIXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
+this->TheCXXABI.set(TargetCXXABI::XL);
+
 if (this->PointerWidth == 64) {
   this->WCharType = this->UnsignedInt;
 } else {
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -874,6 +874,7 @@
   case TargetCXXABI::GenericMIPS:
   case TargetCXXABI::GenericItanium:
   case TargetCXXABI::WebAssembly:
+  case TargetCXXABI::XL:
 return CreateItaniumCXXABI(*this);
   case TargetCXXABI::Microsoft:
 return CreateMicrosoftCXXABI(*this);
@@ -10253,6 +10254,7 @@
   case TargetCXXABI::iOS64:
   case TargetCXXABI::WebAssembly:
   case TargetCXXABI::WatchOS:
+  case TargetCXXABI::XL:
 return ItaniumMangleContext::create(*this, getDiagnostics());
   case TargetCXXABI::Microsoft:
 return MicrosoftMangleContext::create(*this, getDiagnostics());
Index: clang/include/clang/Basic/TargetCXXABI.h
===
--- clang/include/clang/Basic/TargetCXXABI.h
+++ clang/include/clang/Basic/TargetCXXABI.h
@@ -109,6 +109,13 @@
 ///   - constructors and destructors return 'this', as in ARM.
 Fuchsia,
 
+/// The XL ABI is the ABI used by IBM xlclang compiler and is a modified
+/// version of the Itanium ABI.
+///
+/// The relevant changes from the Itanium ABI are:
+///   - static initialization is adjusted to use sinit and sterm functions;
+XL,
+
 /// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and
 /// compatible compilers).
 ///
@@ -148,6 +155,7 @@
 case WatchOS:
 cas

[PATCH] D74912: [AArch64][SVE] Add SVE2 intrinsics for bit permutation & table lookup

2020-02-21 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin marked 4 inline comments as done.
kmclaughlin added a comment.

Thanks for reviewing this, @andwar!




Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:2035
+
+def int_aarch64_sve_bdep_x : AdvSIMD_2VectorArg_Intrinsic;
+def int_aarch64_sve_bext_x : AdvSIMD_2VectorArg_Intrinsic;

andwar wrote:
> What does `_x` mean here?
_x indicates that this is an unpredicated intrinsic.



Comment at: llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp:3592
+  if (VT == MVT::nxv16i8) {
+SelectTableSVE2(Node, 2, AArch64::TBL__B);
+return;

andwar wrote:
> `NumVecs` seems be always 2 in this patch. Will we need this to work for 
> other values in the future too?
> 
> [Nit] `2` is a bit of a magic number here. What about `2` -> `/*NumVecs=*/2`
I agree that it's not very clear what 2 is used for here. As NumVecs will 
always be the same value for the tbl2 intrinsic and SelectTableSVE2 is unlikely 
to be used for anything else, I've removed it from the list of parameters & 
added a comment there to explain the value used.


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

https://reviews.llvm.org/D74912



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


[clang] a49a41e - [AST][NFC] Update outdated comments in ASTStructuralEquivalence.cpp

2020-02-21 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-02-21T15:54:58+01:00
New Revision: a49a41e7855fad426abf6ee9b8b88a535e8d33cc

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

LOG: [AST][NFC] Update outdated comments in ASTStructuralEquivalence.cpp

Added: 


Modified: 
clang/lib/AST/ASTStructuralEquivalence.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTStructuralEquivalence.cpp 
b/clang/lib/AST/ASTStructuralEquivalence.cpp
index 91a2f3a8391b..c29b7b2f5907 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -31,10 +31,9 @@
 // }
 // ```
 // Indeed, it has it's queue, which holds pairs of nodes, one from each graph,
-// this is the `DeclsToCheck` and it's pair is in `TentativeEquivalences`.
-// `TentativeEquivalences` also plays the role of the marking (`marked`)
-// functionality above, we use it to check whether we've already seen a pair of
-// nodes.
+// this is the `DeclsToCheck` member. `VisitedDecls` plays the role of the
+// marking (`marked`) functionality above, we use it to check whether we've
+// already seen a pair of nodes.
 //
 // We put in the elements into the queue only in the toplevel decl check
 // function:
@@ -57,11 +56,6 @@
 // doing. Thus, static implementation functions must not call the **member**
 // functions.
 //
-// So, now `TentativeEquivalences` plays two roles. It is used to store the
-// second half of the decls which we want to compare, plus it plays a role in
-// closing the recursion. On a long term, we could refactor structural
-// equivalency to be more alike to the traditional BFS.
-//
 
//===--===//
 
 #include "clang/AST/ASTStructuralEquivalence.h"



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


[PATCH] D74953: [profile] Don't dump counters when forking and don't reset when calling exec** functions

2020-02-21 Thread Marco Castelluccio via Phabricator via cfe-commits
marco-c accepted this revision.
marco-c added a comment.
This revision is now accepted and ready to land.

Could you test the last iteration of the patch on Mozilla's CI (with the 
workaround for the mismatch in LLVM version used by Rust)?




Comment at: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp:635
 void GCOVProfiler::AddFlushBeforeForkAndExec() {
-  SmallVector ForkAndExecs;
+  SmallVector, 2> ForkAndExecs;
   for (auto &F : M->functions()) {

calixte wrote:
> marco-c wrote:
> > Since we are now mostly doing different things on forks and execs, we could 
> > remove this vector and just do the operations directly instead of adding to 
> > the vec.
> If we make the insertions of new code in the second for loop, we'll 
> invalidate the iterator used in this loop. 
M->getOrInsertFunction is what would invalidate the iterator?

You could clean things up a bit by having two vectors then, one for forks and 
one for execs.



Comment at: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp:686
+  // Since the process is replaced by a new one we need to write out gcdas
+  // No need to reset the counters since there'll be lost after the exec**
+  FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);

Replace with `// No need to reset the counters since they'll be lost after the 
exec**`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74953



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


[PATCH] D74941: [OpenMP] `omp begin/end declare variant` - part 1, parsing

2020-02-21 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added a comment.

Will tests come in a later patch?




Comment at: clang/include/clang/AST/OpenMPClause.h:6700
   /// independent of clang. Thus, expressions and conditions are evaluated in
-  /// this method.
+  /// this method. If \p DeviceSetOnly is set only the device selector set, if
+  /// present, is put into \p VMI.

only the -> only on the ?



Comment at: clang/lib/Parse/ParseOpenMP.cpp:1807
+--Nesting;
+  if (DK == OMPD_begin_declare_variant)
+++Nesting;

Can there be an else here? Or is this the recommended style?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74941



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


[PATCH] D74953: [profile] Don't dump counters when forking and don't reset when calling exec** functions

2020-02-21 Thread calixte via Phabricator via cfe-commits
calixte marked an inline comment as done.
calixte added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp:635
 void GCOVProfiler::AddFlushBeforeForkAndExec() {
-  SmallVector ForkAndExecs;
+  SmallVector, 2> ForkAndExecs;
   for (auto &F : M->functions()) {

marco-c wrote:
> calixte wrote:
> > marco-c wrote:
> > > Since we are now mostly doing different things on forks and execs, we 
> > > could remove this vector and just do the operations directly instead of 
> > > adding to the vec.
> > If we make the insertions of new code in the second for loop, we'll 
> > invalidate the iterator used in this loop. 
> M->getOrInsertFunction is what would invalidate the iterator?
> 
> You could clean things up a bit by having two vectors then, one for forks and 
> one for execs.
Builder.Create** will invalidate the iterator 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74953



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


[PATCH] D74953: [profile] Don't dump counters when forking and don't reset when calling exec** functions

2020-02-21 Thread calixte via Phabricator via cfe-commits
calixte updated this revision to Diff 245848.
calixte added a comment.

Fix a typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74953

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/lib/profile/GCDAProfiling.c
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Index: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -115,7 +115,8 @@
   // list.
   Function *
   insertCounterWriteout(ArrayRef>);
-  Function *insertFlush(ArrayRef>);
+  Function *insertReset(ArrayRef>);
+  Function *insertFlush(Function *ResetF);
 
   void AddFlushBeforeForkAndExec();
 
@@ -631,35 +632,74 @@
 }
 
 void GCOVProfiler::AddFlushBeforeForkAndExec() {
-  SmallVector ForkAndExecs;
+  SmallVector, 2> ForkAndExecs;
   for (auto &F : M->functions()) {
 auto *TLI = &GetTLI(F);
 for (auto &I : instructions(F)) {
   if (CallInst *CI = dyn_cast(&I)) {
 if (Function *Callee = CI->getCalledFunction()) {
   LibFunc LF;
-  if (TLI->getLibFunc(*Callee, LF) &&
-  (LF == LibFunc_fork || LF == LibFunc_execl ||
-   LF == LibFunc_execle || LF == LibFunc_execlp ||
-   LF == LibFunc_execv || LF == LibFunc_execvp ||
-   LF == LibFunc_execve || LF == LibFunc_execvpe ||
-   LF == LibFunc_execvP)) {
-ForkAndExecs.push_back(&I);
+  if (TLI->getLibFunc(*Callee, LF)) {
+if (LF == LibFunc_fork) {
+#if !defined(_WIN32)
+  ForkAndExecs.push_back({true, CI});
+#endif
+} else if (LF == LibFunc_execl || LF == LibFunc_execle ||
+   LF == LibFunc_execlp || LF == LibFunc_execv ||
+   LF == LibFunc_execvp || LF == LibFunc_execve ||
+   LF == LibFunc_execvpe || LF == LibFunc_execvP) {
+  ForkAndExecs.push_back({false, CI});
+}
   }
 }
   }
 }
   }
 
-  // We need to split the block after the fork/exec call
-  // because else the counters for the lines after will be
-  // the same as before the call.
-  for (auto I : ForkAndExecs) {
-IRBuilder<> Builder(I);
-FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
-FunctionCallee GCOVFlush = M->getOrInsertFunction("__gcov_flush", FTy);
-Builder.CreateCall(GCOVFlush);
-I->getParent()->splitBasicBlock(I);
+  for (auto F : ForkAndExecs) {
+IRBuilder<> Builder(F.second);
+BasicBlock *Parent = F.second->getParent();
+auto NextInst = ++F.second->getIterator();
+
+if (F.first) {
+  // We've a fork so just reset the counters in the child process
+  FunctionType *FTy = FunctionType::get(Builder.getInt32Ty(), {}, false);
+  FunctionCallee GCOVFork = M->getOrInsertFunction("__gcov_fork", FTy);
+  F.second->setCalledFunction(GCOVFork);
+  if (NextInst != Parent->end()) {
+// We split just after the fork to have a counter for the lines after
+// Anyway there's a bug:
+// void foo() { fork(); }
+// void bar() { foo(); blah(); }
+// then "blah();" will be called 2 times but showed as 1
+// because "blah()" belongs to the same block as "foo();"
+Parent->splitBasicBlock(NextInst);
+
+// back() is a br instruction with a debug location
+// equals to the one from NextAfterFork
+// So to avoid to have two debug locs on two blocks just change it
+DebugLoc Loc = F.second->getDebugLoc();
+Parent->back().setDebugLoc(Loc);
+  }
+} else {
+  // Since the process is replaced by a new one we need to write out gcdas
+  // No need to reset the counters since they'll be lost after the exec**
+  FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
+  FunctionCallee WriteoutF =
+  M->getOrInsertFunction("llvm_writeout_files", FTy);
+  Builder.CreateCall(WriteoutF);
+  if (NextInst != Parent->end()) {
+DebugLoc Loc = F.second->getDebugLoc();
+Builder.SetInsertPoint(&*NextInst);
+// If the exec** fails we must reset the counters since they've been
+// dumped
+FunctionCallee ResetF =
+M->getOrInsertFunction("llvm_reset_counters", FTy);
+Builder.CreateCall(ResetF)->setDebugLoc(Loc);
+Parent->splitBasicBlock(NextInst);
+Parent->back().setDebugLoc(Loc);
+  }
+}
   }
 }
 
@@ -851,7 +891,8 @@
 }
 
 Function *WriteoutF = insertCounterWriteout(CountersBySP);
-Function *FlushF = insertFlush(CountersBySP);
+Function *ResetF = insertReset(CountersBySP);
+Function *FlushF = insertFlush(ResetF);
 
 // Create a small bit of code that registers the "__llvm_gcov_writeout" to
 // be executed 

[PATCH] D74941: [OpenMP] `omp begin/end declare variant` - part 1, parsing

2020-02-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:1357-1359
+  // Skip last tokens.
+  while (Tok.isNot(tok::annot_pragma_openmp_end))
+ConsumeAnyToken();

Better to emit a warning here about extra tokens at the end of the directive


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74941



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


[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-02-21 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg updated this revision to Diff 245853.

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

https://reviews.llvm.org/D73245

Files:
  libcxx/include/cstddef
  libcxx/include/new
  libcxx/include/stddef.h


Index: libcxx/include/stddef.h
===
--- libcxx/include/stddef.h
+++ libcxx/include/stddef.h
@@ -51,12 +51,6 @@
 using std::nullptr_t;
 }
 
-// Re-use the compiler's  max_align_t where possible.
-#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
-!defined(__DEFINED_max_align_t) && !defined(__NetBSD__)
-typedef long double max_align_t;
-#endif
-
 #endif
 
 #endif  // _LIBCPP_STDDEF_H
Index: libcxx/include/new
===
--- libcxx/include/new
+++ libcxx/include/new
@@ -226,9 +226,19 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if defined(_LIBCPP_CXX03_LANG)
+union __libcpp_max_align_t {
+  void * __f1;
+  long long int __f2;
+  long double __f3;
+};
+#endif
+
 _LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool 
__is_overaligned_for_new(size_t __align) _NOEXCEPT {
 #ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
   return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
+#elif defined(_LIBCPP_CXX03_LANG)
+  return __align > alignment_of<__libcpp_max_align_t>::value;
 #else
   return __align > alignment_of::value;
 #endif
Index: libcxx/include/cstddef
===
--- libcxx/include/cstddef
+++ libcxx/include/cstddef
@@ -25,7 +25,7 @@
 
 ptrdiff_t
 size_t
-max_align_t
+max_align_t // C++11
 nullptr_t
 byte // C++17
 
@@ -49,12 +49,8 @@
 using ::ptrdiff_t;
 using ::size_t;
 
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
-defined(__DEFINED_max_align_t) || defined(__NetBSD__)
-// Re-use the compiler's  max_align_t where possible.
+#if !defined(_LIBCPP_CXX03_LANG)
 using ::max_align_t;
-#else
-typedef long double max_align_t;
 #endif
 
 template  struct __libcpp_is_integral { enum { 
value = 0 }; };


Index: libcxx/include/stddef.h
===
--- libcxx/include/stddef.h
+++ libcxx/include/stddef.h
@@ -51,12 +51,6 @@
 using std::nullptr_t;
 }
 
-// Re-use the compiler's  max_align_t where possible.
-#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
-!defined(__DEFINED_max_align_t) && !defined(__NetBSD__)
-typedef long double max_align_t;
-#endif
-
 #endif
 
 #endif  // _LIBCPP_STDDEF_H
Index: libcxx/include/new
===
--- libcxx/include/new
+++ libcxx/include/new
@@ -226,9 +226,19 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if defined(_LIBCPP_CXX03_LANG)
+union __libcpp_max_align_t {
+  void * __f1;
+  long long int __f2;
+  long double __f3;
+};
+#endif
+
 _LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {
 #ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
   return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
+#elif defined(_LIBCPP_CXX03_LANG)
+  return __align > alignment_of<__libcpp_max_align_t>::value;
 #else
   return __align > alignment_of::value;
 #endif
Index: libcxx/include/cstddef
===
--- libcxx/include/cstddef
+++ libcxx/include/cstddef
@@ -25,7 +25,7 @@
 
 ptrdiff_t
 size_t
-max_align_t
+max_align_t // C++11
 nullptr_t
 byte // C++17
 
@@ -49,12 +49,8 @@
 using ::ptrdiff_t;
 using ::size_t;
 
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
-defined(__DEFINED_max_align_t) || defined(__NetBSD__)
-// Re-use the compiler's  max_align_t where possible.
+#if !defined(_LIBCPP_CXX03_LANG)
 using ::max_align_t;
-#else
-typedef long double max_align_t;
 #endif
 
 template  struct __libcpp_is_integral { enum { value = 0 }; };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74834: [clangd] Expose the rename LimitFiles option to the C++ API, NFC.

2020-02-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 245852.
hokein marked 2 inline comments as done.
hokein added a comment.

address review comments - move the options to clangdServer::rename API


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74834

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -39,7 +39,8 @@
 runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos);
 
 llvm::Expected runRename(ClangdServer &Server, PathRef File,
-Position Pos, StringRef NewName);
+Position Pos, StringRef NewName,
+const clangd::RenameOptions &RenameOpts);
 
 std::string runDumpAST(ClangdServer &Server, PathRef File);
 
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -97,9 +97,10 @@
 }
 
 llvm::Expected runRename(ClangdServer &Server, PathRef File,
-Position Pos, llvm::StringRef NewName) {
+Position Pos, llvm::StringRef NewName,
+const RenameOptions &RenameOpts) {
   llvm::Optional> Result;
-  Server.rename(File, Pos, NewName, /*WantFormat=*/false, capture(Result));
+  Server.rename(File, Pos, NewName, RenameOpts, capture(Result));
   return std::move(*Result);
 }
 
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -714,8 +714,13 @@
   TestTU TU = TestTU::withCode(MainCode.code());
   auto AST = TU.build();
   llvm::StringRef NewName = "newName";
-  auto Results = rename({MainCode.point(), NewName, AST, MainFilePath,
- Index.get(), /*CrossFile=*/true, GetDirtyBuffer});
+  auto Results = rename({MainCode.point(),
+ NewName,
+ AST,
+ MainFilePath,
+ Index.get(),
+ {/*CrossFile=*/true},
+ GetDirtyBuffer});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   EXPECT_THAT(
   applyEdits(std::move(*Results)),
@@ -730,8 +735,13 @@
   // Set a file "bar.cc" on disk.
   TU.AdditionalFiles["bar.cc"] = std::string(BarCode.code());
   AST = TU.build();
-  Results = rename({MainCode.point(), NewName, AST, MainFilePath, Index.get(),
-/*CrossFile=*/true, GetDirtyBuffer});
+  Results = rename({MainCode.point(),
+NewName,
+AST,
+MainFilePath,
+Index.get(),
+{/*CrossFile=*/true},
+GetDirtyBuffer});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   EXPECT_THAT(
   applyEdits(std::move(*Results)),
@@ -761,8 +771,13 @@
Callback) const override {}
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
-  Results = rename({MainCode.point(), NewName, AST, MainFilePath, &PIndex,
-/*CrossFile=*/true, GetDirtyBuffer});
+  Results = rename({MainCode.point(),
+NewName,
+AST,
+MainFilePath,
+&PIndex,
+{/*CrossFile=*/true},
+GetDirtyBuffer});
   EXPECT_FALSE(Results);
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("too many occurrences"));
@@ -803,9 +818,12 @@
 
 RefsRequest *Out;
   } RIndex(&Req);
-  auto Results =
-  rename({MainCode.point(), "NewName", AST, testPath("main.cc"), &RIndex,
-  /*CrossFile=*/true});
+  auto Results = rename({MainCode.point(),
+ "NewName",
+ AST,
+ testPath("main.cc"),
+ &RIndex,
+ {/*CrossFile=*/true}});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   const auto HeaderSymbols = TU.hea

[PATCH] D74015: [AIX][Frontend] C++ ABI customizations for AIX boilerplate

2020-02-21 Thread Sean Fertile via Phabricator via cfe-commits
sfertile accepted this revision.
sfertile added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74015



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


[PATCH] D71920: [AST] Refactor propagation of dependency bits. NFC

2020-02-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added a comment.

Thanks Richard! Haojian agreed to take a look at this.




Comment at: clang/lib/AST/ExprConcepts.cpp:186
+  if (Dependent)
+addDependence(ExprDependence::ValueInstantiation);
 }

Per Richard's comment, it sounds like this may be incorrect in obscure cases 
(if we have a non-dependent requirement that is always unsatisfied, but 
parameters are instantiation-dependent). I'll add a FIXME


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71920



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


[PATCH] D74961: [clangd] Make global rename file limit adjustable

2020-02-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

oops, I should have synced with you first (the task was assigned to me in the 
Tuesday meeting), I have https://reviews.llvm.org/D74834 which is under review. 
Apology for this.

Maybe you subscribe all clangd patches in phabricator as well (to allow better 
tracking), since most of our teammates have already done it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74961



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


Re: patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-02-21 Thread John Marshall via cfe-commits
On 18 Feb 2020, at 16:40, Aaron Ballman  wrote:
> Yup, I saw the failure on IRC and pushed up a change

Thanks again Aaron. Now that the dust has settled, bug 23564 can be closed 
(fixed by commit 260b91f379c) if someone with a bugzilla account wants to do 
that. I didn't search further to see if there were other duplicate bug reports.

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

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


Re: patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-02-21 Thread Aaron Ballman via cfe-commits
On Fri, Feb 21, 2020 at 10:54 AM John Marshall
 wrote:
>
> On 18 Feb 2020, at 16:40, Aaron Ballman  wrote:
> > Yup, I saw the failure on IRC and pushed up a change
>
> Thanks again Aaron. Now that the dust has settled, bug 23564 can be closed 
> (fixed by commit 260b91f379c) if someone with a bugzilla account wants to do 
> that. I didn't search further to see if there were other duplicate bug 
> reports.
>
> https://bugs.llvm.org/show_bug.cgi?id=23564

Thank you for pointing this out, I've closed the bug as well.

~Aaron

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


[PATCH] D74941: [OpenMP] `omp begin/end declare variant` - part 1, parsing

2020-02-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D74941#1886403 , @kiranchandramohan 
wrote:

> Will tests come in a later patch?


I have tests, seems I forgot to add them. Will fix later today with the other 
things.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74941



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


[PATCH] D74962: [clang][Tooling] Add a way to tokenize a FileRange

2020-02-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:335
   clang::Token T;
-  while (!L.LexFromRawLexer(T))
+  while (!L.LexFromRawLexer(T) && L.getCurrentBufferOffset() < FR.endOffset())
 AddToken(T);

Discussed offline, this loop includes an extra token if the truncation is at 
whitespace between tokens. (Please test this case)

Also the eof comment is confusing.

I think the loop should be rewritten.



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:346
+const LangOptions &LO) {
+  return tokenize(syntax::FileRange(SM, SM.getLocForStartOfFile(FID),
+SM.getLocForEndOfFile(FID)),

nit: FileRange(FID, 0, SM.getFileIDSize(FID)) is a lot more direct :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74962



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


[PATCH] D74966: [PATCH] [ARM] Add Cortex-M55 Support for clang and llvm

2020-02-21 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson created this revision.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

This patch upstreams support for the ARM Armv8.1m cpu Cortex-M55.

In detail adding support for:

- mcpu option in clang
- Arm Target Features in clang
- llvm Arm TargetParser definitions

details of the CPU can be found here:
https://developer.arm.com/ip-products/processors/cortex-m/cortex-m55


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74966

Files:
  clang/test/CodeGen/arm-target-features.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Target/ARM/ARM.td
  llvm/test/CodeGen/ARM/build-attributes.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -290,6 +290,11 @@
  ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP, "8-M.Mainline"));
   EXPECT_TRUE(testARMCPU("cortex-m35p", "armv8-m.main", "fpv5-sp-d16",
  ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP, "8-M.Mainline"));
+  EXPECT_TRUE(testARMCPU("cortex-m55", "armv8.1-m.main", "fp-armv8-fullfp16-d16",
+ ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_SIMD |
+ ARM::AEK_FP | ARM::AEK_RAS | ARM::AEK_LOB |
+ ARM::AEK_FP16,
+"8.1-M.Mainline"));
   EXPECT_TRUE(testARMCPU("iwmmxt", "iwmmxt", "none",
  ARM::AEK_NONE, "iwmmxt"));
   EXPECT_TRUE(testARMCPU("xscale", "xscale", "none",
@@ -299,7 +304,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 85;
+static constexpr unsigned NumARMCPUArchs = 86;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
Index: llvm/test/CodeGen/ARM/build-attributes.ll
===
--- llvm/test/CodeGen/ARM/build-attributes.ll
+++ llvm/test/CodeGen/ARM/build-attributes.ll
@@ -233,6 +233,7 @@
 ; RUN: llc < %s -mtriple=thumbv8.1m.main-none-none-eabi | FileCheck %s --check-prefix=ARMv81M-MAIN
 ; RUN: llc < %s -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve | FileCheck %s --check-prefix=ARMv81M-MAIN-MVEINT
 ; RUN: llc < %s -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve.fp | FileCheck %s --check-prefix=ARMv81M-MAIN-MVEFP
+; RUN: llc < %s -mtriple=arm-none-none-eabi -mcpu=cortex-m55 | FileCheck %s --check-prefix=CORTEX-M55
 
 ; CPU-SUPPORTED-NOT: is not a recognized processor for this target
 
@@ -1722,6 +1723,9 @@
 ; ARMv81M-MAIN-MVEINT: .eabi_attribute 48, 1 @ Tag_MVE_arch
 ; ARMv81M-MAIN-MVEFP: .eabi_attribute 6, 21 @ Tag_CPU_arch
 ; ARMv81M-MAIN-MVEFP: .eabi_attribute 48, 2 @ Tag_MVE_arch
+
+; CORTEX-M55: .cpu cortex-m55
+
 define i32 @f(i64 %z) {
 ret i32 0
 }
Index: llvm/lib/Target/ARM/ARM.td
===
--- llvm/lib/Target/ARM/ARM.td
+++ llvm/lib/Target/ARM/ARM.td
@@ -622,7 +622,6 @@
 def ProcM3  : SubtargetFeature<"m3", "ARMProcFamily", "CortexM3",
"Cortex-M3 ARM processors", []>;
 
-
 //===--===//
 // ARM Helper classes.
 //
@@ -1124,6 +1123,14 @@
  FeatureUseMISched,
  FeatureHasNoBranchPredictor]>;
 
+def : ProcessorModel<"cortex-m55", CortexM4Model,  [ARMv81mMainline,
+ FeatureDSP,
+ FeatureFPARMv8_D16,
+ FeatureUseMISched,
+ FeatureHasNoBranchPredictor,
+ FeaturePrefLoopAlign32,
+ FeatureHasSlowFPVMLx,
+ HasMVEFloatOps]>;
 
 def : ProcNoItin<"cortex-a32",   [ARMv8a,
  FeatureHWDivThumb,
Index: llvm/include/llvm/Support/ARMTargetParser.def
===
--- llvm/include/llvm/Support/ARMTargetParser.def
+++ llvm/include/llvm/Support/ARMTargetParser.def
@@ -268,6 +268,8 @@
 ARM_CPU_NAME("cortex-m23", ARMV8MBaseline, FK_NONE, false, ARM::AEK_NONE)
 ARM_CPU_NAME("cortex-m33", ARMV8MMainline, FK_FPV5_SP_D16, false, ARM::AEK_DSP)
 ARM_CPU_NAME("cortex-m35p", ARMV8MMainline, FK_FPV5_SP_D16, false, ARM::AEK_DSP)
+ARM_CPU_NAME("cortex-m55", ARMV8_1MMainline, FK_FP_ARMV8_FULLFP16_D16, false,
+

[PATCH] D74941: [OpenMP] `omp begin/end declare variant` - part 1, parsing

2020-02-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 2 inline comments as done.
jdoerfert added inline comments.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:1357-1359
+  // Skip last tokens.
+  while (Tok.isNot(tok::annot_pragma_openmp_end))
+ConsumeAnyToken();

ABataev wrote:
> Better to emit a warning here about extra tokens at the end of the directive
I think I copied that at some point but I'll add a helper and a warning



Comment at: clang/lib/Parse/ParseOpenMP.cpp:1807
+--Nesting;
+  if (DK == OMPD_begin_declare_variant)
+++Nesting;

kiranchandramohan wrote:
> Can there be an else here? Or is this the recommended style?
I can make it else if


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74941



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


[PATCH] D74934: [Clang interpreter] Rename Block.{h,cpp} to InterpBlock.{h,cpp}

2020-02-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 245862.
MaskRay retitled this revision from "[Clang interpreter] Rename Block.{h,cpp} 
to AllocatedBlock.{h,cpp}" to "[Clang interpreter] Rename Block.{h,cpp} to 
InterpBlock.{h,cpp}".
MaskRay added a comment.

Rename Block.{h,cpp} to InterpBlock.{h,cpp}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74934

Files:
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Interp/Block.cpp
  clang/lib/AST/Interp/Block.h
  clang/lib/AST/Interp/InterpBlock.cpp
  clang/lib/AST/Interp/InterpBlock.h
  clang/lib/AST/Interp/Pointer.cpp
  clang/lib/AST/Interp/Pointer.h
  llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn


Index: llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
@@ -81,7 +81,6 @@
 "ExternalASTSource.cpp",
 "FormatString.cpp",
 "InheritViz.cpp",
-"Interp/Block.cpp",
 "Interp/ByteCodeEmitter.cpp",
 "Interp/ByteCodeExprGen.cpp",
 "Interp/ByteCodeGenError.cpp",
@@ -93,6 +92,7 @@
 "Interp/Frame.cpp",
 "Interp/Function.cpp",
 "Interp/Interp.cpp",
+"Interp/InterpBlock.cpp",
 "Interp/InterpFrame.cpp",
 "Interp/InterpStack.cpp",
 "Interp/InterpState.cpp",
Index: clang/lib/AST/Interp/Pointer.h
===
--- clang/lib/AST/Interp/Pointer.h
+++ clang/lib/AST/Interp/Pointer.h
@@ -13,12 +13,12 @@
 #ifndef LLVM_CLANG_AST_INTERP_POINTER_H
 #define LLVM_CLANG_AST_INTERP_POINTER_H
 
-#include "Block.h"
 #include "Descriptor.h"
+#include "InterpBlock.h"
+#include "clang/AST/ComparisonCategories.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/ComparisonCategories.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/Support/raw_ostream.h"
 
Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -7,8 +7,8 @@
 
//===--===//
 
 #include "Pointer.h"
-#include "Block.h"
 #include "Function.h"
+#include "InterpBlock.h"
 #include "PrimType.h"
 
 using namespace clang;
Index: clang/lib/AST/Interp/InterpBlock.h
===
--- clang/lib/AST/Interp/InterpBlock.h
+++ clang/lib/AST/Interp/InterpBlock.h
@@ -1,4 +1,4 @@
-//===--- Block.h - Allocated blocks for the interpreter -*- C++ 
-*-===//
+//===-- InterpBlock.h - Allocated blocks for the interpreter -*- C++ 
*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: clang/lib/AST/Interp/InterpBlock.cpp
===
--- clang/lib/AST/Interp/InterpBlock.cpp
+++ clang/lib/AST/Interp/InterpBlock.cpp
@@ -10,7 +10,7 @@
 //
 
//===--===//
 
-#include "Block.h"
+#include "InterpBlock.h"
 #include "Pointer.h"
 
 using namespace clang;
Index: clang/lib/AST/CMakeLists.txt
===
--- clang/lib/AST/CMakeLists.txt
+++ clang/lib/AST/CMakeLists.txt
@@ -55,7 +55,6 @@
   ExternalASTSource.cpp
   FormatString.cpp
   InheritViz.cpp
-  Interp/Block.cpp
   Interp/ByteCodeEmitter.cpp
   Interp/ByteCodeExprGen.cpp
   Interp/ByteCodeGenError.cpp
@@ -67,6 +66,7 @@
   Interp/Frame.cpp
   Interp/Function.cpp
   Interp/Interp.cpp
+  Interp/InterpBlock.cpp
   Interp/InterpFrame.cpp
   Interp/InterpStack.cpp
   Interp/InterpState.cpp


Index: llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
@@ -81,7 +81,6 @@
 "ExternalASTSource.cpp",
 "FormatString.cpp",
 "InheritViz.cpp",
-"Interp/Block.cpp",
 "Interp/ByteCodeEmitter.cpp",
 "Interp/ByteCodeExprGen.cpp",
 "Interp/ByteCodeGenError.cpp",
@@ -93,6 +92,7 @@
 "Interp/Frame.cpp",
 "Interp/Function.cpp",
 "Interp/Interp.cpp",
+"Interp/InterpBlock.cpp",
 "Interp/InterpFrame.cpp",
 "Interp/InterpStack.cpp",
 "Interp/InterpState.cpp",
Index: clang/lib/AST/Interp/Pointer.h
===
--- clang/lib/AST/Interp/Pointer.h
+++ clang/lib/AST/Interp/Pointer.h
@@ -13,12 +13,12 @@
 #ifndef LLVM_CLANG_AST_INTERP_POINTER_H
 #define LLVM_CLANG_AST_INTERP_POINTER_H
 
-#include "Block.h"
 #include "Descriptor.h"
+#include "InterpBlock.h"
+#include "clang/AST/ComparisonCategories.h"
 #include "clang/AST/Decl.h"
 #inc

[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-02-21 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 245863.
hliao added a comment.

Rebase to the trunk.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/global-initializers-host.cu
  clang/test/SemaCUDA/hip-pinned-shadow.cu

Index: clang/test/SemaCUDA/hip-pinned-shadow.cu
===
--- clang/test/SemaCUDA/hip-pinned-shadow.cu
+++ clang/test/SemaCUDA/hip-pinned-shadow.cu
@@ -13,13 +13,19 @@
 
 template 
 struct texture : public textureReference {
+// expected-note@-1{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-2{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-3{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-4{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
 texture() { a = 1; }
+// expected-note@-1{{candidate constructor not viable: call to __host__ function from __device__ function}}
+// expected-note@-2{{candidate constructor not viable: call to __host__ function from __device__ function}}
 };
 
 __hip_pinned_shadow__ texture tex;
 __device__ __hip_pinned_shadow__ texture tex2; // expected-error{{'hip_pinned_shadow' and 'device' attributes are not compatible}}
-// expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-// expected-note@-2{{conflicting attribute is here}}
+// expected-note@-1{{conflicting attribute is here}}
+// expected-error@-2{{no matching constructor for initialization of 'texture'}}
 __constant__ __hip_pinned_shadow__ texture tex3; // expected-error{{'hip_pinned_shadow' and 'constant' attributes are not compatible}}
-  // expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-  // expected-note@-2{{conflicting attribute is here}}
+  // expected-note@-1{{conflicting attribute is here}}
+  // expected-error@-2{{no matching constructor for initialization of 'texture'}}
Index: clang/test/SemaCUDA/global-initializers-host.cu
===
--- clang/test/SemaCUDA/global-initializers-host.cu
+++ clang/test/SemaCUDA/global-initializers-host.cu
@@ -6,12 +6,14 @@
 // module initializer.
 
 struct S {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
   __device__ S() {}
-  // expected-note@-1 {{'S' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 
 S s;
-// expected-error@-1 {{reference to __device__ function 'S' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'S'}}
 
 struct T {
   __host__ __device__ T() {}
@@ -19,14 +21,17 @@
 T t;  // No error, this is OK.
 
 struct U {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const U' for 1st argument}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'U' for 1st argument}}
   __host__ U() {}
+  // expected-note@-1 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
   __device__ U(int) {}
-  // expected-note@-1 {{'U' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 U u(42);
-// expected-error@-1 {{reference to __device__ function 'U' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'U'}}
 
 __device__ int device_fn() { return 42; }
-// expected-note@-1 {{'device_fn' declared here}}
+// expected-note@-1 {{candidate function not viable: call to __device__ functio

[PATCH] D73186: [AST] Add fixed-point multiplication constant evaluation.

2020-02-21 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: clang/lib/Basic/FixedPoint.cpp:242
+  } else
+Overflowed = Result < Min || Result > Max;
+

rjmccall wrote:
> leonardchan wrote:
> > ebevhan wrote:
> > > rjmccall wrote:
> > > > ebevhan wrote:
> > > > > rjmccall wrote:
> > > > > > leonardchan wrote:
> > > > > > > ebevhan wrote:
> > > > > > > > rjmccall wrote:
> > > > > > > > > ebevhan wrote:
> > > > > > > > > > ebevhan wrote:
> > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > If the maximum expressible value is *k*, and the 
> > > > > > > > > > > > fully-precise multiplication yields *k+e* for some 
> > > > > > > > > > > > epsilon *e* that isn't representable in the result 
> > > > > > > > > > > > semantics, is that considered an overflow?  If so, I 
> > > > > > > > > > > > think you need to do the shift after these bound 
> > > > > > > > > > > > checks, since the shift destroys the difference between 
> > > > > > > > > > > > *k* and *k+e*.  That is, unless there's a compelling 
> > > > > > > > > > > > mathematical argument that it's not possible to 
> > > > > > > > > > > > overflow only in the fully-precision multiplication — 
> > > > > > > > > > > > but while I think that's possibly true of `_Fract` 
> > > > > > > > > > > > (since *k^2 < k*), it seems unlikely to be true of 
> > > > > > > > > > > > `_Accum`, although I haven't looked for a 
> > > > > > > > > > > > counter-example.  And if there is a compelling 
> > > > > > > > > > > > argument, it should probably be at least alluded to in 
> > > > > > > > > > > > a comment.
> > > > > > > > > > > > 
> > > > > > > > > > > > Would this algorithm be simpler if you took advantage 
> > > > > > > > > > > > of the fact that `APFixedPointSemantics` doesn't have 
> > > > > > > > > > > > to correspond to a real type?  You could probably just 
> > > > > > > > > > > > convert to a double-width common semantics, right?
> > > > > > > > > > > > If the maximum expressible value is *k*, and the 
> > > > > > > > > > > > fully-precise multiplication yields *k+e* for some 
> > > > > > > > > > > > epsilon *e* that isn't representable in the result 
> > > > > > > > > > > > semantics, is that considered an overflow? If so, I 
> > > > > > > > > > > > think you need to do the shift after these bound 
> > > > > > > > > > > > checks, since the shift destroys the difference between 
> > > > > > > > > > > > *k* and *k+e*.
> > > > > > > > > > > 
> > > > > > > > > > > I don't think I would consider that to be overflow; 
> > > > > > > > > > > that's precision loss. E-C considers these to be 
> > > > > > > > > > > different:
> > > > > > > > > > > 
> > > > > > > > > > > > If the source value cannot be represented exactly by 
> > > > > > > > > > > > the fixed-point type, the source value is rounded to 
> > > > > > > > > > > > either the closest fixed-point value greater than the 
> > > > > > > > > > > > source value (rounded up) or to the closest fixed-point 
> > > > > > > > > > > > value less than the source value (rounded down).
> > > > > > > > > > > >
> > > > > > > > > > > > When the source value does not fit within the range of 
> > > > > > > > > > > > the fixed-point type, the conversion overflows. [...]
> > > > > > > > > > > >
> > > > > > > > > > > > [...]
> > > > > > > > > > > >
> > > > > > > > > > > > If the result type of an arithmetic operation is a 
> > > > > > > > > > > > fixed-point type, [...] the calculated result is the 
> > > > > > > > > > > > mathematically exact result with overflow handling and 
> > > > > > > > > > > > rounding performed to the full precision of the result 
> > > > > > > > > > > > type as explained in 4.1.3. 
> > > > > > > > > > > 
> > > > > > > > > > > There is also no value of `e` that would affect 
> > > > > > > > > > > saturation. Any full precision calculation that gives 
> > > > > > > > > > > `k+e` must be `k` after downscaling, since the bits that 
> > > > > > > > > > > represent `e` must come from the extra precision range. 
> > > > > > > > > > > Even though `k+e` is technically larger than `k`, 
> > > > > > > > > > > saturation would still just give us `k` after truncating 
> > > > > > > > > > > out `e`, so the end result is the same.
> > > > > > > > > > > 
> > > > > > > > > > > > Would this algorithm be simpler if you took advantage 
> > > > > > > > > > > > of the fact that APFixedPointSemantics doesn't have to 
> > > > > > > > > > > > correspond to a real type? You could probably just 
> > > > > > > > > > > > convert to a double-width common semantics, right?
> > > > > > > > > > > 
> > > > > > > > > > > It's likely possible to use APFixedPoint in the 
> > > > > > > > > > > calculations here, but I used APInt to make the behavior 
> > > > > > > > > > > explicit and not accidentally be dependent on the 
> > > > > > > > > > > behavior of APFixedPoint's conversions or operations.
> > > > > > > > > > Although.,. I guess I see your point in that an 
> > > > > > > > > > intermediate result of k+e technically

[PATCH] D74966: [PATCH] [ARM] Add Cortex-M55 Support for clang and llvm

2020-02-21 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/lib/Target/ARM/ARM.td:625
 
-
 
//===--===//

Seems unrelated ;)



Comment at: llvm/test/CodeGen/ARM/build-attributes.ll:1376
 
 ; CORTEX-M33:  .cpu cortex-m33
 ; CORTEX-M33:  .eabi_attribute 6, 17

Should we have a bunch of tests like these, but for M55?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74966



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


[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-02-21 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey updated this revision to Diff 245875.
awpandey marked 7 inline comments as done.

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

https://reviews.llvm.org/D73462

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-template-parameter.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/Assembler/DITemplateParameter.ll
  llvm/test/Bitcode/DITemplateParameter-5.0.ll
  llvm/test/Bitcode/DITemplateParameter-5.0.ll.bc
  llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
  llvm/unittests/IR/MetadataTest.cpp

Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -2076,17 +2076,19 @@
 TEST_F(DITemplateTypeParameterTest, get) {
   StringRef Name = "template";
   DIType *Type = getBasicType("basic");
+  bool defaulted = false;
 
-  auto *N = DITemplateTypeParameter::get(Context, Name, Type);
+  auto *N = DITemplateTypeParameter::get(Context, Name, Type, defaulted);
 
   EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag());
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(Type, N->getType());
-  EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type));
+  EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, defaulted));
 
-  EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type));
-  EXPECT_NE(N,
-DITemplateTypeParameter::get(Context, Name, getBasicType("other")));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, defaulted));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name,
+getBasicType("other"), defaulted));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, Type, true));
 
   TempDITemplateTypeParameter Temp = N->clone();
   EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -2100,22 +2102,26 @@
   DIType *Type = getBasicType("basic");
   Metadata *Value = getConstantAsMetadata();
 
-  auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value);
+  auto *N =
+  DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value);
   EXPECT_EQ(Tag, N->getTag());
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(Type, N->getType());
   EXPECT_EQ(Value, N->getValue());
-  EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value));
+  EXPECT_EQ(
+  N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value));
 
   EXPECT_NE(N, DITemplateValueParameter::get(
Context, dwarf::DW_TAG_GNU_template_template_param, Name,
-   Type, Value));
-  EXPECT_NE(N,
-DITemplateValueParameter::get(Context, Tag, "other", Type, Value));
-  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name,
- getBasicType("other"), Value));
-  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type,
+   Type, false, Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false,
+ Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(
+   Context, Tag, Name, getBasicType("other"), false, Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false,
  getConstantAsMetadata()));
+  EXPECT_NE(
+  N, DITemplateValueParameter::get(Context, Tag, Name, Type, true, Value));
 
   TempDITemplateValueParameter Temp = N->clone();
   EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
@@ -0,0 +1,90 @@
+; RUN: %llc_dwarf  %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; C++ source to regenerate:
+
+;template 
+;class foo {
+;};
+;
+;int main() {
+; foo f1;
+; foo<> f2;
+; return 0;
+;}
+
+; $ clang++ -O0 -gdwarf-5 -S -gdwarf-5 test.cpp 
+
+; CHECK: .debug_abbrev contents:
+; CHECK: DW_AT_default_value DW_FORM_flag_present
+
+; CHECK: debug_info contents:
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NOT: DW_AT_default_value
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "i"
+; CHECK-NOT: DW_AT_default_value
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "char"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK_NEXT: DW_AT_default_value {{.*}} true

[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor clause.

2020-02-21 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen created this revision.
cchen added a reviewer: ABataev.
Herald added subscribers: cfe-commits, guansong.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

This step is the preparation of allowing lvalue in map/motion clause.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74970

Files:
  clang/lib/Sema/SemaOpenMP.cpp

Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15197,256 +15197,306 @@
   return ConstLength.getSExtValue() != 1;
 }
 
-// Return the expression of the base of the mappable expression or null if it
-// cannot be determined and do all the necessary checks to see if the expression
-// is valid as a standalone mappable expression. In the process, record all the
-// components of the expression.
-static const Expr *checkMapClauseExpressionBase(
-Sema &SemaRef, Expr *E,
-OMPClauseMappableExprCommon::MappableExprComponentList &CurComponents,
-OpenMPClauseKind CKind, bool NoDiagnose) {
-  SourceLocation ELoc = E->getExprLoc();
-  SourceRange ERange = E->getSourceRange();
-
-  // The base of elements of list in a map clause have to be either:
-  //  - a reference to variable or field.
-  //  - a member expression.
-  //  - an array expression.
-  //
-  // E.g. if we have the expression 'r.S.Arr[:12]', we want to retrieve the
-  // reference to 'r'.
-  //
-  // If we have:
-  //
-  // struct SS {
-  //   Bla S;
-  //   foo() {
-  // #pragma omp target map (S.Arr[:12]);
-  //   }
-  // }
-  //
-  // We want to retrieve the member expression 'this->S';
-
-  const Expr *RelevantExpr = nullptr;
+// The base of elements of list in a map clause have to be either:
+//  - a reference to variable or field.
+//  - a member expression.
+//  - an array expression.
+//
+// E.g. if we have the expression 'r.S.Arr[:12]', we want to retrieve the
+// reference to 'r'.
+//
+// If we have:
+//
+// struct SS {
+//   Bla S;
+//   foo() {
+// #pragma omp target map (S.Arr[:12]);
+//   }
+// }
+//
+// We want to retrieve the member expression 'this->S';
 
-  // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2]
-  //  If a list item is an array section, it must specify contiguous storage.
-  //
-  // For this restriction it is sufficient that we make sure only references
-  // to variables or fields and array expressions, and that no array sections
-  // exist except in the rightmost expression (unless they cover the whole
-  // dimension of the array). E.g. these would be invalid:
-  //
-  //   r.ArrS[3:5].Arr[6:7]
-  //
-  //   r.ArrS[3:5].x
-  //
-  // but these would be valid:
-  //   r.ArrS[3].Arr[6:7]
-  //
-  //   r.ArrS[3].x
+// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2]
+//  If a list item is an array section, it must specify contiguous storage.
+//
+// For this restriction it is sufficient that we make sure only references
+// to variables or fields and array expressions, and that no array sections
+// exist except in the rightmost expression (unless they cover the whole
+// dimension of the array). E.g. these would be invalid:
+//
+//   r.ArrS[3:5].Arr[6:7]
+//
+//   r.ArrS[3:5].x
+//
+// but these would be valid:
+//   r.ArrS[3].Arr[6:7]
+//
+//   r.ArrS[3].x
+namespace {
+class MapBaseChecker final : public StmtVisitor {
+  Sema &SemaRef;
+  OpenMPClauseKind CKind;
+  OMPClauseMappableExprCommon::MappableExprComponentList &Components;
+  bool NoDiagnose;
+  const Expr *RelevantExpr{nullptr};
+  bool AllowUnitySizeArraySection{true};
+  bool AllowWholeSizeArraySection{true};
+  SourceLocation ELoc;
+  SourceRange ERange;
+
+  void emitErrorMsg() {
+if (!NoDiagnose) {
+  // If nothing else worked, this is not a valid map clause expression.
+  SemaRef.Diag(ELoc, diag::err_omp_expected_named_var_member_or_array_expression)
+<< ERange;
+}
+  }
 
-  bool AllowUnitySizeArraySection = true;
-  bool AllowWholeSizeArraySection = true;
+public:
+  bool VisitDeclRefExpr(DeclRefExpr *DRE) {
+if (!isa(DRE->getDecl()))
+  return false;
+RelevantExpr = DRE;
+// Record the component.
+Components.emplace_back(DRE, DRE->getDecl());
+return true;
+  }
 
-  while (!RelevantExpr) {
-E = E->IgnoreParenImpCasts();
+  bool VisitMemberExpr(MemberExpr *ME) {
+Expr *E = cast(ME);
+Expr *BaseE = ME->getBase()->IgnoreParenImpCasts();
 
-if (auto *CurE = dyn_cast(E)) {
-  if (!isa(CurE->getDecl()))
-return nullptr;
+if (isa(BaseE))
+  // We found a base expression: this->Val.
+  RelevantExpr = ME;
+else
+  E = BaseE;
 
-  RelevantExpr = CurE;
+if (!isa(ME->getMemberDecl())) {
+  if (!NoDiagnose) {
+SemaRef.Diag(ELoc, diag::err_omp_expected_access_to_data_field)
+  << ME->getSourceRange();
+return false;
+  }
+  if (RelevantExpr)
+return false;
+  return Visit(E->IgnoreParenImpCasts());;
+   

[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor clause.

2020-02-21 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15283
+return false;
+  return Visit(E->IgnoreParenImpCasts());;
+}

@ABataev, in the previous patch you mentioned that we don't need 
`IgnoreParenImpCasts()` here, but I think I was just trying to do what line 
15232 did.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74970



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-02-21 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 245879.
Xiangling_L added a comment.

Rebase to incorparate `XL` C++ ABI name && comdat changes;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-priority-attribute.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- clang/test/CodeGen/static-init.cpp
+++ clang/test/CodeGen/static-init.cpp
@@ -1,12 +1,55 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
 struct test {
   test();
   ~test();
 } t;
 
-// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd, i8* null }]
+// CHECK: define dso_local void @__cxx_global_var_init() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testC1Ei(%class.test* @t, i32 1)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor_t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__dtor_t() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testD1Ev(%class.test* @t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*) #2
+
+// CHECK: define dso_local void @__cxx_global_var_destruct_t() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor_t)
+// CHECK:   %guard.hasSrterm = icmp eq i32 %0, 0
+// CHECK:   br i1 %guard.hasSrterm, label %destruct.check, label %destruct.end
+
+// CHECK: destruct.check:
+// CHECK:   call void @__dtor_t()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*) #2
+
+// CHECK: define dso_local void @__sinit8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_init()
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__sterm8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_destruct_t()
+// CHECK:   ret void
+// CHECK: }
Index: clang/test/CodeGen/aix-priority-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-priority-attribute.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 | \
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 | \
+// RUN: FileCheck %s
+
+int foo() __attribute__((constructor(180)));
+int bar() __attribute__((destructor(180)));
+
+class test {
+   int a;
+public:
+test(int c) {a = c;}
+~test() {a = 0;}
+};
+
+__attribute__ ((init_priority (2000)))
+test t(1);
+
+// CHECK: warning: 'constructor' attribute argument not supported:
+// CHECK: int foo() __attribute__((constructor(180)));
+ 
+// CHECK: warning: 'destructor' attribute argument not supported:
+// check: int bar() __attribute__((destructor(180)));
+
+// CHECK: warning: 'init_priority' attribute argument not supported:
+// CHECK: __attribute__ ((init_priority (2000)))
+
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6819,7 +6819,11 @@
 handlePassObjectSizeAttr(S, D, AL);
 break;
   case ParsedAttr::AT_Constructor:
-handleConstructorAttr(S, D, AL);
+if (S.Context.getTargetInfo().getTriple().isOSAIX())
+  S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+  << AL << "";
+else
+  handleConstructorAttr(S, D, AL);
 break;
   case ParsedAttr::AT_CXX11NoReturn:
 handleSimpleAttribute(S, D, AL);
@@ -6828,7 +6832,11 @@
 handleDeprecatedAttr(S, D, AL);
 break;
   case ParsedAttr::AT_Destructor:
-handleDestructorAttr(S, D, AL);
+if (S.Context.getTargetInfo().getTriple().isOSAIX())
+  S.Diag(AL.get

[PATCH] D74847: [CodeGen][RISCV] Fix clang/test/CodeGen/atomic_ops.c for RISC-V

2020-02-21 Thread Luís Marques via Phabricator via cfe-commits
luismarques updated this revision to Diff 245881.
luismarques edited the summary of this revision.
luismarques added a comment.
Herald added a subscriber: fedor.sergeev.

As suggested by @efriedma, the patch was reworked to have one target with 
native atomics, and one without. No RUN run with a default target remains.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74847

Files:
  clang/test/CodeGen/atomic_ops.c


Index: clang/test/CodeGen/atomic_ops.c
===
--- clang/test/CodeGen/atomic_ops.c
+++ clang/test/CodeGen/atomic_ops.c
@@ -1,7 +1,7 @@
-// XFAIL: hexagon,sparc
-//(due to not having native load atomic support)
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64 -emit-llvm %s \
+// RUN:   -o - | FileCheck -check-prefixes=CHECK,NATIVE %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature -a -emit-llvm %s \
+// RUN:   -o - | FileCheck -check-prefixes=CHECK,LIBCALL %s
 
 void foo(int x)
 {
@@ -9,32 +9,47 @@
   _Atomic(short) j = 0;
   // Check that multiply / divides on atomics produce a cmpxchg loop
   i *= 2;
-  // CHECK: mul nsw i32
-  // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4,)}}
+  // NATIVE: mul nsw i32
+  // NATIVE: cmpxchg i32*
+  // LIBCALL: mul nsw i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 4,
   i /= 2;
-  // CHECK: sdiv i32
-  // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4, )}}
+  // NATIVE: sdiv i32
+  // NATIVE: cmpxchg i32*
+  // LIBCALL: sdiv i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 4,
   j /= x;
-  // CHECK: sdiv i32
-  // CHECK: {{(cmpxchg i16*|i1 @__atomic_compare_exchange\(i32 2, )}}
+  // NATIVE: sdiv i32
+  // NATIVE: cmpxchg i16*
+  // LIBCALL: sdiv i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 2,
 
 }
 
 extern _Atomic _Bool b;
 
 _Bool bar() {
-// CHECK-LABEL: @bar
-// CHECK: %[[load:.*]] = load atomic i8, i8* @b seq_cst
-// CHECK: %[[tobool:.*]] = trunc i8 %[[load]] to i1
-// CHECK: ret i1 %[[tobool]]
+// NATIVE-LABEL: @bar
+// NATIVE: %[[load:.*]] = load atomic i8, i8* @b seq_cst
+// NATIVE: %[[tobool:.*]] = trunc i8 %[[load]] to i1
+// NATIVE: ret i1 %[[tobool]]
+// LIBCALL-LABEL: @bar
+// LIBCALL: call void @__atomic_load(i32 1, i8* @b, i8* %atomic-temp, i32 5)
+// LIBCALL: %[[load:.*]] = load i8, i8* %atomic-temp
+// LIBCALL: %[[tobool:.*]] = trunc i8 %[[load]] to i1
+// LIBCALL: ret i1 %[[tobool]]
+
   return b;
 }
 
 extern _Atomic(_Complex int) x;
 
 void baz(int y) {
-// CHECK-LABEL: @baz
-// CHECK: {{store atomic|call void @__atomic_store}}
+// NATIVE-LABEL: @baz
+// NATIVE: store atomic
+// LIBCALL-LABEL: @baz
+// LIBCALL: call void @__atomic_store
+
   x += y;
 }
 
@@ -84,9 +99,11 @@
 }
 
 _Atomic(int) compound_mul(_Atomic(int) in) {
-// CHECK-LABEL: @compound_mul
-// CHECK: cmpxchg i32* {{%.*}}, i32 {{%.*}}, i32 [[NEW:%.*]] seq_cst seq_cst
-// CHECK: ret i32 [[NEW]]
+// NATIVE-LABEL: @compound_mul
+// NATIVE: cmpxchg i32* {{%.*}}, i32 {{%.*}}, i32 [[NEW:%.*]] seq_cst seq_cst
+// NATIVE: ret i32 [[NEW]]
+// LIBCALL-LABEL: @compound_mul
+// LIBCALL: i1 @__atomic_compare_exchange(i32 4,
 
   return (in *= 5);
 }


Index: clang/test/CodeGen/atomic_ops.c
===
--- clang/test/CodeGen/atomic_ops.c
+++ clang/test/CodeGen/atomic_ops.c
@@ -1,7 +1,7 @@
-// XFAIL: hexagon,sparc
-//(due to not having native load atomic support)
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64 -emit-llvm %s \
+// RUN:   -o - | FileCheck -check-prefixes=CHECK,NATIVE %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature -a -emit-llvm %s \
+// RUN:   -o - | FileCheck -check-prefixes=CHECK,LIBCALL %s
 
 void foo(int x)
 {
@@ -9,32 +9,47 @@
   _Atomic(short) j = 0;
   // Check that multiply / divides on atomics produce a cmpxchg loop
   i *= 2;
-  // CHECK: mul nsw i32
-  // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4,)}}
+  // NATIVE: mul nsw i32
+  // NATIVE: cmpxchg i32*
+  // LIBCALL: mul nsw i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 4,
   i /= 2;
-  // CHECK: sdiv i32
-  // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4, )}}
+  // NATIVE: sdiv i32
+  // NATIVE: cmpxchg i32*
+  // LIBCALL: sdiv i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 4,
   j /= x;
-  // CHECK: sdiv i32
-  // CHECK: {{(cmpxchg i16*|i1 @__atomic_compare_exchange\(i32 2, )}}
+  // NATIVE: sdiv i32
+  // NATIVE: cmpxchg i16*
+  // LIBCALL: sdiv i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 2,
 
 }
 
 extern _Atomic _Bool b;
 
 _Bool bar() {
-// CHECK-LABEL: @bar
-// CHECK: %[[load:.*]] = load atomic i8, i8* @b seq_cst
-// CHECK: %[[tobool:.*]] = trunc i8 %[[lo

Re: [PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-21 Thread Rong Xu via cfe-commits
OK. I will add  a warning but not turn it off at the CodeGenOpt (but it
will not pass to LLVMContext). I will update the patch shortly.

On Fri, Feb 21, 2020 at 1:53 AM serge via Phabricator <
revi...@reviews.llvm.org> wrote:

> serge-sans-paille added a comment.
>
> Let's go that way then. @xur I leave it to you to add the appropriate
> warning at least on the clang side? Feel free to just use the code from
> https://reviews.llvm.org/D74871?id=245594.
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D74878/new/
>
> https://reviews.llvm.org/D74878
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 23444ed - [AST matchers] Add basic matchers for googletest EXPECT/ASSERT calls.

2020-02-21 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-02-21T12:05:15-05:00
New Revision: 23444edf30ba00ccefa3a582ac7ddc29774e9da5

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

LOG: [AST matchers] Add basic matchers for googletest EXPECT/ASSERT calls.

Summary:
This revision adds matchers that match calls to the gtest EXPECT and ASSERT
macros almost like function calls. The matchers are placed in separate files
(GtestMatchers...), because they are specific to the gtest library.

Reviewers: gribozavr2

Subscribers: mgorny, cfe-commits

Tags: #clang

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

Added: 
clang/include/clang/ASTMatchers/GtestMatchers.h
clang/lib/ASTMatchers/GtestMatchers.cpp
clang/unittests/ASTMatchers/GtestMatchersTest.cpp

Modified: 
clang/lib/ASTMatchers/CMakeLists.txt
clang/unittests/ASTMatchers/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/GtestMatchers.h 
b/clang/include/clang/ASTMatchers/GtestMatchers.h
new file mode 100644
index ..4f8addcf744a
--- /dev/null
+++ b/clang/include/clang/ASTMatchers/GtestMatchers.h
@@ -0,0 +1,45 @@
+//===- GtestMatchers.h - AST Matchers for GTest -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file implements matchers specific to structures in the Googletest
+//  (gtest) framework.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_ASTMATCHERS_GTESTMATCHERS_H
+#define LLVM_CLANG_ASTMATCHERS_GTESTMATCHERS_H
+
+#include "clang/AST/Stmt.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+
+namespace clang {
+namespace ast_matchers {
+
+/// Gtest's comparison operations.
+enum class GtestCmp {
+  Eq,
+  Ne,
+  Ge,
+  Gt,
+  Le,
+  Lt,
+};
+
+/// Matcher for gtest's ASSERT_... macros.
+internal::BindableMatcher gtestAssert(GtestCmp Cmp, StatementMatcher 
Left,
+StatementMatcher Right);
+
+/// Matcher for gtest's EXPECT_... macros.
+internal::BindableMatcher gtestExpect(GtestCmp Cmp, StatementMatcher 
Left,
+StatementMatcher Right);
+
+} // namespace ast_matchers
+} // namespace clang
+
+#endif // LLVM_CLANG_ASTMATCHERS_GTESTMATCHERS_H
+

diff  --git a/clang/lib/ASTMatchers/CMakeLists.txt 
b/clang/lib/ASTMatchers/CMakeLists.txt
index cd88d1db9ce4..8f700ca3226b 100644
--- a/clang/lib/ASTMatchers/CMakeLists.txt
+++ b/clang/lib/ASTMatchers/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS support)
 add_clang_library(clangASTMatchers
   ASTMatchFinder.cpp
   ASTMatchersInternal.cpp
+  GtestMatchers.cpp
 
   LINK_LIBS
   clangAST

diff  --git a/clang/lib/ASTMatchers/GtestMatchers.cpp 
b/clang/lib/ASTMatchers/GtestMatchers.cpp
new file mode 100644
index ..317bddd035f8
--- /dev/null
+++ b/clang/lib/ASTMatchers/GtestMatchers.cpp
@@ -0,0 +1,101 @@
+//===- GtestMatchers.cpp - AST Matchers for Gtest ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/ASTMatchers/GtestMatchers.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Support/Timer.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace ast_matchers {
+
+static DeclarationMatcher getComparisonDecl(GtestCmp Cmp) {
+  switch (Cmp) {
+case GtestCmp::Eq:
+  return cxxMethodDecl(hasName("Compare"),
+   ofClass(cxxRecordDecl(isSameOrDerivedFrom(
+   hasName("::testing::internal::EqHelper");
+case GtestCmp::Ne:
+  return functionDecl(hasName("::testing::internal::CmpHelperNE"));
+case GtestCmp::Ge:
+  return functionDecl(hasName("::testing::internal::CmpHelperGE"));
+case GtestCmp::Gt:
+  return functionDecl(hasName("::testing::internal::CmpHelperGT"));
+case GtestCmp::Le:
+  return functionDecl(hasName("::testing::internal::CmpHelperLE"));
+case GtestCmp::Lt:
+  return functionDecl(hasName("::testing::internal::CmpHelperLT"));
+  }
+}
+
+static llvm::StringRef getAssertMacro(GtestCmp Cmp) {
+  switch (Cmp

[PATCH] D74972: [hexagon] Define __ELF__ by default.

2020-02-21 Thread Sid Manning via Phabricator via cfe-commits
sidneym created this revision.
sidneym added reviewers: kparzysz, bcain.
Herald added subscribers: Sanitizers, cfe-commits, mgorny.
Herald added projects: clang, Sanitizers, LLVM.

__ELF__ is not enabled by default.  Correcting an issue in compiler-rt's cmake 
revealed that __ELF__ was not defined.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74972

Files:
  clang/lib/Basic/Targets/Hexagon.cpp
  clang/test/Preprocessor/hexagon-predefines.c
  compiler-rt/lib/builtins/CMakeLists.txt


Index: compiler-rt/lib/builtins/CMakeLists.txt
===
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -492,7 +492,6 @@
 set(armv7em_SOURCES ${arm_SOURCES})
 
 # hexagon arch
-set(hexagon_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
 set(hexagon_SOURCES
   hexagon/common_entry_exit_abi1.S
   hexagon/common_entry_exit_abi2.S
@@ -524,6 +523,8 @@
   hexagon/udivsi3.S
   hexagon/umoddi3.S
   hexagon/umodsi3.S
+  ${GENERIC_SOURCES}
+  ${GENERIC_TF_SOURCES}
 )
 
 
Index: clang/test/Preprocessor/hexagon-predefines.c
===
--- clang/test/Preprocessor/hexagon-predefines.c
+++ clang/test/Preprocessor/hexagon-predefines.c
@@ -96,3 +96,8 @@
 // CHECK-V67HVX-128B: #define __HVX_LENGTH__ 128
 // CHECK-V67HVX-128B: #define __HVX__ 1
 // CHECK-V67HVX-128B: #define __hexagon__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv67 \
+// RUN: -target-feature +hvxv67 -target-feature +hvx-length128b %s | FileCheck 
\
+// RUN: %s -check-prefix CHECK-ELF
+// CHECK-ELF: #define __ELF__ 1
Index: clang/lib/Basic/Targets/Hexagon.cpp
===
--- clang/lib/Basic/Targets/Hexagon.cpp
+++ clang/lib/Basic/Targets/Hexagon.cpp
@@ -24,6 +24,8 @@
   Builder.defineMacro("__qdsp6__", "1");
   Builder.defineMacro("__hexagon__", "1");
 
+  Builder.defineMacro("__ELF__");
+
   // The macro __HVXDBL__ is deprecated.
   bool DefineHvxDbl = false;
 


Index: compiler-rt/lib/builtins/CMakeLists.txt
===
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -492,7 +492,6 @@
 set(armv7em_SOURCES ${arm_SOURCES})
 
 # hexagon arch
-set(hexagon_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
 set(hexagon_SOURCES
   hexagon/common_entry_exit_abi1.S
   hexagon/common_entry_exit_abi2.S
@@ -524,6 +523,8 @@
   hexagon/udivsi3.S
   hexagon/umoddi3.S
   hexagon/umodsi3.S
+  ${GENERIC_SOURCES}
+  ${GENERIC_TF_SOURCES}
 )
 
 
Index: clang/test/Preprocessor/hexagon-predefines.c
===
--- clang/test/Preprocessor/hexagon-predefines.c
+++ clang/test/Preprocessor/hexagon-predefines.c
@@ -96,3 +96,8 @@
 // CHECK-V67HVX-128B: #define __HVX_LENGTH__ 128
 // CHECK-V67HVX-128B: #define __HVX__ 1
 // CHECK-V67HVX-128B: #define __hexagon__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv67 \
+// RUN: -target-feature +hvxv67 -target-feature +hvx-length128b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-ELF
+// CHECK-ELF: #define __ELF__ 1
Index: clang/lib/Basic/Targets/Hexagon.cpp
===
--- clang/lib/Basic/Targets/Hexagon.cpp
+++ clang/lib/Basic/Targets/Hexagon.cpp
@@ -24,6 +24,8 @@
   Builder.defineMacro("__qdsp6__", "1");
   Builder.defineMacro("__hexagon__", "1");
 
+  Builder.defineMacro("__ELF__");
+
   // The macro __HVXDBL__ is deprecated.
   bool DefineHvxDbl = false;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74840: [AST matchers] Add basic matchers for googletest EXPECT/ASSERT calls.

2020-02-21 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG23444edf30ba: [AST matchers] Add basic matchers for 
googletest EXPECT/ASSERT calls. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74840

Files:
  clang/include/clang/ASTMatchers/GtestMatchers.h
  clang/lib/ASTMatchers/CMakeLists.txt
  clang/lib/ASTMatchers/GtestMatchers.cpp
  clang/unittests/ASTMatchers/CMakeLists.txt
  clang/unittests/ASTMatchers/GtestMatchersTest.cpp

Index: clang/unittests/ASTMatchers/GtestMatchersTest.cpp
===
--- /dev/null
+++ clang/unittests/ASTMatchers/GtestMatchersTest.cpp
@@ -0,0 +1,191 @@
+//===- unittests/ASTMatchers/GTestMatchersTest.cpp - GTest matcher unit tests //
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ASTMatchersTest.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/GtestMatchers.h"
+
+namespace clang {
+namespace ast_matchers {
+
+constexpr llvm::StringLiteral GtestMockDecls = R"cc(
+  static int testerr;
+
+#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+switch (0)  \
+case 0: \
+default:  // NOLINT
+
+#define GTEST_NONFATAL_FAILURE_(code) testerr = code
+
+#define GTEST_FATAL_FAILURE_(code) testerr = code
+
+#define GTEST_ASSERT_(expression, on_failure) \
+GTEST_AMBIGUOUS_ELSE_BLOCKER_   \
+if (const int gtest_ar = (expression))  \
+  ; \
+else\
+  on_failure(gtest_ar)
+
+  // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
+  // Don't use this in your code.
+#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure) \
+GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
+
+#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
+GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
+#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
+GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
+
+#define EXPECT_EQ(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
+#define EXPECT_NE(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
+#define EXPECT_GE(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
+#define EXPECT_GT(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
+#define EXPECT_LE(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
+#define EXPECT_LT(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
+
+#define ASSERT_EQ(val1, val2) \
+ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
+#define ASSERT_NE(val1, val2) \
+ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
+
+  namespace testing {
+  namespace internal {
+  class EqHelper {
+   public:
+// This templatized version is for the general case.
+template 
+static int Compare(const char* lhs_expression, const char* rhs_expression,
+   const T1& lhs, const T2& rhs) {
+  return 0;
+}
+  };
+  template 
+  int CmpHelperNE(const char* expr1, const char* expr2, const T1& val1,
+  const T2& val2) {
+return 0;
+  }
+  template 
+  int CmpHelperGE(const char* expr1, const char* expr2, const T1& val1,
+  const T2& val2) {
+return 0;
+  }
+  template 
+  int CmpHelperGT(const char* expr1, const char* expr2, const T1& val1,
+  const T2& val2) {
+return 0;
+  }
+  template 
+  int CmpHelperLE(const char* expr1, const char* expr2, const T1& val1,
+  const T2& val2) {
+return 0;
+  }
+  template 
+  int CmpHelperLT(const char* expr1, const char* expr2, const T1& val1,
+  const T2& val2) {
+return 0;
+  }
+  }  // namespace internal
+  }  // namespace testing
+)cc";
+
+static std::string wrapGtest(llvm::StringRef Input) {
+  return (GtestMockDecls + Input).str();
+}
+
+TEST(GtestAssertTest, ShouldMatchAssert) {
+  std::string Input = R"cc(
+void Test() { ASSERT_EQ(1010, 4321); }
+  )cc";
+  EXPECT_TRUE(matches(wrapGtest(Input),
+  gtestAssert(GtestCmp::Eq, integerLiteral(equals(1010)),
+  integerLiteral(equals(4321);
+}
+
+TEST(GtestAssertTest, ShouldNotMatchExpect) {
+  std::string Input = R"cc(
+void Test() { EXPECT_EQ(2, 3); }
+  )cc";
+  EXPECT_TRUE(
+  notMatches(wrapGtest(Input), gtestAssert(GtestCmp::E

[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-21 Thread Rong Xu via Phabricator via cfe-commits
xur updated this revision to Diff 245891.
xur added reviewers: mehdi_amini, serge-sans-paille.
xur added a comment.

Update the patch based on the reviews from Mehdi and Serge.
Reuse Sege's warning code in https://reviews.llvm.org/D74871?id=245594.


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

https://reviews.llvm.org/D74878

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/PR44896.ll


Index: clang/test/CodeGen/PR44896.ll
===
--- /dev/null
+++ clang/test/CodeGen/PR44896.ll
@@ -0,0 +1,13 @@
+; RUN: %clang -fdiscard-value-names -S %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: %clang_cc1 -S -emit-llvm %s -discard-value-names -o /dev/null
+; PR 44896
+
+; CHECK: ignoring -fdiscard-value-names for LLVM Bitcode
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64--linux-gnu"
+
+define linkonce i8* @b(i8* %a) {
+  ret i8* %a
+}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4332,8 +4332,15 @@
 
   // Discard value names in assert builds unless otherwise specified.
   if (Args.hasFlag(options::OPT_fdiscard_value_names,
-   options::OPT_fno_discard_value_names, !IsAssertBuild))
+   options::OPT_fno_discard_value_names, !IsAssertBuild)) {
+if (std::any_of(Inputs.begin(), Inputs.end(),
+[](const clang::driver::InputInfo &II) {
+  return types::isLLVMIR(II.getType());
+})) {
+  D.Diag(diag::warn_ignoring_fdiscard_for_bitcode);
+}
 CmdArgs.push_back("-discard-value-names");
+  }
 
   // Set the main file name, so that debug info works even with
   // -save-temps.
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1146,6 +1146,9 @@
CI.getTargetOpts(), CI.getLangOpts(),
CI.getFrontendOpts().ShowTimers,
std::move(LinkModules), *VMContext, nullptr);
+// PR44896: Force DiscardValueNames as false. DiscardValueNames cannot be
+// true here because the valued names are needed for reading textual IR.
+Ctx.setDiscardValueNames(false);
 Ctx.setDiagnosticHandler(
 std::make_unique(CodeGenOpts, &Result));
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -271,6 +271,9 @@
   InGroup;
 def warn_c_kext : Warning<
   "ignoring -fapple-kext which is valid for C++ and Objective-C++ only">;
+def warn_ignoring_fdiscard_for_bitcode : Warning<
+  "ignoring -fdiscard-value-names for LLVM Bitcode">,
+  InGroup;
 def warn_drv_input_file_unused : Warning<
   "%0: '%1' input unused%select{ when '%3' is present|}2">,
   InGroup;


Index: clang/test/CodeGen/PR44896.ll
===
--- /dev/null
+++ clang/test/CodeGen/PR44896.ll
@@ -0,0 +1,13 @@
+; RUN: %clang -fdiscard-value-names -S %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: %clang_cc1 -S -emit-llvm %s -discard-value-names -o /dev/null
+; PR 44896
+
+; CHECK: ignoring -fdiscard-value-names for LLVM Bitcode
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64--linux-gnu"
+
+define linkonce i8* @b(i8* %a) {
+  ret i8* %a
+}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4332,8 +4332,15 @@
 
   // Discard value names in assert builds unless otherwise specified.
   if (Args.hasFlag(options::OPT_fdiscard_value_names,
-   options::OPT_fno_discard_value_names, !IsAssertBuild))
+   options::OPT_fno_discard_value_names, !IsAssertBuild)) {
+if (std::any_of(Inputs.begin(), Inputs.end(),
+[](const clang::driver::InputInfo &II) {
+  return types::isLLVMIR(II.getType());
+})) {
+  D.Diag(diag::warn_ignoring_fdiscard_for_bitcode);
+}
 CmdArgs.push_back("-discard-value-names");
+  }
 
   // Set the main file name, so that debug info works even with
   // -save-temps.
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1146,6 +1146,9 @@

[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor clause.

2020-02-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15238
+  Sema &SemaRef;
+  OpenMPClauseKind CKind;
+  OMPClauseMappableExprCommon::MappableExprComponentList &Components;

Default initializer here



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15240
+  OMPClauseMappableExprCommon::MappableExprComponentList &Components;
+  bool NoDiagnose;
+  const Expr *RelevantExpr{nullptr};

Default initializer



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15241-15243
+  const Expr *RelevantExpr{nullptr};
+  bool AllowUnitySizeArraySection{true};
+  bool AllowWholeSizeArraySection{true};

Better to use ` = ;` here. Just a nit.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15258
+if (!isa(DRE->getDecl()))
+  return false;
+RelevantExpr = DRE;

`emitErrorMsg()` here?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15266
+  bool VisitMemberExpr(MemberExpr *ME) {
+Expr *E = cast(ME);
+Expr *BaseE = ME->getBase()->IgnoreParenImpCasts();

No need `cast` here.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15267
+Expr *E = cast(ME);
+Expr *BaseE = ME->getBase()->IgnoreParenImpCasts();
 

Better to use `IgnoreParenCasts()` to handle explicit casting to the base class.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15283
+return false;
+  return Visit(E->IgnoreParenImpCasts());;
+}

cchen wrote:
> @ABataev, in the previous patch you mentioned that we don't need 
> `IgnoreParenImpCasts()` here, but I think I was just trying to do what line 
> 15232 did.
Just `Visit(E)`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15299
+return false;
+  return Visit(E->IgnoreParenImpCasts());;
+}

Just `Visit(E)`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15317
   }
+  return Visit(E->IgnoreParenImpCasts());;
+}

Just `Visit(E)`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15332
+Components.emplace_back(ME, FD);
+return RelevantExpr || Visit(E->IgnoreParenImpCasts());
+  }

Just `Visit(E)`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15344
   }
+  return Visit(E->IgnoreParenImpCasts());
+}

`Visit(E)`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15354
 
-  // Record the component.
-  CurComponents.emplace_back(CurE, FD);
-} else if (auto *CurE = dyn_cast(E)) {
-  E = CurE->getBase()->IgnoreParenImpCasts();
-
-  if (!E->getType()->isAnyPointerType() && !E->getType()->isArrayType()) {
-if (!NoDiagnose) {
-  SemaRef.Diag(ELoc, diag::err_omp_expected_base_var_name)
-  << 0 << CurE->getSourceRange();
-  return nullptr;
+if (const auto *TE = dyn_cast(E)) {
+  Expr::EvalResult Result;

`E->IgnoreParensCasts()`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15356
+  Expr::EvalResult Result;
+  if (AE->getIdx()->EvaluateAsInt(Result, SemaRef.getASTContext())) {
+if (!Result.Val.getInt().isNullValue()) {

Need to check that `AE->getIdx()` is not value dependent, otherwise it may crash



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15370
 
-  if (const auto *TE = dyn_cast(E)) {
-Expr::EvalResult Result;
-if (CurE->getIdx()->EvaluateAsInt(Result, SemaRef.getASTContext())) {
-  if (!Result.Val.getInt().isNullValue()) {
-SemaRef.Diag(CurE->getIdx()->getExprLoc(),
- diag::err_omp_invalid_map_this_expr);
-SemaRef.Diag(CurE->getIdx()->getExprLoc(),
- diag::note_omp_invalid_subscript_on_this_ptr_map);
-  }
-}
-RelevantExpr = TE;
-  }
-
-  // Record the component - we don't have any declaration associated.
-  CurComponents.emplace_back(CurE, nullptr);
-} else if (auto *CurE = dyn_cast(E)) {
-  assert(!NoDiagnose && "Array sections cannot be implicitly mapped.");
-  E = CurE->getBase()->IgnoreParenImpCasts();
+return E && Visit(E->IgnoreParenImpCasts());
+  }

Just `Visit(E)`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15419-15428
+  if (OASE->getLength()->EvaluateAsInt(ResultR,
+   SemaRef.getASTContext())) {
+if (!ResultR.Val.getInt().isOneValue()) {
+  SemaRef.Diag(OASE->getLength()->getExprLoc(),
+   diag::err_omp_invalid_map_this_expr);
+  SemaRef.Diag(OASE->getLength()->getExprLoc(),
+   diag::note_omp_invalid_length_on_this_ptr_mapping);

Also, need to be sure that the expressions here are not value-dependent.



Comment at: clang/lib/

[PATCH] D69782: Summary: Instead of dropping all the ranges associated with a Diagnostic when converting them to a ClangTidy error, instead attach them to the ClangTidyError, so they can be consumed b

2020-02-21 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.

LG. Thanks!

Do you have commit rights or should someone help you committing the patch?


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

https://reviews.llvm.org/D69782



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


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-02-21 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked an inline comment as done.
zoecarver added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:1834
+case CK_Tigerlake:
+case CK_Lakemont:
+

craig.topper wrote:
> zoecarver wrote:
> > craig.topper wrote:
> > > I think Lakemont is 16 bytes. Assuming I'm interpretting the CLFLUSH line 
> > > size from this CPUID dump correctly 
> > > https://github.com/InstLatx64/InstLatx64/blob/master/GenuineIntel/GenuineIntel590_Lakemont_CPUID2.txt
> > >  
> > I may very well be interpreting this incorrectly but I think that the cache 
> > line sizes are at `eax = 0x8005` and `eax = 0x8006`. However, all 
> > the registers at those codes are zero. If I instead look at `eax = 
> > 0x0001` (which I think is incorrect), `ecx = 00010200` which would be 
> > 128 bytes (maybe this is where the 16 came from, if they were bits 
> > instead?). How were you interpreting it?
> Interpreted bits 15:8 of the ecx = 00010200 to be the clflush information. 
> The spec for cpuid says to multiply by 8 to get cache line size. So 15:8 is 
> 2, multiply by 8 is 16 bytes.
> 
> I think Lakemont is based on the 486 architecture so that seems possible.
I see. That looks correct. I'll update it.

Still, I do find it strange that all registers at `eax = 0x8006` are zeroed 
out. Using the `cpuid` instruction on my cpu I get the following:
```
CPUID 0: 13 71 110 105
CPUID 1: 97 0 191 255
CPUID 2: 1 255 0 0
CPUID 8000: 8 0 0 0
CPUID 8001: 0 0 33 0
CPUID 8002: 73 108 32 101
CPUID 8003: 41 45 48 67
CPUID 8004: 64 50 122 0
CPUID 8005: 0 0 0 0
CPUID 8006: 0 0 64 0
CPUID 8007: 0 0 0 0
CPUID 8008: 39 0 0 0
```
I know my L2 cache line size is 64 and the L2 cache line size should be `ecx` 
at `eax = 0x8006` which would be `64`. But, when I read the dump you linked 
to, it doesn't look like there's any data at `0x8006`.

Anyway, as I said above, I'll look past this and update it based on the clflush 
information. That seems valid. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74918



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


[PATCH] D74912: [AArch64][SVE] Add SVE2 intrinsics for bit permutation & table lookup

2020-02-21 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp:1226
+  // intrinsic currently, where NumVecs is always 2
+  unsigned NumVecs = 2;
+

nit: You can just as well inline this value now.



Comment at: llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp:1229
+  // Form a REG_SEQUENCE to force register allocation.
+  SmallVector Regs(N->op_begin() + 1, N->op_begin() + 1 + NumVecs);
+  SDValue RegSeq = createZTuple(Regs);

nit: given that we know NumVecs == 2, you can write `SmallVector`.
nit: How about `N->ops().slice(1, 2)` ?
https://llvm.org/doxygen/classllvm_1_1ArrayRef.html#ace7bdce94e806bb8870626657630dab0



Comment at: llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp:1235
+  Ops.push_back(N->getOperand(NumVecs + 1));
+  ReplaceNode(N, CurDAG->getMachineNode(Opc, DL, VT, Ops));
+}

nit: Maybe just:
```ReplaceNode(N, CurDAG->getMachineNode(Opc, DL, VT, { RegSeq, 
N->getOperand(NumVecs + 1) });```



Comment at: llvm/test/CodeGen/AArch64/sve2-intrinsics-perm-tb.ll:9
+; CHECK-LABEL: tbl2_b:
+; CHECK: tbl z0.b, { z0.b, z1.b }, z2.b
+; CHECK-NEXT: ret

We should test this with operands that are not already consecutive. `%a` and 
`%b` will come in as `z0` and `z1` by definition of the calling convention.
By adding a `%dummy` in between `%a` and `%b`, you can check that a `mov` is 
inserted to ensure both registers are consecutive.


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

https://reviews.llvm.org/D74912



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


[PATCH] D69782: Summary: Instead of dropping all the ranges associated with a Diagnostic when converting them to a ClangTidy error, instead attach them to the ClangTidyError, so they can be consumed b

2020-02-21 Thread Joe Turner via Phabricator via cfe-commits
compositeprimes added a comment.

I don't have commit rights (this is my first llvm commit!), so could someone 
help out? Thanks!


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

https://reviews.llvm.org/D69782



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


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-02-21 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 245897.
zoecarver added a comment.

- Update getCPUCacheLineSize to return optional


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74918

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h

Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -182,6 +182,8 @@
   StringRef Name,
   llvm::SmallVectorImpl &Features) const override;
 
+  Optional getCPUCacheLineSize() const override;
+
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &info) const override;
 
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -1731,6 +1731,118 @@
   }
 }
 
+// Below is based on the following information:
+// ++-+--+
+// |   Processor Name   | Cache Line Size (Bytes) |Source|
+// ++-+--+
+// | i386   |  64 | https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf  |
+// | i486   |  16 | "four doublewords" (doubleword = 32 bits, 4 bits * 32 bits = 16 bytes) https://en.wikichip.org/w/images/d/d3/i486_MICROPROCESSOR_HARDWARE_REFERENCE_MANUAL_%281990%29.pdf and http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.126.4216&rep=rep1&type=pdf (page 29) |
+// | i586/Pentium MMX   |  32 | https://www.7-cpu.com/cpu/P-MMX.html |
+// | i686/Pentium   |  32 | https://www.7-cpu.com/cpu/P6.html|
+// | Netburst/Pentium4  |  64 | https://www.7-cpu.com/cpu/P4-180.html|
+// | Atom   |  64 | https://www.7-cpu.com/cpu/Atom.html  |
+// | Westmere   |  64 | https://en.wikichip.org/wiki/intel/microarchitectures/sandy_bridge_(client) "Cache Architecture" |
+// | Sandy Bridge   |  64 | https://en.wikipedia.org/wiki/Sandy_Bridge and https://www.7-cpu.com/cpu/SandyBridge.html|
+// | Ivy Bridge |  64 | https://blog.stuffedcow.net/2013/01/ivb-cache-replacement/ and https://www.7-cpu.com/cpu/IvyBridge.html  |
+// | Haswell|  64 | https://www.7-cpu.com/cpu/Haswell.html   |
+// | Bradwell   |  64 | https://www.7-cpu.com/cpu/Broadwell.html |
+// | Skylake (including skylake-avx512) |  64 | https://www.nas.nasa.gov/hecc/support/kb/skylake-processors_550.html "Cache Hierarchy"   |
+// | Cascade Lake   |  64 | https://www.nas.nasa.gov/hecc/support/kb/cascade-lake-processors_579.html "Cache Hierarchy"  |
+// | Skylake|  64 | https://en.wikichip.org/wiki/intel/microarchitectures/kaby_lake "Memory H

[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-02-21 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 245896.
zoecarver marked 6 inline comments as done.
zoecarver added a comment.

- Update values returned by getCPUCacheLineSize based on review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74918

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h

Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -182,6 +182,8 @@
   StringRef Name,
   llvm::SmallVectorImpl &Features) const override;
 
+  unsigned getCPUCacheLineSize() const override;
+
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &info) const override;
 
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -1731,6 +1731,118 @@
   }
 }
 
+// Below is based on the following information:
+// ++-+--+
+// |   Processor Name   | Cache Line Size (Bytes) |Source|
+// ++-+--+
+// | i386   |  64 | https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf  |
+// | i486   |  16 | "four doublewords" (doubleword = 32 bits, 4 bits * 32 bits = 16 bytes) https://en.wikichip.org/w/images/d/d3/i486_MICROPROCESSOR_HARDWARE_REFERENCE_MANUAL_%281990%29.pdf and http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.126.4216&rep=rep1&type=pdf (page 29) |
+// | i586/Pentium MMX   |  32 | https://www.7-cpu.com/cpu/P-MMX.html |
+// | i686/Pentium   |  32 | https://www.7-cpu.com/cpu/P6.html|
+// | Netburst/Pentium4  |  64 | https://www.7-cpu.com/cpu/P4-180.html|
+// | Atom   |  64 | https://www.7-cpu.com/cpu/Atom.html  |
+// | Westmere   |  64 | https://en.wikichip.org/wiki/intel/microarchitectures/sandy_bridge_(client) "Cache Architecture" |
+// | Sandy Bridge   |  64 | https://en.wikipedia.org/wiki/Sandy_Bridge and https://www.7-cpu.com/cpu/SandyBridge.html|
+// | Ivy Bridge |  64 | https://blog.stuffedcow.net/2013/01/ivb-cache-replacement/ and https://www.7-cpu.com/cpu/IvyBridge.html  |
+// | Haswell|  64 | https://www.7-cpu.com/cpu/Haswell.html   |
+// | Bradwell   |  64 | https://www.7-cpu.com/cpu/Broadwell.html |
+// | Skylake (including skylake-avx512) |  64 | https://www.nas.nasa.gov/hecc/support/kb/skylake-processors_550.html "Cache Hierarchy"   |
+// | Cascade Lake   |  64 | https://www.nas.nasa.gov/hecc/support/kb/cascade-lake-processors_579.html "Cache Hierarchy"  |
+// | Skylake|  64 | http

[PATCH] D74015: [AIX][Frontend] C++ ABI customizations for AIX boilerplate

2020-02-21 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added a comment.

Just kindly reminder that you might want to update the Summary in the commit 
message to reflect the new name we picked.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74015



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


[clang] e4df934 - [Clang interpreter] Rename Block.{h,cpp} to InterpBlock.{h,cpp}

2020-02-21 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-02-21T09:47:28-08:00
New Revision: e4df934ca7b408cfb52531016198545a8d50f41a

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

LOG: [Clang interpreter] Rename Block.{h,cpp} to InterpBlock.{h,cpp}

The Blocks runtime provide a header named Block.h.
It is generally preferable to avoid name collision with system headers
(reducing reliance on -isystem order, more friendly when navigating files in
an editor, etc).

Reviewed By: gribozavr2

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

Added: 
clang/lib/AST/Interp/InterpBlock.cpp
clang/lib/AST/Interp/InterpBlock.h

Modified: 
clang/lib/AST/CMakeLists.txt
clang/lib/AST/Interp/Pointer.cpp
clang/lib/AST/Interp/Pointer.h
llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn

Removed: 
clang/lib/AST/Interp/Block.cpp
clang/lib/AST/Interp/Block.h



diff  --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt
index a741ca5a80e1..da7b808e4f51 100644
--- a/clang/lib/AST/CMakeLists.txt
+++ b/clang/lib/AST/CMakeLists.txt
@@ -55,7 +55,6 @@ add_clang_library(clangAST
   ExternalASTSource.cpp
   FormatString.cpp
   InheritViz.cpp
-  Interp/Block.cpp
   Interp/ByteCodeEmitter.cpp
   Interp/ByteCodeExprGen.cpp
   Interp/ByteCodeGenError.cpp
@@ -67,6 +66,7 @@ add_clang_library(clangAST
   Interp/Frame.cpp
   Interp/Function.cpp
   Interp/Interp.cpp
+  Interp/InterpBlock.cpp
   Interp/InterpFrame.cpp
   Interp/InterpStack.cpp
   Interp/InterpState.cpp

diff  --git a/clang/lib/AST/Interp/Block.cpp 
b/clang/lib/AST/Interp/InterpBlock.cpp
similarity index 98%
rename from clang/lib/AST/Interp/Block.cpp
rename to clang/lib/AST/Interp/InterpBlock.cpp
index 5fc93eb39f4e..ed6e8910194d 100644
--- a/clang/lib/AST/Interp/Block.cpp
+++ b/clang/lib/AST/Interp/InterpBlock.cpp
@@ -10,7 +10,7 @@
 //
 
//===--===//
 
-#include "Block.h"
+#include "InterpBlock.h"
 #include "Pointer.h"
 
 using namespace clang;

diff  --git a/clang/lib/AST/Interp/Block.h b/clang/lib/AST/Interp/InterpBlock.h
similarity index 98%
rename from clang/lib/AST/Interp/Block.h
rename to clang/lib/AST/Interp/InterpBlock.h
index 97fb9a3ca096..0ccdef221c83 100644
--- a/clang/lib/AST/Interp/Block.h
+++ b/clang/lib/AST/Interp/InterpBlock.h
@@ -1,4 +1,4 @@
-//===--- Block.h - Allocated blocks for the interpreter -*- C++ 
-*-===//
+//===-- InterpBlock.h - Allocated blocks for the interpreter -*- C++ 
*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

diff  --git a/clang/lib/AST/Interp/Pointer.cpp 
b/clang/lib/AST/Interp/Pointer.cpp
index 1a10723aaca5..ef2638e2a36b 100644
--- a/clang/lib/AST/Interp/Pointer.cpp
+++ b/clang/lib/AST/Interp/Pointer.cpp
@@ -7,8 +7,8 @@
 
//===--===//
 
 #include "Pointer.h"
-#include "Block.h"
 #include "Function.h"
+#include "InterpBlock.h"
 #include "PrimType.h"
 
 using namespace clang;

diff  --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h
index b8fa98e24faa..f2f6e0e76018 100644
--- a/clang/lib/AST/Interp/Pointer.h
+++ b/clang/lib/AST/Interp/Pointer.h
@@ -13,12 +13,12 @@
 #ifndef LLVM_CLANG_AST_INTERP_POINTER_H
 #define LLVM_CLANG_AST_INTERP_POINTER_H
 
-#include "Block.h"
 #include "Descriptor.h"
+#include "InterpBlock.h"
+#include "clang/AST/ComparisonCategories.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/ComparisonCategories.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/Support/raw_ostream.h"
 

diff  --git a/llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn 
b/llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
index 671583755902..eb635fa453d8 100644
--- a/llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
@@ -81,7 +81,6 @@ static_library("AST") {
 "ExternalASTSource.cpp",
 "FormatString.cpp",
 "InheritViz.cpp",
-"Interp/Block.cpp",
 "Interp/ByteCodeEmitter.cpp",
 "Interp/ByteCodeExprGen.cpp",
 "Interp/ByteCodeGenError.cpp",
@@ -93,6 +92,7 @@ static_library("AST") {
 "Interp/Frame.cpp",
 "Interp/Function.cpp",
 "Interp/Interp.cpp",
+"Interp/InterpBlock.cpp",
 "Interp/InterpFrame.cpp",
 "Interp/InterpStack.cpp",
 "Interp/InterpState.cpp",



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


[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-02-21 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: NoQ, Szelethus, balazske, gamesh411, 
baloghadamsoftware, steakhal.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
Herald added a project: clang.
martong added a child revision: D73898: [analyzer] StdLibraryFunctionsChecker: 
Add argument constraints.

Currently, ValueRange is very hard to extend with new kind of constraints.
For instance, it forcibly encapsulates relations between arguments and the
return value (ComparesToArgument) besides handling the regular value
ranges (OutOfRange, WithinRange).
ValueRange in this form is not suitable to add new constraints on
arguments like "not-null".

This refactor introduces a new base class ValueConstraint with an
abstract apply function. Descendants must override this. There are 2
descendants: RangeConstraint and ComparisonConstraint. In the following
patches I am planning to add the NotNullConstraint, and additional
virtual functions like `negate()` and `warning()`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74973

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -71,14 +71,6 @@
   /// to us. If he doesn't, he performs additional invalidations.
   enum InvalidationKind { NoEvalCall, EvalCallAsPure };
 
-  /// A pair of ValueRangeKind and IntRangeVector would describe a range
-  /// imposed on a particular argument or return value symbol.
-  ///
-  /// Given a range, should the argument stay inside or outside this range?
-  /// The special `ComparesToArgument' value indicates that we should
-  /// impose a constraint that involves other argument or return value symbols.
-  enum ValueRangeKind { OutOfRange, WithinRange, ComparesToArgument };
-
   // The universal integral type to use in value range descriptions.
   // Unsigned to make sure overflows are well-defined.
   typedef uint64_t RangeInt;
@@ -93,44 +85,35 @@
   /// ArgNo in CallExpr and CallEvent is defined as Unsigned, but
   /// obviously uint32_t should be enough for all practical purposes.
   typedef uint32_t ArgNo;
-  static const ArgNo Ret = std::numeric_limits::max();
+  static const ArgNo Ret;
+
+  class ValueConstraint {
+  public:
+ValueConstraint(ArgNo ArgN) : ArgN(ArgN) {}
+virtual ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call,
+  const Summary &Summary) const = 0;
+ArgNo getArgNo() const { return ArgN; }
+
+  protected:
+ArgNo ArgN; // Argument to which we apply the constraint.
+  };
+
+  /// Given a range, should the argument stay inside or outside this range?
+  enum RangeKind { OutOfRange, WithinRange };
 
   /// Incapsulates a single range on a single symbol within a branch.
-  class ValueRange {
-ArgNo ArgN;  // Argument to which we apply the range.
-ValueRangeKind Kind; // Kind of range definition.
+  class RangeConstraint : public ValueConstraint {
+RangeKind Kind;  // Kind of range definition.
 IntRangeVector Args; // Polymorphic arguments.
 
   public:
-ValueRange(ArgNo ArgN, ValueRangeKind Kind, const IntRangeVector &Args)
-: ArgN(ArgN), Kind(Kind), Args(Args) {}
-
-ArgNo getArgNo() const { return ArgN; }
-ValueRangeKind getKind() const { return Kind; }
-
-BinaryOperator::Opcode getOpcode() const {
-  assert(Kind == ComparesToArgument);
-  assert(Args.size() == 1);
-  BinaryOperator::Opcode Op =
-  static_cast(Args[0].first);
-  assert(BinaryOperator::isComparisonOp(Op) &&
- "Only comparison ops are supported for ComparesToArgument");
-  return Op;
-}
-
-ArgNo getOtherArgNo() const {
-  assert(Kind == ComparesToArgument);
-  assert(Args.size() == 1);
-  return static_cast(Args[0].second);
-}
+RangeConstraint(ArgNo ArgN, RangeKind Kind, const IntRangeVector &Args)
+: ValueConstraint(ArgN), Kind(Kind), Args(Args) {}
 
 const IntRangeVector &getRanges() const {
-  assert(Kind != ComparesToArgument);
   return Args;
 }
 
-// We avoid creating a virtual apply() method because
-// it makes initializer lists harder to write.
   private:
 ProgramStateRef applyAsOutOfRange(ProgramStateRef State,
   const CallEvent &Call,
@@ -138,30 +121,39 @@
 ProgramStateRef applyAsWithinRange(ProgramStateRef State,
const CallEvent &Call,
const Summary &Summary) const;
-ProgramStateRef applyAsComparesToArgument(ProgramStateRef State,
-  const CallEvent

[PATCH] D74934: [Clang interpreter] Rename Block.{h,cpp} to InterpBlock.{h,cpp}

2020-02-21 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe4df934ca7b4: [Clang interpreter] Rename Block.{h,cpp} to 
InterpBlock.{h,cpp} (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74934

Files:
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Interp/Block.cpp
  clang/lib/AST/Interp/Block.h
  clang/lib/AST/Interp/InterpBlock.cpp
  clang/lib/AST/Interp/InterpBlock.h
  clang/lib/AST/Interp/Pointer.cpp
  clang/lib/AST/Interp/Pointer.h
  llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn


Index: llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
@@ -81,7 +81,6 @@
 "ExternalASTSource.cpp",
 "FormatString.cpp",
 "InheritViz.cpp",
-"Interp/Block.cpp",
 "Interp/ByteCodeEmitter.cpp",
 "Interp/ByteCodeExprGen.cpp",
 "Interp/ByteCodeGenError.cpp",
@@ -93,6 +92,7 @@
 "Interp/Frame.cpp",
 "Interp/Function.cpp",
 "Interp/Interp.cpp",
+"Interp/InterpBlock.cpp",
 "Interp/InterpFrame.cpp",
 "Interp/InterpStack.cpp",
 "Interp/InterpState.cpp",
Index: clang/lib/AST/Interp/Pointer.h
===
--- clang/lib/AST/Interp/Pointer.h
+++ clang/lib/AST/Interp/Pointer.h
@@ -13,12 +13,12 @@
 #ifndef LLVM_CLANG_AST_INTERP_POINTER_H
 #define LLVM_CLANG_AST_INTERP_POINTER_H
 
-#include "Block.h"
 #include "Descriptor.h"
+#include "InterpBlock.h"
+#include "clang/AST/ComparisonCategories.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/ComparisonCategories.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/Support/raw_ostream.h"
 
Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -7,8 +7,8 @@
 
//===--===//
 
 #include "Pointer.h"
-#include "Block.h"
 #include "Function.h"
+#include "InterpBlock.h"
 #include "PrimType.h"
 
 using namespace clang;
Index: clang/lib/AST/Interp/InterpBlock.h
===
--- clang/lib/AST/Interp/InterpBlock.h
+++ clang/lib/AST/Interp/InterpBlock.h
@@ -1,4 +1,4 @@
-//===--- Block.h - Allocated blocks for the interpreter -*- C++ 
-*-===//
+//===-- InterpBlock.h - Allocated blocks for the interpreter -*- C++ 
*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: clang/lib/AST/Interp/InterpBlock.cpp
===
--- clang/lib/AST/Interp/InterpBlock.cpp
+++ clang/lib/AST/Interp/InterpBlock.cpp
@@ -10,7 +10,7 @@
 //
 
//===--===//
 
-#include "Block.h"
+#include "InterpBlock.h"
 #include "Pointer.h"
 
 using namespace clang;
Index: clang/lib/AST/CMakeLists.txt
===
--- clang/lib/AST/CMakeLists.txt
+++ clang/lib/AST/CMakeLists.txt
@@ -55,7 +55,6 @@
   ExternalASTSource.cpp
   FormatString.cpp
   InheritViz.cpp
-  Interp/Block.cpp
   Interp/ByteCodeEmitter.cpp
   Interp/ByteCodeExprGen.cpp
   Interp/ByteCodeGenError.cpp
@@ -67,6 +66,7 @@
   Interp/Frame.cpp
   Interp/Function.cpp
   Interp/Interp.cpp
+  Interp/InterpBlock.cpp
   Interp/InterpFrame.cpp
   Interp/InterpStack.cpp
   Interp/InterpState.cpp


Index: llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/AST/BUILD.gn
@@ -81,7 +81,6 @@
 "ExternalASTSource.cpp",
 "FormatString.cpp",
 "InheritViz.cpp",
-"Interp/Block.cpp",
 "Interp/ByteCodeEmitter.cpp",
 "Interp/ByteCodeExprGen.cpp",
 "Interp/ByteCodeGenError.cpp",
@@ -93,6 +92,7 @@
 "Interp/Frame.cpp",
 "Interp/Function.cpp",
 "Interp/Interp.cpp",
+"Interp/InterpBlock.cpp",
 "Interp/InterpFrame.cpp",
 "Interp/InterpStack.cpp",
 "Interp/InterpState.cpp",
Index: clang/lib/AST/Interp/Pointer.h
===
--- clang/lib/AST/Interp/Pointer.h
+++ clang/lib/AST/Interp/Pointer.h
@@ -13,12 +13,12 @@
 #ifndef LLVM_CLANG_AST_INTERP_POINTER_H
 #define LLVM_CLANG_AST_INTERP_POINTER_H
 
-#include "Block.h"
 #include "Descriptor.h"
+#include "InterpBlock.h"
+#include "clang/AST/ComparisonCategories.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/ComparisonCategories.h

[PATCH] D74833: [AArch64][SVE] Add intrinsics for SVE2 cryptographic instructions

2020-02-21 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74833



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


[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor clause.

2020-02-21 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15356
+  Expr::EvalResult Result;
+  if (AE->getIdx()->EvaluateAsInt(Result, SemaRef.getASTContext())) {
+if (!Result.Val.getInt().isNullValue()) {

ABataev wrote:
> Need to check that `AE->getIdx()` is not value dependent, otherwise it may 
> crash
It seems Clang would catch the error before we do the analysis:

```
orig.cpp:6:24: error: array subscript is not an integer
#pragma omp target map(a[b])
   ^ ~
orig.cpp:15:3: note: in instantiation of function template specialization 
'gg' requested here
  gg(a, c);
  ^
orig.cpp:8:5: error: array subscript is not an integer
a[b] = 10;
^ ~
2 errors generated.
```

Also, if we still need it, do we also check type dependent?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74970



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


[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-02-21 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:151
+
+  using ValueConstraintPtr = std::shared_ptr;
+  /// The complete list of constraints that defines a single branch.

Note here, we need a copyable, polymorphic and default initializable type 
(vector needs that). A raw pointer were good, however, we cannot default 
initialize that. unique_ptr makes the Summary class non-copyable, therefore not 
an option.
Releasing the copyablitly requirement would render the initialization of the 
Summary map infeasible.
Perhaps we could come up with a [[ https://www.youtube.com/watch?v=bIhUE5uUFOA 
| type erasure technique without inheritance ]] once we consider the shared_ptr 
as restriction, but for now that seems to be overkill.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74973



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


[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor clause.

2020-02-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15356
+  Expr::EvalResult Result;
+  if (AE->getIdx()->EvaluateAsInt(Result, SemaRef.getASTContext())) {
+if (!Result.Val.getInt().isNullValue()) {

cchen wrote:
> ABataev wrote:
> > Need to check that `AE->getIdx()` is not value dependent, otherwise it may 
> > crash
> It seems Clang would catch the error before we do the analysis:
> 
> ```
> orig.cpp:6:24: error: array subscript is not an integer
> #pragma omp target map(a[b])
>^ ~
> orig.cpp:15:3: note: in instantiation of function template specialization 
> 'gg' requested here
>   gg(a, c);
>   ^
> orig.cpp:8:5: error: array subscript is not an integer
> a[b] = 10;
> ^ ~
> 2 errors generated.
> ```
> 
> Also, if we still need it, do we also check type dependent?
1. Yes, it will find incorrect expression at the instantiation. But what if 
you're working with the template? In this case, the expression can be 
value-dependent.
2. No, no need to check for type-dependence here, a check for value-dependent 
expression should be enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74970



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


[PATCH] D66178: Remove std::shared_ptr::make_shared and std::shared_ptr::allocate_shared

2020-02-21 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 245908.
zoecarver added a comment.

- Remove std::shared_ptr::allocate_shared


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66178

Files:
  libcxx/include/memory


Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3863,11 +3863,6 @@
 return __r;
 }
 
-template
-static
-shared_ptr<_Tp>
-allocate_shared(const _Alloc& __a, _Args&& ...__args);
-
 private:
 template ::value>
 struct __shared_ptr_default_allocator
@@ -4180,26 +4175,6 @@
 __r.release();
 }
 
-template
-template
-shared_ptr<_Tp>
-shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
-{
-static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct 
object in allocate_shared" );
-typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
-typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
-typedef __allocator_destructor<_A2> _D2;
-_A2 __a2(__a);
-unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
-::new(static_cast(_VSTD::addressof(*__hold2.get(
-_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
-shared_ptr<_Tp> __r;
-__r.__ptr_ = __hold2.get()->get();
-__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
-__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
-return __r;
-}
-
 template
 shared_ptr<_Tp>::~shared_ptr()
 {
@@ -4412,7 +4387,22 @@
 >::type
 allocate_shared(const _Alloc& __a, _Args&& ...__args)
 {
-return shared_ptr<_Tp>::allocate_shared(__a, 
_VSTD::forward<_Args>(__args)...);
+static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct 
object in allocate_shared");
+
+typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
+typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
+typedef __allocator_destructor<_A2> _D2;
+
+_A2 __a2(__a);
+unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
+::new(static_cast(_VSTD::addressof(*__hold2.get(
+_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
+
+shared_ptr<_Tp> __r;
+__r.__ptr_ = __hold2.get()->get();
+__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
+__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
+return __r;
 }
 
 template


Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3863,11 +3863,6 @@
 return __r;
 }
 
-template
-static
-shared_ptr<_Tp>
-allocate_shared(const _Alloc& __a, _Args&& ...__args);
-
 private:
 template ::value>
 struct __shared_ptr_default_allocator
@@ -4180,26 +4175,6 @@
 __r.release();
 }
 
-template
-template
-shared_ptr<_Tp>
-shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
-{
-static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared" );
-typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
-typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
-typedef __allocator_destructor<_A2> _D2;
-_A2 __a2(__a);
-unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
-::new(static_cast(_VSTD::addressof(*__hold2.get(
-_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
-shared_ptr<_Tp> __r;
-__r.__ptr_ = __hold2.get()->get();
-__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
-__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
-return __r;
-}
-
 template
 shared_ptr<_Tp>::~shared_ptr()
 {
@@ -4412,7 +4387,22 @@
 >::type
 allocate_shared(const _Alloc& __a, _Args&& ...__args)
 {
-return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...);
+static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared");
+
+typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
+typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
+typedef __allocator_destructor<_A2> _D2;
+
+_A2 __a2(__a);
+unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
+::new(static_cast(_VSTD::addressof(*__hold2.get(
+_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
+
+shared_ptr<_Tp> __r;
+__r.__ptr_ = __hold2.get()->get();
+__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
+__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
+return __r;
 }
 
 template
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74847: [CodeGen][RISCV] Fix clang/test/CodeGen/atomic_ops.c for RISC-V

2020-02-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74847



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


[PATCH] D66178: Remove std::shared_ptr::make_shared and std::shared_ptr::allocate_shared

2020-02-21 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 245907.
zoecarver edited the summary of this revision.
zoecarver added a comment.
Herald added projects: clang, libc++.
Herald added a subscriber: cfe-commits.

- Remove std::shared_ptr::allocate_shared


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66178

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  libcxx/include/memory

Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3863,11 +3863,6 @@
 return __r;
 }
 
-template
-static
-shared_ptr<_Tp>
-allocate_shared(const _Alloc& __a, _Args&& ...__args);
-
 private:
 template ::value>
 struct __shared_ptr_default_allocator
@@ -4180,26 +4175,6 @@
 __r.release();
 }
 
-template
-template
-shared_ptr<_Tp>
-shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
-{
-static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared" );
-typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
-typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
-typedef __allocator_destructor<_A2> _D2;
-_A2 __a2(__a);
-unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
-::new(static_cast(_VSTD::addressof(*__hold2.get(
-_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
-shared_ptr<_Tp> __r;
-__r.__ptr_ = __hold2.get()->get();
-__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
-__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
-return __r;
-}
-
 template
 shared_ptr<_Tp>::~shared_ptr()
 {
@@ -4412,7 +4387,22 @@
 >::type
 allocate_shared(const _Alloc& __a, _Args&& ...__args)
 {
-return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...);
+static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared");
+
+typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
+typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
+typedef __allocator_destructor<_A2> _D2;
+
+_A2 __a2(__a);
+unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
+::new(static_cast(_VSTD::addressof(*__hold2.get(
+_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
+
+shared_ptr<_Tp> __r;
+__r.__ptr_ = __hold2.get()->get();
+__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
+__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
+return __r;
 }
 
 template
Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -182,6 +182,8 @@
   StringRef Name,
   llvm::SmallVectorImpl &Features) const override;
 
+  Optional getCPUCacheLineSize() const override;
+
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &info) const override;
 
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -1731,6 +1731,118 @@
   }
 }
 
+// Below is based on the following information:
+// ++-+--+
+// |   Processor Name   | Cache Line Size (Bytes) |Source|
+// ++-+--+
+// | i386   |  64 | https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf  |
+// | i486   |  16 | "four doublewords" (doubleword = 32 bits, 4 bits * 32 bits = 16 bytes) https://en.wikichip.org/w/images/d/d3/i486_MICROPROCESSOR_HARDWARE_REFERENCE_MANUAL_%281990%29.pdf and http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.126.4216&rep=rep1&type=pdf (page 29) |
+// | i586/Pentium MMX   |  32 | https://www.7-cpu.com/cpu/P-MMX.html |
+// | i686/Pentium   |  32 | https://www.7-cp

[PATCH] D74912: [AArch64][SVE] Add SVE2 intrinsics for bit permutation & table lookup

2020-02-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp:1220
 
+void AArch64DAGToDAGISel::SelectTableSVE2(SDNode *N, unsigned Opc) {
+  SDLoc DL(N);

Is it possible to write this as a TableGen pattern?  We manage for other 
variants of tbl (for example, 
https://github.com/llvm/llvm-project/blob/bc7b26c333f51b4b534abb81d597c0b86123718c/llvm/lib/Target/ARM/ARMInstrNEON.td#L7059
 ).


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

https://reviews.llvm.org/D74912



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


[PATCH] D68887: [clang-tidy] Copy the Ranges field from the Diagnostic when creating the ClangTidyError

2020-02-21 Thread Joe Turner via Phabricator via cfe-commits
compositeprimes updated this revision to Diff 245915.
compositeprimes edited the summary of this revision.

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

https://reviews.llvm.org/D68887

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp


Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -62,6 +62,9 @@
 }
 assert(Error.Message.Message.empty() && "Overwriting a diagnostic 
message");
 Error.Message = TidyMessage;
+for (const CharSourceRange &SourceRange : Ranges) {
+  Error.Ranges.emplace_back(Loc.getManager(), SourceRange);
+}
   }
 
   void emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,


Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -62,6 +62,9 @@
 }
 assert(Error.Message.Message.empty() && "Overwriting a diagnostic message");
 Error.Message = TidyMessage;
+for (const CharSourceRange &SourceRange : Ranges) {
+  Error.Ranges.emplace_back(Loc.getManager(), SourceRange);
+}
   }
 
   void emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor class.

2020-02-21 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 245912.
cchen added a comment.

Fix based on feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74970

Files:
  clang/lib/Sema/SemaOpenMP.cpp

Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15197,256 +15197,289 @@
   return ConstLength.getSExtValue() != 1;
 }
 
-// Return the expression of the base of the mappable expression or null if it
-// cannot be determined and do all the necessary checks to see if the expression
-// is valid as a standalone mappable expression. In the process, record all the
-// components of the expression.
-static const Expr *checkMapClauseExpressionBase(
-Sema &SemaRef, Expr *E,
-OMPClauseMappableExprCommon::MappableExprComponentList &CurComponents,
-OpenMPClauseKind CKind, bool NoDiagnose) {
-  SourceLocation ELoc = E->getExprLoc();
-  SourceRange ERange = E->getSourceRange();
-
-  // The base of elements of list in a map clause have to be either:
-  //  - a reference to variable or field.
-  //  - a member expression.
-  //  - an array expression.
-  //
-  // E.g. if we have the expression 'r.S.Arr[:12]', we want to retrieve the
-  // reference to 'r'.
-  //
-  // If we have:
-  //
-  // struct SS {
-  //   Bla S;
-  //   foo() {
-  // #pragma omp target map (S.Arr[:12]);
-  //   }
-  // }
-  //
-  // We want to retrieve the member expression 'this->S';
+// The base of elements of list in a map clause have to be either:
+//  - a reference to variable or field.
+//  - a member expression.
+//  - an array expression.
+//
+// E.g. if we have the expression 'r.S.Arr[:12]', we want to retrieve the
+// reference to 'r'.
+//
+// If we have:
+//
+// struct SS {
+//   Bla S;
+//   foo() {
+// #pragma omp target map (S.Arr[:12]);
+//   }
+// }
+//
+// We want to retrieve the member expression 'this->S';
 
+// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2]
+//  If a list item is an array section, it must specify contiguous storage.
+//
+// For this restriction it is sufficient that we make sure only references
+// to variables or fields and array expressions, and that no array sections
+// exist except in the rightmost expression (unless they cover the whole
+// dimension of the array). E.g. these would be invalid:
+//
+//   r.ArrS[3:5].Arr[6:7]
+//
+//   r.ArrS[3:5].x
+//
+// but these would be valid:
+//   r.ArrS[3].Arr[6:7]
+//
+//   r.ArrS[3].x
+namespace {
+class MapBaseChecker final : public StmtVisitor {
+  Sema &SemaRef;
+  OpenMPClauseKind CKind = OMPC_unknown;
+  OMPClauseMappableExprCommon::MappableExprComponentList &Components;
+  bool NoDiagnose = false;
   const Expr *RelevantExpr = nullptr;
-
-  // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2]
-  //  If a list item is an array section, it must specify contiguous storage.
-  //
-  // For this restriction it is sufficient that we make sure only references
-  // to variables or fields and array expressions, and that no array sections
-  // exist except in the rightmost expression (unless they cover the whole
-  // dimension of the array). E.g. these would be invalid:
-  //
-  //   r.ArrS[3:5].Arr[6:7]
-  //
-  //   r.ArrS[3:5].x
-  //
-  // but these would be valid:
-  //   r.ArrS[3].Arr[6:7]
-  //
-  //   r.ArrS[3].x
-
   bool AllowUnitySizeArraySection = true;
   bool AllowWholeSizeArraySection = true;
+  SourceLocation ELoc;
+  SourceRange ERange;
 
-  while (!RelevantExpr) {
-E = E->IgnoreParenImpCasts();
-
-if (auto *CurE = dyn_cast(E)) {
-  if (!isa(CurE->getDecl()))
-return nullptr;
-
-  RelevantExpr = CurE;
+  void emitErrorMsg() {
+if (!NoDiagnose) {
+  // If nothing else worked, this is not a valid map clause expression.
+  SemaRef.Diag(ELoc, diag::err_omp_expected_named_var_member_or_array_expression)
+<< ERange;
+}
+  }
 
-  // If we got a reference to a declaration, we should not expect any array
-  // section before that.
-  AllowUnitySizeArraySection = false;
-  AllowWholeSizeArraySection = false;
+public:
+  bool VisitDeclRefExpr(DeclRefExpr *DRE) {
+if (!isa(DRE->getDecl())) {
+  emitErrorMsg();
+  return false;
+}
+RelevantExpr = DRE;
+// Record the component.
+Components.emplace_back(DRE, DRE->getDecl());
+return true;
+  }
 
-  // Record the component.
-  CurComponents.emplace_back(CurE, CurE->getDecl());
-} else if (auto *CurE = dyn_cast(E)) {
-  Expr *BaseE = CurE->getBase()->IgnoreParenImpCasts();
+  bool VisitMemberExpr(MemberExpr *ME) {
+Expr *E = ME;
+Expr *BaseE = ME->getBase()->IgnoreParenCasts();
 
-  if (isa(BaseE))
-// We found a base expression: this->Val.
-RelevantExpr = CurE;
-  else
-E = BaseE;
+if (isa(BaseE))
+  // We found a base expression: this-

[clang] 1723f21 - Fix MSVC "not all control paths return a value" warning. NFCI.

2020-02-21 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-02-21T18:23:55Z
New Revision: 1723f219939e1d4dc1c53ec7caf10c9380822b99

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

LOG: Fix MSVC "not all control paths return a value" warning. NFCI.

Added: 


Modified: 
clang/lib/ASTMatchers/GtestMatchers.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/GtestMatchers.cpp 
b/clang/lib/ASTMatchers/GtestMatchers.cpp
index 317bddd035f8..c99fdf6c0fcd 100644
--- a/clang/lib/ASTMatchers/GtestMatchers.cpp
+++ b/clang/lib/ASTMatchers/GtestMatchers.cpp
@@ -38,6 +38,7 @@ static DeclarationMatcher getComparisonDecl(GtestCmp Cmp) {
 case GtestCmp::Lt:
   return functionDecl(hasName("::testing::internal::CmpHelperLT"));
   }
+  llvm_unreachable("Unhandled GtestCmp enum");
 }
 
 static llvm::StringRef getAssertMacro(GtestCmp Cmp) {
@@ -55,6 +56,7 @@ static llvm::StringRef getAssertMacro(GtestCmp Cmp) {
 case GtestCmp::Lt:
   return "ASSERT_LT";
   }
+  llvm_unreachable("Unhandled GtestCmp enum");
 }
 
 static llvm::StringRef getExpectMacro(GtestCmp Cmp) {
@@ -72,6 +74,7 @@ static llvm::StringRef getExpectMacro(GtestCmp Cmp) {
 case GtestCmp::Lt:
   return "EXPECT_LT";
   }
+  llvm_unreachable("Unhandled GtestCmp enum");
 }
 
 // In general, AST matchers cannot match calls to macros. However, we can



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


[PATCH] D74734: [AArch64][SVE] Add the SVE dupq_lane intrinsic

2020-02-21 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:7495
+  // DUPQ can be used when idx is in range.
+  auto CIdx = dyn_cast(Idx128);
+  if (CIdx && (CIdx->getZExtValue() <= 3)) {

nit: `auto *CIdx`



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:7496
+  auto CIdx = dyn_cast(Idx128);
+  if (CIdx && (CIdx->getZExtValue() <= 3)) {
+auto CI = DAG.getTargetConstant(CIdx->getZExtValue(), DL, MVT::i64);

nit: can you replace `auto` in these cases with SDValue? (which I think this 
is?)



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:7506
+  //   index * 2))
+  auto Zero = DAG.getConstant(0, DL, MVT::i64);
+  auto One = DAG.getConstant(1, DL, MVT::i64);

nit: please move `Zero` down to its use below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74734



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


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-02-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:1834
+case CK_Tigerlake:
+case CK_Lakemont:
+

zoecarver wrote:
> craig.topper wrote:
> > zoecarver wrote:
> > > craig.topper wrote:
> > > > I think Lakemont is 16 bytes. Assuming I'm interpretting the CLFLUSH 
> > > > line size from this CPUID dump correctly 
> > > > https://github.com/InstLatx64/InstLatx64/blob/master/GenuineIntel/GenuineIntel590_Lakemont_CPUID2.txt
> > > >  
> > > I may very well be interpreting this incorrectly but I think that the 
> > > cache line sizes are at `eax = 0x8005` and `eax = 0x8006`. 
> > > However, all the registers at those codes are zero. If I instead look at 
> > > `eax = 0x0001` (which I think is incorrect), `ecx = 00010200` which 
> > > would be 128 bytes (maybe this is where the 16 came from, if they were 
> > > bits instead?). How were you interpreting it?
> > Interpreted bits 15:8 of the ecx = 00010200 to be the clflush information. 
> > The spec for cpuid says to multiply by 8 to get cache line size. So 15:8 is 
> > 2, multiply by 8 is 16 bytes.
> > 
> > I think Lakemont is based on the 486 architecture so that seems possible.
> I see. That looks correct. I'll update it.
> 
> Still, I do find it strange that all registers at `eax = 0x8006` are 
> zeroed out. Using the `cpuid` instruction on my cpu I get the following:
> ```
> CPUID 0: 13 71 110 105
> CPUID 1: 97 0 191 255
> CPUID 2: 1 255 0 0
> CPUID 8000: 8 0 0 0
> CPUID 8001: 0 0 33 0
> CPUID 8002: 73 108 32 101
> CPUID 8003: 41 45 48 67
> CPUID 8004: 64 50 122 0
> CPUID 8005: 0 0 0 0
> CPUID 8006: 0 0 64 0
> CPUID 8007: 0 0 0 0
> CPUID 8008: 39 0 0 0
> ```
> I know my L2 cache line size is 64 and the L2 cache line size should be `ecx` 
> at `eax = 0x8006` which would be `64`. But, when I read the dump you 
> linked to, it doesn't look like there's any data at `0x8006`.
> 
> Anyway, as I said above, I'll look past this and update it based on the 
> clflush information. That seems valid. 
Lakemont is a modernized version of a 486 which probably had none of the 
8000 leafs originally. My speculation is that they really wanted to support 
leaf 8008 so they just put zeros in the rest rather than add a lot of 
microcode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74918



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


[PATCH] D66178: Remove std::shared_ptr::make_shared and std::shared_ptr::allocate_shared

2020-02-21 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

@ldionne friendly ping. This patch now //only// removes 
`std::shared_ptr::allocate_shared`. Should be an easy change. And I think we 
fixed @phosek's issue by breaking `__hold2.get()->get()` into a variable so 
that compilers that parse args backwards still work here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66178



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


[PATCH] D66178: Remove std::shared_ptr::make_shared and std::shared_ptr::allocate_shared

2020-02-21 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 245918.
zoecarver added a comment.

- Use __create_with_control_block in allocate_shared


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66178

Files:
  libcxx/include/memory


Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3863,11 +3863,6 @@
 return __r;
 }
 
-template
-static
-shared_ptr<_Tp>
-allocate_shared(const _Alloc& __a, _Args&& ...__args);
-
 private:
 template ::value>
 struct __shared_ptr_default_allocator
@@ -4180,26 +4175,6 @@
 __r.release();
 }
 
-template
-template
-shared_ptr<_Tp>
-shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
-{
-static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct 
object in allocate_shared" );
-typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
-typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
-typedef __allocator_destructor<_A2> _D2;
-_A2 __a2(__a);
-unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
-::new(static_cast(_VSTD::addressof(*__hold2.get(
-_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
-shared_ptr<_Tp> __r;
-__r.__ptr_ = __hold2.get()->get();
-__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
-__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
-return __r;
-}
-
 template
 shared_ptr<_Tp>::~shared_ptr()
 {
@@ -4412,7 +4387,19 @@
 >::type
 allocate_shared(const _Alloc& __a, _Args&& ...__args)
 {
-return shared_ptr<_Tp>::allocate_shared(__a, 
_VSTD::forward<_Args>(__args)...);
+static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct 
object in allocate_shared");
+
+typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
+typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
+typedef __allocator_destructor<_A2> _D2;
+
+_A2 __a2(__a);
+unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
+::new(static_cast(_VSTD::addressof(*__hold2.get(
+_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
+
+typename shared_ptr<_Tp>::element_type *__p = __hold2.get()->get();
+return shared_ptr<_Tp>::__create_with_control_block(__p, 
_VSTD::addressof(*__hold2.release()));
 }
 
 template


Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3863,11 +3863,6 @@
 return __r;
 }
 
-template
-static
-shared_ptr<_Tp>
-allocate_shared(const _Alloc& __a, _Args&& ...__args);
-
 private:
 template ::value>
 struct __shared_ptr_default_allocator
@@ -4180,26 +4175,6 @@
 __r.release();
 }
 
-template
-template
-shared_ptr<_Tp>
-shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
-{
-static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared" );
-typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
-typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
-typedef __allocator_destructor<_A2> _D2;
-_A2 __a2(__a);
-unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
-::new(static_cast(_VSTD::addressof(*__hold2.get(
-_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
-shared_ptr<_Tp> __r;
-__r.__ptr_ = __hold2.get()->get();
-__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
-__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
-return __r;
-}
-
 template
 shared_ptr<_Tp>::~shared_ptr()
 {
@@ -4412,7 +4387,19 @@
 >::type
 allocate_shared(const _Alloc& __a, _Args&& ...__args)
 {
-return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...);
+static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared");
+
+typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
+typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
+typedef __allocator_destructor<_A2> _D2;
+
+_A2 __a2(__a);
+unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
+::new(static_cast(_VSTD::addressof(*__hold2.get(
+_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
+
+typename shared_ptr<_Tp>::element_type *__p = __hold2.get()->get();
+return shared_ptr<_Tp>::__create_with_control_block(__p, _VSTD::addressof(*__hold2.release()));
 }
 
 template
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-02-21 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked an inline comment as done.
zoecarver added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:1834
+case CK_Tigerlake:
+case CK_Lakemont:
+

craig.topper wrote:
> zoecarver wrote:
> > craig.topper wrote:
> > > zoecarver wrote:
> > > > craig.topper wrote:
> > > > > I think Lakemont is 16 bytes. Assuming I'm interpretting the CLFLUSH 
> > > > > line size from this CPUID dump correctly 
> > > > > https://github.com/InstLatx64/InstLatx64/blob/master/GenuineIntel/GenuineIntel590_Lakemont_CPUID2.txt
> > > > >  
> > > > I may very well be interpreting this incorrectly but I think that the 
> > > > cache line sizes are at `eax = 0x8005` and `eax = 0x8006`. 
> > > > However, all the registers at those codes are zero. If I instead look 
> > > > at `eax = 0x0001` (which I think is incorrect), `ecx = 00010200` 
> > > > which would be 128 bytes (maybe this is where the 16 came from, if they 
> > > > were bits instead?). How were you interpreting it?
> > > Interpreted bits 15:8 of the ecx = 00010200 to be the clflush 
> > > information. The spec for cpuid says to multiply by 8 to get cache line 
> > > size. So 15:8 is 2, multiply by 8 is 16 bytes.
> > > 
> > > I think Lakemont is based on the 486 architecture so that seems possible.
> > I see. That looks correct. I'll update it.
> > 
> > Still, I do find it strange that all registers at `eax = 0x8006` are 
> > zeroed out. Using the `cpuid` instruction on my cpu I get the following:
> > ```
> > CPUID 0: 13 71 110 105
> > CPUID 1: 97 0 191 255
> > CPUID 2: 1 255 0 0
> > CPUID 8000: 8 0 0 0
> > CPUID 8001: 0 0 33 0
> > CPUID 8002: 73 108 32 101
> > CPUID 8003: 41 45 48 67
> > CPUID 8004: 64 50 122 0
> > CPUID 8005: 0 0 0 0
> > CPUID 8006: 0 0 64 0
> > CPUID 8007: 0 0 0 0
> > CPUID 8008: 39 0 0 0
> > ```
> > I know my L2 cache line size is 64 and the L2 cache line size should be 
> > `ecx` at `eax = 0x8006` which would be `64`. But, when I read the dump 
> > you linked to, it doesn't look like there's any data at `0x8006`.
> > 
> > Anyway, as I said above, I'll look past this and update it based on the 
> > clflush information. That seems valid. 
> Lakemont is a modernized version of a 486 which probably had none of the 
> 8000 leafs originally. My speculation is that they really wanted to 
> support leaf 8008 so they just put zeros in the rest rather than add a 
> lot of microcode.
Alrighty, that makes sense. Thanks :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74918



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


[PATCH] D72579: Evaluate __{c11_,}atomic_is_lock_free to 0 (avoid libcall) if larger than MaxAtomicPromoteWidth

2020-02-21 Thread James Y Knight via Phabricator via cfe-commits
jyknight requested changes to this revision.
jyknight added a comment.
This revision now requires changes to proceed.

This isn't correct.

The atomic interface is designed to be forward-compatible with new CPUs that 
have wider atomic instructions. That clang has a MaxAtomicPromoteWidth value 
_at all_ is unfortunate, because it breaks this ability. We've locked ourselves 
into an unfortunate ABI here -- and what's worse, it's incompatible with GCC's 
ABI.

But, the MaxAtomicPromoteWidth value impactsaffects C11 _Atomic (and therefore 
libc++ std::atomic) variables' default alignment. But, the user can in any case 
specify additional alignment. For the __atomic_is_lock_free function, 
MaxAtomicPromoteWidth is irrelevant -- it can be used on variables of any size 
or alignment and needs to return correct answers, even on future CPUs.

It's not good that clang doesn't provide the ability to create a working 
libatomic, but the right answer is to fix that, not add hacks like this. I've 
started writing up a proposal on what we need to do there, but need to finish 
that up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72579



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


[PATCH] D74846: fix -fcodegen-modules code when used with PCH (PR44958)

2020-02-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a reviewer: rsmith.
aganea added a comment.

I've tested this patch and it solves our original issue.

Could anyone please take a look so that it can be landed & merged into 10.0?


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor class.

2020-02-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15319
   }
+  return Visit(E);
+}

`return RelevantExpr || Visit(E);`?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15346
   }
+  return Visit(E);
+}

`return RelevantExpr || Visit(E);`?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15358-15359
+  Expr::EvalResult Result;
+  if (AE->isValueDependent())
+return false;
+  if (AE->getIdx()->EvaluateAsInt(Result, SemaRef.getASTContext())) {

1. Need to check `AE->getIdx()`, not `AE`.
2. Why return `false` here? I would say, just skip the check.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15374
 
-  QualType CurType =
-  OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+return E && Visit(E);
+  }

`return RelevantExpr || Visit(E);`?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15423-15424
+  Expr::EvalResult ResultL;
+  if (OASE->isValueDependent())
+return false;
+  if (OASE->getLength()->EvaluateAsInt(ResultR,

1. Need to check `OASE->getLength()`, not `OASE`.
2. Why return `false` here? I would say, just skip the check.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15434
   }
-
-  // Record the component - we don't have any declaration associated.
-  CurComponents.emplace_back(CurE, nullptr);
-} else {
-  if (!NoDiagnose) {
-// If nothing else worked, this is not a valid map clause expression.
-SemaRef.Diag(
-ELoc, diag::err_omp_expected_named_var_member_or_array_expression)
-<< ERange;
+  if (OASE->getLowerBound() && OASE->getLowerBound()->EvaluateAsInt(
+  ResultL, SemaRef.getASTContext())) {

Need a check for value-dependent `OASE->getLowerBound()`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15448
+Components.emplace_back(OASE, nullptr);
+return RelevantExpr || Visit(E->IgnoreParenImpCasts());
   }

Just `Visit(E)`;



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15450
   }
+  bool VisitCXXThisExpr(CXXThisExpr *CTE) { return true; }
+  bool VisitStmt(Stmt *) {

Do you really need this function?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15467-15470
+// Return the expression of the base of the mappable expression or null if it
+// cannot be determined and do all the necessary checks to see if the 
expression
+// is valid as a standalone mappable expression. In the process, record all the
+// components of the expression.

Use `\\\` style of comment here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74970



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


[clang] 0781e93 - [CodeGen][RISCV] Fix clang/test/CodeGen/atomic_ops.c for RISC-V

2020-02-21 Thread Luís Marques via cfe-commits

Author: Luís Marques
Date: 2020-02-21T19:29:57Z
New Revision: 0781e93a6eaa71ec5d87be3bbd053067f7ee

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

LOG: [CodeGen][RISCV] Fix clang/test/CodeGen/atomic_ops.c for RISC-V

By default the RISC-V target doesn't have the atomics standard extension
enabled. The first RUN line in `clang/test/CodeGen/atomic_ops.c` didn't
specify a target triple, which meant that on RISC-V Linux hosts it would
target RISC-V, but because it used clang cc1 we didn't get the toolchain
driver functionality to automatically turn on the extensions implied by
the target triple (riscv64-linux includes atomics). This would cause the
test to fail on RISC-V hosts.

This patch changes the test to have RUN lines for two explicit targets,
one with native atomics and one without. To work around FileCheck
limitations and more accurately match the output, some tests now have
separate prefixes for the two cases.

Reviewers: jyknight, eli.friedman, lenary, efriedma
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D74847

Added: 


Modified: 
clang/test/CodeGen/atomic_ops.c

Removed: 




diff  --git a/clang/test/CodeGen/atomic_ops.c b/clang/test/CodeGen/atomic_ops.c
index a853ba9f739c..c1eb1d005dba 100644
--- a/clang/test/CodeGen/atomic_ops.c
+++ b/clang/test/CodeGen/atomic_ops.c
@@ -1,7 +1,7 @@
-// XFAIL: hexagon,sparc
-//(due to not having native load atomic support)
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64 -emit-llvm %s \
+// RUN:   -o - | FileCheck -check-prefixes=CHECK,NATIVE %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature -a -emit-llvm %s \
+// RUN:   -o - | FileCheck -check-prefixes=CHECK,LIBCALL %s
 
 void foo(int x)
 {
@@ -9,32 +9,47 @@ void foo(int x)
   _Atomic(short) j = 0;
   // Check that multiply / divides on atomics produce a cmpxchg loop
   i *= 2;
-  // CHECK: mul nsw i32
-  // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4,)}}
+  // NATIVE: mul nsw i32
+  // NATIVE: cmpxchg i32*
+  // LIBCALL: mul nsw i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 4,
   i /= 2;
-  // CHECK: sdiv i32
-  // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4, )}}
+  // NATIVE: sdiv i32
+  // NATIVE: cmpxchg i32*
+  // LIBCALL: sdiv i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 4,
   j /= x;
-  // CHECK: sdiv i32
-  // CHECK: {{(cmpxchg i16*|i1 @__atomic_compare_exchange\(i32 2, )}}
+  // NATIVE: sdiv i32
+  // NATIVE: cmpxchg i16*
+  // LIBCALL: sdiv i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 2,
 
 }
 
 extern _Atomic _Bool b;
 
 _Bool bar() {
-// CHECK-LABEL: @bar
-// CHECK: %[[load:.*]] = load atomic i8, i8* @b seq_cst
-// CHECK: %[[tobool:.*]] = trunc i8 %[[load]] to i1
-// CHECK: ret i1 %[[tobool]]
+// NATIVE-LABEL: @bar
+// NATIVE: %[[load:.*]] = load atomic i8, i8* @b seq_cst
+// NATIVE: %[[tobool:.*]] = trunc i8 %[[load]] to i1
+// NATIVE: ret i1 %[[tobool]]
+// LIBCALL-LABEL: @bar
+// LIBCALL: call void @__atomic_load(i32 1, i8* @b, i8* %atomic-temp, i32 5)
+// LIBCALL: %[[load:.*]] = load i8, i8* %atomic-temp
+// LIBCALL: %[[tobool:.*]] = trunc i8 %[[load]] to i1
+// LIBCALL: ret i1 %[[tobool]]
+
   return b;
 }
 
 extern _Atomic(_Complex int) x;
 
 void baz(int y) {
-// CHECK-LABEL: @baz
-// CHECK: {{store atomic|call void @__atomic_store}}
+// NATIVE-LABEL: @baz
+// NATIVE: store atomic
+// LIBCALL-LABEL: @baz
+// LIBCALL: call void @__atomic_store
+
   x += y;
 }
 
@@ -84,9 +99,11 @@ _Atomic(int) compound_and(_Atomic(int) in) {
 }
 
 _Atomic(int) compound_mul(_Atomic(int) in) {
-// CHECK-LABEL: @compound_mul
-// CHECK: cmpxchg i32* {{%.*}}, i32 {{%.*}}, i32 [[NEW:%.*]] seq_cst seq_cst
-// CHECK: ret i32 [[NEW]]
+// NATIVE-LABEL: @compound_mul
+// NATIVE: cmpxchg i32* {{%.*}}, i32 {{%.*}}, i32 [[NEW:%.*]] seq_cst seq_cst
+// NATIVE: ret i32 [[NEW]]
+// LIBCALL-LABEL: @compound_mul
+// LIBCALL: i1 @__atomic_compare_exchange(i32 4,
 
   return (in *= 5);
 }



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


[PATCH] D74847: [CodeGen][RISCV] Fix clang/test/CodeGen/atomic_ops.c for RISC-V

2020-02-21 Thread Luís Marques via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0781e93a6eaa: [CodeGen][RISCV] Fix 
clang/test/CodeGen/atomic_ops.c for RISC-V (authored by luismarques).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74847

Files:
  clang/test/CodeGen/atomic_ops.c


Index: clang/test/CodeGen/atomic_ops.c
===
--- clang/test/CodeGen/atomic_ops.c
+++ clang/test/CodeGen/atomic_ops.c
@@ -1,7 +1,7 @@
-// XFAIL: hexagon,sparc
-//(due to not having native load atomic support)
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64 -emit-llvm %s \
+// RUN:   -o - | FileCheck -check-prefixes=CHECK,NATIVE %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature -a -emit-llvm %s \
+// RUN:   -o - | FileCheck -check-prefixes=CHECK,LIBCALL %s
 
 void foo(int x)
 {
@@ -9,32 +9,47 @@
   _Atomic(short) j = 0;
   // Check that multiply / divides on atomics produce a cmpxchg loop
   i *= 2;
-  // CHECK: mul nsw i32
-  // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4,)}}
+  // NATIVE: mul nsw i32
+  // NATIVE: cmpxchg i32*
+  // LIBCALL: mul nsw i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 4,
   i /= 2;
-  // CHECK: sdiv i32
-  // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4, )}}
+  // NATIVE: sdiv i32
+  // NATIVE: cmpxchg i32*
+  // LIBCALL: sdiv i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 4,
   j /= x;
-  // CHECK: sdiv i32
-  // CHECK: {{(cmpxchg i16*|i1 @__atomic_compare_exchange\(i32 2, )}}
+  // NATIVE: sdiv i32
+  // NATIVE: cmpxchg i16*
+  // LIBCALL: sdiv i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 2,
 
 }
 
 extern _Atomic _Bool b;
 
 _Bool bar() {
-// CHECK-LABEL: @bar
-// CHECK: %[[load:.*]] = load atomic i8, i8* @b seq_cst
-// CHECK: %[[tobool:.*]] = trunc i8 %[[load]] to i1
-// CHECK: ret i1 %[[tobool]]
+// NATIVE-LABEL: @bar
+// NATIVE: %[[load:.*]] = load atomic i8, i8* @b seq_cst
+// NATIVE: %[[tobool:.*]] = trunc i8 %[[load]] to i1
+// NATIVE: ret i1 %[[tobool]]
+// LIBCALL-LABEL: @bar
+// LIBCALL: call void @__atomic_load(i32 1, i8* @b, i8* %atomic-temp, i32 5)
+// LIBCALL: %[[load:.*]] = load i8, i8* %atomic-temp
+// LIBCALL: %[[tobool:.*]] = trunc i8 %[[load]] to i1
+// LIBCALL: ret i1 %[[tobool]]
+
   return b;
 }
 
 extern _Atomic(_Complex int) x;
 
 void baz(int y) {
-// CHECK-LABEL: @baz
-// CHECK: {{store atomic|call void @__atomic_store}}
+// NATIVE-LABEL: @baz
+// NATIVE: store atomic
+// LIBCALL-LABEL: @baz
+// LIBCALL: call void @__atomic_store
+
   x += y;
 }
 
@@ -84,9 +99,11 @@
 }
 
 _Atomic(int) compound_mul(_Atomic(int) in) {
-// CHECK-LABEL: @compound_mul
-// CHECK: cmpxchg i32* {{%.*}}, i32 {{%.*}}, i32 [[NEW:%.*]] seq_cst seq_cst
-// CHECK: ret i32 [[NEW]]
+// NATIVE-LABEL: @compound_mul
+// NATIVE: cmpxchg i32* {{%.*}}, i32 {{%.*}}, i32 [[NEW:%.*]] seq_cst seq_cst
+// NATIVE: ret i32 [[NEW]]
+// LIBCALL-LABEL: @compound_mul
+// LIBCALL: i1 @__atomic_compare_exchange(i32 4,
 
   return (in *= 5);
 }


Index: clang/test/CodeGen/atomic_ops.c
===
--- clang/test/CodeGen/atomic_ops.c
+++ clang/test/CodeGen/atomic_ops.c
@@ -1,7 +1,7 @@
-// XFAIL: hexagon,sparc
-//(due to not having native load atomic support)
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64 -emit-llvm %s \
+// RUN:   -o - | FileCheck -check-prefixes=CHECK,NATIVE %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature -a -emit-llvm %s \
+// RUN:   -o - | FileCheck -check-prefixes=CHECK,LIBCALL %s
 
 void foo(int x)
 {
@@ -9,32 +9,47 @@
   _Atomic(short) j = 0;
   // Check that multiply / divides on atomics produce a cmpxchg loop
   i *= 2;
-  // CHECK: mul nsw i32
-  // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4,)}}
+  // NATIVE: mul nsw i32
+  // NATIVE: cmpxchg i32*
+  // LIBCALL: mul nsw i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 4,
   i /= 2;
-  // CHECK: sdiv i32
-  // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4, )}}
+  // NATIVE: sdiv i32
+  // NATIVE: cmpxchg i32*
+  // LIBCALL: sdiv i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 4,
   j /= x;
-  // CHECK: sdiv i32
-  // CHECK: {{(cmpxchg i16*|i1 @__atomic_compare_exchange\(i32 2, )}}
+  // NATIVE: sdiv i32
+  // NATIVE: cmpxchg i16*
+  // LIBCALL: sdiv i32
+  // LIBCALL: i1 @__atomic_compare_exchange(i32 2,
 
 }
 
 extern _Atomic _Bool b;
 
 _Bool bar() {
-// CHECK-LABEL: @bar
-// CHECK: %[[load:.*]] = load atomic i8, i8* @b seq_cst
-// CHECK: %[[tobool:.*]] = trunc i8 %[[load]] to i1
-// CHECK: ret i1 %[[tobool]]
+// NATIVE-LABEL: @bar
+// NATIVE: %[[load:.*]] = load atomic i8, i8* @b seq_cst
+

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-02-21 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 245929.
Xiangling_L edited the summary of this revision.
Xiangling_L added a comment.

Update the testcase;


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

https://reviews.llvm.org/D74166

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-priority-attribute.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- clang/test/CodeGen/static-init.cpp
+++ clang/test/CodeGen/static-init.cpp
@@ -1,12 +1,55 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
 struct test {
   test();
   ~test();
 } t;
 
-// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd, i8* null }]
+// CHECK: define dso_local void @__cxx_global_var_init() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testC1Ev(%struct.test* @t)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor_t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__dtor_t() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testD1Ev(%struct.test* @t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*) #3
+
+// CHECK: define dso_local void @__cxx_global_var_destruct_t() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor_t)
+// CHECK:   %guard.hasSrterm = icmp eq i32 %0, 0
+// CHECK:   br i1 %guard.hasSrterm, label %destruct.check, label %destruct.end
+
+// CHECK: destruct.check:
+// CHECK:   call void @__dtor_t()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*) #3
+
+// CHECK: define dso_local void @__sinit8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_init()
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__sterm8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_destruct_t()
+// CHECK:   ret void
+// CHECK: }
Index: clang/test/CodeGen/aix-priority-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-priority-attribute.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 | \
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 | \
+// RUN: FileCheck %s
+
+int foo() __attribute__((constructor(180)));
+int bar() __attribute__((destructor(180)));
+
+class test {
+   int a;
+public:
+test(int c) {a = c;}
+~test() {a = 0;}
+};
+
+__attribute__ ((init_priority (2000)))
+test t(1);
+
+// CHECK: warning: 'constructor' attribute argument not supported:
+// CHECK: int foo() __attribute__((constructor(180)));
+ 
+// CHECK: warning: 'destructor' attribute argument not supported:
+// check: int bar() __attribute__((destructor(180)));
+
+// CHECK: warning: 'init_priority' attribute argument not supported:
+// CHECK: __attribute__ ((init_priority (2000)))
+
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6819,7 +6819,11 @@
 handlePassObjectSizeAttr(S, D, AL);
 break;
   case ParsedAttr::AT_Constructor:
-handleConstructorAttr(S, D, AL);
+if (S.Context.getTargetInfo().getTriple().isOSAIX())
+  S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+  << AL << "";
+else
+  handleConstructorAttr(S, D, AL);
 break;
   case ParsedAttr::AT_CXX11NoReturn:
 handleSimpleAttribute(S, D, AL);
@@ -6828,7 +6832,11 @@
 handleDeprecatedAttr(S, D, AL);
 break;
   case ParsedAttr::AT_Destructor:
-handleDestructorAttr(S, D, AL);
+if (S.Context.getTargetInfo().getTriple().isOSAIX())
+  S.Diag(AL.getLoc(), diag::warn_attribute_type_

[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor class.

2020-02-21 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked 11 inline comments as done.
cchen added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15450
   }
+  bool VisitCXXThisExpr(CXXThisExpr *CTE) { return true; }
+  bool VisitStmt(Stmt *) {

ABataev wrote:
> Do you really need this function?
Removed the function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74970



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


[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor class.

2020-02-21 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 245955.
cchen added a comment.

Fix by feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74970

Files:
  clang/lib/Sema/SemaOpenMP.cpp

Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15197,256 +15197,290 @@
   return ConstLength.getSExtValue() != 1;
 }
 
-// Return the expression of the base of the mappable expression or null if it
-// cannot be determined and do all the necessary checks to see if the expression
-// is valid as a standalone mappable expression. In the process, record all the
-// components of the expression.
-static const Expr *checkMapClauseExpressionBase(
-Sema &SemaRef, Expr *E,
-OMPClauseMappableExprCommon::MappableExprComponentList &CurComponents,
-OpenMPClauseKind CKind, bool NoDiagnose) {
-  SourceLocation ELoc = E->getExprLoc();
-  SourceRange ERange = E->getSourceRange();
-
-  // The base of elements of list in a map clause have to be either:
-  //  - a reference to variable or field.
-  //  - a member expression.
-  //  - an array expression.
-  //
-  // E.g. if we have the expression 'r.S.Arr[:12]', we want to retrieve the
-  // reference to 'r'.
-  //
-  // If we have:
-  //
-  // struct SS {
-  //   Bla S;
-  //   foo() {
-  // #pragma omp target map (S.Arr[:12]);
-  //   }
-  // }
-  //
-  // We want to retrieve the member expression 'this->S';
+// The base of elements of list in a map clause have to be either:
+//  - a reference to variable or field.
+//  - a member expression.
+//  - an array expression.
+//
+// E.g. if we have the expression 'r.S.Arr[:12]', we want to retrieve the
+// reference to 'r'.
+//
+// If we have:
+//
+// struct SS {
+//   Bla S;
+//   foo() {
+// #pragma omp target map (S.Arr[:12]);
+//   }
+// }
+//
+// We want to retrieve the member expression 'this->S';
 
+// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2]
+//  If a list item is an array section, it must specify contiguous storage.
+//
+// For this restriction it is sufficient that we make sure only references
+// to variables or fields and array expressions, and that no array sections
+// exist except in the rightmost expression (unless they cover the whole
+// dimension of the array). E.g. these would be invalid:
+//
+//   r.ArrS[3:5].Arr[6:7]
+//
+//   r.ArrS[3:5].x
+//
+// but these would be valid:
+//   r.ArrS[3].Arr[6:7]
+//
+//   r.ArrS[3].x
+namespace {
+class MapBaseChecker final : public StmtVisitor {
+  Sema &SemaRef;
+  OpenMPClauseKind CKind = OMPC_unknown;
+  OMPClauseMappableExprCommon::MappableExprComponentList &Components;
+  bool NoDiagnose = false;
   const Expr *RelevantExpr = nullptr;
-
-  // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2]
-  //  If a list item is an array section, it must specify contiguous storage.
-  //
-  // For this restriction it is sufficient that we make sure only references
-  // to variables or fields and array expressions, and that no array sections
-  // exist except in the rightmost expression (unless they cover the whole
-  // dimension of the array). E.g. these would be invalid:
-  //
-  //   r.ArrS[3:5].Arr[6:7]
-  //
-  //   r.ArrS[3:5].x
-  //
-  // but these would be valid:
-  //   r.ArrS[3].Arr[6:7]
-  //
-  //   r.ArrS[3].x
-
   bool AllowUnitySizeArraySection = true;
   bool AllowWholeSizeArraySection = true;
+  SourceLocation ELoc;
+  SourceRange ERange;
 
-  while (!RelevantExpr) {
-E = E->IgnoreParenImpCasts();
-
-if (auto *CurE = dyn_cast(E)) {
-  if (!isa(CurE->getDecl()))
-return nullptr;
-
-  RelevantExpr = CurE;
+  void emitErrorMsg() {
+if (!NoDiagnose) {
+  // If nothing else worked, this is not a valid map clause expression.
+  SemaRef.Diag(ELoc, diag::err_omp_expected_named_var_member_or_array_expression)
+<< ERange;
+}
+  }
 
-  // If we got a reference to a declaration, we should not expect any array
-  // section before that.
-  AllowUnitySizeArraySection = false;
-  AllowWholeSizeArraySection = false;
+public:
+  bool VisitDeclRefExpr(DeclRefExpr *DRE) {
+if (!isa(DRE->getDecl())) {
+  emitErrorMsg();
+  return false;
+}
+RelevantExpr = DRE;
+// Record the component.
+Components.emplace_back(DRE, DRE->getDecl());
+return true;
+  }
 
-  // Record the component.
-  CurComponents.emplace_back(CurE, CurE->getDecl());
-} else if (auto *CurE = dyn_cast(E)) {
-  Expr *BaseE = CurE->getBase()->IgnoreParenImpCasts();
+  bool VisitMemberExpr(MemberExpr *ME) {
+Expr *E = ME;
+Expr *BaseE = ME->getBase()->IgnoreParenCasts();
 
-  if (isa(BaseE))
-// We found a base expression: this->Val.
-RelevantExpr = CurE;
-  else
-E = BaseE;
+if (isa(BaseE))
+  // We found a base expression: this->Val.
+

[PATCH] D74846: fix -fcodegen-modules code when used with PCH (PR44958)

2020-02-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Please simplify the test case - at least to remove the long/uppercase 
identifiers to use placeholder names (this avoids any accidental semantic 
meaning they might carry (or appear to carry, but not actually carry)).

What's the failure mode this is avoiding? There's no checking for the behavior 
of the compiler here, other than "it does not crash" - that's usually a sign of 
undertesting. If the program crashed without the fix, then there's some 
specific behavior that's desirable that was hiding behind the crash, something 
more specific than "does anything other than crash". Please include testing 
(I'm guessing some FileChecking on IR output in this case, but haven't looked 
closely)


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor class.

2020-02-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Did you try to run the tests? I would suggest adding a test, at least, where a 
function is mapped. We should see the error message here. Seems to me, we don't 
have this one.




Comment at: clang/lib/Sema/SemaOpenMP.cpp:15422-15423
+  Expr::EvalResult ResultL;
+  if (!OASE->getLength()->isValueDependent()) {
+if (OASE->getLength()->EvaluateAsInt(ResultR,
  SemaRef.getASTContext())) {

Just a nit. Try to reduce the structural complexity here by using logical 
exressions, `if (!OASE->getLength()->isValueDependent() && 
OASE->getLength()->EvaluateAsInt(...) && !ResultR.Val.getInt().isOneValue())`. 
Also, you can 



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15433-15436
+  if (OASE->getLowerBound() && !OASE->getLowerBound()->isValueDependent()) 
{
+if (OASE->getLowerBound()->EvaluateAsInt(
+ ResultL, SemaRef.getASTContext())) {
   if (!ResultL.Val.getInt().isNullValue()) {

Same here, try to reduce complexity


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74970



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


[PATCH] D74846: fix -fcodegen-modules code when used with PCH (PR44958)

2020-02-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@llunak Small typo: your patch fixes PR44953, not PR44958.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D74842: [clangd] Make use of syntax tokens in ReplayPreamble

2020-02-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 7 inline comments as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:138
+  : Includes(Includes), Delegate(Delegate), SM(SM), PP(PP) {
+MainFileTokens = syntax::tokenize(SM.getMainFileID(), SM, LangOpts);
+  }

sammccall wrote:
> tokenizing the whole file an extra time on every AST build seems a bit sad - 
> this is considerably more lexing than we were doing before. Probably doesn't 
> matter?
> 
> We could trim this to the preamble bounds I guess. Or even compute it once 
> when the preamble is built, since we assume all the bytes are the same? I 
> guess SourceLocations are the problem... we could just translate offsets into 
> the new SM, but that gets messy.
> On the other hand, assuming the preamble isn't going to change at all seems 
> like an assumption not long for this world.
> On the first hand again, maybe we'll have to revisit looots of stuff (go to 
> definition and everything) once that assumption breaks anyway.
Implemented a way to partially tokenize a file in D74962.

> On the other hand, assuming the preamble isn't going to change at all seems 
> like an assumption not long for this world.

It should be okay for replaypreambles as only clang tidy checkers depends on 
this logic and we are not planning to emit diagnostics with stale preambles.



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:175
+  auto HashTok =
+  llvm::find_if(MainFileTokens, [&HashLoc](const syntax::Token &T) {
+return T.location().getRawEncoding() == HashLoc;

sammccall wrote:
> this looks like a linear search for each #include
made it logarithmic instead, we can also make it linear in total if we decide 
to rely on the fact that `MainFileIncludes` are sorted. I believe it is 
currently true but never promised by the include collector.



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:186
+
+  // We imitate the PP logic here, except clang::Token::Flags, none of the
+  // callers seem to care about it (yet).

sammccall wrote:
> Not clear what "imitate the PP logic" means.
> We construct a fake 'import'/'include' token... nobody cares about 
> clang::Token::Flags.
it was refering to the fact that we were performing the 
`PP.LookupIdentifierInfo` call to set kind etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74842



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


[PATCH] D74842: [clangd] Make use of syntax tokens in ReplayPreamble

2020-02-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 245960.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Address comments.
- Add tests by mimicking a clang-tidy check.
- only tokenize the preamble section, not the whole file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74842

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -11,6 +11,8 @@
 //
 //===--===//
 
+#include "../../clang-tidy/ClangTidyModule.h"
+#include "../../clang-tidy/ClangTidyModuleRegistry.h"
 #include "AST.h"
 #include "Annotations.h"
 #include "Compiler.h"
@@ -20,8 +22,13 @@
 #include "TestFS.h"
 #include "TestTU.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Token.h"
 #include "clang/Tooling/Syntax/Tokens.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock-matchers.h"
 #include "gmock/gmock.h"
@@ -296,6 +303,112 @@
   testing::UnorderedElementsAreArray(TestCase.points()));
 }
 
+TEST(ParsedASTTest, ReplayPreambleForTidyCheckers) {
+  struct Inclusion {
+Inclusion(const SourceManager &SM, SourceLocation HashLoc,
+  const Token &IncludeTok, llvm::StringRef FileName, bool IsAngled,
+  CharSourceRange FilenameRange)
+: HashOffset(SM.getDecomposedLoc(HashLoc).second), IncTok(IncludeTok),
+  IncDirective(IncludeTok.getIdentifierInfo()->getName()),
+  FileNameOffset(SM.getDecomposedLoc(FilenameRange.getBegin()).second),
+  FileName(FileName), IsAngled(IsAngled) {}
+size_t HashOffset;
+syntax::Token IncTok;
+llvm::StringRef IncDirective;
+size_t FileNameOffset;
+llvm::StringRef FileName;
+bool IsAngled;
+  };
+  static std::vector Includes;
+  static std::vector SkippedFiles;
+  struct ReplayPreamblePPCallback : public PPCallbacks {
+const SourceManager &SM;
+explicit ReplayPreamblePPCallback(const SourceManager &SM) : SM(SM) {}
+
+void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
+StringRef FileName, bool IsAngled,
+CharSourceRange FilenameRange, const FileEntry *,
+StringRef, StringRef, const Module *,
+SrcMgr::CharacteristicKind) override {
+  Includes.emplace_back(SM, HashLoc, IncludeTok, FileName, IsAngled,
+FilenameRange);
+}
+
+void FileSkipped(const FileEntryRef &, const Token &FilenameTok,
+ SrcMgr::CharacteristicKind) override {
+  SkippedFiles.emplace_back(FilenameTok);
+}
+  };
+  struct ReplayPreambleCheck : public tidy::ClangTidyCheck {
+ReplayPreambleCheck(StringRef Name, tidy::ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {}
+void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override {
+  PP->addPPCallbacks(::std::make_unique(SM));
+}
+  };
+  struct ReplayPreambleModule : public tidy::ClangTidyModule {
+void
+addCheckFactories(tidy::ClangTidyCheckFactories &CheckFactories) override {
+  CheckFactories.registerCheck(
+  "replay-preamble-check");
+}
+  };
+
+  static tidy::ClangTidyModuleRegistry::Add X(
+  "replay-preamble-module", "");
+  TestTU TU;
+  // this check runs the preprocessor, we need to make sure it does not break
+  // our recording logic.
+  TU.ClangTidyChecks = "replay-preamble-check";
+  llvm::Annotations Test(R"cpp(
+^#[[import]] ^"[[bar.h]]"
+^#[[include_next]] ^"[[baz.h]]"
+^#[[include]] ^<[[a.h]]>)cpp");
+  llvm::StringRef Code = Test.code();
+  TU.Code = Code.str();
+  TU.AdditionalFiles["bar.h"] = "";
+  TU.AdditionalFiles["baz.h"] = "";
+  TU.AdditionalFiles["a.h"] = "";
+  TU.ExtraArgs = {"-isystem."};
+
+  const auto &AST = TU.build();
+  const auto &SM = AST.getSourceManager();
+
+  auto Ranges = Test.ranges();
+  auto Points = Test.points();
+  ASSERT_EQ(Ranges.size() / 2, Includes.size());
+  ASSERT_EQ(SkippedFiles.size(), Includes.size());
+  for (size_t I = 0; I < Includes.size(); ++I) {
+const auto &Inc = Includes[I];
+
+auto &P = Points[2 * I];
+EXPECT_EQ(Inc.HashOffset, P);
+
+auto R = Ranges[2 * I];
+const auto &IncRange = Inc.IncTok.range(SM);
+EXPECT_EQ(IncRange.beginOffset(), R.Begin);
+EXPECT_EQ(IncRange.endOffset(), R.End);

[PATCH] D74842: [clangd] Make use of syntax tokens in ReplayPreamble

2020-02-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 245962.
kadircet added a comment.

- Update comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74842

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -11,6 +11,8 @@
 //
 //===--===//
 
+#include "../../clang-tidy/ClangTidyModule.h"
+#include "../../clang-tidy/ClangTidyModuleRegistry.h"
 #include "AST.h"
 #include "Annotations.h"
 #include "Compiler.h"
@@ -20,8 +22,13 @@
 #include "TestFS.h"
 #include "TestTU.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Token.h"
 #include "clang/Tooling/Syntax/Tokens.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock-matchers.h"
 #include "gmock/gmock.h"
@@ -296,6 +303,111 @@
   testing::UnorderedElementsAreArray(TestCase.points()));
 }
 
+TEST(ParsedASTTest, ReplayPreambleForTidyCheckers) {
+  struct Inclusion {
+Inclusion(const SourceManager &SM, SourceLocation HashLoc,
+  const Token &IncludeTok, llvm::StringRef FileName, bool IsAngled,
+  CharSourceRange FilenameRange)
+: HashOffset(SM.getDecomposedLoc(HashLoc).second), IncTok(IncludeTok),
+  IncDirective(IncludeTok.getIdentifierInfo()->getName()),
+  FileNameOffset(SM.getDecomposedLoc(FilenameRange.getBegin()).second),
+  FileName(FileName), IsAngled(IsAngled) {}
+size_t HashOffset;
+syntax::Token IncTok;
+llvm::StringRef IncDirective;
+size_t FileNameOffset;
+llvm::StringRef FileName;
+bool IsAngled;
+  };
+  static std::vector Includes;
+  static std::vector SkippedFiles;
+  struct ReplayPreamblePPCallback : public PPCallbacks {
+const SourceManager &SM;
+explicit ReplayPreamblePPCallback(const SourceManager &SM) : SM(SM) {}
+
+void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
+StringRef FileName, bool IsAngled,
+CharSourceRange FilenameRange, const FileEntry *,
+StringRef, StringRef, const Module *,
+SrcMgr::CharacteristicKind) override {
+  Includes.emplace_back(SM, HashLoc, IncludeTok, FileName, IsAngled,
+FilenameRange);
+}
+
+void FileSkipped(const FileEntryRef &, const Token &FilenameTok,
+ SrcMgr::CharacteristicKind) override {
+  SkippedFiles.emplace_back(FilenameTok);
+}
+  };
+  struct ReplayPreambleCheck : public tidy::ClangTidyCheck {
+ReplayPreambleCheck(StringRef Name, tidy::ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {}
+void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override {
+  PP->addPPCallbacks(::std::make_unique(SM));
+}
+  };
+  struct ReplayPreambleModule : public tidy::ClangTidyModule {
+void
+addCheckFactories(tidy::ClangTidyCheckFactories &CheckFactories) override {
+  CheckFactories.registerCheck(
+  "replay-preamble-check");
+}
+  };
+
+  static tidy::ClangTidyModuleRegistry::Add X(
+  "replay-preamble-module", "");
+  TestTU TU;
+  // This check records inclusion directives replayed by clangd.
+  TU.ClangTidyChecks = "replay-preamble-check";
+  llvm::Annotations Test(R"cpp(
+^#[[import]] ^"[[bar.h]]"
+^#[[include_next]] ^"[[baz.h]]"
+^#[[include]] ^<[[a.h]]>)cpp");
+  llvm::StringRef Code = Test.code();
+  TU.Code = Code.str();
+  TU.AdditionalFiles["bar.h"] = "";
+  TU.AdditionalFiles["baz.h"] = "";
+  TU.AdditionalFiles["a.h"] = "";
+  TU.ExtraArgs = {"-isystem."};
+
+  const auto &AST = TU.build();
+  const auto &SM = AST.getSourceManager();
+
+  auto Ranges = Test.ranges();
+  auto Points = Test.points();
+  ASSERT_EQ(Ranges.size() / 2, Includes.size());
+  ASSERT_EQ(SkippedFiles.size(), Includes.size());
+  for (size_t I = 0; I < Includes.size(); ++I) {
+const auto &Inc = Includes[I];
+
+auto &P = Points[2 * I];
+EXPECT_EQ(Inc.HashOffset, P);
+
+auto R = Ranges[2 * I];
+const auto &IncRange = Inc.IncTok.range(SM);
+EXPECT_EQ(IncRange.beginOffset(), R.Begin);
+EXPECT_EQ(IncRange.endOffset(), R.End);
+EXPECT_EQ(Inc.IncTok.kind(), tok::identifier);
+EXPECT_EQ(Inc.IncDirective, Code.substr(R.Begin, R.End - R.Begin));
+
+P = Points[2 * I + 1];
+EXPECT_EQ(Inc.FileNameOffset,

  1   2   >