[PATCH] D73261: [dwarf5] Support DebugInfo for constexpr for C++ variables and functions

2020-02-11 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added inline comments.



Comment at: llvm/include/llvm/IR/DebugInfoFlags.def:61
 HANDLE_DI_FLAG((1 << 29), AllCallsDescribed)
+HANDLE_DI_FLAG((1 << 30), ConstExpr)
 

We are almost out of space here... I wouldn't add any additional flag here 
before we do necessary refactoring. 

As we discussed, it makes sense moving the function-related flags into the 
existing `DISPFlags`. In addition, we may want to introduce something like 
`DIVarFlags`, and move the variable-related flags into that.

Also, we need to pay attention on the bitcode compatibility as well. Back then, 
I have implemented something similar here: https://reviews.llvm.org/D59288, so 
it can be used as a reference.

I think we have to do it first, as a preparation patch for this one.


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

https://reviews.llvm.org/D73261



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


[PATCH] D74387: [SYCL] Do not diagnose use of __float128

2020-02-11 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added subscribers: cfe-commits, Anastasia, ebevhan.
Herald added a project: clang.

While SYCL does not support __float128 for some device targets, emitting the
diagnostic here prevents the compilation of host header files with
__float128 type usage.
For now just do not diagnose __float128 for SYCL. In the future we should
have more precise check.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74387

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaSYCL/float128.cpp


Index: clang/test/SemaSYCL/float128.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/float128.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -verify -fsyntax-only %s
+// expected-no-diagnostics
+
+void F(__float128);
+
+template 
+__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
+  kernelFunc();
+}
+
+int main() {
+  __float128 A;
+  kernel_single_task([=]() {});
+  return 0;
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1516,6 +1516,7 @@
 break;
   case DeclSpec::TST_float128:
 if (!S.Context.getTargetInfo().hasFloat128Type() &&
+!S.getLangOpts().SYCLIsDevice &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__float128";


Index: clang/test/SemaSYCL/float128.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/float128.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -verify -fsyntax-only %s
+// expected-no-diagnostics
+
+void F(__float128);
+
+template 
+__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
+  kernelFunc();
+}
+
+int main() {
+  __float128 A;
+  kernel_single_task([=]() {});
+  return 0;
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1516,6 +1516,7 @@
 break;
   case DeclSpec::TST_float128:
 if (!S.Context.getTargetInfo().hasFloat128Type() &&
+!S.getLangOpts().SYCLIsDevice &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__float128";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73261: [dwarf5] Support DebugInfo for constexpr for C++ variables and functions

2020-02-11 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

@awpandey Thanks for doing this, but could you please explain the motivation of 
implementing this? Can we use is (somehow) to generate more variables with the 
`DW_AT_const_value`?


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

https://reviews.llvm.org/D73261



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


[PATCH] D74216: [clang-rename] Fix the missing template constructors.

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

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74216

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  clang/test/clang-rename/Ctor.cpp


Index: clang/test/clang-rename/Ctor.cpp
===
--- clang/test/clang-rename/Ctor.cpp
+++ clang/test/clang-rename/Ctor.cpp
@@ -5,10 +5,23 @@
 
 Foo::Foo()  /* Test 2 */ {}   // CHECK: Bar::Bar()  /* Test 2 */ {}
 
+
+class Foo2 { /* Test 3 */ // CHECK: class Bar2 {
+public:
+  template 
+  Foo2(); // CHECK: Bar2();
+
+  template 
+  Foo2(Foo2 &);   // CHECK: Bar2(Bar2 &);
+};
+
+
 // Test 1.
 // RUN: clang-rename -offset=62 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
 // Test 2.
 // RUN: clang-rename -offset=116 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=187 -new-name=Bar2 %s -- | sed 's,//.*,,' | 
FileCheck %s
 
 // To find offsets after modifying the file, use:
 //   grep -Ubo 'Foo.*' 
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -135,6 +135,13 @@
 
 for (const auto *CtorDecl : RecordDecl->ctors())
   USRSet.insert(getUSRForDecl(CtorDecl));
+// Add template constructor decls, they are not in ctors() unfortunately.
+if (RecordDecl->hasUserDeclaredConstructor())
+  for (const auto *D : RecordDecl->decls())
+if (const auto *FTD = dyn_cast(D))
+  if (const auto *Ctor =
+  dyn_cast(FTD->getTemplatedDecl()))
+USRSet.insert(getUSRForDecl(Ctor));
 
 USRSet.insert(getUSRForDecl(RecordDecl->getDestructor()));
 USRSet.insert(getUSRForDecl(RecordDecl));
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -137,6 +137,17 @@
 };
   )cpp",
 
+  // Rename template class constructor.
+   R"cpp(
+class [[F^oo]] {
+  template
+  [[Fo^o]]();
+
+  template
+  [[F^oo]](T t);
+};
+  )cpp",
+
   // Class in template argument.
   R"cpp(
 class [[F^oo]] {};


Index: clang/test/clang-rename/Ctor.cpp
===
--- clang/test/clang-rename/Ctor.cpp
+++ clang/test/clang-rename/Ctor.cpp
@@ -5,10 +5,23 @@
 
 Foo::Foo()  /* Test 2 */ {}   // CHECK: Bar::Bar()  /* Test 2 */ {}
 
+
+class Foo2 { /* Test 3 */ // CHECK: class Bar2 {
+public:
+  template 
+  Foo2(); // CHECK: Bar2();
+
+  template 
+  Foo2(Foo2 &);   // CHECK: Bar2(Bar2 &);
+};
+
+
 // Test 1.
 // RUN: clang-rename -offset=62 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
 // Test 2.
 // RUN: clang-rename -offset=116 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=187 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s
 
 // To find offsets after modifying the file, use:
 //   grep -Ubo 'Foo.*' 
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -135,6 +135,13 @@
 
 for (const auto *CtorDecl : RecordDecl->ctors())
   USRSet.insert(getUSRForDecl(CtorDecl));
+// Add template constructor decls, they are not in ctors() unfortunately.
+if (RecordDecl->hasUserDeclaredConstructor())
+  for (const auto *D : RecordDecl->decls())
+if (const auto *FTD = dyn_cast(D))
+  if (const auto *Ctor =
+  dyn_cast(FTD->getTemplatedDecl()))
+USRSet.insert(getUSRForDecl(Ctor));
 
 USRSet.insert(getUSRForDecl(RecordDecl->getDestructor()));
 USRSet.insert(getUSRForDecl(RecordDecl));
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -137,6 +137,17 @@
 };
   )cpp",
 
+  // Rename template class constructor.
+   R"cpp(
+class [[F^oo]] {
+  template
+  [[Fo^o]]();
+
+  template
+  [[F^oo]](T t);
+};
+  )cpp",
+
   // Class in template argument.
   R"cpp(
 class [[F^oo]] {};

[clang-tools-extra] 4876212 - [clangd] Remove a FIXME which has been done, NFC.

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

Author: Haojian Wu
Date: 2020-02-11T09:27:00+01:00
New Revision: 487621237d2fe5a53ac40a29f6443d3e4f106c61

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

LOG: [clangd] Remove a FIXME which has been done, NFC.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 44ebdbce628d..9946dfe65ec8 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -352,9 +352,6 @@ findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
 // index (background index) is relatively stale. We choose the dirty buffers
 // as the file content we rename on, and fallback to file content on disk if
 // there is no dirty buffer.
-//
-// FIXME: Our index may return implicit references, which are not eligible for
-// rename, we should filter out these references.
 llvm::Expected renameOutsideFile(
 const NamedDecl &RenameDecl, llvm::StringRef MainFilePath,
 llvm::StringRef NewName, const SymbolIndex &Index,



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


[PATCH] D74216: [clang-rename] Fix the missing template constructors.

2020-02-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

Should be good to go, please run `git-clang-format` on the changes just to make 
sure.

Thanks for fixing this!




Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:141
+  // Rename template class constructor.
+   R"cpp(
+class [[F^oo]] {

nit: I think this is still not formatted as the comment has a different offset.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74216



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


[clang-tools-extra] a7fd548 - [clang-rename] Fix the missing template constructors.

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

Author: Haojian Wu
Date: 2020-02-11T09:41:39+01:00
New Revision: a7fd548a4f9e50e1aa2def57bae885604c9c5878

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

LOG: [clang-rename] Fix the missing template constructors.

Summary:
When renaming a class with template constructors, we are missing the
occurrences of the template constructors, because getUSRsForDeclaration doesn't
give USRs of the templated constructors (they are not in the normal `ctors()`
method).

Reviewers: kbobyrev

Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/RenameTests.cpp
clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
clang/test/clang-rename/Ctor.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index fb6993ef0d40..0314a6fabe42 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -137,6 +137,17 @@ TEST(RenameTest, WithinFileRename) {
 };
   )cpp",
 
+  // Rename template class constructor.
+  R"cpp(
+class [[F^oo]] {
+  template
+  [[Fo^o]]();
+
+  template
+  [[F^oo]](T t);
+};
+  )cpp",
+
   // Class in template argument.
   R"cpp(
 class [[F^oo]] {};

diff  --git a/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp 
b/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
index d966a5ef23c2..a17b880a71a0 100644
--- a/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ b/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -135,6 +135,13 @@ class AdditionalUSRFinder : public 
RecursiveASTVisitor {
 
 for (const auto *CtorDecl : RecordDecl->ctors())
   USRSet.insert(getUSRForDecl(CtorDecl));
+// Add template constructor decls, they are not in ctors() unfortunately.
+if (RecordDecl->hasUserDeclaredConstructor())
+  for (const auto *D : RecordDecl->decls())
+if (const auto *FTD = dyn_cast(D))
+  if (const auto *Ctor =
+  dyn_cast(FTD->getTemplatedDecl()))
+USRSet.insert(getUSRForDecl(Ctor));
 
 USRSet.insert(getUSRForDecl(RecordDecl->getDestructor()));
 USRSet.insert(getUSRForDecl(RecordDecl));

diff  --git a/clang/test/clang-rename/Ctor.cpp 
b/clang/test/clang-rename/Ctor.cpp
index 9908a4123ddf..1213cc6a239d 100644
--- a/clang/test/clang-rename/Ctor.cpp
+++ b/clang/test/clang-rename/Ctor.cpp
@@ -5,10 +5,23 @@ class Foo {   // CHECK: class Bar {
 
 Foo::Foo()  /* Test 2 */ {}   // CHECK: Bar::Bar()  /* Test 2 */ {}
 
+
+class Foo2 { /* Test 3 */ // CHECK: class Bar2 {
+public:
+  template 
+  Foo2(); // CHECK: Bar2();
+
+  template 
+  Foo2(Foo2 &);   // CHECK: Bar2(Bar2 &);
+};
+
+
 // Test 1.
 // RUN: clang-rename -offset=62 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
 // Test 2.
 // RUN: clang-rename -offset=116 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=187 -new-name=Bar2 %s -- | sed 's,//.*,,' | 
FileCheck %s
 
 // To find offsets after modifying the file, use:
 //   grep -Ubo 'Foo.*' 



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


[PATCH] D74372: [OpenMP][IRBuilder] Perform finalization (incl. outlining) late

2020-02-11 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Patch looks good with the above nits.

I'm not totally sure about the callback vs running a separate IR pass after the 
finalize() call, but when the callback is this simple it looks fine. I like 
that this preserves the current semantics.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:275
+  /// Get a handle for a new region that will be outlined later.
+  OutlineInfo &getNewOutlineInfo() {
+OutlineInfos.push_back({});

Calling getNewOutlineInfo will invalidate the references previously returned. 
That's not a bug in this patch but looks like it'll be easy to get wrong in 
future.

Perhaps the backing store should be a linked list, such that push_back doesn't 
invalidate any existing references?



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:587
+  CallInst *CI = cast(OutlinedFn.user_back());
+  CI->getParent()->setName("omp_parallel");
+  Builder.SetInsertPoint(CI);

s/parallel/outlined?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74372



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


[PATCH] D74216: [clang-rename] Fix the missing template constructors.

2020-02-11 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa7fd548a4f9e: [clang-rename] Fix the missing template 
constructors. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74216

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  clang/test/clang-rename/Ctor.cpp


Index: clang/test/clang-rename/Ctor.cpp
===
--- clang/test/clang-rename/Ctor.cpp
+++ clang/test/clang-rename/Ctor.cpp
@@ -5,10 +5,23 @@
 
 Foo::Foo()  /* Test 2 */ {}   // CHECK: Bar::Bar()  /* Test 2 */ {}
 
+
+class Foo2 { /* Test 3 */ // CHECK: class Bar2 {
+public:
+  template 
+  Foo2(); // CHECK: Bar2();
+
+  template 
+  Foo2(Foo2 &);   // CHECK: Bar2(Bar2 &);
+};
+
+
 // Test 1.
 // RUN: clang-rename -offset=62 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
 // Test 2.
 // RUN: clang-rename -offset=116 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=187 -new-name=Bar2 %s -- | sed 's,//.*,,' | 
FileCheck %s
 
 // To find offsets after modifying the file, use:
 //   grep -Ubo 'Foo.*' 
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -135,6 +135,13 @@
 
 for (const auto *CtorDecl : RecordDecl->ctors())
   USRSet.insert(getUSRForDecl(CtorDecl));
+// Add template constructor decls, they are not in ctors() unfortunately.
+if (RecordDecl->hasUserDeclaredConstructor())
+  for (const auto *D : RecordDecl->decls())
+if (const auto *FTD = dyn_cast(D))
+  if (const auto *Ctor =
+  dyn_cast(FTD->getTemplatedDecl()))
+USRSet.insert(getUSRForDecl(Ctor));
 
 USRSet.insert(getUSRForDecl(RecordDecl->getDestructor()));
 USRSet.insert(getUSRForDecl(RecordDecl));
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -137,6 +137,17 @@
 };
   )cpp",
 
+  // Rename template class constructor.
+  R"cpp(
+class [[F^oo]] {
+  template
+  [[Fo^o]]();
+
+  template
+  [[F^oo]](T t);
+};
+  )cpp",
+
   // Class in template argument.
   R"cpp(
 class [[F^oo]] {};


Index: clang/test/clang-rename/Ctor.cpp
===
--- clang/test/clang-rename/Ctor.cpp
+++ clang/test/clang-rename/Ctor.cpp
@@ -5,10 +5,23 @@
 
 Foo::Foo()  /* Test 2 */ {}   // CHECK: Bar::Bar()  /* Test 2 */ {}
 
+
+class Foo2 { /* Test 3 */ // CHECK: class Bar2 {
+public:
+  template 
+  Foo2(); // CHECK: Bar2();
+
+  template 
+  Foo2(Foo2 &);   // CHECK: Bar2(Bar2 &);
+};
+
+
 // Test 1.
 // RUN: clang-rename -offset=62 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
 // Test 2.
 // RUN: clang-rename -offset=116 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=187 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s
 
 // To find offsets after modifying the file, use:
 //   grep -Ubo 'Foo.*' 
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -135,6 +135,13 @@
 
 for (const auto *CtorDecl : RecordDecl->ctors())
   USRSet.insert(getUSRForDecl(CtorDecl));
+// Add template constructor decls, they are not in ctors() unfortunately.
+if (RecordDecl->hasUserDeclaredConstructor())
+  for (const auto *D : RecordDecl->decls())
+if (const auto *FTD = dyn_cast(D))
+  if (const auto *Ctor =
+  dyn_cast(FTD->getTemplatedDecl()))
+USRSet.insert(getUSRForDecl(Ctor));
 
 USRSet.insert(getUSRForDecl(RecordDecl->getDestructor()));
 USRSet.insert(getUSRForDecl(RecordDecl));
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -137,6 +137,17 @@
 };
   )cpp",
 
+  // Rename template class constructor.
+  R"cpp(
+class [[F^oo]] {
+  template
+  [[Fo^o]]();
+
+  template
+  [[F^oo]](T t);
+};
+  )cpp",
+
   // Class in template argument.
   R"c

[PATCH] D74216: [clang-rename] Fix the missing template constructors.

2020-02-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 243753.
hokein marked an inline comment as done.
hokein added a comment.

Fix the format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74216

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  clang/test/clang-rename/Ctor.cpp


Index: clang/test/clang-rename/Ctor.cpp
===
--- clang/test/clang-rename/Ctor.cpp
+++ clang/test/clang-rename/Ctor.cpp
@@ -5,10 +5,23 @@
 
 Foo::Foo()  /* Test 2 */ {}   // CHECK: Bar::Bar()  /* Test 2 */ {}
 
+
+class Foo2 { /* Test 3 */ // CHECK: class Bar2 {
+public:
+  template 
+  Foo2(); // CHECK: Bar2();
+
+  template 
+  Foo2(Foo2 &);   // CHECK: Bar2(Bar2 &);
+};
+
+
 // Test 1.
 // RUN: clang-rename -offset=62 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
 // Test 2.
 // RUN: clang-rename -offset=116 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=187 -new-name=Bar2 %s -- | sed 's,//.*,,' | 
FileCheck %s
 
 // To find offsets after modifying the file, use:
 //   grep -Ubo 'Foo.*' 
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -135,6 +135,13 @@
 
 for (const auto *CtorDecl : RecordDecl->ctors())
   USRSet.insert(getUSRForDecl(CtorDecl));
+// Add template constructor decls, they are not in ctors() unfortunately.
+if (RecordDecl->hasUserDeclaredConstructor())
+  for (const auto *D : RecordDecl->decls())
+if (const auto *FTD = dyn_cast(D))
+  if (const auto *Ctor =
+  dyn_cast(FTD->getTemplatedDecl()))
+USRSet.insert(getUSRForDecl(Ctor));
 
 USRSet.insert(getUSRForDecl(RecordDecl->getDestructor()));
 USRSet.insert(getUSRForDecl(RecordDecl));
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -137,6 +137,17 @@
 };
   )cpp",
 
+  // Rename template class constructor.
+  R"cpp(
+class [[F^oo]] {
+  template
+  [[Fo^o]]();
+
+  template
+  [[F^oo]](T t);
+};
+  )cpp",
+
   // Class in template argument.
   R"cpp(
 class [[F^oo]] {};


Index: clang/test/clang-rename/Ctor.cpp
===
--- clang/test/clang-rename/Ctor.cpp
+++ clang/test/clang-rename/Ctor.cpp
@@ -5,10 +5,23 @@
 
 Foo::Foo()  /* Test 2 */ {}   // CHECK: Bar::Bar()  /* Test 2 */ {}
 
+
+class Foo2 { /* Test 3 */ // CHECK: class Bar2 {
+public:
+  template 
+  Foo2(); // CHECK: Bar2();
+
+  template 
+  Foo2(Foo2 &);   // CHECK: Bar2(Bar2 &);
+};
+
+
 // Test 1.
 // RUN: clang-rename -offset=62 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
 // Test 2.
 // RUN: clang-rename -offset=116 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=187 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s
 
 // To find offsets after modifying the file, use:
 //   grep -Ubo 'Foo.*' 
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -135,6 +135,13 @@
 
 for (const auto *CtorDecl : RecordDecl->ctors())
   USRSet.insert(getUSRForDecl(CtorDecl));
+// Add template constructor decls, they are not in ctors() unfortunately.
+if (RecordDecl->hasUserDeclaredConstructor())
+  for (const auto *D : RecordDecl->decls())
+if (const auto *FTD = dyn_cast(D))
+  if (const auto *Ctor =
+  dyn_cast(FTD->getTemplatedDecl()))
+USRSet.insert(getUSRForDecl(Ctor));
 
 USRSet.insert(getUSRForDecl(RecordDecl->getDestructor()));
 USRSet.insert(getUSRForDecl(RecordDecl));
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -137,6 +137,17 @@
 };
   )cpp",
 
+  // Rename template class constructor.
+  R"cpp(
+class [[F^oo]] {
+  template
+  [[Fo^o]]();
+
+  template
+  [[F^oo]](T t);
+};
+  )cpp",
+
   // Class in template argument.
   R"cpp(
 class [[F^oo]] {};

[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-02-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added reviewers: mclow.lists, EricWF.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, but I think it would be helpful if someone from the libc++ side also 
double-checked the behavior of patch if possible. I've added a couple potential 
reviewers, but they may be busy with wg21 meetings this week. If we don't hear 
anything back from them in a few weeks, then I think the patch can go in and we 
can handle issues post-commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72282



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


[PATCH] D44609: [clang-format] New option BeforeLambdaBody to manage lambda line break inside function parameter call (in Allman style)

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

This patch is nearly 2 years old, and there has been a lot of discussion and I 
can see you've put a lot of work into adding the tests which prove it works, 
from my perspective this LGTM as long as you are prepared to help resolve any 
issues that might come up as a result of this change.

Please own this change, and if you haven't done so already go get commit 
permission land it. You clearly understand how clang-format works and I feel we 
need more people like yourself, especially if you prepared to fix a bug, and if 
your prepared to keep going at it for 2 years.

Thank you and sorry for the delay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44609



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


[clang] 2733ad2 - [clang-rename] Fix the failure rename test.

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

Author: Haojian Wu
Date: 2020-02-11T10:07:00+01:00
New Revision: 2733ad2c244ab33553bbd1aaca4c76907fdd0760

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

LOG: [clang-rename] Fix the failure rename test.

We cannot run two different tests in a single lit test, split into two.

Added: 
clang/test/clang-rename/TemplateCtor.cpp

Modified: 
clang/test/clang-rename/Ctor.cpp

Removed: 




diff  --git a/clang/test/clang-rename/Ctor.cpp 
b/clang/test/clang-rename/Ctor.cpp
index 1213cc6a239d..9908a4123ddf 100644
--- a/clang/test/clang-rename/Ctor.cpp
+++ b/clang/test/clang-rename/Ctor.cpp
@@ -5,23 +5,10 @@ class Foo {   // CHECK: class Bar {
 
 Foo::Foo()  /* Test 2 */ {}   // CHECK: Bar::Bar()  /* Test 2 */ {}
 
-
-class Foo2 { /* Test 3 */ // CHECK: class Bar2 {
-public:
-  template 
-  Foo2(); // CHECK: Bar2();
-
-  template 
-  Foo2(Foo2 &);   // CHECK: Bar2(Bar2 &);
-};
-
-
 // Test 1.
 // RUN: clang-rename -offset=62 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
 // Test 2.
 // RUN: clang-rename -offset=116 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
-// Test 3.
-// RUN: clang-rename -offset=187 -new-name=Bar2 %s -- | sed 's,//.*,,' | 
FileCheck %s
 
 // To find offsets after modifying the file, use:
 //   grep -Ubo 'Foo.*' 

diff  --git a/clang/test/clang-rename/TemplateCtor.cpp 
b/clang/test/clang-rename/TemplateCtor.cpp
new file mode 100644
index ..9a59194ac3f4
--- /dev/null
+++ b/clang/test/clang-rename/TemplateCtor.cpp
@@ -0,0 +1,10 @@
+class Foo { // CHECK: class Bar {
+public:
+  template 
+  Foo(); // CHECK: Bar();
+
+  template 
+  Foo(Foo &); // CHECK: Bar(Bar &);
+};
+
+// RUN: clang-rename -offset=6 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s



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


[PATCH] D74214: [clang-tidy] Fix PR#34798 'readability-braces-around-statements breaks statements containing braces.'

2020-02-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp:30
   Lexer::getRawToken(Beginning, Tok, SM, Context->getLangOpts());
-  assert(!Invalid && "Expected a valid token.");
+  if (!Invalid) {
+Kind = Tok.getKind();

Elide the braces.



Comment at: 
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp:40
+  tok::TokenKind Kind;
+  if (tryGetTokenKind(Loc, SM, Context, Kind)) {
+return Kind;

Elide braces



Comment at: 
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp:76-77
+
+  // We need to check that it is not 'InitListExpr' which ends with 
+  // the tokens '};' because it will break the following analysis
+  tok::TokenKind NextTokKind;

Is there evidence that this behavior is desired? I have a hunch that this is a 
bug in Clang -- not all `InitListExpr`s will terminate with a semicolon, such 
as ones that appear as function arguments, like `foo({1, 2, 3});`, so I'm 
surprised to see it included here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74214



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


[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-02-11 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal updated this revision to Diff 243757.
vingeldal added a comment.

Updating D70265 : [clang-tidy] Add 
CppCoreGuidelines I.2 "Avoid non-const global variables" check

Created the requested pull request to C++ Core guidelines and since it is now 
merged this patch is updated accordingly.

- Anonymous namespaces are no longer ignored by the check as guideline editors 
explained that was not wanted.
- The option to ignore data members was reomved, they are now always ignored.
- Documentation was updated to mention that this check also covers C++ COre 
Guideline R.6, since R.6 is simply a duplication of I.2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-non-const-global-variables.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
@@ -0,0 +1,239 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-avoid-non-const-global-variables %t
+
+int nonConstInt = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+
+int &nonConstIntReference = nonConstInt;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: variable 'nonConstIntReference' provides global access to non-const type, consider making the referenced data const [cppcoreguidelines-avoid-non-const-global-variables]
+
+int *pointerToNonConstInt = &nonConstInt;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: variable 'pointerToNonConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-MESSAGES: :[[@LINE-2]]:6: warning: variable 'pointerToNonConstInt' provides global access to non-const type, consider making the pointed-to data const [cppcoreguidelines-avoid-non-const-global-variables]
+
+int *const constPointerToNonConstInt = &nonConstInt;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'constPointerToNonConstInt' provides global access to non-const type, consider making the pointed-to data const [cppcoreguidelines-avoid-non-const-global-variables]
+
+namespace namespace_name {
+int nonConstNamespaceInt = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstNamespaceInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+
+const int constNamespaceInt = 0;
+} // namespace namespace_name
+
+const int constInt = 0;
+
+const int *pointerToConstInt = &constInt;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'pointerToConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+
+const int *const constPointerToConstInt = &constInt;
+
+const int &constReferenceToConstInt = constInt;
+
+constexpr int constexprInt = 0;
+
+int function() {
+  int nonConstReturnValue = 0;
+  return nonConstReturnValue;
+}
+
+namespace {
+int nonConstAnonymousNamespaceInt = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstAnonymousNamespaceInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+} // namespace
+
+class DummyClass {
+public:
+  int nonConstPublicMemberVariable = 0;
+  const int constPublicMemberVariable = 0;
+
+private:
+  int nonConstPrivateMemberVariable = 0;
+  const int constPrivateMemberVariable = 0;
+};
+
+DummyClass nonConstClassInstance;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'nonConstClassInstance' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+
+DummyClass *pointerToNonConstDummyClass = &nonConstClassInstance;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'pointerToNonConstDummyClass' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: variable 'pointerToNonConstDummyClass' provides global access to non-const type, consider making the pointed-to data const [cppcoreguidelines-avoid

[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

2020-02-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 243758.
balazske marked 2 inline comments as done.
balazske added a comment.
Herald added a subscriber: martong.

Improved tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/ErrorReturnChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/error-return.c

Index: clang/test/Analysis/error-return.c
===
--- /dev/null
+++ clang/test/Analysis/error-return.c
@@ -0,0 +1,157 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.ErrorReturn -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+FILE *file();
+
+void test_EOFOrNeg_LT_Good() {
+  if (fputs("str", file()) < 0) {
+  }
+}
+
+void test_EOFOrNeg_LT_Bad() {
+  if (fputs("str", file()) < -1) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void test_EOFOrNeg_GT_Good() {
+  if (fputs("str", file()) > -1) {
+  }
+}
+
+void test_EOFOrNeg_GT_Bad() {
+  if (fputs("str", file()) > 0) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void test_EOFOrNeg_LE_Good() {
+  if (fputs("str", file()) <= -1) {
+  }
+}
+
+void test_EOFOrNeg_LE_Bad() {
+  if (fputs("str", file()) <= 0) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void test_EOFOrNeg_GE_Good() {
+  if (fputs("str", file()) >= 0) {
+  }
+}
+
+void test_EOFOrNeg_GE_Bad() {
+  if (fputs("str", file()) >= -1) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void test_EOFOrNeg_EQ_Good() {
+  if (fputs("str", file()) == -1) {
+  }
+}
+
+void test_EOFOrNeg_EQ_Bad() {
+  if (fputs("str", file()) == 0) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void test_EOFOrNeg_NE_Good() {
+  if (fputs("str", file()) != -1) {
+  }
+}
+
+void test_EOFOrNeg_NE_Bad() {
+  if (fputs("str", file()) != 0) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void test_EOFOrNeg_EQ_BadVal() {
+  if (fputs("str", file()) == -2) { // expected-warning{{Use of return value that was not checked}}
+  }
+  if (fputs("str", file()) == 1) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void test_EOFOrNeg_VarAssign() {
+  int X = fputs("str", file());
+  if (X != 0) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void test_EOFOrNeg_VarAssignInCond() {
+  int X;
+  if ((X = fputs("str", file())) != 0) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void test_EOFOrNeg_VarAssign1() {
+  int X = fputs("str", file());
+  int Y = X;
+  if (Y != 0) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void badcheck(int X) {
+  if (X == 0) { } // expected-warning{{Use of return value that was not checked}}
+}
+
+void test_EOFOrNeg_Call() {
+  int X = fputs("str", file());
+  badcheck(X);
+}
+
+void test_EOFOrNeg_Syscall() {
+  int X = fputs("str", file());
+  fakeSystemHeaderCallIntVal(X); // expected-warning{{Use of return value that was not checked}}
+  fakeSystemHeaderCallIntVal(fputs("str", file())); // expected-warning{{Use of return value that was not checked}}
+}
+
+void test_EOFOrNeg_Use_LNot() {
+  int X = fputs("str", file());
+  if (!X) { // expected-warning{{Use of return value that was not checked}}
+  }
+}
+
+void test_EOFOrNeg_Use_Add() {
+  int X = fputs("str", file());
+  int Y = X + 1; // expected-warning{{Use of return value that was not checked}}
+}
+
+void test_EOFOrNeg_If() {
+  int X = fputs("str", file());
+  // FIXME: This should be detected.
+  if (X) {
+  }
+}
+
+void test_EOFOrNeg_IfCond() {
+  // FIXME: This should be detected.
+  if (fputs("str", file())) {
+  }
+}
+
+void unknown1(int);
+
+void test_EOFOrNeg_EscapeCall() {
+  int X = fputs("str", file());
+  unknown1(X);
+  int Y = X + 1;
+}
+
+int GlobalInt;
+
+void test_EOFOrNeg_EscapeGlobalAssign() {
+  GlobalInt = fputs("str", file());
+  int X = GlobalInt + 1;
+}
+
+void test_EOFOrNeg_NoErrorAfterGoodCheck() {
+  int X = fputs("str", file());
+  if (X < 0) {
+  }
+  if (X < 1) {
+  }
+}
+
+void test_EOFOrNeg_Unused() {
+  fputs("str", file());
+}
Index: clang/test/Analysis/Inputs/system-header-simulator.h
===
--- clang/test/Analysis/Inputs/system-header-simulator.h
+++ clang/test/Analysis/Inputs/system-header-simulator.h
@@ -53,6 +53,7 @@
  int (*)(void *, const char *, int),
  fpos_t (*)(void *, fpos_t, int),
  int (*)(void *));
+int fputs(const char *restrict, FILE *restrict);
 
 int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*));
 
@@ -82,6 +83,7 @@
 //The following are fake syste

[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-02-11 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal added a comment.

The pull request to C++ Core guidelines have been merged: 
https://github.com/isocpp/CppCoreGuidelines/pull/1553

Herb set me straight regarding the anonymous namespaces so I had to change that.
While waiting for the pull request to be reviewed I looked at more guidelines 
and also changed my mind about optionally ignoring data members, so I removed 
that option and made this check always ignore data members.
Data members are probably better dealt with in separate rules after all.

Sorry for the rather significant changes coming in this late when you all have 
already put so much time into reviewing, at least the check changed to be 
smaller in scope -which felt like the right way to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265



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


[PATCH] D74129: Prefer __vector over vector keyword for altivec use

2020-02-11 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D74129#1861777 , @serge-sans-paille 
wrote:

> @hans :  clang 10.0.0rc1  doesn't build on ppc64le in Fedora without that 
> patch.


Cherry-picked to 10.x as 699e2a6c5551eacf10be7e64f579120954f55b10 
. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74129



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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-02-11 Thread Tony Lewis via Phabricator via cfe-commits
tonyelewis added a comment.

Thanks very much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413



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


[PATCH] D74033: [clang-tidy] Fix PR#44620 'readability-redundant-string-cstr quick-fix causes invalid code'

2020-02-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp:64
 
+// Trying to get CallExpr in which CxxConstructExpr is called
+const clang::CallExpr *

Missing a full stop at the end of the comment.



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp:66
+const clang::CallExpr *
+tryGetCallExprAncestorForCxxConstructExpr(const Expr *TheExpr,
+ ASTContext &Context) {

This function and the one below can be `static`.



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp:83
+
+// Check that ParamDecl of CallExprDecl has rvalue type
+bool checkParamDeclOfAncestorCallExprHasRValueRefType(

Missing full stop at the end of the comment.



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp:93
+if (const auto *TheCallExprDecl =
+dyn_cast(TheCallExpr->getCalleeDecl())) {
+  if (TheCallExprDecl->getParamDecl(i)

What if the call expression has no callee decl, like a call through a function 
pointer? This might have to be `dyn_cast_or_null<>` (That's probably a good 
test case to add.)



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp:147
+  // If CxxConstructExpr is the part of some CallExpr we need to
+  // check that matched ParamDecl of the ancestor CallExpr is not rvalue
+  Finder->addMatcher(

Missing a full stop at the end of the comment.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp:209-210
+
+// Test for rvalue std::string
+
+void m1(std::string&& s) {

Missing full stop, can also remove the trailing newline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74033



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


[PATCH] D71110: [clangd] A tool to evaluate cross-file rename.

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

sorry for the delay, I just saw the comment today.

In D71110#1799960 , @kbobyrev wrote:

> For some reason, running this patch on a recent version of the source tree 
> fails. The AST parsing fails with fatal diagnostics, but I can't understand 
> why:
>
>   E[15:14:33.084] source file unknown type name 'PathRef' is illformed: 1
>   E[15:15:02.831] source file unknown type name 'NestedNameSpecifierLoc'; did 
> you mean 'std::clang::NestedNameSpecifierLoc'? is illformed: 1
>   E[15:14:02.912] source file unknown type name 'Location' is illformed: 1
>   E[15:14:47.797] source file 'index' is not a class, namespace, or 
> enumeration is illformed: 1
>   E[15:14:17.658] source file no template named 'vector' in namespace 'std' 
> is illformed: 1
>


I encountered the same error when rebasing to master. It was work before. To 
parse the file correctly, we need to inject the clang builtin header directory 
(via `resource-dir`) to the compile command, it was done by OverlayCDB, but 
there was a patch changing this behavior in December, which broke the tool.
It should be fixed now.




Comment at: clang-tools-extra/clangd/eval-rename/eval-rename.py:1
+#!/usr/bin/python
+"""

kbobyrev wrote:
> It probably makes sense to migrate this to Python 3 instead (shouldn't be too 
> hard, from what I can see there are Python 2 print statements, but nothing 
> else I can find).
good point.



Comment at: clang-tools-extra/clangd/eval-rename/eval-rename.py:21
+
+RENAME_EXECUTOR='build/bin/clangd-rename'
+

kbobyrev wrote:
> Would be useful to add an argument to the build directory, I typically don't 
> put `build/` into `llvm/`.
yeah. the current script currently assumes the directory layout:

```
llvm-project
  - build/
- bin/...
  - clang-tools-extra
  - ...
```



Comment at: clang-tools-extra/clangd/eval-rename/eval-rename.py:82
+success_cnt += 1
+  Run(['git', 'reset', '--hard'])
+  print 'Evaluated rename on %d symbols, %d symbol succeeded, go %s for 
failure logs' % (

kbobyrev wrote:
> `git reset --hard` might be dangerous if compile-commands are symlinked to 
> the build directory: `ninja -C build` would re-generate them and `git reset 
> --hard` will e.g. erase `add_subdirectory(eval-rename)` if it's not 
> committed. Maybe this should be mentioned somewhere in the comments/user 
> guide.
agree. it is dangerous, the script is expected to be ran on a clean client. we 
could improve it, e.g. prompt a confirm dialog, or abandon if  there are dirty 
changes in the client. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71110



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


[PATCH] D71110: [clangd] A tool to evaluate cross-file rename.

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

- rebase to master
- fix the breakage of the rename tool
- add more symbol to the tests
- some tweaks on the python script


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71110

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/eval-rename/CMakeLists.txt
  clang-tools-extra/clangd/eval-rename/RenameMain.cpp
  clang-tools-extra/clangd/eval-rename/eval-rename.py
  clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt

Index: clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
@@ -0,0 +1,16 @@
+# normal functions
+clang-tools-extra/clangd/XRefs.h clang::clangd::findReferences clangd
+# normal class methods
+clang-tools-extra/clangd/index/Index.h clang::clangd::SwapIndex::reset clangd
+# normal classes
+clang-tools-extra/clangd/index/Index.h clang::clangd::SymbolIndex clangd
+clang-tools-extra/clangd/ClangdServer.h clang::clangd::ClangdServer clangd
+clang-tools-extra/clangd/GlobalCompilationDatabase.h clang::clangd::GlobalCompilationDatabase clangd
+clang-tools-extra/clangd/GlobalCompilationDatabase.h clang::clangd::OverlayCDB clangd
+clang-tools-extra/clangd/Protocol.h clang::clangd::CodeAction clangd
+# rename enum
+clang-tools-extra/clangd/index/Ref.h clang::clangd::RefKind clangd
+# rename enum constants
+clang-tools-extra/clangd/FindTarget.h clang::clangd::DeclRelation::Alias clangd
+# class with template constructors
+clang-tools-extra/clangd/index/MemIndex.h clang::clangd::MemIndex clangd
\ No newline at end of file
Index: clang-tools-extra/clangd/eval-rename/eval-rename.py
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/eval-rename.py
@@ -0,0 +1,88 @@
+#!/usr/bin/python
+"""
+A script to perform cross-file rename and evalute the results.
+
+Usage:
+
+$ cd /llvm-project
+$ ninja -C build clangd-indexer
+$ ./build/bin/clangd-indexer -format=binary -executor=all-TUs . > llvm-index.idx
+$ ninja -C build clangd-rename
+$ clang-tools-extra/clangd/eval-rename/eval-rename.py --index=llvm-index.idx --file=clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
+"""
+
+from __future__ import print_function
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+import tempfile
+
+RENAME_EXECUTOR='build/bin/clangd-rename'
+
+def Run(cmd):
+  s = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+  print('>', ' '.join(cmd))
+  [stdout, stderr] = s.communicate()
+  return (s.returncode, stdout, stderr)
+
+if __name__ == '__main__':
+  if not os.getcwd().endswith('llvm-project'):
+sys.exit('The tool must be run from llvm-project/ root.')
+
+  ap = argparse.ArgumentParser()
+  ap.add_argument(
+  '-f',
+  '--file',
+  required=True,
+  help='A file containing rename symbols to be evaluted.'
+  )
+  ap.add_argument(
+  '-idx',
+  '--index',
+  required=True,
+  help='A path to the index file'
+  )
+  args = ap.parse_args()
+
+  with open(args.file) as f:
+out = f.read()
+  test_cases = [line.strip().split() for line in out.split('\n') \
+ if line and not line.startswith('#') and line.strip()]
+
+  log_output_dir = tempfile.mkdtemp(prefix='eval-rename_')
+  success_cnt = 0
+  for file_name, rename_symbol, verify_target in test_cases:
+Run(['git', 'reset', '--hard'])
+execute_rename_cmd = [
+  RENAME_EXECUTOR,
+   '--index-path=%s' % args.index,
+   '--rename-symbol=%s' % rename_symbol,
+   '-fix',
+   file_name,
+]
+rename_results = Run(execute_rename_cmd)
+if rename_results[0] != 0:
+  log_file = open(os.path.join(
+log_output_dir, rename_symbol.replace("::", "_") + '_RenameFailed'), 'w')
+  log_file.write(rename_results[1]) # stdout
+  log_file.write(rename_results[2]) # stderr
+  log_file.close()
+  continue
+
+build_results = Run(['ninja', '-C', 'build', verify_target])
+if build_results[0] != 0:
+  print('failed on renaming %s' % rename_symbol)
+  log_file = open(os.path.join(
+log_output_dir, rename_symbol.replace("::", "_") + '_BuildFailed'), 'w')
+  log_file.write(build_results[1]) # stdout
+  log_file.write(build_results[2]) # stderr
+  log_file.close()
+  continue
+print('succeed on renaming %s' % rename_symbol)
+success_cnt += 1
+  Run(['git', 'reset', '--hard'])
+  print('Evaluated rename on %d symbols, %d symbol succeeded, go %s for failure logs' %
+  (len(test_cases), success_cnt, log_output_dir))
Index: clang-tools-extra/clangd/eval-rename/RenameMain.cpp
===
--- /dev/null
+++ clang-tools-extra/clang

[PATCH] D72872: [ObjC generics] Fix not inheriting type bounds in categories/extensions.

2020-02-11 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I don't have the context here. Was I added as a subscriber because it's related 
to the clang 10 release?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72872



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


[PATCH] D74384: Use std::foo_t rather than std::foo in LLVM.

2020-02-11 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.

Push and watch the bots


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74384



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


[PATCH] D73644: [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores.

2020-02-11 Thread Mirko Brkusanin via Phabricator via cfe-commits
mbrkusanin updated this revision to Diff 243775.
mbrkusanin edited the summary of this revision.
mbrkusanin added a comment.

- Rebase
- Rename **ldrq_w** to **ldr_w**; Rename **strq_w** to **str_w**.




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

https://reviews.llvm.org/D73644

Files:
  clang/include/clang/Basic/BuiltinsMips.def
  clang/lib/Headers/msa.h
  clang/lib/Sema/SemaChecking.cpp
  llvm/include/llvm/IR/IntrinsicsMips.td
  llvm/lib/Target/Mips/MipsISelLowering.cpp
  llvm/lib/Target/Mips/MipsISelLowering.h
  llvm/lib/Target/Mips/MipsMSAInstrInfo.td
  llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
  llvm/test/CodeGen/Mips/msa/ldr_str.ll

Index: llvm/test/CodeGen/Mips/msa/ldr_str.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/msa/ldr_str.ll
@@ -0,0 +1,224 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -march=mips -mcpu=mips32r5 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R5-EB
+; RUN: llc -march=mipsel   -mcpu=mips32r5 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R5-EL
+; RUN: llc -march=mips -mcpu=mips32r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R6-EB
+; RUN: llc -march=mipsel   -mcpu=mips32r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R6-EL
+; RUN: llc -march=mips64   -mcpu=mips64r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS64R6
+; RUN: llc -march=mips64el -mcpu=mips64r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS64R6
+
+; Test intrinsics for 4-byte and 8-byte MSA load and stores.
+
+define void @llvm_mips_ldr_d_test(<2 x i64>* %val, i8* %ptr) nounwind {
+; MIPS32R5-EB-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R5-EB:   # %bb.0: # %entry
+; MIPS32R5-EB-NEXT:# implicit-def: $at
+; MIPS32R5-EB-NEXT:lwr $1, 23($5)
+; MIPS32R5-EB-NEXT:lwl $1, 20($5)
+; MIPS32R5-EB-NEXT:# implicit-def: $v0
+; MIPS32R5-EB-NEXT:lwr $2, 19($5)
+; MIPS32R5-EB-NEXT:lwl $2, 16($5)
+; MIPS32R5-EB-NEXT:fill.w $w0, $1
+; MIPS32R5-EB-NEXT:insert.w $w0[1], $2
+; MIPS32R5-EB-NEXT:st.d $w0, 0($4)
+; MIPS32R5-EB-NEXT:jr $ra
+; MIPS32R5-EB-NEXT:nop
+;
+; MIPS32R5-EL-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R5-EL:   # %bb.0: # %entry
+; MIPS32R5-EL-NEXT:# implicit-def: $at
+; MIPS32R5-EL-NEXT:lwr $1, 16($5)
+; MIPS32R5-EL-NEXT:lwl $1, 19($5)
+; MIPS32R5-EL-NEXT:# implicit-def: $v0
+; MIPS32R5-EL-NEXT:lwr $2, 20($5)
+; MIPS32R5-EL-NEXT:lwl $2, 23($5)
+; MIPS32R5-EL-NEXT:fill.w $w0, $1
+; MIPS32R5-EL-NEXT:insert.w $w0[1], $2
+; MIPS32R5-EL-NEXT:st.d $w0, 0($4)
+; MIPS32R5-EL-NEXT:jr $ra
+; MIPS32R5-EL-NEXT:nop
+;
+; MIPS32R6-EB-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R6-EB:   # %bb.0: # %entry
+; MIPS32R6-EB-NEXT:lw $1, 20($5)
+; MIPS32R6-EB-NEXT:lw $2, 16($5)
+; MIPS32R6-EB-NEXT:fill.w $w0, $1
+; MIPS32R6-EB-NEXT:insert.w $w0[1], $2
+; MIPS32R6-EB-NEXT:st.d $w0, 0($4)
+; MIPS32R6-EB-NEXT:jrc $ra
+;
+; MIPS32R6-EL-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R6-EL:   # %bb.0: # %entry
+; MIPS32R6-EL-NEXT:lw $1, 16($5)
+; MIPS32R6-EL-NEXT:lw $2, 20($5)
+; MIPS32R6-EL-NEXT:fill.w $w0, $1
+; MIPS32R6-EL-NEXT:insert.w $w0[1], $2
+; MIPS32R6-EL-NEXT:st.d $w0, 0($4)
+; MIPS32R6-EL-NEXT:jrc $ra
+;
+; MIPS64R6-LABEL: llvm_mips_ldr_d_test:
+; MIPS64R6:   # %bb.0: # %entry
+; MIPS64R6-NEXT:ld $1, 16($5)
+; MIPS64R6-NEXT:fill.d $w0, $1
+; MIPS64R6-NEXT:st.d $w0, 0($4)
+; MIPS64R6-NEXT:jrc $ra
+entry:
+  %0 = tail call <2 x i64> @llvm.mips.ldr.d(i8* %ptr, i32 16)
+  store <2 x i64> %0, <2 x i64>* %val
+  ret void
+}
+
+declare <2 x i64> @llvm.mips.ldr.d(i8*, i32) nounwind
+
+define void @llvm_mips_ldr_w_test(<4 x i32>* %val, i8* %ptr) nounwind {
+; MIPS32R5-EB-LABEL: llvm_mips_ldr_w_test:
+; MIPS32R5-EB:   # %bb.0: # %entry
+; MIPS32R5-EB-NEXT:# implicit-def: $at
+; MIPS32R5-EB-NEXT:lwr $1, 19($5)
+; MIPS32R5-EB-NEXT:lwl $1, 16($5)
+; MIPS32R5-EB-NEXT:fill.w $w0, $1
+; MIPS32R5-EB-NEXT:st.w $w0, 0($4)
+; MIPS32R5-EB-NEXT:jr $ra
+; MIPS32R5-EB-NEXT:nop
+;
+; MIPS32R5-EL-LABEL: llvm_mips_ldr_w_test:
+; MIPS32R5-EL:   # %bb.0: # %entry
+; MIPS32R5-EL-NEXT:# implicit-def: $at
+; MIPS32R5-EL-NEXT:lwr $1, 16($5)
+; MIPS32R5-EL-NEXT:lwl $1, 19($5)
+; MIPS32R5-EL-NEXT:fill.w $w0, $1
+; MIPS32R5-EL-NEXT:st.w $w0, 0($4)
+; MIPS32R5-EL-NEXT:jr $ra
+; MIPS32R5-EL-NEXT:nop
+;
+; MIPS32R6-EB-LABEL: llvm_mips_ldr_w_test:
+; MIPS32R6-EB:   # %bb.0: # %entry
+; MIPS32R6-EB-NEXT:lw $1, 16($5)
+; MIPS32R6-EB-NEXT:fill.w $w0, $1
+; MIPS32R6-EB-NEXT:st.w $w0, 0($4)
+; MIPS32R6-EB-NEXT:jrc $ra
+;
+; MIPS32R6-EL-LABEL: llvm_mips_ldr_w_test:
+; MIPS32R6-EL:   # %bb.0: # %entry
+; MIPS32R6-EL-NEXT:lw $1, 16($5)
+; MIPS32R6-EL-NEXT:fill.w $w0, $1
+; MIPS32R6-EL-NEXT:st.w $

[PATCH] D70876: [clang-tidy] Add spuriously-wake-up-functions check

2020-02-11 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis updated this revision to Diff 243779.
abelkocsis added a comment.

Checker update to analyse language, separated checks for C and C++.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70876

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-spuriously-wake-up-functions.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.c
  clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.cpp
@@ -0,0 +1,191 @@
+// RUN: %check_clang_tidy %s bugprone-spuriously-wake-up-functions %t -- --
+#define NULL 0
+
+namespace std {
+using intmax_t = int;
+
+template 
+class ratio {
+public:
+  static constexpr intmax_t num = 0;
+  static constexpr intmax_t den = 0;
+  typedef ratio type;
+};
+typedef ratio<1, 1000> milli;
+namespace chrono {
+
+template >
+class duration {
+public:
+  using rep = Rep;
+  using period = Period;
+
+public:
+  constexpr duration() = default;
+  template 
+  constexpr explicit duration(const Rep2 &r);
+  template 
+  constexpr duration(const duration &d);
+  ~duration() = default;
+  duration(const duration &) = default;
+};
+
+template 
+class time_point {
+public:
+  using clock = Clock;
+  using duration = Duration;
+
+public:
+  constexpr time_point();
+  constexpr explicit time_point(const duration &d);
+  template 
+  constexpr time_point(const time_point &t);
+};
+
+using milliseconds = duration;
+
+class system_clock {
+public:
+  typedef milliseconds duration;
+  typedef duration::rep rep;
+  typedef duration::period period;
+  typedef chrono::time_point time_point;
+
+  static time_point now() noexcept;
+};
+} // namespace chrono
+
+class mutex;
+template 
+class unique_lock {
+public:
+  typedef Mutex mutex_type;
+
+  unique_lock() noexcept;
+  explicit unique_lock(mutex_type &m);
+};
+
+class mutex {
+public:
+  constexpr mutex() noexcept;
+  ~mutex();
+  mutex(const mutex &) = delete;
+  mutex &operator=(const mutex &) = delete;
+};
+
+enum class cv_status {
+  no_timeout,
+  timeout
+};
+
+class condition_variable {
+public:
+  condition_variable();
+  ~condition_variable();
+  condition_variable(const condition_variable &) = delete;
+
+  void wait(unique_lock &lock);
+  template 
+  void wait(unique_lock &lock, Predicate pred);
+  template 
+  cv_status wait_until(unique_lock &lock,
+   const chrono::time_point &abs_time){};
+  template 
+  bool wait_until(unique_lock &lock,
+  const chrono::time_point &abs_time,
+  Predicate pred){};
+  template 
+  cv_status wait_for(unique_lock &lock,
+ const chrono::duration &rel_time){};
+  template 
+  bool wait_for(unique_lock &lock,
+const chrono::duration &rel_time,
+Predicate pred){};
+};
+
+} // namespace std
+
+struct Node1 {
+  void *Node1;
+  struct Node1 *next;
+};
+
+static Node1 list;
+static std::mutex m;
+static std::condition_variable condition;
+
+void consume_list_element(std::condition_variable &condition) {
+  std::unique_lock lk(m);
+
+  if (list.next == nullptr) {
+condition.wait(lk);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait' should be placed inside a while statement or used with a conditional parameter [bugprone-spuriously-wake-up-functions]
+  }
+
+  while (list.next == nullptr) {
+condition.wait(lk);
+  }
+
+  do {
+condition.wait(lk);
+  } while (list.next == nullptr);
+
+  for (;; list.next == nullptr) {
+condition.wait(lk);
+  }
+
+  if (list.next == nullptr) {
+while (list.next == nullptr) {
+  condition.wait(lk);
+}
+  }
+
+  if (list.next == nullptr) {
+do {
+  condition.wait(lk);
+} while (list.next == nullptr);
+  }
+
+  if (list.next == nullptr) {
+for (;; list.next == nullptr) {
+  condition.wait(lk);
+}
+  }
+  using durtype = std::chrono::duration;
+  durtype dur = std::chrono::duration();
+  if (list.next == nullptr) {
+condition.wait_for(lk, dur);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait_for' should be placed inside a while statement or used with a conditional parameter [bugprone-spuriously-wake-up-functions]
+

[PATCH] D73687: [AArch64][SVE] Add SVE2 intrinsics for complex integer dot product

2020-02-11 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe7755f9e4f48: [AArch64][SVE] Add SVE2 intrinsics for complex 
integer dot product (authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D73687?vs=241726&id=243781#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73687

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll
@@ -0,0 +1,61 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+
+;
+; CDOT
+;
+
+define  @cdot_s( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_s:
+; CHECK: cdot z0.s, z1.b, z2.b, #0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.nxv4i32( %a,
+ %b,
+ %c,
+i32 0)
+  ret  %out
+}
+
+define  @cdot_d( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_d:
+; CHECK: cdot z0.d, z1.h, z2.h, #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.nxv2i64( %a,
+ %b,
+ %c,
+i32 90)
+  ret  %out
+}
+
+;
+; CDOT(indexed)
+;
+
+define  @cdot_s_idx( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_s_idx:
+; CHECK: cdot z0.s, z1.b, z2.b[0], #180
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.lane.nxv4i32( %a,
+  %b,
+  %c,
+ i32 0, i32 180)
+  ret  %out
+}
+
+
+define  @cdot_d_idx( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_d_idx:
+; CHECK: cdot z0.d, z1.h, z2.h[1], #270
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.lane.nxv2i64( %a,
+  %b,
+  %c,
+ i32 1, i32 270)
+  ret  %out
+}
+
+
+declare  @llvm.aarch64.sve.cdot.nxv4i32(, , , i32)
+declare  @llvm.aarch64.sve.cdot.nxv2i64(, , , i32)
+declare  @llvm.aarch64.sve.cdot.lane.nxv4i32(, , , i32, i32)
+declare  @llvm.aarch64.sve.cdot.lane.nxv2i64(, , , i32, i32)
Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -2542,9 +2542,16 @@
   let ElementSize = ElementSizeNone;
 }
 
-multiclass sve2_cintx_dot {
+multiclass sve2_cintx_dot {
   def _S : sve2_complex_int_arith<0b10, 0b0001, asm, ZPR32, ZPR8>;
   def _D : sve2_complex_int_arith<0b11, 0b0001, asm, ZPR64, ZPR16>;
+
+  def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
+ (i32 complexrotateop:$imm))),
+(!cast(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, complexrotateop:$imm)>;
+  def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
+ (i32 complexrotateop:$imm))),
+(!cast(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, complexrotateop:$imm)>;
 }
 
 //===--===//
@@ -2589,19 +2596,26 @@
   let ElementSize = ElementSizeNone;
 }
 
-multiclass sve2_cintx_dot_by_indexed_elem {
-  def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS> {
+multiclass sve2_cintx_dot_by_indexed_elem {
+  def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> {
 bits<2> iop;
 bits<3> Zm;
 let Inst{20-19} = iop;
 let Inst{18-16} = Zm;
   }
-  def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD> {
+  def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> {
 bit iop;
 bits<4> Zm;
 let Inst{20} = iop;
 let Inst{19-16} = Zm;
   }
+
+  def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
+ (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
+(!cast(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
+  def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1

[clang] 5ba931a - [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores.

2020-02-11 Thread Mirko Brkusanin via cfe-commits

Author: Mirko Brkusanin
Date: 2020-02-11T11:47:30+01:00
New Revision: 5ba931a84a3466aebab5d6dde3525e7a27c40c28

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

LOG: [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores.

New intrinisics are implemented for when we need to port SIMD code from other
arhitectures and only load or store portions of MSA registers.

Following intriniscs are added which only load/store element 0 of a vector:
v4i32 __builtin_msa_ldrq_w (const void *, imm_n2048_2044);
v2i64 __builtin_msa_ldr_d (const void *, imm_n4096_4088);
void __builtin_msa_strq_w (v4i32, void *, imm_n2048_2044);
void __builtin_msa_str_d (v2i64, void *, imm_n4096_4088);

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

Added: 
llvm/test/CodeGen/Mips/msa/ldr_str.ll

Modified: 
clang/include/clang/Basic/BuiltinsMips.def
clang/lib/Headers/msa.h
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsMips.td
llvm/lib/Target/Mips/MipsISelLowering.cpp
llvm/lib/Target/Mips/MipsISelLowering.h
llvm/lib/Target/Mips/MipsMSAInstrInfo.td
llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsMips.def 
b/clang/include/clang/Basic/BuiltinsMips.def
index 9ac75b7a174e..2aca4cb226bc 100644
--- a/clang/include/clang/Basic/BuiltinsMips.def
+++ b/clang/include/clang/Basic/BuiltinsMips.def
@@ -635,6 +635,9 @@ BUILTIN(__builtin_msa_ld_h, "V8Ssv*Ii", "nc")
 BUILTIN(__builtin_msa_ld_w, "V4Siv*Ii", "nc")
 BUILTIN(__builtin_msa_ld_d, "V2SLLiv*Ii", "nc")
 
+BUILTIN(__builtin_msa_ldr_d, "V2SLLiv*Ii", "nc")
+BUILTIN(__builtin_msa_ldr_w, "V4Siv*Ii", "nc")
+
 BUILTIN(__builtin_msa_ldi_b, "V16cIi", "nc")
 BUILTIN(__builtin_msa_ldi_h, "V8sIi", "nc")
 BUILTIN(__builtin_msa_ldi_w, "V4iIi", "nc")
@@ -857,6 +860,9 @@ BUILTIN(__builtin_msa_st_h, "vV8Ssv*Ii", "nc")
 BUILTIN(__builtin_msa_st_w, "vV4Siv*Ii", "nc")
 BUILTIN(__builtin_msa_st_d, "vV2SLLiv*Ii", "nc")
 
+BUILTIN(__builtin_msa_str_d, "vV2SLLiv*Ii", "nc")
+BUILTIN(__builtin_msa_str_w, "vV4Siv*Ii", "nc")
+
 BUILTIN(__builtin_msa_subs_s_b, "V16ScV16ScV16Sc", "nc")
 BUILTIN(__builtin_msa_subs_s_h, "V8SsV8SsV8Ss", "nc")
 BUILTIN(__builtin_msa_subs_s_w, "V4SiV4SiV4Si", "nc")

diff  --git a/clang/lib/Headers/msa.h b/clang/lib/Headers/msa.h
index 19ea6071aa93..0ca4900870f1 100644
--- a/clang/lib/Headers/msa.h
+++ b/clang/lib/Headers/msa.h
@@ -212,10 +212,14 @@ typedef double v2f64_d __attribute__ ((vector_size(16), 
aligned(8)));
 #define __msa_ld_h __builtin_msa_ld_h
 #define __msa_ld_w __builtin_msa_ld_w
 #define __msa_ld_d __builtin_msa_ld_d
+#define __msa_ldr_d __builtin_msa_ldr_d
+#define __msa_ldr_w __builtin_msa_ldrq_w
 #define __msa_st_b __builtin_msa_st_b
 #define __msa_st_h __builtin_msa_st_h
 #define __msa_st_w __builtin_msa_st_w
 #define __msa_st_d __builtin_msa_st_d
+#define __msa_str_d __builtin_msa_str_d
+#define __msa_str_w __builtin_msa_strq_w
 #define __msa_sat_s_b __builtin_msa_sat_s_b
 #define __msa_sat_s_h __builtin_msa_sat_s_h
 #define __msa_sat_s_w __builtin_msa_sat_s_w

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a06a82331c9b..eca82c559e06 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2755,10 +2755,14 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, 
CallExpr *TheCall) {
   case Mips::BI__builtin_msa_ld_h: i = 1; l = -1024; u = 1022; m = 2; break;
   case Mips::BI__builtin_msa_ld_w: i = 1; l = -2048; u = 2044; m = 4; break;
   case Mips::BI__builtin_msa_ld_d: i = 1; l = -4096; u = 4088; m = 8; break;
+  case Mips::BI__builtin_msa_ldr_d: i = 1; l = -4096; u = 4088; m = 8; break;
+  case Mips::BI__builtin_msa_ldr_w: i = 1; l = -2048; u = 2044; m = 4; break;
   case Mips::BI__builtin_msa_st_b: i = 2; l = -512; u = 511; m = 1; break;
   case Mips::BI__builtin_msa_st_h: i = 2; l = -1024; u = 1022; m = 2; break;
   case Mips::BI__builtin_msa_st_w: i = 2; l = -2048; u = 2044; m = 4; break;
   case Mips::BI__builtin_msa_st_d: i = 2; l = -4096; u = 4088; m = 8; break;
+  case Mips::BI__builtin_msa_str_d: i = 2; l = -4096; u = 4088; m = 8; break;
+  case Mips::BI__builtin_msa_str_w: i = 2; l = -2048; u = 2044; m = 4; break;
   }
 
   if (!m)

diff  --git a/llvm/include/llvm/IR/IntrinsicsMips.td 
b/llvm/include/llvm/IR/IntrinsicsMips.td
index bfcdd80a52d5..9f9d6d78abea 100644
--- a/llvm/include/llvm/IR/IntrinsicsMips.td
+++ b/llvm/include/llvm/IR/IntrinsicsMips.td
@@ -1271,6 +1271,13 @@ def int_mips_ld_d : GCCBuiltin<"__builtin_msa_ld_d">,
   Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_i32_ty],
   [IntrReadMem, IntrArgMemOnly]>;
 
+def int_mips_ldr_d : GCCBuiltin<"__builtin_msa_ldr_d">,
+  Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_i32_ty],
+  [IntrReadMem, IntrA

[PATCH] D73644: [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores.

2020-02-11 Thread Mirko Brkusanin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ba931a84a34: [Mips] Add intrinsics for 4-byte and 8-byte 
MSA loads/stores. (authored by mbrkusanin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73644

Files:
  clang/include/clang/Basic/BuiltinsMips.def
  clang/lib/Headers/msa.h
  clang/lib/Sema/SemaChecking.cpp
  llvm/include/llvm/IR/IntrinsicsMips.td
  llvm/lib/Target/Mips/MipsISelLowering.cpp
  llvm/lib/Target/Mips/MipsISelLowering.h
  llvm/lib/Target/Mips/MipsMSAInstrInfo.td
  llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
  llvm/test/CodeGen/Mips/msa/ldr_str.ll

Index: llvm/test/CodeGen/Mips/msa/ldr_str.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/msa/ldr_str.ll
@@ -0,0 +1,224 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -march=mips -mcpu=mips32r5 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R5-EB
+; RUN: llc -march=mipsel   -mcpu=mips32r5 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R5-EL
+; RUN: llc -march=mips -mcpu=mips32r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R6-EB
+; RUN: llc -march=mipsel   -mcpu=mips32r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R6-EL
+; RUN: llc -march=mips64   -mcpu=mips64r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS64R6
+; RUN: llc -march=mips64el -mcpu=mips64r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS64R6
+
+; Test intrinsics for 4-byte and 8-byte MSA load and stores.
+
+define void @llvm_mips_ldr_d_test(<2 x i64>* %val, i8* %ptr) nounwind {
+; MIPS32R5-EB-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R5-EB:   # %bb.0: # %entry
+; MIPS32R5-EB-NEXT:# implicit-def: $at
+; MIPS32R5-EB-NEXT:lwr $1, 23($5)
+; MIPS32R5-EB-NEXT:lwl $1, 20($5)
+; MIPS32R5-EB-NEXT:# implicit-def: $v0
+; MIPS32R5-EB-NEXT:lwr $2, 19($5)
+; MIPS32R5-EB-NEXT:lwl $2, 16($5)
+; MIPS32R5-EB-NEXT:fill.w $w0, $1
+; MIPS32R5-EB-NEXT:insert.w $w0[1], $2
+; MIPS32R5-EB-NEXT:st.d $w0, 0($4)
+; MIPS32R5-EB-NEXT:jr $ra
+; MIPS32R5-EB-NEXT:nop
+;
+; MIPS32R5-EL-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R5-EL:   # %bb.0: # %entry
+; MIPS32R5-EL-NEXT:# implicit-def: $at
+; MIPS32R5-EL-NEXT:lwr $1, 16($5)
+; MIPS32R5-EL-NEXT:lwl $1, 19($5)
+; MIPS32R5-EL-NEXT:# implicit-def: $v0
+; MIPS32R5-EL-NEXT:lwr $2, 20($5)
+; MIPS32R5-EL-NEXT:lwl $2, 23($5)
+; MIPS32R5-EL-NEXT:fill.w $w0, $1
+; MIPS32R5-EL-NEXT:insert.w $w0[1], $2
+; MIPS32R5-EL-NEXT:st.d $w0, 0($4)
+; MIPS32R5-EL-NEXT:jr $ra
+; MIPS32R5-EL-NEXT:nop
+;
+; MIPS32R6-EB-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R6-EB:   # %bb.0: # %entry
+; MIPS32R6-EB-NEXT:lw $1, 20($5)
+; MIPS32R6-EB-NEXT:lw $2, 16($5)
+; MIPS32R6-EB-NEXT:fill.w $w0, $1
+; MIPS32R6-EB-NEXT:insert.w $w0[1], $2
+; MIPS32R6-EB-NEXT:st.d $w0, 0($4)
+; MIPS32R6-EB-NEXT:jrc $ra
+;
+; MIPS32R6-EL-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R6-EL:   # %bb.0: # %entry
+; MIPS32R6-EL-NEXT:lw $1, 16($5)
+; MIPS32R6-EL-NEXT:lw $2, 20($5)
+; MIPS32R6-EL-NEXT:fill.w $w0, $1
+; MIPS32R6-EL-NEXT:insert.w $w0[1], $2
+; MIPS32R6-EL-NEXT:st.d $w0, 0($4)
+; MIPS32R6-EL-NEXT:jrc $ra
+;
+; MIPS64R6-LABEL: llvm_mips_ldr_d_test:
+; MIPS64R6:   # %bb.0: # %entry
+; MIPS64R6-NEXT:ld $1, 16($5)
+; MIPS64R6-NEXT:fill.d $w0, $1
+; MIPS64R6-NEXT:st.d $w0, 0($4)
+; MIPS64R6-NEXT:jrc $ra
+entry:
+  %0 = tail call <2 x i64> @llvm.mips.ldr.d(i8* %ptr, i32 16)
+  store <2 x i64> %0, <2 x i64>* %val
+  ret void
+}
+
+declare <2 x i64> @llvm.mips.ldr.d(i8*, i32) nounwind
+
+define void @llvm_mips_ldr_w_test(<4 x i32>* %val, i8* %ptr) nounwind {
+; MIPS32R5-EB-LABEL: llvm_mips_ldr_w_test:
+; MIPS32R5-EB:   # %bb.0: # %entry
+; MIPS32R5-EB-NEXT:# implicit-def: $at
+; MIPS32R5-EB-NEXT:lwr $1, 19($5)
+; MIPS32R5-EB-NEXT:lwl $1, 16($5)
+; MIPS32R5-EB-NEXT:fill.w $w0, $1
+; MIPS32R5-EB-NEXT:st.w $w0, 0($4)
+; MIPS32R5-EB-NEXT:jr $ra
+; MIPS32R5-EB-NEXT:nop
+;
+; MIPS32R5-EL-LABEL: llvm_mips_ldr_w_test:
+; MIPS32R5-EL:   # %bb.0: # %entry
+; MIPS32R5-EL-NEXT:# implicit-def: $at
+; MIPS32R5-EL-NEXT:lwr $1, 16($5)
+; MIPS32R5-EL-NEXT:lwl $1, 19($5)
+; MIPS32R5-EL-NEXT:fill.w $w0, $1
+; MIPS32R5-EL-NEXT:st.w $w0, 0($4)
+; MIPS32R5-EL-NEXT:jr $ra
+; MIPS32R5-EL-NEXT:nop
+;
+; MIPS32R6-EB-LABEL: llvm_mips_ldr_w_test:
+; MIPS32R6-EB:   # %bb.0: # %entry
+; MIPS32R6-EB-NEXT:lw $1, 16($5)
+; MIPS32R6-EB-NEXT:fill.w $w0, $1
+; MIPS32R6-EB-NEXT:st.w $w0, 0($4)
+; MIPS32R6-EB-NEXT:jrc $ra
+;
+; MIPS32R6-EL-LABEL: llvm_mips_ldr_w_test:
+; MIPS32R6-EL:   # %bb.0: # %entry
+; MIPS32R6-EL-NEXT:lw $1, 16($5)
+; MIPS32R6-EL-NEXT:fill.w $w0, $1

[PATCH] D74332: [ARM,MVE] Add intrinsics for int <-> float conversion.

2020-02-11 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM accepted this revision.
MarkMurrayARM 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/D74332/new/

https://reviews.llvm.org/D74332



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


[PATCH] D74331: [ARM,MVE] Add intrinsics for abs, neg and not operations.

2020-02-11 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 243788.
simon_tatham added a comment.

Rebased to current master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74331

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/absneg.c

Index: clang/test/CodeGen/arm-mve-intrinsics/absneg.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/absneg.c
@@ -0,0 +1,338 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vabsq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.fabs.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vabsq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.fabs.v4f32(<4 x float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vabsq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <16 x i8> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <16 x i8> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <16 x i1> [[TMP0]], <16 x i8> [[TMP1]], <16 x i8> [[A]]
+// CHECK-NEXT:ret <16 x i8> [[TMP2]]
+//
+int8x16_t test_vabsq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <8 x i16> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <8 x i16> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <8 x i1> [[TMP0]], <8 x i16> [[TMP1]], <8 x i16> [[A]]
+// CHECK-NEXT:ret <8 x i16> [[TMP2]]
+//
+int16x8_t test_vabsq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <4 x i32> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <4 x i32> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <4 x i1> [[TMP0]], <4 x i32> [[TMP1]], <4 x i32> [[A]]
+// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+//
+int32x4_t test_vabsq_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vmvnq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i16> [[A:%.*]], 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vmvnq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <4 x i32> [[A:%.*]], 
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vmvnq_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vmvnq_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i16> [[A:%.*]], 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+uint16x8_t test_vmvnq_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return v

[PATCH] D74332: [ARM,MVE] Add intrinsics for int <-> float conversion.

2020-02-11 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 243789.
simon_tatham added a comment.

Rebased to current master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74332

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vcvt.c

Index: clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
+++ clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
@@ -4,6 +4,102 @@
 
 #include 
 
+// CHECK-LABEL: @test_vcvtq_f16_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = sitofp <8 x i16> [[A:%.*]] to <8 x half>
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vcvtq_f16_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f16_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f16_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = uitofp <8 x i16> [[A:%.*]] to <8 x half>
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vcvtq_f16_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f16_u16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f32_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = sitofp <4 x i32> [[A:%.*]] to <4 x float>
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vcvtq_f32_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f32_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f32_u32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = uitofp <4 x i32> [[A:%.*]] to <4 x float>
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vcvtq_f32_u32(uint32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f32_u32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_s16_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptosi <8 x half> [[A:%.*]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vcvtq_s16_f16(float16x8_t a)
+{
+return vcvtq_s16_f16(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_s32_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptosi <4 x float> [[A:%.*]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vcvtq_s32_f32(float32x4_t a)
+{
+return vcvtq_s32_f32(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_u16_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptoui <8 x half> [[A:%.*]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+uint16x8_t test_vcvtq_u16_f16(float16x8_t a)
+{
+return vcvtq_u16_f16(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_u32_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptoui <4 x float> [[A:%.*]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+uint32x4_t test_vcvtq_u32_f32(float32x4_t a)
+{
+return vcvtq_u32_f32(a);
+}
+
 // CHECK-LABEL: @test_vcvttq_f16_f32(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.arm.mve.vcvt.narrow(<8 x half> [[A:%.*]], <4 x float> [[B:%.*]], i32 1)
Index: clang/include/clang/Basic/arm_mve_defs.td
===
--- clang/include/clang/Basic/arm_mve_defs.td
+++ clang/include/clang/Basic/arm_mve_defs.td
@@ -121,6 +121,10 @@
 def splat: CGHelperFn<"ARMMVEVectorSplat">;
 def select: IRBuilder<"CreateSelect">;
 def fneg: IRBuilder<"CreateFNeg">;
+def sitofp: IRBuilder<"CreateSIToFP">;
+def uitofp: IRBuilder<"CreateUIToFP">;
+def fptosi: IRBuilder<"CreateFPToSI">;
+def fptoui: IRBuilder<"CreateFPToUI">;
 
 // A node that makes an Address out of a pointer-typed Value, by
 // providing an alignment as the second argument.
Index: clang/include/clang/Basic/arm_mve.td
===
--- clang/include/clang/Basic/arm_mve.td
+++ clang/include/clang/Basic/arm_mve.td
@@ -332,6 +332,23 @@
   } // params = [f32], pnt = PNT_None
 } // loop over half = "b", "t"
 
+multiclass float_int_conversions {
+  defvar FVector = VecOf;
+  defvar IVector = VecOf;
+
+  let params = [IScalar], pnt = PNT_2Type in
+def : Intrinsic,
+  NameOverride<"vcvtq_" # FScalar>;
+  let params = [FScalar], pnt = PNT_None in
+def : Intrinsic,
+  NameOverride<"vcvtq_" # IScalar>;
+}
+
+defm : float_int_conversions;
+defm : float_int_conversions;
+defm : float_int_conversions;
+defm : float_int_conversions;
+
 multiclass compare_with_pred {
   // Make the predicated and unpredicated versions of a single comparison.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74334: [ARM,MVE] Add the vrev16q, vrev32q, vrev64q family.

2020-02-11 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 243791.
simon_tatham added a comment.

Rebased to current master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74334

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vrev.c

Index: clang/test/CodeGen/arm-mve-intrinsics/vrev.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vrev.c
@@ -0,0 +1,215 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vrev16q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev16q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev16q(a);
+#else /* POLYMORPHIC */
+return vrev16q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev16q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev16q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev16q(a);
+#else /* POLYMORPHIC */
+return vrev16q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev32q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev32q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vrev32q_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+uint16x8_t test_vrev32q_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_u16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x half> [[A:%.*]], <8 x half> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrev32q_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev64q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev64q(a);
+#else /* POLYMORPHIC */
+return vrev64q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev64q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev64q(a);
+#else /* POLYMORPHIC */
+return vrev64q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vrev64q_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev64q(a);
+#else /* POLYMORPHIC */
+return vrev64q_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEX

[PATCH] D74336: [ARM,MVE] Add the vmovlbq,vmovltq intrinsic family.

2020-02-11 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 243793.
simon_tatham added a comment.

Spotted a mistake by myself: one of my new isel patterns was generating signed 
VMOVL where it should have been generating unsigned. Fixed, and updated the llc 
test that had the wrong expectation in it.

Also rebased to current master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74336

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovl.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
  llvm/test/CodeGen/Thumb2/mve-shuffleext.ll

Index: llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
===
--- llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
+++ llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
@@ -15,8 +15,7 @@
 define arm_aapcs_vfpcc <4 x i32> @sext_1357(<8 x i16> %src) {
 ; CHECK-LABEL: sext_1357:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev32.16 q0, q0
-; CHECK-NEXT:vmovlb.s16 q0, q0
+; CHECK-NEXT:vmovlt.s16 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <8 x i16> %src, <8 x i16> undef, <4 x i32> 
@@ -38,8 +37,7 @@
 define arm_aapcs_vfpcc <4 x i32> @zext_1357(<8 x i16> %src) {
 ; CHECK-LABEL: zext_1357:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev32.16 q0, q0
-; CHECK-NEXT:vmovlb.u16 q0, q0
+; CHECK-NEXT:vmovlt.s16 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <8 x i16> %src, <8 x i16> undef, <4 x i32> 
@@ -61,8 +59,7 @@
 define arm_aapcs_vfpcc <8 x i16> @sext_13579111315(<16 x i8> %src) {
 ; CHECK-LABEL: sext_13579111315:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev16.8 q0, q0
-; CHECK-NEXT:vmovlb.s8 q0, q0
+; CHECK-NEXT:vmovlt.s8 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <16 x i8> %src, <16 x i8> undef, <8 x i32> 
@@ -84,8 +81,7 @@
 define arm_aapcs_vfpcc <8 x i16> @zext_13579111315(<16 x i8> %src) {
 ; CHECK-LABEL: zext_13579111315:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev16.8 q0, q0
-; CHECK-NEXT:vmovlb.u8 q0, q0
+; CHECK-NEXT:vmovlt.u8 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <16 x i8> %src, <16 x i8> undef, <8 x i32> 
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
@@ -0,0 +1,90 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovlbq_s8(<16 x i8> %a) {
+; CHECK-LABEL: test_vmovlbq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.s8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = sext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovlbq_s16(<8 x i16> %a) {
+; CHECK-LABEL: test_vmovlbq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.s16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = sext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovlbq_u8(<16 x i8> %a) {
+; CHECK-LABEL: test_vmovlbq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.u8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = zext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovlbq_u16(<8 x i16> %a) {
+; CHECK-LABEL: test_vmovlbq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.u16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = zext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovltq_s8(<16 x i8> %a) {
+; CHECK-LABEL: test_vmovltq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlt.s8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = sext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovltq_s16(<8 x i16> %a) {
+; CHECK-LABEL: test_vmovltq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlt.s16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = sext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovltq_u8(<16 x i8> %a) {
+; CHECK-LABEL: test_vmovltq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlt.u8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0

[PATCH] D74333: [ARM,MVE] Add intrinsics for FP rounding operations.

2020-02-11 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 243790.
simon_tatham added a comment.

Rebased to current master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74333

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll
@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x half> @test_vrndnq_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vrndnq_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrintn.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x half> @llvm.arm.mve.vrintn.v8f16(<8 x half> %a)
+  ret <8 x half> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vrndnq_f32(<4 x float> %a) {
+; CHECK-LABEL: test_vrndnq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrintn.f32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vrintn.v4f32(<4 x float> %a)
+  ret <4 x float> %0
+}
+
+declare <8 x half> @llvm.arm.mve.vrintn.v8f16(<8 x half>)
+declare <4 x float> @llvm.arm.mve.vrintn.v4f32(<4 x float>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -3179,6 +3179,10 @@
 (v4f32 (MVE_VRINTf32P (v4f32 MQPR:$val1)))>;
   def : Pat<(v8f16 (fceil (v8f16 MQPR:$val1))),
 (v8f16 (MVE_VRINTf16P (v8f16 MQPR:$val1)))>;
+  def : Pat<(v4f32 (int_arm_mve_vrintn (v4f32 MQPR:$val1))),
+(v4f32 (MVE_VRINTf32N (v4f32 MQPR:$val1)))>;
+  def : Pat<(v8f16 (int_arm_mve_vrintn (v8f16 MQPR:$val1))),
+(v8f16 (MVE_VRINTf16N (v8f16 MQPR:$val1)))>;
 }
 
 class MVEFloatArithNeon, llvm_anyvector_ty>;
+
+def int_arm_mve_vrintn: Intrinsic<
+  [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
+
 } // end TargetPrefix
Index: clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
@@ -0,0 +1,173 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vrndaq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.round.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndaq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndaq(a);
+#else /* POLYMORPHIC */
+return vrndaq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndaq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.round.v4f32(<4 x float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vrndaq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vrndaq(a);
+#else /* POLYMORPHIC */
+return vrndaq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndmq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.floor.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndmq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndmq(a);
+#else /* POLYMORPHIC */
+return vrndmq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndmq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.floor.v4f32(<4 x float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vrndmq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vrndmq(a);
+#else /* POLYMORPHIC */
+return vrndmq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndpq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.ceil.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndpq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndpq(a);
+#else /* POLYMORPHIC */
+return vrndpq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test

[PATCH] D74337: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic family.

2020-02-11 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 243794.
simon_tatham added a comment.

Rebased on top of fixes to previous patches in the stack.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74337

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovn.c
  clang/utils/TableGen/MveEmitter.cpp
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
@@ -0,0 +1,102 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_s16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovnbq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = bitcast <16 x i8> %0 to <8 x i16>
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_s32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmovnbq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = bitcast <8 x i16> %0 to <4 x i32>
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_u16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovnbq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = bitcast <16 x i8> %0 to <8 x i16>
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_u32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmovnbq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = bitcast <8 x i16> %0 to <4 x i32>
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovntq_s16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovntq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnt.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <16 x i8> %a to <8 x i16>
+  %1 = shufflevector <8 x i16> %0, <8 x i16> %b, <16 x i32> 
+  %2 = trunc <16 x i16> %1 to <16 x i8>
+  ret <16 x i8> %2
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovntq_s32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmovntq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnt.i32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <8 x i16> %a to <4 x i32>
+  %1 = shufflevector <4 x i32> %0, <4 x i32> %b, <8 x i32> 
+  %2 = trunc <8 x i32> %1 to <8 x i16>
+  ret <8 x i16> %2
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovntq_u16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovntq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnt.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <16 x i8> %a to <8 x i16>
+  %1 = shufflevector <8 x i16> %0, <8 x i16> %b, <16 x i32> 
+  %2 = trunc <16 x i16> %1 to <16 x i8>
+  ret <16 x i8> %2
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovntq_u32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmovntq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnt.i32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <8 x i16> %a to <4 x i32>
+  %1 = shufflevector <4 x i32> %0, <4 x i32> %b, <8 x i32> 
+  %2 = trunc <8 x i32> %1 to <8 x i16>
+  ret <8 x i16> %2
+}
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -4333,8 +4333,16 @@
 (v16i8 (MVE_VMOVNi16bh (v16i8 MQPR:$Qd_src), (v16i8 MQPR:$Qm)))>;
   def : Pat<(v16i8 (MVEvmovn (v16i8 MQPR:$Qd_src), (v16i8 MQPR:$Qm), (i32 1))),
 (v16i8 (MVE_VMOVNi16th (v16i8 MQPR:$Qd_src), (v16i8 MQPR:$Qm)))>;
+
+  def : Pat<(v8i16 (MVEvmovn (v8i16 MQPR:$Qm),
+ (v8i16 (ARMvrev32 MQPR:$Qd_src)), (i32 1))),
+(v8i16 (MVE_VMOVNi32bh (v8i16 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
+  def : Pat<(v16i8 (MVEvmovn 

[PATCH] D74335: [ARM,MVE] Add intrinsics vclzq and vclsq.

2020-02-11 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 243792.
simon_tatham added a comment.

Spotted a mistake by myself: I had accidentally implemented the `vclsq` 
intrinsics for unsigned integer types as well as signed. ACLE only defines them 
for signed integers.

Also rebased to current master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74335

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vclz.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll
@@ -0,0 +1,36 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vclsq_s8(<16 x i8> %a) {
+; CHECK-LABEL: test_vclsq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vcls.v16i8(<16 x i8> %a)
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vclsq_s16(<8 x i16> %a) {
+; CHECK-LABEL: test_vclsq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vcls.v8i16(<8 x i16> %a)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vclsq_s32(<4 x i32> %a) {
+; CHECK-LABEL: test_vclsq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vcls.v4i32(<4 x i32> %a)
+  ret <4 x i32> %0
+}
+
+declare <16 x i8> @llvm.arm.mve.vcls.v16i8(<16 x i8>)
+declare <8 x i16> @llvm.arm.mve.vcls.v8i16(<8 x i16>)
+declare <4 x i32> @llvm.arm.mve.vcls.v4i32(<4 x i32>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -2076,6 +2076,13 @@
 (v4i32 ( MVE_VCLZs32 (v4i32 MQPR:$val1)))>;
   def : Pat<(v8i16 ( ctlz (v8i16 MQPR:$val1))),
 (v8i16 ( MVE_VCLZs16 (v8i16 MQPR:$val1)))>;
+
+  def : Pat<(v16i8 ( int_arm_mve_vcls (v16i8 MQPR:$val1))),
+(v16i8 ( MVE_VCLSs8 (v16i8 MQPR:$val1)))>;
+  def : Pat<(v4i32 ( int_arm_mve_vcls (v4i32 MQPR:$val1))),
+(v4i32 ( MVE_VCLSs32 (v4i32 MQPR:$val1)))>;
+  def : Pat<(v8i16 ( int_arm_mve_vcls (v8i16 MQPR:$val1))),
+(v8i16 ( MVE_VCLSs16 (v8i16 MQPR:$val1)))>;
 }
 
 class MVE_VABSNEG_int size, bit negate,
Index: llvm/include/llvm/IR/IntrinsicsARM.td
===
--- llvm/include/llvm/IR/IntrinsicsARM.td
+++ llvm/include/llvm/IR/IntrinsicsARM.td
@@ -1161,5 +1161,7 @@
 
 def int_arm_mve_vrintn: Intrinsic<
   [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
+def int_arm_mve_vcls: Intrinsic<
+  [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
 
 } // end TargetPrefix
Index: clang/test/CodeGen/arm-mve-intrinsics/vclz.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vclz.c
@@ -0,0 +1,132 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vclzq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> [[A:%.*]], i1 false)
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vclzq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> [[A:%.*]], i1 false)
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vclzq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> [[A:%.*]], i1 false)
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vclz

[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2020-02-11 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill added a comment.

Since the DebugInfo fix has been accepted, I'm looking to get this patch and 
that fix committed shortly if there are no problems caused by rebasing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62686



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


[PATCH] D74334: [ARM,MVE] Add the vrev16q, vrev32q, vrev64q family.

2020-02-11 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

Sounds good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74334



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


[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-02-11 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 243796.
baloghadamsoftware added a comment.

First real checker `IteratorRange` now marks container as interesting to 
benefit from container note tags. The other two iterator checkers will be 
updated after a second phase of container note tags which also cares for 
reassignment (upon move) and invalidation of iterators.


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

https://reviews.llvm.org/D73720

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/iterator-range.cpp

Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false -analyzer-output=text %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -analyzer-output=text %s -verify
 
 #include "Inputs/system-header-simulator-cxx.h"
 
@@ -32,6 +32,7 @@
 void deref_end(const std::vector &V) {
   auto i = V.end();
   *i; // expected-warning{{Past-the-end iterator dereferenced}}
+  // expected-note@-1{{Past-the-end iterator dereferenced}}
 }
 
 // Prefix increment - operator++()
@@ -59,6 +60,7 @@
 void incr_end(const std::vector &V) {
   auto i = V.end();
   ++i; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Postfix increment - operator++(int)
@@ -86,6 +88,7 @@
 void end_incr(const std::vector &V) {
   auto i = V.end();
   i++; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Prefix decrement - operator--()
@@ -93,6 +96,7 @@
 void decr_begin(const std::vector &V) {
   auto i = V.begin();
   --i; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_behind_begin(const std::vector &V) {
@@ -120,6 +124,7 @@
 void begin_decr(const std::vector &V) {
   auto i = V.begin();
   i--; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void behind_begin_decr(const std::vector &V) {
@@ -168,11 +173,13 @@
 void incr_by_2_ahead_of_end(const std::vector &V) {
   auto i = --V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_end(const std::vector &V) {
   auto i = V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Addition - operator+(int)
@@ -201,11 +208,13 @@
 void incr_by_2_copy_ahead_of_end(const std::vector &V) {
   auto i = --V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_copy_end(const std::vector &V) {
   auto i = V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Subtraction assignment - operator-=(int)
@@ -213,11 +222,13 @@
 void decr_by_2_begin(const std::vector &V) {
   auto i = V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begin(const std::vector &V) {
   auto i = ++V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note

[PATCH] D74395: [clangd] Add tracer to the rename workflow, NFC

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74395

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

Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -13,6 +13,7 @@
 #include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
+#include "Trace.h"
 #include "index/SymbolCollector.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -124,6 +125,7 @@
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFile) {
+  trace::Span Tracer("Renameable");
   // Filter out symbols that are unsupported in both rename modes.
   if (llvm::isa(&RenameDecl))
 return ReasonToReject::UnsupportedSymbol;
@@ -225,6 +227,7 @@
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
+  trace::Span Tracer("FindOccurrenceeWithinFile");
   // If the cursor is at the underlying CXXRecordDecl of the
   // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
   // get the primary template maunally.
@@ -260,6 +263,7 @@
 llvm::Expected
 renameWithinFile(ParsedAST &AST, const NamedDecl &RenameDecl,
  llvm::StringRef NewName) {
+  trace::Span Tracer("RenameWithinFile");
   const SourceManager &SM = AST.getSourceManager();
 
   tooling::Replacements FilteredChanges;
@@ -302,6 +306,7 @@
 llvm::Expected>>
 findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
llvm::StringRef MainFile, const SymbolIndex &Index) {
+  trace::Span Tracer("FindOccurrencesOutsideFile");
   RefsRequest RQuest;
   RQuest.IDs.insert(*getSymbolID(&RenameDecl));
 
@@ -336,6 +341,9 @@
 auto &Ranges = FileAndOccurrences.getValue();
 llvm::sort(Ranges);
 Ranges.erase(std::unique(Ranges.begin(), Ranges.end()), Ranges.end());
+
+SPAN_ATTACH(Tracer, FileAndOccurrences.first(),
+static_cast(Ranges.size()));
   }
   return AffectedFiles;
 }
@@ -356,6 +364,7 @@
 const NamedDecl &RenameDecl, llvm::StringRef MainFilePath,
 llvm::StringRef NewName, const SymbolIndex &Index,
 llvm::function_ref(PathRef)> GetFileContent) {
+  trace::Span Tracer("RenameOutsideFile");
   auto AffectedFiles =
   findOccurrencesOutsideFile(RenameDecl, MainFilePath, Index);
   if (!AffectedFiles)
@@ -438,6 +447,7 @@
 } // namespace
 
 llvm::Expected rename(const RenameInputs &RInputs) {
+  trace::Span Tracer("Rename flow");
   ParsedAST &AST = RInputs.AST;
   const SourceManager &SM = AST.getSourceManager();
   llvm::StringRef MainFileCode = SM.getBufferData(SM.getMainFileID());
@@ -530,6 +540,11 @@
  llvm::StringRef InitialCode,
  std::vector Occurrences,
  llvm::StringRef NewName) {
+  trace::Span Tracer("BuildRenameEdit");
+  SPAN_ATTACH(Tracer, "file_path", AbsFilePath);
+  SPAN_ATTACH(Tracer, "rename_occurrences",
+  static_cast(Occurrences.size()));
+
   assert(std::is_sorted(Occurrences.begin(), Occurrences.end()));
   assert(std::unique(Occurrences.begin(), Occurrences.end()) ==
  Occurrences.end() &&
@@ -593,6 +608,7 @@
 llvm::Optional>
 adjustRenameRanges(llvm::StringRef DraftCode, llvm::StringRef Identifier,
std::vector Indexed, const LangOptions &LangOpts) {
+  trace::Span Tracer("AdjustRenameRanges");
   assert(!Indexed.empty());
   assert(std::is_sorted(Indexed.begin(), Indexed.end()));
   std::vector Lexed =
@@ -603,6 +619,7 @@
 
 llvm::Optional> getMappedRanges(ArrayRef Indexed,
ArrayRef Lexed) {
+  trace::Span Tracer("GetMappedRanges");
   assert(!Indexed.empty());
   assert(std::is_sorted(Indexed.begin(), Indexed.end()));
   assert(std::is_sorted(Lexed.begin(), Lexed.end()));
@@ -635,15 +652,18 @@
});
   if (HasMultiple) {
 vlog("The best near miss is not unique.");
+SPAN_ATTACH(Tracer, "error", "The best near miss is not unique");
 return llvm::None;
   }
   if (Best.empty()) {
 vlog("Didn't find a near miss.");
+SPAN_ATTACH(Tracer, "error", "Didn't find a near miss");
 return llvm::None;
   }
   std::vector Mapped;
   for (auto I : Best)
 Mapped.push_back(Lexed[I]);
+  SPAN_ATTACH(Tracer, "mapped_ranges", static_cast(Mapped.size()));
   return Mapped;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
ht

[PATCH] D74396: [clangd] Mention the CLANGD_TRACE env var in the overview as well.

2020-02-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74396

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -475,7 +475,7 @@
https://clang.llvm.org/extra/clangd/
https://microsoft.github.io/language-server-protocol/
 
-clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment 
variable.
+clangd accepts flags on the commandline, and in the CLANGD_FLAGS/CLANGD_TRACE 
environment variable.
 )";
   llvm::cl::HideUnrelatedOptions(ClangdCategories);
   llvm::cl::ParseCommandLineOptions(argc, argv, Overview,


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -475,7 +475,7 @@
 	https://clang.llvm.org/extra/clangd/
 	https://microsoft.github.io/language-server-protocol/
 
-clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment variable.
+clangd accepts flags on the commandline, and in the CLANGD_FLAGS/CLANGD_TRACE environment variable.
 )";
   llvm::cl::HideUnrelatedOptions(ClangdCategories);
   llvm::cl::ParseCommandLineOptions(argc, argv, Overview,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b46f925 - [clang-format] Improve handling of C# attributes

2020-02-11 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-02-11T12:00:17Z
New Revision: b46f925d68d480246e1447f26459bdc894631a88

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

LOG: [clang-format] Improve handling of C# attributes

Summary:
C# attributes can appear on classes and methods, in which case they should go 
on their own line, or on method parameters in which case
they should be left inline.

Reviewers: krasimir, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: klimek

Tags: #clang-format

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 7538b03f4f7c..1c15859e5786 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3280,13 +3280,6 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
&Line,
   return true;
   }
 
-  // Put multiple C# attributes on a new line.
-  if (Style.isCSharp() &&
-  ((Left.is(TT_AttributeSquare) && Left.is(tok::r_square)) ||
-   (Left.is(tok::r_square) && Right.is(TT_AttributeSquare) &&
-Right.is(tok::l_square
-return true;
-
   // Put multiple Java annotation on a new line.
   if ((Style.Language == FormatStyle::LK_Java ||
Style.Language == FormatStyle::LK_JavaScript) &&

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 321a7405e24a..b455a7f2ebed 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -323,6 +323,20 @@ void UnwrappedLineParser::parseFile() {
   addUnwrappedLine();
 }
 
+void UnwrappedLineParser::parseCSharpAttribute() {
+  do {
+switch (FormatTok->Tok.getKind()) {
+case tok::r_square:
+  nextToken();
+  addUnwrappedLine();
+  return;
+default:
+  nextToken();
+  break;
+}
+  } while (!eof());
+}
+
 void UnwrappedLineParser::parseLevel(bool HasOpeningBrace) {
   bool SwitchLabelEncountered = false;
   do {
@@ -381,6 +395,13 @@ void UnwrappedLineParser::parseLevel(bool HasOpeningBrace) 
{
   SwitchLabelEncountered = true;
   parseStructuralElement();
   break;
+case tok::l_square:
+  if (Style.isCSharp()) {
+nextToken();
+parseCSharpAttribute();
+break;
+  }
+  LLVM_FALLTHROUGH;
 default:
   parseStructuralElement();
   break;

diff  --git a/clang/lib/Format/UnwrappedLineParser.h 
b/clang/lib/Format/UnwrappedLineParser.h
index 5d9bafc429a7..e184cf5354fd 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -125,6 +125,7 @@ class UnwrappedLineParser {
   bool parseObjCProtocol();
   void parseJavaScriptEs6ImportExport();
   void parseStatementMacro();
+  void parseCSharpAttribute();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
   void tryToParseJSFunction();

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 918f8aed83e9..e859aeb0d22d 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -258,6 +258,21 @@ TEST_F(FormatTestCSharp, Attributes) {
   "// The const char* returned by hello_world must not be deleted.\n"
   "private static extern IntPtr HelloFromCpp();)");
 
+  // Class attributes go on their own line and do not affect layout of
+  // interfaces. Line wrapping decisions previously caused each interface to be
+  // on its own line.
+  verifyFormat("[SomeAttribute]\n"
+   "[SomeOtherAttribute]\n"
+   "public class A : IShape, IAnimal, IVehicle\n"
+   "{\n"
+   "int X;\n"
+   "}");
+
+  // Attributes in a method declaration do not cause line wrapping.
+  verifyFormat("void MethodA([In][Out] ref double x)\n"
+   "{\n"
+   "}");
+
   //  Unwrappable lines go on a line of their own.
   // 'target:' is not treated as a label.
   // Modify Style to enforce a column limit.



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


[PATCH] D74265: [clang-format] Improve handling of C# attributes

2020-02-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb46f925d68d4: [clang-format] Improve handling of C# 
attributes (authored by Jonathan Coe ).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74265

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -258,6 +258,21 @@
   "// The const char* returned by hello_world must not be deleted.\n"
   "private static extern IntPtr HelloFromCpp();)");
 
+  // Class attributes go on their own line and do not affect layout of
+  // interfaces. Line wrapping decisions previously caused each interface to be
+  // on its own line.
+  verifyFormat("[SomeAttribute]\n"
+   "[SomeOtherAttribute]\n"
+   "public class A : IShape, IAnimal, IVehicle\n"
+   "{\n"
+   "int X;\n"
+   "}");
+
+  // Attributes in a method declaration do not cause line wrapping.
+  verifyFormat("void MethodA([In][Out] ref double x)\n"
+   "{\n"
+   "}");
+
   //  Unwrappable lines go on a line of their own.
   // 'target:' is not treated as a label.
   // Modify Style to enforce a column limit.
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -125,6 +125,7 @@
   bool parseObjCProtocol();
   void parseJavaScriptEs6ImportExport();
   void parseStatementMacro();
+  void parseCSharpAttribute();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
   void tryToParseJSFunction();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -323,6 +323,20 @@
   addUnwrappedLine();
 }
 
+void UnwrappedLineParser::parseCSharpAttribute() {
+  do {
+switch (FormatTok->Tok.getKind()) {
+case tok::r_square:
+  nextToken();
+  addUnwrappedLine();
+  return;
+default:
+  nextToken();
+  break;
+}
+  } while (!eof());
+}
+
 void UnwrappedLineParser::parseLevel(bool HasOpeningBrace) {
   bool SwitchLabelEncountered = false;
   do {
@@ -381,6 +395,13 @@
   SwitchLabelEncountered = true;
   parseStructuralElement();
   break;
+case tok::l_square:
+  if (Style.isCSharp()) {
+nextToken();
+parseCSharpAttribute();
+break;
+  }
+  LLVM_FALLTHROUGH;
 default:
   parseStructuralElement();
   break;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3280,13 +3280,6 @@
   return true;
   }
 
-  // Put multiple C# attributes on a new line.
-  if (Style.isCSharp() &&
-  ((Left.is(TT_AttributeSquare) && Left.is(tok::r_square)) ||
-   (Left.is(tok::r_square) && Right.is(TT_AttributeSquare) &&
-Right.is(tok::l_square
-return true;
-
   // Put multiple Java annotation on a new line.
   if ((Style.Language == FormatStyle::LK_Java ||
Style.Language == FormatStyle::LK_JavaScript) &&


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -258,6 +258,21 @@
   "// The const char* returned by hello_world must not be deleted.\n"
   "private static extern IntPtr HelloFromCpp();)");
 
+  // Class attributes go on their own line and do not affect layout of
+  // interfaces. Line wrapping decisions previously caused each interface to be
+  // on its own line.
+  verifyFormat("[SomeAttribute]\n"
+   "[SomeOtherAttribute]\n"
+   "public class A : IShape, IAnimal, IVehicle\n"
+   "{\n"
+   "int X;\n"
+   "}");
+
+  // Attributes in a method declaration do not cause line wrapping.
+  verifyFormat("void MethodA([In][Out] ref double x)\n"
+   "{\n"
+   "}");
+
   //  Unwrappable lines go on a line of their own.
   // 'target:' is not treated as a label.
   // Modify Style to enforce a column limit.
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format

[clang] da3f2b4 - [ARM][MVE] Fix a corner case of checking for MVE-I with -mfpu=none

2020-02-11 Thread Momchil Velikov via cfe-commits

Author: Momchil Velikov
Date: 2020-02-11T12:03:41Z
New Revision: da3f2b414ace1f24054ae9255f811b653d9cff99

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

LOG: [ARM][MVE] Fix a corner case of checking for MVE-I with -mfpu=none

-march=armv8.1-m.main+mve.fp+nomve -mfpu=none should disable FP
registers and instructions moving to/from FP registers.

This patch fixes the case when "+mve" (added to the feature list by
"+mve.fp"), is followed by "-mve" (added by "+nomve").

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/Driver/arm-mfpu.c
clang/test/Preprocessor/arm-target-features.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 18bd1317fbc2..afe896b4a65b 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -278,6 +278,13 @@ arm::FloatABI arm::getARMFloatABI(const Driver &D, const 
llvm::Triple &Triple,
   return ABI;
 }
 
+static bool hasIntegerMVE(const std::vector &F) {
+  auto MVE = llvm::find(llvm::reverse(F), "+mve");
+  auto NoMVE = llvm::find(llvm::reverse(F), "-mve");
+  return MVE != F.rend() &&
+ (NoMVE == F.rend() || std::distance(MVE, NoMVE) > 0);
+}
+
 void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args, ArgStringList &CmdArgs,
std::vector &Features, bool ForAS) {
@@ -456,18 +463,13 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 
 // Disable all features relating to hardware FP, not already disabled by 
the
 // above call.
-Features.insert(Features.end(), {"-neon", "-crypto", "-dotprod", 
"-fp16fml",
- "-mve", "-mve.fp", "-fpregs"});
+Features.insert(Features.end(),
+{"-dotprod", "-fp16fml", "-mve", "-mve.fp", "-fpregs"});
   } else if (FPUID == llvm::ARM::FK_NONE) {
 // -mfpu=none is *very* similar to -mfloat-abi=soft, only that it should 
not
 // disable MVE-I.
-Features.insert(Features.end(),
-{"-neon", "-crypto", "-dotprod", "-fp16fml", "-mve.fp"});
-// Even though we remove MVE-FP, we still need to check if it was 
originally
-// present among the requested extensions, because it implies MVE-I, which
-// should not be disabled by -mfpu-none.
-if (!llvm::is_contained(Features, "+mve") &&
-!llvm::is_contained(Features, "+mve.fp"))
+Features.insert(Features.end(), {"-dotprod", "-fp16fml", "-mve.fp"});
+if (!hasIntegerMVE(Features))
   Features.emplace_back("-fpregs");
   }
 

diff  --git a/clang/test/Driver/arm-mfpu.c b/clang/test/Driver/arm-mfpu.c
index 5309977d0f90..fc6f09df1bae 100644
--- a/clang/test/Driver/arm-mfpu.c
+++ b/clang/test/Driver/arm-mfpu.c
@@ -419,6 +419,21 @@
 // CHECK-MVEFP-FPUNONE-DAG: "-target-feature" "-mve.fp"
 // CHECK-MVEFP-FPUNONE-NOT: "-target-feature" "-fpregs"
 
+// RUN: %clang -target arm-none-none-eabi %s 
-march=armv8.1-m.main+mve.fp+nomve -mfpu=none -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MVEFP-NOMVE-FPUNONE %s
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-vfp2sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-vfp3d16sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-vfp4d16sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-fp-armv8d16sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-fp64"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-d32"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-neon"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-crypto"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "+dsp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-mve"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-mve.fp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-fpregs"
+
 // RUN: %clang -target arm-none-none-eabi %s -march=armv8.1-m.main+mve 
-mfpu=none -### -c 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MVEI-FPUNONE %s
 // CHECK-MVEI-FPUNONE-DAG: "-target-feature" "-mve.fp"

diff  --git a/clang/test/Preprocessor/arm-target-features.c 
b/clang/test/Preprocessor/arm-target-features.c
index 72b77b6124fe..401e0a41a769 100644
--- a/clang/test/Preprocessor/arm-target-features.c
+++ b/clang/test/Preprocessor/arm-target-features.c
@@ -761,8 +761,9 @@
 // CHECK-V81M-MVEFP: #define __ARM_FEATURE_SIMD32 1
 // CHECK-V81M-MVEFP: #define __ARM_FPV5__ 1
 
-// nofp discards mve.fp, but not mve/dsp
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp+nofp -x 
c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-V8

[PATCH] D72633: [ARM][MVE] Fix a corner case of checking for MVE-I with -mfpu=none

2020-02-11 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGda3f2b414ace: [ARM][MVE] Fix a corner case of checking for 
MVE-I with -mfpu=none (authored by chill).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D72633?vs=240836&id=243803#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72633

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-mfpu.c
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -761,8 +761,9 @@
 // CHECK-V81M-MVEFP: #define __ARM_FEATURE_SIMD32 1
 // CHECK-V81M-MVEFP: #define __ARM_FPV5__ 1
 
-// nofp discards mve.fp, but not mve/dsp
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp+nofp -x 
c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-V81M-MVEFP-NOFP %s
+// fpu=none/nofp discards mve.fp, but not mve/dsp
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp+nofp 
   -x c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-V81M-MVEFP-NOFP %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp  
-mfpu=none -x c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-V81M-MVEFP-NOFP %s
 // CHECK-V81M-MVEFP-NOFP: #define __ARM_FEATURE_DSP 1
 // CHECK-V81M-MVEFP-NOFP: #define __ARM_FEATURE_MVE 1
 
Index: clang/test/Driver/arm-mfpu.c
===
--- clang/test/Driver/arm-mfpu.c
+++ clang/test/Driver/arm-mfpu.c
@@ -419,6 +419,21 @@
 // CHECK-MVEFP-FPUNONE-DAG: "-target-feature" "-mve.fp"
 // CHECK-MVEFP-FPUNONE-NOT: "-target-feature" "-fpregs"
 
+// RUN: %clang -target arm-none-none-eabi %s 
-march=armv8.1-m.main+mve.fp+nomve -mfpu=none -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MVEFP-NOMVE-FPUNONE %s
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-vfp2sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-vfp3d16sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-vfp4d16sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-fp-armv8d16sp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-fp64"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-d32"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-neon"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-crypto"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "+dsp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-mve"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-mve.fp"
+// CHECK-MVEFP-NOMVE-FPUNONE-DAG: "-target-feature" "-fpregs"
+
 // RUN: %clang -target arm-none-none-eabi %s -march=armv8.1-m.main+mve 
-mfpu=none -### -c 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MVEI-FPUNONE %s
 // CHECK-MVEI-FPUNONE-DAG: "-target-feature" "-mve.fp"
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -278,6 +278,13 @@
   return ABI;
 }
 
+static bool hasIntegerMVE(const std::vector &F) {
+  auto MVE = llvm::find(llvm::reverse(F), "+mve");
+  auto NoMVE = llvm::find(llvm::reverse(F), "-mve");
+  return MVE != F.rend() &&
+ (NoMVE == F.rend() || std::distance(MVE, NoMVE) > 0);
+}
+
 void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args, ArgStringList &CmdArgs,
std::vector &Features, bool ForAS) {
@@ -456,18 +463,13 @@
 
 // Disable all features relating to hardware FP, not already disabled by 
the
 // above call.
-Features.insert(Features.end(), {"-neon", "-crypto", "-dotprod", 
"-fp16fml",
- "-mve", "-mve.fp", "-fpregs"});
+Features.insert(Features.end(),
+{"-dotprod", "-fp16fml", "-mve", "-mve.fp", "-fpregs"});
   } else if (FPUID == llvm::ARM::FK_NONE) {
 // -mfpu=none is *very* similar to -mfloat-abi=soft, only that it should 
not
 // disable MVE-I.
-Features.insert(Features.end(),
-{"-neon", "-crypto", "-dotprod", "-fp16fml", "-mve.fp"});
-// Even though we remove MVE-FP, we still need to check if it was 
originally
-// present among the requested extensions, because it implies MVE-I, which
-// should not be disabled by -mfpu-none.
-if (!llvm::is_contained(Features, "+mve") &&
-!llvm::is_contained(Features, "+mve.fp"))
+Features.insert(Features.end(), {"-dotprod", "-fp16fml", "-mve.fp"});
+if (!hasIntegerMVE(Features))
   Features.emplace_back("-fpregs");
   

[PATCH] D74396: [clangd] Mention the CLANGD_TRACE env var in the overview as well.

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

That comment is talking about how CLANGD_FLAGS corresponds to command-line 
flags in general.

The CLANGD_TRACE environment variable controls only one piece of behavior, 
which doesn't correspond to any flag.
(It'd be reasonable to add a matching flag and describe the environment 
variable in that flag's description...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74396



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


[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-02-11 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

I think I've spotted a bug in the ABI spec, which you've faithfully implemented 
here. I don't know of any other compiler which has implemented this ABI change 
yet, so it's probably worth seeing if we can get the spec fixed.

The intention of the ABI is to avoid conflicting with the C/C++11 spec, which 
requires access to one "memory location" to not write to any adjacent memory 
locations. However, the wording of the ABI does not take into account 
zero-sized bitfields, which are defined in C/C++ to start a new memory 
location. For example:

  struct foo {
int a : 8;
char  : 0;
int b : 8;
  };

Here, C/C++ says that `a` and `b` are separate memory locations, so it must be 
possible to read and write them from two threads. However, the ABI does not 
have the special case for zero-sized bitfields, so requires access to both 
fields to use 32-bit loads and stores, which overlap.

I've raised a ticket (internal to Arm) to consider changing the ABI to match 
C/C++ in this case.




Comment at: clang/include/clang/Basic/CodeGenOptions.def:396
+/// according to the field declaring type width.
+CODEGENOPT(ForceNoAAPCSBitfieldWidth, 1, 0)
+

Why is this a negative option, when the one above is positive?



Comment at: clang/include/clang/Driver/Options.td:2328
   HelpText<"Follows the AAPCS standard that all volatile bit-field write 
generates at least one load. (ARM only).">;
+def ForceNoAAPCSBitfieldWidth : Flag<["-"], "fno-AAPCSBitfieldWidth">, 
Group,
+  Flags<[DriverOption,CC1Option]>,

Command-line options are in kebab-case, so this should be something like 
`fno-aapcs-bitfield-width`. This also applies to the `fAAPCSBitfieldLoad` 
option above, assuming it's not too late to change that.

Please also add a positive version of this option (i.e. 
`faapcs-bitfield-width`).



Comment at: clang/include/clang/Driver/Options.td:2330
+  Flags<[DriverOption,CC1Option]>,
+  HelpText<"Does not follow the AAPCS standard that volatile bit-field width 
is dictated by the field declarative type. (ARM only).">;
 

s/Does/Do/

s/declarative/container/



Comment at: clang/lib/CodeGen/CGRecordLayout.h:100
+ unsigned StorageSize, CharUnits StorageOffset,
+ unsigned VolatileOffset, unsigned VolatileStorageSize,
+ CharUnits VolatileStorageOffset)

It doesn't look like this is ever called with different volatile/non-volatile 
values, so I don't think we need the extra parameters.



Comment at: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:525
+/// When a volatile bit-field is read, and its container does not overlap
+/// with any non-bit-field member, itscontainer must be read exactly once
+/// using the access width appropriate to the type of the container.

Space in "itscontainer".



Comment at: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:528
+/// When a volatile bit-field is written, and its container does not overlap
+/// with any non-bit-field member, itscontainer must be read exactly once and
+/// written exactly once using the access width appropriate to thetype of the

Space in "itscontainer".



Comment at: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:529
+/// with any non-bit-field member, itscontainer must be read exactly once and
+/// written exactly once using the access width appropriate to thetype of the
+/// container. The two accesses are not atomic.

Space in "thetype".



Comment at: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:541
+llvm::Type *ResLTy = Types.ConvertTypeForMem(Field->getType());
+// If the register alignment is less than the type width, we can't enforce 
a
+// aligned load, bail out

_register_ alignment?



Comment at: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:542
+// If the register alignment is less than the type width, we can't enforce 
a
+// aligned load, bail out
+if ((uint64_t)(Context.toBits(Layout.getAlignment())) <

Comments end in a full stop (multiple times in this function).



Comment at: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:631
   if (Layout.hasOwnVFPtr())
-Members.push_back(MemberInfo(CharUnits::Zero(), MemberInfo::VFPtr,
-llvm::FunctionType::get(getIntNType(32), /*isVarArg=*/true)->
-getPointerTo()->getPointerTo()));
+Members.push_back(
+MemberInfo(CharUnits::Zero(), MemberInfo::VFPtr,

Unnecessary formatting change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72932



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

[PATCH] D74305: [clangd] Expose completion range in code completion results (C++ API)

2020-02-11 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 accepted this revision.
usaxena95 added a comment.
This revision is now accepted and ready to land.

Thanks. LG.




Comment at: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp:2680
+TEST(CompletionTest, CompletionRange) {
+  const char* WithRange = "auto x = [[abc]]^";
+  auto Completions = completions(WithRange);

Please fix the lint errors. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74305



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


[PATCH] D74331: [ARM,MVE] Add intrinsics for abs, neg and not operations.

2020-02-11 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM accepted this revision.
MarkMurrayARM 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/D74331/new/

https://reviews.llvm.org/D74331



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


[PATCH] D74399: [Driver][RISCV] Add RedHat Linux RISC-V triple

2020-02-11 Thread Luís Marques via Phabricator via cfe-commits
luismarques created this revision.
luismarques added reviewers: lenary, asb, dlj.
Herald added subscribers: cfe-commits, evandro, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, PkmX, rkruppe, rogfer01, shiva0217, kito-cheng, simoncook.
Herald added a project: clang.

Adds the RedHat Linux triple to the list of 64-bit RISC-V triples. Without this 
the gcc libraries wouldn't be found by clang on a redhat/fedora system, as the 
search list included `/usr/lib/gcc/riscv64-redhat-linux-gnu` but the correct 
path didn't include the `-gnu` suffix.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74399

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2090,6 +2090,7 @@
   static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu",
"riscv64-linux-gnu",
"riscv64-unknown-elf",
+   "riscv64-redhat-linux",
"riscv64-suse-linux"};
 
   static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2090,6 +2090,7 @@
   static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu",
"riscv64-linux-gnu",
"riscv64-unknown-elf",
+   "riscv64-redhat-linux",
"riscv64-suse-linux"};
 
   static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74033: [clang-tidy] Fix PR#44620 'readability-redundant-string-cstr quick-fix causes invalid code'

2020-02-11 Thread Karasev Nikita via Phabricator via cfe-commits
f00kat updated this revision to Diff 243833.
f00kat added a comment.

1. Add full stops at the end of the lines.
2. Add some static.
3. Fix function 'checkParamDeclOfAncestorCallExprHasRValueRefType' to work well 
with the function pointer calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74033

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -205,3 +205,18 @@
 void invalid(const NotAString &s) {
   dummy(s.c_str());
 }
+
+// Test for rvalue std::string.
+void m1(std::string&&) {
+  std::string s;
+
+  m1(s.c_str());
+
+  void (*m1p1)(std::string&&);
+  m1p1 = m1;
+  m1p1(s.c_str());
+
+  using m1tp = void (*)(std::string &&);
+  m1tp m1p2 = m1;
+  m1p2(s.c_str());  
+}
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -61,6 +61,55 @@
   return (llvm::Twine("*") + Text).str();
 }
 
+// Trying to get CallExpr in which CxxConstructExpr is called.
+static const clang::CallExpr *
+tryGetCallExprAncestorForCxxConstructExpr(const Expr *TheExpr,
+  ASTContext &Context) {
+  // We skip nodes such as CXXBindTemporaryExpr, MaterializeTemporaryExpr.
+  for (ast_type_traits::DynTypedNode DynParent : Context.getParents(*TheExpr)) 
{
+if (const auto *Parent = DynParent.get()) {
+  if (const auto *TheCallExpr = dyn_cast(Parent))
+return TheCallExpr;
+
+  if (const clang::CallExpr *TheCallExpr =
+  tryGetCallExprAncestorForCxxConstructExpr(Parent, Context))
+return TheCallExpr;
+}
+  }
+
+  return nullptr;
+}
+
+// Check that ParamDecl of CallExprDecl has rvalue type.
+static bool checkParamDeclOfAncestorCallExprHasRValueRefType(
+const Expr *TheCxxConstructExpr, ASTContext &Context) {
+  if (const clang::CallExpr *TheCallExpr =
+  tryGetCallExprAncestorForCxxConstructExpr(TheCxxConstructExpr,
+Context)) {
+for (int i = 0; i < TheCallExpr->getNumArgs(); ++i) {
+  const Expr *Arg = TheCallExpr->getArg(i);
+  if (Arg->getSourceRange() == TheCxxConstructExpr->getSourceRange()) {
+if (const auto *TheCallExprFuncProto =
+TheCallExpr->getCallee()
+->getType()
+->getPointeeType()
+->getAs()) {
+  if (TheCallExprFuncProto->getParamType(i)->isRValueReferenceType())
+return true;
+}
+  }
+}
+  }
+
+  return false;
+}
+
+AST_MATCHER(CXXConstructExpr,
+matchedParamDeclOfAncestorCallExprHasRValueRefType) {
+  return checkParamDeclOfAncestorCallExprHasRValueRefType(
+  &Node, Finder->getASTContext());
+}
+
 } // end namespace
 
 void RedundantStringCStrCheck::registerMatchers(
@@ -95,9 +144,13 @@
   .bind("call");
 
   // Detect redundant 'c_str()' calls through a string constructor.
-  Finder->addMatcher(cxxConstructExpr(StringConstructorExpr,
-  hasArgument(0, StringCStrCallExpr)),
- this);
+  // If CxxConstructExpr is the part of some CallExpr we need to
+  // check that matched ParamDecl of the ancestor CallExpr is not rvalue.
+  Finder->addMatcher(
+  cxxConstructExpr(
+  StringConstructorExpr, hasArgument(0, StringCStrCallExpr),
+  unless(matchedParamDeclOfAncestorCallExprHasRValueRefType())),
+  this);
 
   // Detect: 's == str.c_str()'  ->  's == str'
   Finder->addMatcher(


Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -205,3 +205,18 @@
 void invalid(const NotAString &s) {
   dummy(s.c_str());
 }
+
+// Test for rvalue std::string.
+void m1(std::string&&) {
+  std::string s;
+
+  m1(s.c_str());
+
+  void (*m1p1)(std::string&&);
+  m1p1 = m1;
+  m1p1(s.c_str());
+
+  using m1tp = void (*)(std::string &&);
+  m1tp m1p2 = m1;
+  m1p2(s.c_str());  
+}
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-too

[PATCH] D67052: Add reference type transformation builtins

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

- Combine D67052  and D67588 
.
- Remove `__add*` type traits.
- Update mangling/dumping/encoding of all traits.
- Remove stress tests.
- Address comments in D67588 .

I'll work on some failing tests and add those when they're ready.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/remove_cv.cpp
  clang/test/SemaCXX/remove_reference.cpp

Index: clang/test/SemaCXX/remove_reference.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/remove_reference.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++11 %s
+
+template
+struct test_remove_ref_trait
+{
+  typedef __remove_reference(T) type;
+};
+
+template
+struct test_remove_ref
+{
+  static const bool value = __is_same(typename test_remove_ref_trait::type, T)  &&
+__is_same(typename test_remove_ref_trait::type, T) &&
+__is_same(typename test_remove_ref_trait::type, T);
+};
+
+template
+struct test
+{
+  static const bool value = test_remove_ref::value &&
+test_rval::value &&
+test_lval::value;
+};
+
+struct Foo { };
+
+template
+struct Bar { };
+
+template
+class Baz { };
+
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test>::value, "");
+static_assert(test>::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
Index: clang/test/SemaCXX/remove_cv.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/remove_cv.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -std=c++11 %s
+
+template
+struct remove_const
+{
+  typedef __remove_const(T) type;
+};
+
+template
+struct remove_volatile
+{
+  typedef __remove_volatile(T) type;
+};
+
+template
+struct remove_cv
+{
+  typedef __remove_cv(T) type;
+};
+
+template
+struct test
+{
+  static const bool value =
+__is_same(typename remove_const::type, T) &&
+__is_same(typename remove_const::type, volatile T) &&
+__is_same(typename remove_const::type, T) &&
+
+__is_same(typename remove_volatile::type, T) &&
+__is_same(typename remove_volatile::type, const T) &&
+__is_same(typename remove_volatile::type, T) &&
+
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T);
+};
+
+struct Foo { };
+
+template
+struct Bar { };
+
+template
+class Baz { };
+
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test>::value, "");
+static_assert(test>::value, "");
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1252,6 +1252,24 @@
   return OpenCLAccessAttr::Keyword_read_only;
 }
 
+static UnaryTransformType::UTTKind
+TSTToUnaryTransformType(DeclSpec::TST SwitchTST) {
+  switch (SwitchTST) {
+  case TST_removeCV:
+return UnaryTransformType::RemoveCV;
+  case TST_removeConst:
+return UnaryTransformType::RemoveConst;
+  case TST_removeVolatile:
+return UnaryTransformType::RemoveVolatile;
+  case TST_removeReferenceType:
+return UnaryTransformType::RemoveReferenceType;
+  case TST_underlyingType:
+return UnaryTransformType::EnumUnderlyingType;
+  default:
+llvm_unreachable("Cannot map TST to unary transform type");
+  }
+}
+
 static QualType ConvertConstrainedAutoDeclSpecToType(Sema &S, DeclSpec &DS,
  AutoTypeKeyword AutoKW) {
   assert(DS.isConstrainedAuto());
@@ -1603,6 +1621,21 @@
 }
 break;
   }
+  case DeclSpec::TST_removeReferenceType:
+  case DeclSpec::TST_removeCV:
+  case DeclSpec::TST_removeConst:
+  case DeclSpec::TST_removeVolatile: {
+Result = S.GetTypeFromParser(DS.getRepAsType());
+assert(!Result.isNull() &&
+   "Reference 

[PATCH] D67588: Add builtin trait for add/remove cv (and similar)

2020-02-11 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver abandoned this revision.
zoecarver added a comment.

Closing in favor of D67052 .


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

https://reviews.llvm.org/D67588



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


[PATCH] D67052: Add reference type transformation builtins

2020-02-11 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked 3 inline comments as done.
zoecarver added inline comments.



Comment at: clang/lib/AST/TypePrinter.cpp:1028
+case UnaryTransformType::RemoveReferenceType:
+  OS << "__remove_reference";
+  print(T->getBaseType(), OS, StringRef());

These need the opening paren. 



Comment at: clang/lib/AST/TypePrinter.cpp:1062
 case UnaryTransformType::EnumUnderlyingType:
+case UnaryTransformType::RemoveCV:
+case UnaryTransformType::RemoveConst:

Missing `RemoveReference`.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1105
+void Parser::ParseTypeTransformTypeSpecifier(DeclSpec &DS) {
+  DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
+

I'll work on your comment: 
> It would be really cool if we could simplify these conversions to 
> static_cast(Tok.getKind() - base);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D74399: [Driver][RISCV] Add RedHat Linux RISC-V triple

2020-02-11 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary 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/D74399/new/

https://reviews.llvm.org/D74399



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


[PATCH] D67052: Add reference type transformation builtins

2020-02-11 Thread Michael Schellenberger Costa via Phabricator via cfe-commits
miscco added subscribers: cjdb, miscco.
miscco added a comment.

Some nits, looks great, especially for library concepts. Pinging @cjdb




Comment at: clang/lib/AST/TypePrinter.cpp:1020
 
   switch (T->getUTTKind()) {
 case UnaryTransformType::EnumUnderlyingType:

Couldn't we use `TextNodeDumper::VisitUnaryTransformType` to dump the string 
and then simplify it to a single case.

Given the possibility that maybe some day one might add the `add_foo` builtins



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1110
+  if (T.expectAndConsume(diag::err_expected_lparen_after,
+ "reference manipulation builtin",
+ tok::r_paren)) return;

I dont think that this message is valid anymore now that you also remove 
qualifiers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D72304: [OpenMP][OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

2020-02-11 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim updated this revision to Diff 243839.
fghanim added a comment.

fixing unused variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72304

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/master_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPConstants.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -613,4 +613,161 @@
   }
 }
 
+TEST_F(OpenMPIRBuilderTest, MasterDirective) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  AllocaInst *PrivAI = nullptr;
+
+  BasicBlock *EntryBB = nullptr;
+  BasicBlock *ExitBB = nullptr;
+  BasicBlock *ThenBB = nullptr;
+
+  auto BodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+   BasicBlock &FiniBB) {
+if (AllocaIP.isSet())
+  Builder.restoreIP(AllocaIP);
+else
+  Builder.SetInsertPoint(&*(F->getEntryBlock().getFirstInsertionPt()));
+PrivAI = Builder.CreateAlloca(F->arg_begin()->getType());
+Builder.CreateStore(F->arg_begin(), PrivAI);
+
+llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+llvm::Instruction *CodeGenIPInst = &*CodeGenIP.getPoint();
+EXPECT_EQ(CodeGenIPBB->getTerminator(), CodeGenIPInst);
+
+Builder.restoreIP(CodeGenIP);
+
+// collect some info for checks later
+ExitBB = FiniBB.getUniqueSuccessor();
+ThenBB = Builder.GetInsertBlock();
+EntryBB = ThenBB->getUniquePredecessor();
+
+// simple instructions for body
+Value *PrivLoad = Builder.CreateLoad(PrivAI, "local.use");
+Builder.CreateICmpNE(F->arg_begin(), PrivLoad);
+  };
+
+  auto FiniCB = [&](InsertPointTy IP) {
+BasicBlock *IPBB = IP.getBlock();
+EXPECT_NE(IPBB->end(), IP.getPoint());
+  };
+
+  Builder.restoreIP(OMPBuilder.CreateMaster(Builder, BodyGenCB, FiniCB));
+  Value *EntryBBTI = EntryBB->getTerminator();
+  EXPECT_NE(EntryBBTI, nullptr);
+  EXPECT_TRUE(isa(EntryBBTI));
+  BranchInst *EntryBr = cast(EntryBB->getTerminator());
+  EXPECT_TRUE(EntryBr->isConditional());
+  EXPECT_EQ(EntryBr->getSuccessor(0), ThenBB);
+  EXPECT_EQ(ThenBB->getUniqueSuccessor(), ExitBB);
+  EXPECT_EQ(EntryBr->getSuccessor(1), ExitBB);
+
+  CmpInst *CondInst = cast(EntryBr->getCondition());
+  EXPECT_TRUE(isa(CondInst->getOperand(0)));
+
+  CallInst *MasterEntryCI = cast(CondInst->getOperand(0));
+  EXPECT_EQ(MasterEntryCI->getNumArgOperands(), 2U);
+  EXPECT_EQ(MasterEntryCI->getCalledFunction()->getName(), "__kmpc_master");
+  EXPECT_TRUE(isa(MasterEntryCI->getArgOperand(0)));
+
+  CallInst *MasterEndCI = nullptr;
+  for (auto &FI : *ThenBB) {
+Instruction *cur = &FI;
+if (isa(cur)) {
+  MasterEndCI = cast(cur);
+  if (MasterEndCI->getCalledFunction()->getName() == "__kmpc_end_master")
+break;
+  MasterEndCI = nullptr;
+}
+  }
+  EXPECT_NE(MasterEndCI, nullptr);
+  EXPECT_EQ(MasterEndCI->getNumArgOperands(), 2U);
+  EXPECT_TRUE(isa(MasterEndCI->getArgOperand(0)));
+  EXPECT_EQ(MasterEndCI->getArgOperand(1), MasterEntryCI->getArgOperand(1));
+}
+
+TEST_F(OpenMPIRBuilderTest, CriticalDirective) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  AllocaInst *PrivAI = Builder.CreateAlloca(F->arg_begin()->getType());
+
+  BasicBlock *EntryBB = nullptr;
+
+  auto BodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+   BasicBlock &FiniBB) {
+// collect some info for checks later
+EntryBB = FiniBB.getUniquePredecessor();
+
+// actual start for bodyCB
+llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+llvm::Instruction *CodeGenIPInst = &*CodeGenIP.getPoint();
+EXPECT_EQ(CodeGenIPBB->getTerminator(), CodeGenIPInst);
+EXPECT_EQ(EntryBB, CodeGenIPBB);
+
+// body begin
+Builder.restoreIP(CodeGenIP);
+Builder.CreateStore(F->arg_begin(), PrivAI);
+Value *PrivLoad = Builder.CreateLoad(PrivAI, "local.use");
+Builder.CreateICmpNE(F->arg_begin(), PrivLoad);
+  };
+
+  auto FiniCB = [&](InsertPointTy IP) {
+BasicBlock *IPBB = IP.getBlock();
+EXPECT_NE(IPBB->end(), IP.getPoint());
+  };
+
+  Builder.restoreIP(OMPBuilder.CreateCritical(Builder, B

[PATCH] D74399: [Driver][RISCV] Add RedHat Linux RISC-V triple

2020-02-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

passing-by remark: tests missing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74399



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


[clang-tools-extra] d4df372 - [clangd] Expose completion range in code completion results (C++ API)

2020-02-11 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-02-11T15:25:03+01:00
New Revision: d4df372559adb0ba3c652e85817a50db707c9858

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

LOG: [clangd] Expose completion range in code completion results (C++ API)

Summary:
Informative only, useful for positioning UI, interacting with other sources of
completion etc. As requested by an embedder of clangd.

Reviewers: usaxena95

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CodeComplete.h
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 4d4d15b0efae..6fc6c5d21c24 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1473,6 +1473,7 @@ class CodeCompleteFlow {
 }
 Output.HasMore = Incomplete;
 Output.Context = CCContextKind;
+Output.CompletionRange = ReplacedRange;
 return Output;
   }
 

diff  --git a/clang-tools-extra/clangd/CodeComplete.h 
b/clang-tools-extra/clangd/CodeComplete.h
index fd01dfd80b0e..3b3dca3ee8c5 100644
--- a/clang-tools-extra/clangd/CodeComplete.h
+++ b/clang-tools-extra/clangd/CodeComplete.h
@@ -216,6 +216,11 @@ struct CodeCompleteResult {
   std::vector Completions;
   bool HasMore = false;
   CodeCompletionContext::Kind Context = CodeCompletionContext::CCC_Other;
+  // The text that is being directly completed.
+  // Example: foo.pb^ -> foo.push_back()
+  //  ~~
+  // Typically matches the textEdit.range of Completions, but not guaranteed 
to.
+  llvm::Optional CompletionRange;
   // Usually the source will be parsed with a real C++ parser.
   // But heuristics may be used instead if e.g. the preamble is not ready.
   bool RanParser = true;

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 8863d9f278d7..67b8abb722be 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2134,6 +2134,7 @@ TEST(GuessCompletionPrefix, Filters) {
"some text [[scope::more::]][[identif]]^ier",
"some text [[scope::]][[mor]]^e::identifier",
"weird case foo::[[::bar::]][[baz]]^",
+   "/* [[]][[]]^ */",
}) {
 Annotations F(Case);
 auto Offset = cantFail(positionToOffset(F.code(), F.point()));
@@ -2675,6 +2676,28 @@ TEST(CompletionTest, NoCrashWithIncompleteLambda) {
   EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
 }
 
+TEST(CompletionTest, CompletionRange) {
+  const char *WithRange = "auto x = [[abc]]^";
+  auto Completions = completions(WithRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(WithRange).range());
+  Completions = completionsNoCompile(WithRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(WithRange).range());
+
+  const char *EmptyRange = "auto x = [[]]^";
+  Completions = completions(EmptyRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(EmptyRange).range());
+  Completions = completionsNoCompile(EmptyRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(EmptyRange).range());
+
+  // Sema doesn't trigger at all here, while the no-sema completion runs
+  // heuristics as normal and reports a range. It'd be nice to be consistent.
+  const char *NoCompletion = "/* [[]]^ */";
+  Completions = completions(NoCompletion);
+  EXPECT_EQ(Completions.CompletionRange, llvm::None);
+  Completions = completionsNoCompile(NoCompletion);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(NoCompletion).range());
+}
+
 TEST(NoCompileCompletionTest, Basic) {
   auto Results = completionsNoCompile(R"cpp(
 void func() {



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


[PATCH] D74305: [clangd] Expose completion range in code completion results (C++ API)

2020-02-11 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4df372559ad: [clangd] Expose completion range in code 
completion results (C++ API) (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D74305?vs=243491&id=243848#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74305

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2134,6 +2134,7 @@
"some text [[scope::more::]][[identif]]^ier",
"some text [[scope::]][[mor]]^e::identifier",
"weird case foo::[[::bar::]][[baz]]^",
+   "/* [[]][[]]^ */",
}) {
 Annotations F(Case);
 auto Offset = cantFail(positionToOffset(F.code(), F.point()));
@@ -2675,6 +2676,28 @@
   EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
 }
 
+TEST(CompletionTest, CompletionRange) {
+  const char *WithRange = "auto x = [[abc]]^";
+  auto Completions = completions(WithRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(WithRange).range());
+  Completions = completionsNoCompile(WithRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(WithRange).range());
+
+  const char *EmptyRange = "auto x = [[]]^";
+  Completions = completions(EmptyRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(EmptyRange).range());
+  Completions = completionsNoCompile(EmptyRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(EmptyRange).range());
+
+  // Sema doesn't trigger at all here, while the no-sema completion runs
+  // heuristics as normal and reports a range. It'd be nice to be consistent.
+  const char *NoCompletion = "/* [[]]^ */";
+  Completions = completions(NoCompletion);
+  EXPECT_EQ(Completions.CompletionRange, llvm::None);
+  Completions = completionsNoCompile(NoCompletion);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(NoCompletion).range());
+}
+
 TEST(NoCompileCompletionTest, Basic) {
   auto Results = completionsNoCompile(R"cpp(
 void func() {
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -216,6 +216,11 @@
   std::vector Completions;
   bool HasMore = false;
   CodeCompletionContext::Kind Context = CodeCompletionContext::CCC_Other;
+  // The text that is being directly completed.
+  // Example: foo.pb^ -> foo.push_back()
+  //  ~~
+  // Typically matches the textEdit.range of Completions, but not guaranteed 
to.
+  llvm::Optional CompletionRange;
   // Usually the source will be parsed with a real C++ parser.
   // But heuristics may be used instead if e.g. the preamble is not ready.
   bool RanParser = true;
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1473,6 +1473,7 @@
 }
 Output.HasMore = Incomplete;
 Output.Context = CCContextKind;
+Output.CompletionRange = ReplacedRange;
 return Output;
   }
 


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2134,6 +2134,7 @@
"some text [[scope::more::]][[identif]]^ier",
"some text [[scope::]][[mor]]^e::identifier",
"weird case foo::[[::bar::]][[baz]]^",
+   "/* [[]][[]]^ */",
}) {
 Annotations F(Case);
 auto Offset = cantFail(positionToOffset(F.code(), F.point()));
@@ -2675,6 +2676,28 @@
   EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
 }
 
+TEST(CompletionTest, CompletionRange) {
+  const char *WithRange = "auto x = [[abc]]^";
+  auto Completions = completions(WithRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(WithRange).range());
+  Completions = completionsNoCompile(WithRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(WithRange).range());
+
+  const char *EmptyRange = "auto x = [[]]^";
+  Completions = completions(EmptyRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(EmptyRange).range());
+  Completions = completionsNoCompile(EmptyRange);
+  EXPECT_EQ(Completions.CompletionRange, Annotations(EmptyRange).range());
+
+  // Sema doesn't trigger at all here, while the no-sema completion runs
+  // heuristics as normal and reports a range. It'd be nice to be consistent.
+ 

[PATCH] D74214: [clang-tidy] Fix PR#34798 'readability-braces-around-statements breaks statements containing braces.'

2020-02-11 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp:21
 
-tok::TokenKind getTokenKind(SourceLocation Loc, const SourceManager &SM,
-const ASTContext *Context) {
-  Token Tok;
+bool tryGetTokenKind(SourceLocation Loc, const SourceManager &SM,
+ const ASTContext *Context, tok::TokenKind &Kind) {

Could you change this to `llvm::Expected tryGetTokenKind(SourceLocation 
Loc, const SourceManager &SM, const ASTContext *Context)`. From a readability 
and performance standpoint, returned parameters are generally better than out 
parameters.



Comment at: 
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp:76-77
+
+  // We need to check that it is not 'InitListExpr' which ends with 
+  // the tokens '};' because it will break the following analysis
+  tok::TokenKind NextTokKind;

aaron.ballman wrote:
> Is there evidence that this behavior is desired? I have a hunch that this is 
> a bug in Clang -- not all `InitListExpr`s will terminate with a semicolon, 
> such as ones that appear as function arguments, like `foo({1, 2, 3});`, so 
> I'm surprised to see it included here.
On a related note, are you sure the cause of this issue is `makeFileCharRange`? 
AFAIK, that does not involve any examination of tokens. It purely (attempts) to 
map from potentially a mix of expanded locations and file locations to purely 
file locations (and in the same file for that matter).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74214



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


[PATCH] D74214: [clang-tidy] Fix PR#34798 'readability-braces-around-statements breaks statements containing braces.'

2020-02-11 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp:76-77
+
+  // We need to check that it is not 'InitListExpr' which ends with 
+  // the tokens '};' because it will break the following analysis
+  tok::TokenKind NextTokKind;

ymandel wrote:
> aaron.ballman wrote:
> > Is there evidence that this behavior is desired? I have a hunch that this 
> > is a bug in Clang -- not all `InitListExpr`s will terminate with a 
> > semicolon, such as ones that appear as function arguments, like `foo({1, 2, 
> > 3});`, so I'm surprised to see it included here.
> On a related note, are you sure the cause of this issue is 
> `makeFileCharRange`? AFAIK, that does not involve any examination of tokens. 
> It purely (attempts) to map from potentially a mix of expanded locations and 
> file locations to purely file locations (and in the same file for that 
> matter).
I believe the issue lies with `DeclStmt`, not `InitListExpr`. Specifically, the 
source range provided by `DeclStmt`.  See https://godbolt.org/z/vVtQZ8. The 
non-decl statements have an end location on the token before the semi, whereas 
the decl statements given their end location as the semi.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74214



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


[clang] 7ef45f4 - P1957R2: conversion from a pointer to bool is considered narrowing.

2020-02-11 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-11T06:52:44-08:00
New Revision: 7ef45f45f6721af4942f0e0bc38329e236b468cd

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

LOG: P1957R2: conversion from a pointer to bool is considered narrowing.

This is being implemented somewhat speculatively, to match GCC's
behavior.

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp
clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 003d9bb3a97d..1e838fd75130 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -328,9 +328,8 @@ NarrowingKind StandardConversionSequence::getNarrowingKind(
   goto FloatingIntegralConversion;
 if (FromType->isIntegralOrUnscopedEnumerationType())
   goto IntegralConversion;
-// Boolean conversions can be from pointers and pointers to members
-// [conv.bool], and those aren't considered narrowing conversions.
-return NK_Not_Narrowing;
+// -- from a pointer type or pointer-to-member type to bool, or
+return NK_Type_Narrowing;
 
   // -- from a floating-point type to an integer type, or
   //

diff  --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp 
b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
index 4436cb0aac60..eac9ac0e8279 100644
--- a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
@@ -180,9 +180,9 @@ void shrink_int() {
   Agg b2 = {1};  // OK
   Agg b3 = {-1};  // expected-error {{ cannot be narrowed }} 
expected-note {{silence}}
 
-  // Conversions from pointers to booleans aren't narrowing conversions.
+  // Conversions from pointers to booleans are narrowing conversions.
   Agg* ptr = &b1;
-  Agg b = {ptr};  // OK
+  Agg b = {ptr};  // expected-error {{ cannot be narrowed }} 
expected-note {{silence}}
 
   Agg ce1 = { Convert(10) }; // expected-error {{constant 
expression evaluates to 10 which cannot be narrowed to type 'short'}} 
expected-note {{silence}} expected-warning {{changes value from 10 to 
-31072}}
   Agg ce2 = { ConvertVar() }; // expected-error 
{{non-constant-expression cannot be narrowed from type 'short' to 'char'}} 
expected-note {{silence}}
@@ -240,3 +240,13 @@ void test_narrowed(Value vi, 
Value vd) {
   int &ir = check_narrowed(vd);
   float &fr = check_narrowed(vi);
 }
+
+// * from a pointer type or a pointer-to-member type to bool.
+void P1957R2(void *a, int *b, Agg *c, int Agg::*d) {
+  Agg ta = {a}; // expected-error {{cannot be narrowed}} expected-note 
{{}}
+  Agg tb = {b}; // expected-error {{cannot be narrowed}} expected-note 
{{}}
+  Agg tc = {c}; // expected-error {{cannot be narrowed}} expected-note 
{{}}
+  Agg td = {d}; // expected-error {{cannot be narrowed}} expected-note 
{{}}
+}
+template struct BoolParam {};
+BoolParam<&P1957R2> bp; // expected-error {{not allowed in a converted 
constant expression}}

diff  --git 
a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp 
b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
index d4d8198d4fc8..d701ec964605 100644
--- a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
@@ -163,10 +163,6 @@ void shrink_int() {
   Agg b2 = {1};  // OK
   Agg b3 = {-1};  // expected-warning {{ cannot be narrowed }} 
expected-note {{silence}}
 
-  // Conversions from pointers to booleans aren't narrowing conversions.
-  Agg* ptr = &b1;
-  Agg b = {ptr};  // OK
-
   Agg ce1 = { Convert(10) }; // expected-warning {{constant 
expression evaluates to 10 which cannot be narrowed to type 'short'}} 
expected-note {{silence}} expected-warning {{changes value from 10 to 
-31072}}
   Agg ce2 = { ConvertVar() }; // expected-warning 
{{non-constant-expression cannot be narrowed from type 'short' to 'char'}} 
expected-note {{silence}}
 }



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


[clang] 9ce6dc9 - CWG1423: don't permit implicit conversion of nullptr_t to bool.

2020-02-11 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-11T06:52:45-08:00
New Revision: 9ce6dc9872be4081fb98f6161c28581e1cbbe7dc

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

LOG: CWG1423: don't permit implicit conversion of nullptr_t to bool.

The C++ rules briefly allowed this, but the rule changed nearly 10 years
ago and we never updated our implementation to match. However, we've
warned on this by default for a long time, and no other compiler accepts
(even as an extension).

Added: 


Modified: 
clang/include/clang/Sema/Overload.h
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/CXX/drs/dr14xx.cpp
clang/test/CXX/drs/dr6xx.cpp
clang/test/CXX/expr/expr.const/p3-0x.cpp
clang/test/CodeGenCXX/nullptr.cpp
clang/test/SemaCXX/conversion.cpp
clang/test/SemaCXX/nullptr.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index a274102ceb11..f1a8b98e5efd 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -677,6 +677,24 @@ class Sema;
   StdInitializerListElement = V;
 }
 
+/// Form an "implicit" conversion sequence from nullptr_t to bool, for a
+/// direct-initialization of a bool object from nullptr_t.
+static ImplicitConversionSequence getNullptrToBool(QualType SourceType,
+   QualType DestType,
+   bool NeedLValToRVal) {
+  ImplicitConversionSequence ICS;
+  ICS.setStandard();
+  ICS.Standard.setAsIdentityConversion();
+  ICS.Standard.setFromType(SourceType);
+  if (NeedLValToRVal)
+ICS.Standard.First = ICK_Lvalue_To_Rvalue;
+  ICS.Standard.setToType(0, SourceType);
+  ICS.Standard.Second = ICK_Boolean_Conversion;
+  ICS.Standard.setToType(1, DestType);
+  ICS.Standard.setToType(2, DestType);
+  return ICS;
+}
+
 // The result of a comparison between implicit conversion
 // sequences. Use Sema::CompareImplicitConversionSequences to
 // actually perform the comparison.

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 61b7c166239f..61bb1f053ce2 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4420,16 +4420,20 @@ static void TryListInitialization(Sema &S,
 // direct-list-initialization and copy-initialization otherwise.
 // We can't use InitListChecker for this, because it always performs
 // copy-initialization. This only matters if we might use an 'explicit'
-// conversion operator, so we only need to handle the cases where the 
source
-// is of record type.
-if (InitList->getInit(0)->getType()->isRecordType()) {
+// conversion operator, or for the special case conversion of nullptr_t to
+// bool, so we only need to handle those cases.
+//
+// FIXME: Why not do this in all cases?
+Expr *Init = InitList->getInit(0);
+if (Init->getType()->isRecordType() ||
+(Init->getType()->isNullPtrType() && DestType->isBooleanType())) {
   InitializationKind SubKind =
   Kind.getKind() == InitializationKind::IK_DirectList
   ? InitializationKind::CreateDirect(Kind.getLocation(),
  InitList->getLBraceLoc(),
  InitList->getRBraceLoc())
   : Kind;
-  Expr *SubInit[1] = { InitList->getInit(0) };
+  Expr *SubInit[1] = { Init };
   Sequence.InitializeFrom(S, Entity, SubKind, SubInit,
   /*TopLevelOfInitList*/true,
   TreatUnavailableAsInvalid);
@@ -5854,6 +5858,19 @@ void InitializationSequence::InitializeFrom(Sema &S,
 return;
   }
 
+  //- Otherwise, if the initialization is direct-initialization, the source
+  //type is std::nullptr_t, and the destination type is bool, the initial
+  //value of the object being initialized is false.
+  if (!SourceType.isNull() && SourceType->isNullPtrType() &&
+  DestType->isBooleanType() &&
+  Kind.getKind() == InitializationKind::IK_Direct) {
+AddConversionSequenceStep(
+ImplicitConversionSequence::getNullptrToBool(SourceType, DestType,
+ Initializer->isGLValue()),
+DestType);
+return;
+  }
+
   //- Otherwise, the initial value of the object being initialized is the
   //  (possibly converted) value of the initializer expression. Standard
   //  conversions (Clause 4) will be used, if necessary, to convert the

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-11 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 243856.
bader marked 3 inline comments as done.
bader added a comment.

Applied review commits from Alexey.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/sycl.c
  clang/test/Frontend/sycl-aux-triple.cpp
  clang/test/Preprocessor/sycl-macro.cpp
  clang/test/SemaSYCL/kernel-attribute.cpp

Index: clang/test/SemaSYCL/kernel-attribute.cpp
===
--- clang/test/SemaSYCL/kernel-attribute.cpp
+++ clang/test/SemaSYCL/kernel-attribute.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl -fsycl-is-device -verify %s
 
 // Only function templates
 [[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
Index: clang/test/Preprocessor/sycl-macro.cpp
===
--- clang/test/Preprocessor/sycl-macro.cpp
+++ clang/test/Preprocessor/sycl-macro.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 %s -E -dM | FileCheck %s
-// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
+// RUN: %clang_cc1 %s -fsycl -sycl-std=2015 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -sycl-std=1.2.1 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -E -dM | FileCheck --check-prefixes=CHECK-SYCL %s
 
 // CHECK-NOT:#define __SYCL_DEVICE_ONLY__ 1
+// CHECK-NOT:#define CL_SYCL_LANGUAGE_VERSION 121
+// CHECK-SYCL-STD:#define CL_SYCL_LANGUAGE_VERSION 121
 // CHECK-SYCL:#define __SYCL_DEVICE_ONLY__ 1
Index: clang/test/Frontend/sycl-aux-triple.cpp
===
--- clang/test/Frontend/sycl-aux-triple.cpp
+++ clang/test/Frontend/sycl-aux-triple.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck %s
-// RUN: %clang_cc1 %s -fsycl-is-device -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
+// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
 
 // CHECK-NOT:#define __x86_64__ 1
 // CHECK-SYCL:#define __x86_64__ 1
Index: clang/test/Driver/sycl.c
===
--- clang/test/Driver/sycl.c
+++ clang/test/Driver/sycl.c
@@ -1,10 +1,20 @@
 // RUN: %clang -### -fsycl -c %s 2>&1 | FileCheck %s --check-prefix=ENABLED
 // RUN: %clang -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=1.2.1 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=121 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=2015 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=sycl-1.2.1 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
 // RUN: %clang -### -fno-sycl -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -sycl-std=2015 %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 // RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
 // RUN: %clangxx -### -fno-sycl %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 // RUN: %clangxx -### -fsycl -fno-sycl %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 // RUN: %clangxx -### %s 2>&1 | FileCheck %s --check-prefix=DISABLED
+// RUN: %clang_cl -### -fsycl -sycl-std=2015 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang_cl -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang_cl -### %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 
 // ENABLED: "-cc1"{{.*}} "-fsycl-is-device"
+// ENABLED-SAME: "-sycl-std={{[-.sycl0-9]+}}"
 // DISABLED-NOT: "-fsycl-is-device"
+// DISABLED-NOT: "-sycl-std="
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -450,6 +450,16 @@
 if (LangOpts.FastRelaxedMath)
   Builder.defineMacro("__FAST_RELAXED_MATH__");
   }
+
+  // SYCL Version is set to a value when building SYCL applications
+  switch (LangOpts.getSYCLVersion()) {
+  case LangOptions::SYCLVersionList::SYCL_2015:
+Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121");
+break;
+  case LangOptions::SYCLVersionList::Undefined:
+break;
+  }
+
   // Not "standard" per se, but available even with the -un

[PATCH] D74372: [OpenMP][IRBuilder] Perform finalization (incl. outlining) late

2020-02-11 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:113
+  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder())
+OMPBuilder->finalize();
 }

Does this mean that `finalize()` is being called twice everytime, here and 
`~OpenMPIRBuilder()`?
if yes, is there a reason why you want that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74372



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


[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-11 Thread Alexey Bader via Phabricator via cfe-commits
bader marked 3 inline comments as done.
bader added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2548
+  Opts.SYCL = Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false);
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL || Opts.SYCLIsDevice) {

ABataev wrote:
> bader wrote:
> > ABataev wrote:
> > > This option also must be controlled by `-fsycl`:
> > > ```
> > > Opts.SYCLIsDevice =  Opts.SYCL && 
> > > Args.hasArg(options::OPT_fsycl_is_device);
> > > 
> > > ```
> > Does it really has to? This logic is already present in the driver and it 
> > makes front-end tests verbose `%clang_cc1 -fsycl -fsycl-is-device`.
> > Can `-fsycl-is-device` imply `-fsycl`?
> > Looking how CUDA/OpenMP options are handled, not all of them are processed 
> > using this pattern.
> In general, this is how we handle it in OpenMP. Cuda works differently, 
> because it has its own kind of files (.cu) and Cuda is triggered by the 
> language switch (-x cu). Seems to me, you're using something close to OpenMP 
> model, no? Or do you want to define your own language kind just like Cuda?
I applied you suggest, although I don't fully understand the need of using two 
options instead of two. I would prefer having following code:
```
Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
Opts.SYCL = Args.hasArg(options::OPT_fsycl) || Opts.SYCLIsDevice; // 
-fsycl-is-device enable SYCL mode as well
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D74051: Add a dependency on clang for check-llvm

2020-02-11 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 243859.
arichardson added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Move tests to clang/ instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051

Files:
  clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
  clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  clang/test/utils/update_cc_test_checks/def-and-decl.test
  clang/test/utils/update_cc_test_checks/lit.local.cfg
  clang/test/utils/update_cc_test_checks/mangled_names.test
  llvm/test/tools/UpdateTestChecks/lit.local.cfg
  llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c
  
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c.expected
  llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c
  
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c.expected
  
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  llvm/test/tools/UpdateTestChecks/update_cc_test_checks/def-and-decl.test
  llvm/test/tools/UpdateTestChecks/update_cc_test_checks/lit.local.cfg
  llvm/test/tools/UpdateTestChecks/update_cc_test_checks/mangled_names.test

Index: llvm/test/tools/UpdateTestChecks/update_cc_test_checks/lit.local.cfg
===
--- llvm/test/tools/UpdateTestChecks/update_cc_test_checks/lit.local.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-# These tests require clang.
-if 'clang-binary' not in config.available_features:
-config.unsupported = True
Index: llvm/test/tools/UpdateTestChecks/lit.local.cfg
===
--- llvm/test/tools/UpdateTestChecks/lit.local.cfg
+++ llvm/test/tools/UpdateTestChecks/lit.local.cfg
@@ -42,11 +42,3 @@
 config.available_features.add('llvm-mca-binary')
 mca_arg = '--llvm-mca-binary ' + shell_quote(llvm_mca_path)
 add_update_script_substition('%update_test_checks', extra_args=mca_arg)
-
-clang_path = os.path.join(config.llvm_tools_dir, 'clang')
-if os.path.isfile(clang_path):
-config.available_features.add('clang-binary')
-extra_args = '--clang ' + shell_quote(clang_path)
-if os.path.isfile(opt_path):
-extra_args += ' --opt ' + shell_quote(opt_path)
-add_update_script_substition('%update_cc_test_checks', extra_args=extra_args)
Index: llvm/test/tools/UpdateTestChecks/update_cc_test_checks/mangled_names.test
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_cc_test_checks/mangled_names.test
@@ -1,13 +0,0 @@
-## Basic test checking that update_cc_test_checks.py works as expected for
-## functions with mangled names
-# RUN: cp -f %S/Inputs/mangled_names.c %t.c && %update_cc_test_checks -v %t.c
-# RUN: diff -u %t.c %S/Inputs/mangled_names.c.expected
-## Check that running the script again does not change the result:
-# RUN: %update_cc_test_checks -v %t.c
-# RUN: diff -u %t.c %S/Inputs/mangled_names.c.expected
-## Also try the --function-signature flag
-# RUN: %update_cc_test_checks %t.c --function-signature
-# RUN: diff -u %t.c %S/Inputs/mangled_names.c.funcsig.expected
-## Verify that running without the --function-signature flag removes the -SAME: lines:
-# RUN: %update_cc_test_checks %t.c
-# RUN: diff -u %t.c %S/Inputs/mangled_names.c.expected
Index: clang/test/utils/update_cc_test_checks/lit.local.cfg
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -0,0 +1,25 @@
+import os
+
+import lit.util
+
+# python 2.7 backwards compatibility
+try:
+from shlex import quote as shell_quote
+except ImportError:
+from pipes import quote as shell_quote
+
+
+config.test_format = lit.formats.ShTest(execute_external=False)
+config.suffixes = ['.test']
+
+clang_path = os.path.join(config.clang_tools_dir, 'clang')
+extra_args = '--clang ' + shell_quote(clang_path)
+opt_path = os.path.join(config.llvm_tools_dir, 'opt')
+extra_args += ' --opt ' + shell_quote(opt_path)
+script_path = os.path.join(config.llvm_src_root, 'utils',
+   'update_cc_test_checks.py')
+assert os.path.isfile(script_path)
+config.substitutions.append(
+('%update_cc_test_checks', "%s %s %s" % (
+shell_quote(config.python_executable), shell_quote(script_path),
+extra_args)))
Index: llvm/test/tools/UpdateTestChecks/update_cc_test_checks/def-and-decl.test
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_cc_test_

[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-02-11 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added a comment.

Hi @ostannard, thanks for your review.
I updated the patch so it won't act when the computed volatile bit-field access 
will overlap a zero length bit-field, avoiding the conflict. We can update it 
accordingly to future versions of the AAPCS if required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72932



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


[clang] 9a3740c - [OPENMP50]Add restrictions for memory order clauses in atomic directive.

2020-02-11 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-02-11T10:10:41-05:00
New Revision: 9a3740c33919287fd9aa4e0c6f761619e84c62a7

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

LOG: [OPENMP50]Add restrictions for memory order clauses in atomic directive.

Added restrictions for atomic directive.
1. If atomic-clause is read then memory-order-clause must not be acq_rel or 
release.
2. If atomic-clause is write then memory-order-clause must not be
   acq_rel or acquire.
3. If atomic-clause is update or not present then memory-order-clause
   must not be acq_rel or acquire.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/atomic_ast_print.cpp
clang/test/OpenMP/atomic_messages.cpp
clang/test/OpenMP/atomic_read_codegen.c
clang/test/OpenMP/atomic_update_codegen.cpp
clang/test/OpenMP/atomic_write_codegen.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 450075f2e927..9e4e89e61031 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9697,6 +9697,8 @@ def err_omp_atomic_several_clauses : Error<
   "directive '#pragma omp atomic' cannot contain more than one 'read', 
'write', 'update' or 'capture' clause">;
 def err_omp_several_mem_order_clauses : Error<
   "directive '#pragma omp %0' cannot contain more than one %select{'seq_cst', 
|}1'acq_rel', 'acquire' or 'release' clause">;
+def err_omp_atomic_incompatible_mem_order_clause : Error<
+  "directive '#pragma omp atomic%select{ %0|}1' cannot be used with '%2' 
clause">;
 def note_omp_previous_mem_order_clause : Note<
   "'%0' clause used here">;
 def err_omp_target_contains_not_only_teams : Error<

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 2e3c75fed370..313c9791bf87 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -8968,6 +8968,28 @@ StmtResult 
Sema::ActOnOpenMPAtomicDirective(ArrayRef Clauses,
   }
 }
   }
+  // OpenMP 5.0, 2.17.7 atomic Construct, Restrictions
+  // If atomic-clause is read then memory-order-clause must not be acq_rel or
+  // release.
+  // If atomic-clause is write then memory-order-clause must not be acq_rel or
+  // acquire.
+  // If atomic-clause is update or not present then memory-order-clause must 
not
+  // be acq_rel or acquire.
+  if ((AtomicKind == OMPC_read &&
+   (MemOrderKind == OMPC_acq_rel || MemOrderKind == OMPC_release)) ||
+  ((AtomicKind == OMPC_write || AtomicKind == OMPC_update ||
+AtomicKind == OMPC_unknown) &&
+   (MemOrderKind == OMPC_acq_rel || MemOrderKind == OMPC_acquire))) {
+SourceLocation Loc = AtomicKindLoc;
+if (AtomicKind == OMPC_unknown)
+  Loc = StartLoc;
+Diag(Loc, diag::err_omp_atomic_incompatible_mem_order_clause)
+<< getOpenMPClauseName(AtomicKind)
+<< (AtomicKind == OMPC_unknown ? 1 : 0)
+<< getOpenMPClauseName(MemOrderKind);
+Diag(MemOrderLoc, diag::note_omp_previous_mem_order_clause)
+<< getOpenMPClauseName(MemOrderKind);
+  }
 
   Stmt *Body = CS->getCapturedStmt();
   if (auto *EWC = dyn_cast(Body))

diff  --git a/clang/test/OpenMP/atomic_ast_print.cpp 
b/clang/test/OpenMP/atomic_ast_print.cpp
index 4dd64a75f2c9..f3f2883d2368 100644
--- a/clang/test/OpenMP/atomic_ast_print.cpp
+++ b/clang/test/OpenMP/atomic_ast_print.cpp
@@ -44,13 +44,13 @@ T foo(T argc) {
 a = b;
 b++;
   }
-#pragma omp atomic acq_rel
+#pragma omp atomic
   a++;
-#pragma omp atomic read acq_rel
+#pragma omp atomic read
   a = argc;
-#pragma omp atomic acq_rel write
+#pragma omp atomic write
   a = argc + argc;
-#pragma omp atomic update acq_rel
+#pragma omp atomic update
   a = a + argc;
 #pragma omp atomic acq_rel capture
   a = b++;
@@ -59,13 +59,13 @@ T foo(T argc) {
 a = b;
 b++;
   }
-#pragma omp atomic acquire
+#pragma omp atomic
   a++;
 #pragma omp atomic read acquire
   a = argc;
-#pragma omp atomic acquire write
+#pragma omp atomic write
   a = argc + argc;
-#pragma omp atomic update acquire
+#pragma omp atomic update
   a = a + argc;
 #pragma omp atomic acquire capture
   a = b++;
@@ -76,7 +76,7 @@ T foo(T argc) {
   }
 #pragma omp atomic release
   a++;
-#pragma omp atomic read release
+#pragma omp atomic read
   a = argc;
 #pragma omp atomic release write
   a = argc + argc;
@@ -123,13 +123,13 @@ T foo(T argc) {
 // CHECK-NEXT: a = b;
 // CHECK-NEXT: b++;
 // CHECK-NEXT: }
-// CHECK-NEXT: #pragma omp atomic acq_rel
+// CHECK-NEXT: #pragma omp atomic
 // CHECK-NEXT: a++;
-// CHECK-NEXT: #pragma omp atomic read acq_rel
+// CHECK-NEXT: #pragma omp atomic read
 // CHECK-NEXT: a = argc;
-// CHECK-NEXT: #p

[clang] faace36 - [Clang][Driver] After default -fintegrated-cc1, make llvm::report_fatal_error() generate preprocessed source + reproducer.sh again.

2020-02-11 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-11T10:17:30-05:00
New Revision: faace365088a2a3a4cb1050a9facfc34a7a56577

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

LOG: [Clang][Driver] After default -fintegrated-cc1, make 
llvm::report_fatal_error() generate preprocessed source + reproducer.sh again.

Added a test for #pragma clang __debug llvm_fatal_error to test for the 
original issue.
Added llvm::sys::Process::Exit() and replaced ::exit() in places where it was 
appropriate. This new function would call the current CrashRecoveryContext if 
one is running on the same thread; or call ::exit() otherwise.

Fixes PR44705.

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

Added: 


Modified: 
clang/test/Driver/crash-report.c
clang/tools/driver/cc1_main.cpp
clang/tools/driver/cc1as_main.cpp
llvm/include/llvm/Support/CrashRecoveryContext.h
llvm/include/llvm/Support/Process.h
llvm/lib/Support/CrashRecoveryContext.cpp
llvm/lib/Support/ErrorHandling.cpp
llvm/lib/Support/Process.cpp

Removed: 




diff  --git a/clang/test/Driver/crash-report.c 
b/clang/test/Driver/crash-report.c
index 3a77a21c62b4..ceb16cb6e18a 100644
--- a/clang/test/Driver/crash-report.c
+++ b/clang/test/Driver/crash-report.c
@@ -21,12 +21,20 @@
 // RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s
 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
 
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1  \
+// RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \
+// RUN:  not %clang %s @%t.rsp -DFATAL 2>&1 | FileCheck %s
+// RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
 // REQUIRES: crash-recovery
 
 #ifdef PARSER
 #pragma clang __debug parser_crash
 #elif CRASH
 #pragma clang __debug crash
+#elif FATAL
+#pragma clang __debug llvm_fatal_error
 #endif
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:

diff  --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index b551e9f4cf82..6d1a67f2a4fa 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
@@ -69,7 +70,7 @@ static void LLVMErrorHandler(void *UserData, const 
std::string &Message,
   // We cannot recover from llvm errors.  When reporting a fatal error, exit
   // with status 70 to generate crash diagnostics.  For BSD systems this is
   // defined as an internal software error.  Otherwise, exit with status 1.
-  exit(GenCrashDiag ? 70 : 1);
+  llvm::sys::Process::Exit(GenCrashDiag ? 70 : 1);
 }
 
 #ifdef CLANG_HAVE_RLIMITS

diff  --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index ce390b9f3b17..110f1dc70223 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -46,6 +46,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -555,7 +556,7 @@ static void LLVMErrorHandler(void *UserData, const 
std::string &Message,
   Diags.Report(diag::err_fe_error_backend) << Message;
 
   // We cannot recover from llvm errors.
-  exit(1);
+  sys::Process::Exit(1);
 }
 
 int cc1as_main(ArrayRef Argv, const char *Argv0, void *MainAddr) 
{

diff  --git a/llvm/include/llvm/Support/CrashRecoveryContext.h 
b/llvm/include/llvm/Support/CrashRecoveryContext.h
index beeb855c7c58..61a1bd405a4d 100644
--- a/llvm/include/llvm/Support/CrashRecoveryContext.h
+++ b/llvm/include/llvm/Support/CrashRecoveryContext.h
@@ -97,6 +97,11 @@ class CrashRecoveryContext {
 return RunSafelyOnThread([&]() { Fn(UserData); }, RequestedStackSize);
   }
 
+  /// Explicitly trigger a crash recovery in the current process, and
+  /// return failure from RunSafely(). This function does not return.
+  LLVM_ATTRIBUTE_NORETURN
+  void HandleExit(int RetCode);
+
   /// In case of a crash, this is the crash identifier.
   int RetCode = 0;
 

diff  --git a/llvm/include/llvm/Support/Process.h 
b/llvm/include/llvm/Support/Process.h
index 9444e165e142..bb5c33dfb38d 100644
--- a/llvm/include/llvm/Support/Process.h
+++ b/llvm/include/llvm/Support/Process.h
@@ -201,6 +201,12 @@ class Process {
   /// Get the result of a process wide random number generator. The
   /// generator will be automatic

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

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



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2548
+  Opts.SYCL = Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false);
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL || Opts.SYCLIsDevice) {

bader wrote:
> ABataev wrote:
> > bader wrote:
> > > ABataev wrote:
> > > > This option also must be controlled by `-fsycl`:
> > > > ```
> > > > Opts.SYCLIsDevice =  Opts.SYCL && 
> > > > Args.hasArg(options::OPT_fsycl_is_device);
> > > > 
> > > > ```
> > > Does it really has to? This logic is already present in the driver and it 
> > > makes front-end tests verbose `%clang_cc1 -fsycl -fsycl-is-device`.
> > > Can `-fsycl-is-device` imply `-fsycl`?
> > > Looking how CUDA/OpenMP options are handled, not all of them are 
> > > processed using this pattern.
> > In general, this is how we handle it in OpenMP. Cuda works differently, 
> > because it has its own kind of files (.cu) and Cuda is triggered by the 
> > language switch (-x cu). Seems to me, you're using something close to 
> > OpenMP model, no? Or do you want to define your own language kind just like 
> > Cuda?
> I applied you suggest, although I don't fully understand the need of using 
> two options instead of two. I would prefer having following code:
> ```
> Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
> Opts.SYCL = Args.hasArg(options::OPT_fsycl) || Opts.SYCLIsDevice; // 
> -fsycl-is-device enable SYCL mode as well
> ```
I'm not quite familiar with SYCL model, maybe this the right approach. You'd 
better try to provide more details. Are there any differences between just SYCL 
and SYCL-device compilation modes? How do you see the compilation sequence in 
general? At first you're going to compile the host version of the code, then 
the device? OR something different?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D73742: [Clang][Driver] After default -fintegrated-cc1, fix report_fatal_error no longer generates preprocessed source + reproducer.sh

2020-02-11 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfaace365088a: [Clang][Driver] After default 
-fintegrated-cc1, make llvm::report_fatal_error()… (authored by aganea).

Changed prior to commit:
  https://reviews.llvm.org/D73742?vs=243380&id=243863#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73742

Files:
  clang/test/Driver/crash-report.c
  clang/tools/driver/cc1_main.cpp
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/Support/CrashRecoveryContext.h
  llvm/include/llvm/Support/Process.h
  llvm/lib/Support/CrashRecoveryContext.cpp
  llvm/lib/Support/ErrorHandling.cpp
  llvm/lib/Support/Process.cpp

Index: llvm/lib/Support/Process.cpp
===
--- llvm/lib/Support/Process.cpp
+++ llvm/lib/Support/Process.cpp
@@ -13,8 +13,9 @@
 #include "llvm/Support/Process.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/Config/llvm-config.h"
 #include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -88,6 +89,13 @@
 
 bool Process::AreCoreFilesPrevented() { return coreFilesPrevented; }
 
+LLVM_ATTRIBUTE_NORETURN
+void Process::Exit(int RetCode) {
+  if (CrashRecoveryContext *CRC = CrashRecoveryContext::GetCurrent())
+CRC->HandleExit(RetCode);
+  ::exit(RetCode);
+}
+
 // Include the platform-specific parts of this class.
 #ifdef LLVM_ON_UNIX
 #include "Unix/Process.inc"
Index: llvm/lib/Support/ErrorHandling.cpp
===
--- llvm/lib/Support/ErrorHandling.cpp
+++ llvm/lib/Support/ErrorHandling.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/WindowsError.h"
@@ -122,7 +123,7 @@
   // files registered with RemoveFileOnSignal.
   sys::RunInterruptHandlers();
 
-  exit(1);
+  sys::Process::Exit(1);
 }
 
 void llvm::install_bad_alloc_error_handler(fatal_error_handler_t handler,
Index: llvm/lib/Support/CrashRecoveryContext.cpp
===
--- llvm/lib/Support/CrashRecoveryContext.cpp
+++ llvm/lib/Support/CrashRecoveryContext.cpp
@@ -14,9 +14,6 @@
 #include "llvm/Support/ThreadLocal.h"
 #include 
 #include 
-#ifdef _WIN32
-#include  // for GetExceptionInformation
-#endif
 #if LLVM_ON_UNIX
 #include  // EX_IOERR
 #endif
@@ -178,6 +175,9 @@
 }
 
 #if defined(_MSC_VER)
+
+#include  // for GetExceptionInformation
+
 // If _MSC_VER is defined, we must have SEH. Use it if it's available. It's way
 // better than VEH. Vectored exception handling catches all exceptions happening
 // on the thread with installed exception handlers, so it can interfere with
@@ -203,6 +203,8 @@
   }
 
   int RetCode = (int)Except->ExceptionRecord->ExceptionCode;
+  if ((RetCode & 0xF000) == 0xE000)
+RetCode &= ~0xF000; // this crash was generated by sys::Process::Exit
 
   // Handle the crash
   const_cast(CRCI)->HandleCrash(
@@ -280,10 +282,13 @@
   // TODO: We can capture the stack backtrace here and store it on the
   // implementation if we so choose.
 
+  int RetCode = (int)ExceptionInfo->ExceptionRecord->ExceptionCode;
+  if ((RetCode & 0xF000) == 0xE000)
+RetCode &= ~0xF000; // this crash was generated by sys::Process::Exit
+
   // Handle the crash
   const_cast(CRCI)->HandleCrash(
-  (int)ExceptionInfo->ExceptionRecord->ExceptionCode,
-  reinterpret_cast(ExceptionInfo));
+  RetCode, reinterpret_cast(ExceptionInfo));
 
   // Note that we don't actually get here because HandleCrash calls
   // longjmp, which means the HandleCrash function never returns.
@@ -416,6 +421,21 @@
 
 #endif // !_MSC_VER
 
+LLVM_ATTRIBUTE_NORETURN
+void CrashRecoveryContext::HandleExit(int RetCode) {
+#if defined(_WIN32)
+  // SEH and VEH
+  ::RaiseException(0xE000 | RetCode, 0, 0, NULL);
+#else
+  // On Unix we don't need to raise an exception, we go directly to
+  // HandleCrash(), then longjmp will unwind the stack for us.
+  CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *)Impl;
+  assert(CRCI && "Crash recovery context never initialized!");
+  CRCI->HandleCrash(RetCode, 0 /*no sig num*/);
+#endif
+  llvm_unreachable("Most likely setjmp wasn't called!");
+}
+
 // FIXME: Portability.
 static void setThreadBackgroundPriority() {
 #ifdef __APPLE__
Index: llvm/include/llvm/Support/Process.h
===
--- llvm/include/llvm/Support/Process.h
+++ llvm/include/llvm/Support/Process.h
@@ -201,6 +201,12 @@
   /// Get the result of a process wide random

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

2020-02-11 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: clang/include/clang/Basic/TargetCXXABI.h:116
+///   - static initialization is adjusted to use sinit and sterm functions;
+XL_Clang,
+

Why the underscore in the name? This is a bit inconsistent with both the LLVM 
naming convention here and the name as it appears in other sources.


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] D73742: [Clang][Driver] After default -fintegrated-cc1, fix report_fatal_error no longer generates preprocessed source + reproducer.sh

2020-02-11 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked 2 inline comments as done.
aganea added a comment.

Side-note: Perhaps we would need to do the same as this patch, for calls to 
`::abort()`?




Comment at: llvm/include/llvm/Support/Process.h:205
+
+  /// When integrated-cc1 is disabled, terminate the current program.
+  /// When integrated-cc1 is enabled, terminates execution of the current

hans wrote:
> Could the comment be phrased in terms of CrashRecoveryContext instead of 
> integrated-cc1, which is a Clang thing?
Done in the commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73742



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


[PATCH] D74260: Change default relocation model for hexagon when triple includes musl

2020-02-11 Thread Brian Cain via Phabricator via cfe-commits
bcain added inline comments.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:923
+  return ((getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
+  getTriple().isMusl() || getSanitizerArgs().requiresPIE()) &&
+  getTriple().getArch() != llvm::Triple::hexagon;

But if 
```
getSanitizerArgs().requiresPIE() && getTriple().getArch() == 
llvm::Triple::hexagon
```

 then the `!= hexagon` takes precedence?  Seems like "sanitizer requires 
PIE" should, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74260



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


[PATCH] D73904: [clang] stop baremetal driver to append .a to lib

2020-02-11 Thread Christof Douma via Phabricator via cfe-commits
christof updated this revision to Diff 243868.
christof added a comment.

With updated tests


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

https://reviews.llvm.org/D73904

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -13,7 +13,7 @@
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -35,7 +35,7 @@
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -48,7 +48,7 @@
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -61,7 +61,7 @@
 // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
-// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -157,7 +157,7 @@
 void BareMetal::AddLinkRuntimeLib(const ArgList &Args,
   ArgStringList &CmdArgs) const {
   CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
-   getTriple().getArchName() + ".a"));
+   getTriple().getArchName()));
 }
 
 void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -13,7 +13,7 @@
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -35,7 +35,7 @@
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -48,7 +48,7 @@
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" 

[PATCH] D73261: [dwarf5] Support DebugInfo for constexpr for C++ variables and functions

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

In D73261#1868790 , @djtodoro wrote:

> @awpandey Thanks for doing this, but could you please explain the motivation 
> of implementing this?


+1 (as I asked earlier & don't think there's been a response for)


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

https://reviews.llvm.org/D73261



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


[PATCH] D74411: [clangd] Query constructors in the index during rename.

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

Though this is not needed when using clangd's own index, other indexes
(e.g. kythe) need it, as classes and their constructors are different
symbols, otherwise we will miss renaming constructors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74411

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
@@ -768,6 +768,50 @@
   testing::HasSubstr("too many occurrences"));
 }
 
+TEST(CrossFileRename, QueryCtorInIndex) {
+  auto MainCode = Annotations("F^oo f;");
+  auto TU = TestTU::withCode(MainCode.code());
+  TU.HeaderCode = R"cpp(
+class Foo {
+public:
+  Foo() = default;
+};
+  )cpp";
+  auto AST = TU.build();
+
+  RefsRequest Req;
+  class RecordIndex : public SymbolIndex {
+  public:
+RecordIndex(RefsRequest *R) : Out(R) {}
+bool refs(const RefsRequest &Req,
+  llvm::function_ref Callback) const override {
+  *Out = Req;
+  return false;
+}
+
+bool fuzzyFind(const FuzzyFindRequest &,
+   llvm::function_ref) const override {
+  return false;
+}
+void lookup(const LookupRequest &,
+llvm::function_ref) const override {}
+
+void relations(const RelationsRequest &,
+   llvm::function_ref)
+const override {}
+size_t estimateMemoryUsage() const override { return 0; }
+
+RefsRequest *Out;
+  } RIndex(&Req);
+  auto Results =
+  rename({MainCode.point(), "NewName", AST, testPath("main.cc"), &RIndex,
+  /*CrossFile=*/true});
+  ASSERT_TRUE(bool(Results)) << Results.takeError();
+  auto HeaderSymbols = TU.headerSymbols();
+  EXPECT_THAT(Req.IDs,
+  testing::Contains(findSymbol(HeaderSymbols, "Foo::Foo").ID));
+}
+
 TEST(CrossFileRenameTests, DeduplicateRefsFromIndex) {
   auto MainCode = Annotations("int [[^x]] = 2;");
   auto MainFilePath = testPath("main.cc");
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -297,6 +297,22 @@
   return R;
 }
 
+std::vector getConstructors(const NamedDecl *ND) {
+  std::vector Ctors;
+  if (const auto *RD = dyn_cast(ND)) {
+if (!RD->hasUserDeclaredConstructor())
+  return {};
+Ctors = {RD->ctors().begin(), RD->ctors().end()};
+for (const auto *D : RD->decls()) {
+  if (const auto *FTD = dyn_cast(D))
+if (const auto *Ctor =
+dyn_cast(FTD->getTemplatedDecl()))
+  Ctors.push_back(Ctor);
+}
+  }
+  return Ctors;
+}
+
 // Return all rename occurrences (using the index) outside of the main file,
 // grouped by the absolute file path.
 llvm::Expected>>
@@ -304,6 +320,14 @@
llvm::StringRef MainFile, const SymbolIndex &Index) 
{
   RefsRequest RQuest;
   RQuest.IDs.insert(*getSymbolID(&RenameDecl));
+  // Classes and their constructors are different symbols, and have different
+  // symbol ID.
+  // When querying references for a class, clangd's own index will also return
+  // references of the corresponding class constructors, but this is not true
+  // for all index backends, e.g. kythe, so we add all constructors to the 
query
+  // request.
+  for (const auto *Ctor : getConstructors(&RenameDecl))
+RQuest.IDs.insert(*getSymbolID(Ctor));
 
   // Absolute file path => rename occurrences in that file.
   llvm::StringMap> AffectedFiles;


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -768,6 +768,50 @@
   testing::HasSubstr("too many occurrences"));
 }
 
+TEST(CrossFileRename, QueryCtorInIndex) {
+  auto MainCode = Annotations("F^oo f;");
+  auto TU = TestTU::withCode(MainCode.code());
+  TU.HeaderCode = R"cpp(
+class Foo {
+public:
+  Foo() = default;
+};
+  )cpp";
+  auto AST = TU.build();
+
+  RefsRequest Req;
+  class RecordIndex : public SymbolIndex {
+  public:
+RecordIndex(RefsRequest *R) : Out(R) {}
+bool refs(const RefsRequest &Req,
+  llvm::function_ref Callback) const override {
+  *Out = Req;
+  return false;
+}
+
+bool fuzzyFind(const FuzzyFindRequest &,
+   llvm::function_ref) const override {
+  return false;
+}
+void lookup(const LookupRequest &,
+llvm::function_re

[PATCH] D74412: Fix SFINAE in CFG.cpp.

2020-02-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar created this revision.
jlebar added reviewers: bkramer, MaskRay.
Herald added subscribers: cfe-commits, martong.
Herald added a project: clang.
jlebar updated this revision to Diff 243877.
jlebar added a comment.

Rebase


Used std::enable_if without ::type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74412

Files:
  clang/lib/Analysis/CFG.cpp


Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -720,10 +720,10 @@
   // These sorts of call expressions don't have a common superclass,
   // hence strict duck-typing.
   template ::value ||
-std::is_same::value ||
-std::is_same::value>>
+typename = std::enable_if_t<
+std::is_base_of::value ||
+std::is_base_of::value ||
+std::is_base_of::value>>
   void findConstructionContextsForArguments(CallLikeExpr *E) {
 for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
   Expr *Arg = E->getArg(i);


Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -720,10 +720,10 @@
   // These sorts of call expressions don't have a common superclass,
   // hence strict duck-typing.
   template ::value ||
-std::is_same::value ||
-std::is_same::value>>
+typename = std::enable_if_t<
+std::is_base_of::value ||
+std::is_base_of::value ||
+std::is_base_of::value>>
   void findConstructionContextsForArguments(CallLikeExpr *E) {
 for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
   Expr *Arg = E->getArg(i);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74414: Use std::foo_t rather than std::foo in clang.

2020-02-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar created this revision.
jlebar added reviewers: bkramer, MaskRay.
Herald added a reviewer: martong.
Herald added a reviewer: shafik.
Herald added subscribers: cfe-commits, martong.
Herald added a project: clang.

No functional change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74414

Files:
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/CanonicalType.h
  clang/include/clang/AST/DataCollection.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/include/clang/Analysis/CFG.h
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Basic/PartialDiagnostic.h
  clang/include/clang/Tooling/Refactoring/RefactoringOptions.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Interp/Boolean.h
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Source.h
  clang/lib/Analysis/ThreadSafety.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  clang/lib/Tooling/ASTDiff/ASTDiff.cpp
  clang/unittests/Tooling/ASTSelectionTest.cpp

Index: clang/unittests/Tooling/ASTSelectionTest.cpp
===
--- clang/unittests/Tooling/ASTSelectionTest.cpp
+++ clang/unittests/Tooling/ASTSelectionTest.cpp
@@ -101,22 +101,22 @@
 }
 
 template 
-const SelectedASTNode &
-checkNode(const SelectedASTNode &StmtNode, SourceSelectionKind SelectionKind,
-  unsigned NumChildren = 0,
-  typename std::enable_if::value, T>::type
-  *StmtOverloadChecker = nullptr) {
+const SelectedASTNode &checkNode(
+const SelectedASTNode &StmtNode, SourceSelectionKind SelectionKind,
+unsigned NumChildren = 0,
+std::enable_if_t::value, T> *StmtOverloadChecker =
+nullptr) {
   checkNodeImpl(isa(StmtNode.Node.get()), StmtNode, SelectionKind,
 NumChildren);
   return StmtNode;
 }
 
 template 
-const SelectedASTNode &
-checkNode(const SelectedASTNode &DeclNode, SourceSelectionKind SelectionKind,
-  unsigned NumChildren = 0, StringRef Name = "",
-  typename std::enable_if::value, T>::type
-  *DeclOverloadChecker = nullptr) {
+const SelectedASTNode &checkNode(
+const SelectedASTNode &DeclNode, SourceSelectionKind SelectionKind,
+unsigned NumChildren = 0, StringRef Name = "",
+std::enable_if_t::value, T> *DeclOverloadChecker =
+nullptr) {
   checkNodeImpl(isa(DeclNode.Node.get()), DeclNode, SelectionKind,
 NumChildren);
   if (!Name.empty())
Index: clang/lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- clang/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ clang/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -117,12 +117,12 @@
   Impl(SyntaxTree *Parent, Stmt *N, ASTContext &AST);
   template 
   Impl(SyntaxTree *Parent,
-   typename std::enable_if::value, T>::type *Node,
+   std::enable_if_t::value, T> *Node,
ASTContext &AST)
   : Impl(Parent, dyn_cast(Node), AST) {}
   template 
   Impl(SyntaxTree *Parent,
-   typename std::enable_if::value, T>::type *Node,
+   std::enable_if_t::value, T> *Node,
ASTContext &AST)
   : Impl(Parent, dyn_cast(Node), AST) {}
 
Index: clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -51,11 +51,10 @@
 } // end of anonymous namespace
 
 template 
-static
-typename std::conditional::value,
-  typename CheckerOrPackageInfoList::const_iterator,
-  typename CheckerOrPackageInfoList::iterator>::type
-binaryFind(CheckerOrPackageInfoList &Collection, StringRef FullName) {
+static std::conditional_t::value,
+  typename CheckerOrPackageInfoList::const_iterator,
+  typename CheckerOrPackageInfoList::iterator>
+binaryFind(CheckerOrPackageInfoList &Collection, StringRef FullName) {
 
   using CheckerOrPackage = typename CheckerOrPackageInfoList::value_type;
   using CheckerOrPackageFullNameLT = FullNameLT;
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2747,8 +2747,8 @@
 
 /// Complete template argument deduction for a partial specialization.
 template 
-static typename std::enable_if::value,
-   Sema::TemplateDeductionResult>::type
+static std::enable_if_t::value,
+Sema::TemplateDeductionResult>
 FinishTemplateArgumentDeduction(
 Sema &S, T *Partial, bool IsPartialOrdering,
 const T

[PATCH] D74412: Fix SFINAE in CFG.cpp.

2020-02-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar updated this revision to Diff 243877.
jlebar added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74412

Files:
  clang/lib/Analysis/CFG.cpp


Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -720,10 +720,10 @@
   // These sorts of call expressions don't have a common superclass,
   // hence strict duck-typing.
   template ::value ||
-std::is_same::value ||
-std::is_same::value>>
+typename = std::enable_if_t<
+std::is_base_of::value ||
+std::is_base_of::value ||
+std::is_base_of::value>>
   void findConstructionContextsForArguments(CallLikeExpr *E) {
 for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
   Expr *Arg = E->getArg(i);


Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -720,10 +720,10 @@
   // These sorts of call expressions don't have a common superclass,
   // hence strict duck-typing.
   template ::value ||
-std::is_same::value ||
-std::is_same::value>>
+typename = std::enable_if_t<
+std::is_base_of::value ||
+std::is_base_of::value ||
+std::is_base_of::value>>
   void findConstructionContextsForArguments(CallLikeExpr *E) {
 for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
   Expr *Arg = E->getArg(i);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74372: [OpenMP][IRBuilder] Perform finalization (incl. outlining) late

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



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:113
+  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder())
+OMPBuilder->finalize();
 }

fghanim wrote:
> Does this mean that `finalize()` is being called twice everytime, here and 
> `~OpenMPIRBuilder()`?
> if yes, is there a reason why you want that?
It's called twice now, not that it matters. The basic rule is, call it at least 
once before you finalize the module. I'll remove the destructor for now to make 
it explicit only.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:275
+  /// Get a handle for a new region that will be outlined later.
+  OutlineInfo &getNewOutlineInfo() {
+OutlineInfos.push_back({});

JonChesterfield wrote:
> Calling getNewOutlineInfo will invalidate the references previously returned. 
> That's not a bug in this patch but looks like it'll be easy to get wrong in 
> future.
> 
> Perhaps the backing store should be a linked list, such that push_back 
> doesn't invalidate any existing references?
The address of these objects is not stable but without that requirement we 
don't need a list. We make this function take a `OutlineInfo` object that we 
than move into the vector if that is preferred.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:114
+
+// Add some known attributes to the outlined function.
+Function *OutlinedFn = Extractor.extractCodeRegion(CEAC);

rogfer01 wrote:
> This comment seems misplaced now.
Agreed, will be moved.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:587
+  CallInst *CI = cast(OutlinedFn.user_back());
+  CI->getParent()->setName("omp_parallel");
+  Builder.SetInsertPoint(CI);

JonChesterfield wrote:
> s/parallel/outlined?
this is in the `omp parallel` callback so "parallel" is still fine. 



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:654-655
+Instruction *PreFiniTI = PRegPreFiniBB->getTerminator();
+OuterFn->dump();
+PreFiniTI->dump();
+assert(PreFiniTI->getNumSuccessors() == 1 &&

rogfer01 wrote:
> I think you forgot to wrap these in a `LLVM_DEBUG`
I simplify forgot the remove them. Thx for noticing.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:663
 
-  return AfterIP;
+InsertPointTy ExitIP(UI->getParent(), UI->getParent()->end());
+UI->eraseFromParent();

rogfer01 wrote:
> This used to be called `AfterIP`. Probably the exact name is not that 
> important but the unit tests still use `AfterIP` so I'd suggest to keep both 
> names in sync.
I'll call it `AfterIP` again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74372



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


[PATCH] D73904: [clang] stop baremetal driver to append .a to lib

2020-02-11 Thread Christof Douma via Phabricator via cfe-commits
christof added a comment.

Just noticed the comment from Peter asking for 
clang/test/Driver/arm-compiler-rt.c, I'll add that in a moment.


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

https://reviews.llvm.org/D73904



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


[PATCH] D74385: [ARCMT][NFC] Reduce #include dependencies

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

LGTM, as long as it builds fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74385



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


[PATCH] D74333: [ARM,MVE] Add intrinsics for FP rounding operations.

2020-02-11 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

> vrintn behaves the same as vrintx

vrintx is not mentioned anywhere in the patch. Should it say "llvm.rint" 
instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74333



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


[PATCH] D73904: [clang] stop baremetal driver to append .a to lib

2020-02-11 Thread Peter Smith via Phabricator via cfe-commits
psmith accepted this revision.
psmith added a comment.
This revision is now accepted and ready to land.

Thanks for the update, looks good to me. The BareMetal driver tests are better 
than the location I suggested.


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

https://reviews.llvm.org/D73904



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


[PATCH] D74387: [SYCL] Do not diagnose use of __float128

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

I would add a check for the use of unsupported types in kernels. They should 
not be allowed to be used if target does not support it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74387



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


[PATCH] D74333: [ARM,MVE] Add intrinsics for FP rounding operations.

2020-02-11 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

In D74333#1869788 , @miyuki wrote:

> vrintx is not mentioned anywhere in the patch. Should it say "llvm.rint" 
> instead?


No, I meant what I said: `vrintx` is the MVE machine instruction that 
`llvm.rint` already instruction-selects to (which is why I didn't have to 
mention it anywhere in this patch).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74333



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


[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-11 Thread Alexey Bader via Phabricator via cfe-commits
bader marked 2 inline comments as done.
bader added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2548
+  Opts.SYCL = Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false);
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL || Opts.SYCLIsDevice) {

ABataev wrote:
> bader wrote:
> > ABataev wrote:
> > > bader wrote:
> > > > ABataev wrote:
> > > > > This option also must be controlled by `-fsycl`:
> > > > > ```
> > > > > Opts.SYCLIsDevice =  Opts.SYCL && 
> > > > > Args.hasArg(options::OPT_fsycl_is_device);
> > > > > 
> > > > > ```
> > > > Does it really has to? This logic is already present in the driver and 
> > > > it makes front-end tests verbose `%clang_cc1 -fsycl -fsycl-is-device`.
> > > > Can `-fsycl-is-device` imply `-fsycl`?
> > > > Looking how CUDA/OpenMP options are handled, not all of them are 
> > > > processed using this pattern.
> > > In general, this is how we handle it in OpenMP. Cuda works differently, 
> > > because it has its own kind of files (.cu) and Cuda is triggered by the 
> > > language switch (-x cu). Seems to me, you're using something close to 
> > > OpenMP model, no? Or do you want to define your own language kind just 
> > > like Cuda?
> > I applied you suggest, although I don't fully understand the need of using 
> > two options instead of two. I would prefer having following code:
> > ```
> > Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
> > Opts.SYCL = Args.hasArg(options::OPT_fsycl) || Opts.SYCLIsDevice; // 
> > -fsycl-is-device enable SYCL mode as well
> > ```
> I'm not quite familiar with SYCL model, maybe this the right approach. You'd 
> better try to provide more details. Are there any differences between just 
> SYCL and SYCL-device compilation modes? How do you see the compilation 
> sequence in general? At first you're going to compile the host version of the 
> code, then the device? OR something different?
I think SYCL model is quite similar to OpenMP model. One significant difference 
might be that to implement standard SYCL functionality we don't need any 
modifications for the host compiler. AFAIK, OpenMP compiler has to support 
OpenMP pragmas. 
We have a few attributes for Intel FPGA devices, which we can't pre-process 
with `__SYCL_DEVICE_ONLY__` macro and we have added "SYCL-host" mode to 
suppress compiler warnings about attributes ignored on the host. I think there 
might be other options how this can be achieved w/o adding new compilation mode 
and use regular C++ front-end as SYCL host compiler.
I think there is a difference between SYCL and SYCL-device modes, but it's 
mostly changes the compilation workflow in the driver, but not in the 
front-end. In SYCL-device mode, driver invokes only one front-end instance to 
generate offload code. In SYCL mode, driver invokes multiple front-end 
instances: one in SYCL-device mode and one in regular C++ mode (to be accurate 
we use SYCL-host mode, but as I mentioned above I don't think it really needed).
I hope it makes it clear now. Let me know if you have any other questions.

Do I understand it correctly that OpenMP option enables OpenMP mode, which is 
equivalent of "SYCL-host" mode and enabling both OpenMP and OpenMPIsDevice is 
required for enabling OpenMP mode, which is similar to SYCL-device mode?
If so, can we assume that OpenMPIsDevice implies that OpenMP option is also set 
(implicitly)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

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



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2548
+  Opts.SYCL = Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false);
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL || Opts.SYCLIsDevice) {

bader wrote:
> ABataev wrote:
> > bader wrote:
> > > ABataev wrote:
> > > > bader wrote:
> > > > > ABataev wrote:
> > > > > > This option also must be controlled by `-fsycl`:
> > > > > > ```
> > > > > > Opts.SYCLIsDevice =  Opts.SYCL && 
> > > > > > Args.hasArg(options::OPT_fsycl_is_device);
> > > > > > 
> > > > > > ```
> > > > > Does it really has to? This logic is already present in the driver 
> > > > > and it makes front-end tests verbose `%clang_cc1 -fsycl 
> > > > > -fsycl-is-device`.
> > > > > Can `-fsycl-is-device` imply `-fsycl`?
> > > > > Looking how CUDA/OpenMP options are handled, not all of them are 
> > > > > processed using this pattern.
> > > > In general, this is how we handle it in OpenMP. Cuda works differently, 
> > > > because it has its own kind of files (.cu) and Cuda is triggered by the 
> > > > language switch (-x cu). Seems to me, you're using something close to 
> > > > OpenMP model, no? Or do you want to define your own language kind just 
> > > > like Cuda?
> > > I applied you suggest, although I don't fully understand the need of 
> > > using two options instead of two. I would prefer having following code:
> > > ```
> > > Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
> > > Opts.SYCL = Args.hasArg(options::OPT_fsycl) || Opts.SYCLIsDevice; // 
> > > -fsycl-is-device enable SYCL mode as well
> > > ```
> > I'm not quite familiar with SYCL model, maybe this the right approach. 
> > You'd better try to provide more details. Are there any differences between 
> > just SYCL and SYCL-device compilation modes? How do you see the compilation 
> > sequence in general? At first you're going to compile the host version of 
> > the code, then the device? OR something different?
> I think SYCL model is quite similar to OpenMP model. One significant 
> difference might be that to implement standard SYCL functionality we don't 
> need any modifications for the host compiler. AFAIK, OpenMP compiler has to 
> support OpenMP pragmas. 
> We have a few attributes for Intel FPGA devices, which we can't pre-process 
> with `__SYCL_DEVICE_ONLY__` macro and we have added "SYCL-host" mode to 
> suppress compiler warnings about attributes ignored on the host. I think 
> there might be other options how this can be achieved w/o adding new 
> compilation mode and use regular C++ front-end as SYCL host compiler.
> I think there is a difference between SYCL and SYCL-device modes, but it's 
> mostly changes the compilation workflow in the driver, but not in the 
> front-end. In SYCL-device mode, driver invokes only one front-end instance to 
> generate offload code. In SYCL mode, driver invokes multiple front-end 
> instances: one in SYCL-device mode and one in regular C++ mode (to be 
> accurate we use SYCL-host mode, but as I mentioned above I don't think it 
> really needed).
> I hope it makes it clear now. Let me know if you have any other questions.
> 
> Do I understand it correctly that OpenMP option enables OpenMP mode, which is 
> equivalent of "SYCL-host" mode and enabling both OpenMP and OpenMPIsDevice is 
> required for enabling OpenMP mode, which is similar to SYCL-device mode?
> If so, can we assume that OpenMPIsDevice implies that OpenMP option is also 
> set (implicitly)?
> Do I understand it correctly that OpenMP option enables OpenMP mode, which is 
> equivalent of "SYCL-host" mode and enabling both OpenMP and OpenMPIsDevice is 
> required for enabling OpenMP mode, which is similar to SYCL-device mode?

Well, for driver you need to pass `-fopenmp -fopenmp-target=` 
to enable the compilation with offloading support. In the frontend the host 
part is compiled with `-fopenmp` only (+ aux-triple, probably), for devices - 
`-fopenmp -fopenmp-is-device`. Without `-fopenmp` `-fopenmp-is-device` is just 
ignored.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D74387: [SYCL] Do not diagnose use of __float128

2020-02-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The right approach here is probably what we do in ObjC ARC when we see types 
that are illegal in ARC: in system headers, we allow the code but add a special 
`UnavailableAttr` to the declaration so that it can't be directly used.

That is straightforward enough that I think you should just do it instead of 
leaving this as technical debt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74387



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


[PATCH] D74417: [clang][ARC] Remove invalid assertion that can crash clangd

2020-02-11 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
dgoldman added reviewers: erik.pilkington, jkorous.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, 
dexonsmith, MaskRay, ilya-biryukov.
Herald added a project: clang.

- This assertion will fire when functions are marked with 
`objc_externally_retained`, such as in the following function: 
`__attribute__((objc_externally_retained)) void AssertOnQueue(dispatch_queue_t 
queue)`

- Thus the assertion isn't valid as these parameters are indeed psuedo strong


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74417

Files:
  clang/lib/Serialization/ASTWriterDecl.cpp


Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1089,8 +1089,6 @@
 Record.AddStmt(D->getUninstantiatedDefaultArg());
   Code = serialization::DECL_PARM_VAR;
 
-  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
-
   // If the assumptions about the DECL_PARM_VAR abbrev are true, use it.  Here
   // we dynamically check for the properties that we optimize for, but don't
   // know are true of all PARM_VAR_DECLs.


Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1089,8 +1089,6 @@
 Record.AddStmt(D->getUninstantiatedDefaultArg());
   Code = serialization::DECL_PARM_VAR;
 
-  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
-
   // If the assumptions about the DECL_PARM_VAR abbrev are true, use it.  Here
   // we dynamically check for the properties that we optimize for, but don't
   // know are true of all PARM_VAR_DECLs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-11 Thread Alexey Bader via Phabricator via cfe-commits
bader marked 2 inline comments as done.
bader added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2548
+  Opts.SYCL = Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false);
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL || Opts.SYCLIsDevice) {

ABataev wrote:
> bader wrote:
> > ABataev wrote:
> > > bader wrote:
> > > > ABataev wrote:
> > > > > bader wrote:
> > > > > > ABataev wrote:
> > > > > > > This option also must be controlled by `-fsycl`:
> > > > > > > ```
> > > > > > > Opts.SYCLIsDevice =  Opts.SYCL && 
> > > > > > > Args.hasArg(options::OPT_fsycl_is_device);
> > > > > > > 
> > > > > > > ```
> > > > > > Does it really has to? This logic is already present in the driver 
> > > > > > and it makes front-end tests verbose `%clang_cc1 -fsycl 
> > > > > > -fsycl-is-device`.
> > > > > > Can `-fsycl-is-device` imply `-fsycl`?
> > > > > > Looking how CUDA/OpenMP options are handled, not all of them are 
> > > > > > processed using this pattern.
> > > > > In general, this is how we handle it in OpenMP. Cuda works 
> > > > > differently, because it has its own kind of files (.cu) and Cuda is 
> > > > > triggered by the language switch (-x cu). Seems to me, you're using 
> > > > > something close to OpenMP model, no? Or do you want to define your 
> > > > > own language kind just like Cuda?
> > > > I applied you suggest, although I don't fully understand the need of 
> > > > using two options instead of two. I would prefer having following code:
> > > > ```
> > > > Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
> > > > Opts.SYCL = Args.hasArg(options::OPT_fsycl) || Opts.SYCLIsDevice; // 
> > > > -fsycl-is-device enable SYCL mode as well
> > > > ```
> > > I'm not quite familiar with SYCL model, maybe this the right approach. 
> > > You'd better try to provide more details. Are there any differences 
> > > between just SYCL and SYCL-device compilation modes? How do you see the 
> > > compilation sequence in general? At first you're going to compile the 
> > > host version of the code, then the device? OR something different?
> > I think SYCL model is quite similar to OpenMP model. One significant 
> > difference might be that to implement standard SYCL functionality we don't 
> > need any modifications for the host compiler. AFAIK, OpenMP compiler has to 
> > support OpenMP pragmas. 
> > We have a few attributes for Intel FPGA devices, which we can't pre-process 
> > with `__SYCL_DEVICE_ONLY__` macro and we have added "SYCL-host" mode to 
> > suppress compiler warnings about attributes ignored on the host. I think 
> > there might be other options how this can be achieved w/o adding new 
> > compilation mode and use regular C++ front-end as SYCL host compiler.
> > I think there is a difference between SYCL and SYCL-device modes, but it's 
> > mostly changes the compilation workflow in the driver, but not in the 
> > front-end. In SYCL-device mode, driver invokes only one front-end instance 
> > to generate offload code. In SYCL mode, driver invokes multiple front-end 
> > instances: one in SYCL-device mode and one in regular C++ mode (to be 
> > accurate we use SYCL-host mode, but as I mentioned above I don't think it 
> > really needed).
> > I hope it makes it clear now. Let me know if you have any other questions.
> > 
> > Do I understand it correctly that OpenMP option enables OpenMP mode, which 
> > is equivalent of "SYCL-host" mode and enabling both OpenMP and 
> > OpenMPIsDevice is required for enabling OpenMP mode, which is similar to 
> > SYCL-device mode?
> > If so, can we assume that OpenMPIsDevice implies that OpenMP option is also 
> > set (implicitly)?
> > Do I understand it correctly that OpenMP option enables OpenMP mode, which 
> > is equivalent of "SYCL-host" mode and enabling both OpenMP and 
> > OpenMPIsDevice is required for enabling OpenMP mode, which is similar to 
> > SYCL-device mode?
> 
> Well, for driver you need to pass `-fopenmp 
> -fopenmp-target=` to enable the compilation with offloading 
> support. In the frontend the host part is compiled with `-fopenmp` only (+ 
> aux-triple, probably), for devices - `-fopenmp -fopenmp-is-device`. Without 
> `-fopenmp` `-fopenmp-is-device` is just ignored.
What is the reason to require the driver to pass both options for the devices? 
It sounds like `-fopenmp-is-device` should be enough to differentiate from the 
host part (`-fopenmp` only). Right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D74385: [ARCMT][NFC] Reduce #include dependencies

2020-02-11 Thread Nicolás Alvarez via Phabricator via cfe-commits
nicolas17 added a comment.

I don't have commit access, can someone push this for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74385



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


[PATCH] D73842: [xray][clang] Always add xray-skip-entry/exit and xray-ignore-loops attrs

2020-02-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Is it worth adding a test that a function with an explicit xray-instrument 
attribute also has these other attributes applied?




Comment at: clang/test/CodeGen/xray-attributes-skip-entry-exit.cpp:8
+// RUN: -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,NOCUSTOM,NOTYPED,SKIPENTRY %s
+// RUN: %clang_cc1 -fxray-instrument \

I don't see the NOCUSTOM or NOTYPED prefixes defined?



Comment at: clang/test/CodeGen/xray-attributes-skip-entry-exit.cpp:12
+// RUN: -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,FUNCTION,NOCUSTOM,NOTYPED %s
+

Same with the FUNCTION prefix.



Comment at: clang/test/CodeGen/xray-ignore-loops.cpp:2
 // RUN: %clang_cc1 -fxray-instrument -fxray-ignore-loops -x c++ -std=c++11 
-emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang -fxray-instrument -fxray-ignore-loops -x c++ -std=c++11 -S 
-emit-llvm -o - %s -target x86_64-unknown-linux-gnu | FileCheck %s
 

From what I've seen, CodeGen tests don't usually invoke the driver directly. 
They have a test that the driver passes the correct flags to cc1 (as you do 
below), and then they just test that cc1 does the right thing with that flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73842



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


[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-02-11 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 243888.
mibintc added a comment.
Herald added subscribers: kbarton, jvesely, nemanjai.

This patch is a work in progress.

The problem that I want to work on next is that the scope is wrong when the 
pragma token is seen following the right brace of a function body. In this 
patch I worked around that problem by modifying the test case to insert bogus 
"class ResetScope;" to force the scope back to file-level before each pragma 
that occurs at file scope. You can see that workaround in the test case 
clang/test/CodeGen/fp-floatcontrol-stack.cpp

These are the main differences with previous version of this patch:

1. per Andy Kaylor's comments in the llvm-dev discussion "Floating Point 
semantic modes", I changed the -ffp-model=precise to be the default. I changed 
ffp-model=precise to set -ffp-contract=on [previously it was 
-ffp-contract=fast].  This caused the need to change some tests because the 
LLVM IR now has the "contract" bit enabled.
2. I put FMF into the FPOptions struct.  As I mentioned in a previous comment, 
I have a request to allow changing the REASSOC bit via source pragma. I plan to 
submit that in a separate patch.  Putting FMF into FPOptions allows the fast 
bits to be set or disabled via pragma float_control precise, Andy had suggested 
this change in his code review.
3. I put Andy's distillation of floating point options and floating point modes 
into UsersManual.rst
4. I changed how the strictfp attribute was set on functions, now it's set if 
the strict mode is enabled in the function body e.g. either by the option level 
or a float_control pragma

Still needs to be done:

1. The problem with the file scope I mentioned above
2. I assume that the 2 denormal settings need to be added to FPOptions.
3. Required diagnostics a la MSVC that Andy mentioned in llvm-dev discussion 
"Floating Point semantic modes"
4. What else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/UsersManual.rst
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/PragmaKinds.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/constrained-math-builtins.c
  clang/test/CodeGen/fast-math.c
  clang/test/CodeGen/fp-contract-on-pragma.cpp
  clang/test/CodeGen/fp-contract-pragma.cpp
  clang/test/CodeGen/fp-floatcontrol-class.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/CodeGen/fp-floatcontrol-stack.cpp
  clang/test/CodeGen/fpconstrained.c
  clang/test/CodeGen/fpconstrained.cpp
  clang/test/CodeGen/ppc-emmintrin.c
  clang/test/CodeGen/ppc-xmmintrin.c
  clang/test/CodeGenOpenCL/builtins-amdgcn-dl-insts.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-interp.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  clang/test/CodeGenOpenCL/builtins-f16.cl
  clang/test/CodeGenOpenCL/builtins-r600.cl
  clang/test/CodeGenOpenCL/relaxed-fpmath.cl
  clang/test/CodeGenOpenCL/single-precision-constant.cl
  clang/test/Driver/fp-model.c
  clang/test/Parser/fp-floatcontrol-syntax.cpp
  llvm/include/llvm/IR/IRBuilder.h

Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -215,6 +215,8 @@
   /// Get the flags to be applied to created floating point ops
   FastMathFlags getFastMathFlags() const { return FMF; }
 
+  FastMathFlags& getFastMathFlags() { return FMF; }
+
   /// Clear the fast-math flags.
   void clearFastMathFlags() { FMF.clear(); }
 
@@ -299,10 +301,16 @@
 IRBuilderBase &Builder;
 FastMathFlags FMF;
 MDNode *FPMathTag;
+bool IsFPConstrained;
+fp::ExceptionBehavior DefaultConstrainedExcept;
+fp::RoundingMode DefaultConstrainedRounding;
 
   public:
 FastMathFlagGuard(IRBuilderBase &B)
-: Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag) {}
+: Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag),
+  IsFPConstrained(B.IsFPConstrained),
+  DefaultConstrainedExcept(B.DefaultConstrainedExcept),
+  DefaultConstrainedRounding(B

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

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



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2548
+  Opts.SYCL = Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false);
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL || Opts.SYCLIsDevice) {

bader wrote:
> ABataev wrote:
> > bader wrote:
> > > ABataev wrote:
> > > > bader wrote:
> > > > > ABataev wrote:
> > > > > > bader wrote:
> > > > > > > ABataev wrote:
> > > > > > > > This option also must be controlled by `-fsycl`:
> > > > > > > > ```
> > > > > > > > Opts.SYCLIsDevice =  Opts.SYCL && 
> > > > > > > > Args.hasArg(options::OPT_fsycl_is_device);
> > > > > > > > 
> > > > > > > > ```
> > > > > > > Does it really has to? This logic is already present in the 
> > > > > > > driver and it makes front-end tests verbose `%clang_cc1 -fsycl 
> > > > > > > -fsycl-is-device`.
> > > > > > > Can `-fsycl-is-device` imply `-fsycl`?
> > > > > > > Looking how CUDA/OpenMP options are handled, not all of them are 
> > > > > > > processed using this pattern.
> > > > > > In general, this is how we handle it in OpenMP. Cuda works 
> > > > > > differently, because it has its own kind of files (.cu) and Cuda is 
> > > > > > triggered by the language switch (-x cu). Seems to me, you're using 
> > > > > > something close to OpenMP model, no? Or do you want to define your 
> > > > > > own language kind just like Cuda?
> > > > > I applied you suggest, although I don't fully understand the need of 
> > > > > using two options instead of two. I would prefer having following 
> > > > > code:
> > > > > ```
> > > > > Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
> > > > > Opts.SYCL = Args.hasArg(options::OPT_fsycl) || Opts.SYCLIsDevice; // 
> > > > > -fsycl-is-device enable SYCL mode as well
> > > > > ```
> > > > I'm not quite familiar with SYCL model, maybe this the right approach. 
> > > > You'd better try to provide more details. Are there any differences 
> > > > between just SYCL and SYCL-device compilation modes? How do you see the 
> > > > compilation sequence in general? At first you're going to compile the 
> > > > host version of the code, then the device? OR something different?
> > > I think SYCL model is quite similar to OpenMP model. One significant 
> > > difference might be that to implement standard SYCL functionality we 
> > > don't need any modifications for the host compiler. AFAIK, OpenMP 
> > > compiler has to support OpenMP pragmas. 
> > > We have a few attributes for Intel FPGA devices, which we can't 
> > > pre-process with `__SYCL_DEVICE_ONLY__` macro and we have added 
> > > "SYCL-host" mode to suppress compiler warnings about attributes ignored 
> > > on the host. I think there might be other options how this can be 
> > > achieved w/o adding new compilation mode and use regular C++ front-end as 
> > > SYCL host compiler.
> > > I think there is a difference between SYCL and SYCL-device modes, but 
> > > it's mostly changes the compilation workflow in the driver, but not in 
> > > the front-end. In SYCL-device mode, driver invokes only one front-end 
> > > instance to generate offload code. In SYCL mode, driver invokes multiple 
> > > front-end instances: one in SYCL-device mode and one in regular C++ mode 
> > > (to be accurate we use SYCL-host mode, but as I mentioned above I don't 
> > > think it really needed).
> > > I hope it makes it clear now. Let me know if you have any other questions.
> > > 
> > > Do I understand it correctly that OpenMP option enables OpenMP mode, 
> > > which is equivalent of "SYCL-host" mode and enabling both OpenMP and 
> > > OpenMPIsDevice is required for enabling OpenMP mode, which is similar to 
> > > SYCL-device mode?
> > > If so, can we assume that OpenMPIsDevice implies that OpenMP option is 
> > > also set (implicitly)?
> > > Do I understand it correctly that OpenMP option enables OpenMP mode, 
> > > which is equivalent of "SYCL-host" mode and enabling both OpenMP and 
> > > OpenMPIsDevice is required for enabling OpenMP mode, which is similar to 
> > > SYCL-device mode?
> > 
> > Well, for driver you need to pass `-fopenmp 
> > -fopenmp-target=` to enable the compilation with 
> > offloading support. In the frontend the host part is compiled with 
> > `-fopenmp` only (+ aux-triple, probably), for devices - `-fopenmp 
> > -fopenmp-is-device`. Without `-fopenmp` `-fopenmp-is-device` is just 
> > ignored.
> What is the reason to require the driver to pass both options for the 
> devices? It sounds like `-fopenmp-is-device` should be enough to 
> differentiate from the host part (`-fopenmp` only). Right?
We treat a little bit differently. `-fopenmp` turns support for OpenMP, while 
`-fopenmp-is-device` turns processing for device compilation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



___
cfe-commits m

[PATCH] D74412: Fix SFINAE in CFG.cpp.

2020-02-11 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74412



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


  1   2   3   >