[PATCH] D103184: [AArch64] handle -Wa,-march=

2021-06-07 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103184

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


[PATCH] D101696: [Matrix] Implement C-style explicit type conversions in CXX for matrix types

2021-06-07 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

In D101696#2800790 , @SaurabhJha 
wrote:

> In D101696#2798713 , @SjoerdMeijer 
> wrote:
>
>> Perhaps for bonus points, update the Clang documentation in 
>> https://clang.llvm.org/docs/LanguageExtensions.html#matrix-types with some 
>> examples?
>
> Can you please point me to how to submit patches to the documentation? I 
> could only find links like https://clang.llvm.org/hacking.html which talk 
> about code patches. Many thanks.

It works exactly the same as other patches. I think the file you're interested 
in is `llvm-project/clang/docs/LanguageExtensions.rst`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101696

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


[PATCH] D103472: [clang] Fix a crash during code completion

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

we discussed offline but i forgot to stamp this one. it would be nice to have a 
test case, but fix is relatively safe and getting a repro turned out to be hard 
(since it depends on a densemap growing).

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103472

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


[PATCH] D103792: [clang][AST] Set correct DeclContext in ASTImporter lookup table for template params.

2021-06-07 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: whisperity, martong, teemperor, gamesh411, Szelethus, 
dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Template parameters are created in ASTImporter with the translation unit as 
DeclContext.
The DeclContext is later updated (by the create function of template classes).
ASTImporterLookupTable was not updated after these changes of the DC. The patch
adds update of the DeclContext in ASTImporterLookupTable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103792

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4368,6 +4368,178 @@
   EXPECT_EQ(ToD->getNumTemplateParameterLists(), 1u);
 }
 
+const internal::VariadicDynCastAllOfMatcher
+varTemplateDecl;
+
+const internal::VariadicDynCastAllOfMatcher<
+Decl, VarTemplatePartialSpecializationDecl>
+varTemplatePartialSpecializationDecl;
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   FunctionTemplateParameterDeclContext) {
+  constexpr auto Code =
+  R"(
+  template
+  void f() {};
+  )";
+
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl(hasName("f")));
+
+  ASSERT_EQ(FromD->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromD->getTemplatedDecl());
+
+  auto *ToD = Import(FromD, Lang_CXX11);
+  EXPECT_EQ(ToD->getTemplateParameters()->getParam(0)->getDeclContext(),
+ToD->getTemplatedDecl());
+  EXPECT_TRUE(SharedStatePtr->getLookupTable()->contains(
+  ToD->getTemplatedDecl(), ToD->getTemplateParameters()->getParam(0)));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ClassTemplateParameterDeclContext) {
+  constexpr auto Code =
+  R"(
+  template
+  struct S {};
+  template
+  struct S {};
+  )";
+
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, classTemplateDecl(hasName("S")));
+  auto *FromDPart =
+  FirstDeclMatcher().match(
+  FromTU, classTemplatePartialSpecializationDecl(hasName("S")));
+
+  ASSERT_EQ(FromD->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromD->getTemplatedDecl());
+  ASSERT_EQ(FromDPart->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromDPart);
+
+  auto *ToD = Import(FromD, Lang_CXX11);
+  auto *ToDPart = Import(FromDPart, Lang_CXX11);
+
+  EXPECT_EQ(ToD->getTemplateParameters()->getParam(0)->getDeclContext(),
+ToD->getTemplatedDecl());
+  EXPECT_TRUE(SharedStatePtr->getLookupTable()->contains(
+  ToD->getTemplatedDecl(), ToD->getTemplateParameters()->getParam(0)));
+
+  EXPECT_EQ(ToDPart->getTemplateParameters()->getParam(0)->getDeclContext(),
+ToDPart);
+  EXPECT_TRUE(SharedStatePtr->getLookupTable()->contains(
+  ToDPart, ToDPart->getTemplateParameters()->getParam(0)));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, VarTemplateParameterDeclContext) {
+  constexpr auto Code =
+  R"(
+  template
+  int X1;
+  template
+  int X1;
+
+  namespace Ns {
+template
+int X2;
+template
+int X2;
+  }
+  )";
+
+  Decl *FromTU = getTuDecl(Code, Lang_CXX14);
+
+  auto *FromD1 = FirstDeclMatcher().match(
+  FromTU, varTemplateDecl(hasName("X1")));
+  auto *FromD1Part =
+  FirstDeclMatcher().match(
+  FromTU, varTemplatePartialSpecializationDecl(hasName("X1")));
+  auto *FromD2 = FirstDeclMatcher().match(
+  FromTU, varTemplateDecl(hasName("X2")));
+  auto *FromD2Part =
+  FirstDeclMatcher().match(
+  FromTU, varTemplatePartialSpecializationDecl(hasName("X2")));
+
+  ASSERT_EQ(FromD1->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromD1->getDeclContext());
+  ASSERT_EQ(FromD2->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromD2->getDeclContext());
+
+  ASSERT_EQ(FromD1Part->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromD1Part->getDeclContext());
+  // FIXME: VarTemplatePartialSpecializationDecl does not update ("adopt")
+  // template parameter decl context
+  // ASSERT_EQ(FromD2Part->getTemplateParameters()->getParam(0)->getDeclContext(),
+  // FromD2Part->getDeclContext());
+
+  auto *ToD1 = Import(FromD1, Lang_CXX14);
+  auto *ToD2 = Import(FromD2, Lang_CXX14);
+
+  auto *ToD1Part = Import(FromD1Part, Lang_CXX14);
+  auto *ToD2Part = Import(FromD2Part, Lang_CXX14);
+
+  EXPECT_EQ(ToD1->getTemplateParameters()->getParam(0)->getDeclContext(),
+ToD1->getDeclContext());
+  EXPECT_TRUE(SharedStatePtr->getL

[PATCH] D103793: [Clang][OpenMP] Monotonic does not apply to SIMD

2021-06-07 Thread Graham Hunter via Phabricator via cfe-commits
huntergr created this revision.
huntergr added reviewers: ABataev, kkwli0.
Herald added subscribers: guansong, yaxunl.
huntergr requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

The codegen for simd constructs was affected by the presence (or
absence) of the 'monotonic' schedule modifier for worksharing
loops. The modifier is only intended to apply to the scheduling of
chunks for a thread, not iterations of a loop inside a chunk.

In addition, the monotonic modifier was applied to worksharing loops
by default if no schedule clause was present; the referenced part of
the OpenMP 4.5 spec in the code (section 2.7.1) only applies if the
user specified a schedule clause with a static kind but no modifier.
Without a user-specified schedule clause we should default to
nonmonotonic scheduling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103793

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/schedule_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_dist_schedule_codegen.cpp

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


[PATCH] D103793: [Clang][OpenMP] Monotonic does not apply to SIMD

2021-06-07 Thread Graham Hunter via Phabricator via cfe-commits
huntergr added a comment.

Apologies for not including more of the diff for context, but the test files 
are large enough that the full diff exceeds the maximum upload size.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103793

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


[PATCH] D103386: [PowerPC] Fix x86 vector intrinsics wrapper compilation under C++

2021-06-07 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added inline comments.



Comment at: clang/test/CodeGen/ppc-xmmintrin.c:10
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-linux-gnu 
-mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns

bjope wrote:
> qiucf wrote:
> > bjope wrote:
> > > Unfortunately I get some failures with this. Maybe because of an 
> > > unstandard build setup.
> > > 
> > > We've started to use `-DCLANG_DEFAULT_RTLIB=compiler-rt 
> > > -DCLANG_DEFAULT_CXX_STDLIB=libc++` when building clang. And we also use 
> > > `-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON`. Not sure if that is a setup 
> > > that is asking for trouble. Anyway, when running this test case we end up 
> > > with
> > > 
> > > ```
> > > : 'RUN: at line 10';   /workspace/llvm/build/bin/clang -x c++ 
> > > -fsyntax-only -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 
> > > -ffreestanding -DNO_WARN_X86_INTRINSICS 
> > > /workspace/clang/test/CodeGen/ppc-xmmintrin.c-fno-discard-value-names 
> > > -mllvm -disable-llvm-optzns
> > > --
> > > Exit Code: 1
> > > 
> > > Command Output (stderr):
> > > --
> > > In file included from /workspace/clang/test/CodeGen/ppc-xmmintrin.c:13:
> > > In file included from 
> > > /workspace/llvm/build/lib/clang/13.0.0/include/ppc_wrappers/xmmintrin.h:42:
> > > In file included from 
> > > /workspace/llvm/build/lib/clang/13.0.0/include/altivec.h:44:
> > > In file included from 
> > > /workspace/llvm/build/bin/../include/c++/v1/stddef.h:39:
> > > /workspace/llvm/build/bin/../include/c++/v1/__config:13:10: fatal error: 
> > > '__config_site' file not found
> > > #include <__config_site>
> > >  ^~~
> > > 1 error generated.
> > > ```
> > > 
> > > Not sure really how to solve that.
> > > 
> > > Maybe we should stop building like that?
> > > 
> > > Or there is a bug somewhere (such as that we only get the __config_site 
> > > headers in target specific dirs for targets that we actually build 
> > > runtimes for, maybe something that was missing in 
> > > https://reviews.llvm.org/D97572)?
> > > (Maybe @phosek  could comment on that?)
> > > 
> > > Or this test case is missing some options to make it a bit more 
> > > independent on the runtimes build setup?
> > > 
> > The tests relies on some system stuff. Is the failure related to this 
> > change? (or exposed by `-x c++` option?)
> Well, i guess it was exposed by `-x c++` (in combination with D975729).
> 
> I don't really understand how things are supposed to work given the 
> pre-target specific `__config_site`.
> 
> Since I only build libcxx for `x86_64-unknown-linux-gnu`, I only get a 
> `__config_site` file for that specific triple inside 
> `bin/../include/x86_64-unknown-linux-gnu/c++/v1/__config_site` in the build 
> result. But a test case like this one, using a different triple, ends up 
> including `bin/../include/c++/v1/stddef.h`, that wants wants to include 
> `<__config_site>`, but it won't find any such include for the 
> powerpc64le-unknown-linux-gnu triple.
Hi, I tried a build with `libcxx` enabled on ppc64le, by default it still looks 
for `stddef.h` inside `lib/clang/13.0.0/include`. If I specify `-isystem 
include/c++/v1`, the error won't happen because `__config_site` is there.

I didn't try `-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON` since that makes build 
complaining `bin/clang-tblgen: error while loading shared libraries: 
libc++.so.1: cannot open shared object file`.

The revision is going to LLVM 12.0.1. And this failure doesn't look like a 
blocker, since (if I understand correctly) even without this patch, a simple 
test also triggers that in the condition you provided.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103386

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


[clang] 438cf55 - [OpenCL] Fix missing addrspace on implicit move assignment operator

2021-06-07 Thread Ole Strohm via cfe-commits

Author: Ole Strohm
Date: 2021-06-07T09:37:53+01:00
New Revision: 438cf5577e720f84d493a272c5a1cbaf6ce19e51

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

LOG: [OpenCL] Fix missing addrspace on implicit move assignment operator

This fixes the missing address space on `this` in the implicit move
assignment operator.
The function called here is an abstraction around the lines that have
been removed which also sets the address space correctly.
This is copied from CopyConstructor, CopyAssignment and MoveConstructor,
all of which use this function, and now MoveAssignment does too.

Fixes: PR50259

Reviewed By: svenvh

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

Added: 
clang/test/AST/ast-dump-implicit-members.clcpp

Modified: 
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index f6c907b2f98a1..3fffcd33ac50f 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -14344,10 +14344,7 @@ CXXMethodDecl 
*Sema::DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl) {
 /* Diagnose */ false);
   }
 
-  // Build an exception specification pointing back at this member.
-  FunctionProtoType::ExtProtoInfo EPI =
-  getImplicitMethodEPI(*this, MoveAssignment);
-  MoveAssignment->setType(Context.getFunctionType(RetType, ArgType, EPI));
+  setupImplicitSpecialMemberType(MoveAssignment, RetType, ArgType);
 
   // Add the parameter to the operator.
   ParmVarDecl *FromParam = ParmVarDecl::Create(Context, MoveAssignment,

diff  --git a/clang/test/AST/ast-dump-implicit-members.clcpp 
b/clang/test/AST/ast-dump-implicit-members.clcpp
new file mode 100644
index 0..5e1eb7c48c2a9
--- /dev/null
+++ b/clang/test/AST/ast-dump-implicit-members.clcpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -ast-dump -ast-dump-filter S | FileCheck 
-strict-whitespace %s
+
+struct S {};
+
+void f() {
+S i;
+i = i;
+}
+
+// CHECK: CXXConstructorDecl {{.*}} implicit used constexpr S 'void () 
__generic noexcept'
+// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (const 
__generic S &) __generic'
+// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (__generic S 
&&) __generic'
+// CHECK: CXXMethodDecl {{.*}} implicit used constexpr operator= '__generic S 
&(const __generic S &) __generic noexcept'
+// CHECK: CXXMethodDecl {{.*}} implicit constexpr operator= '__generic S 
&(__generic S &&) __generic'



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


[PATCH] D103252: [C++4OpenCL] Fix missing address space on implicit move assignment operator

2021-06-07 Thread Ole Strohm via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG438cf5577e72: [OpenCL] Fix missing addrspace on implicit 
move assignment operator (authored by olestrohm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103252

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/AST/ast-dump-implicit-members.clcpp


Index: clang/test/AST/ast-dump-implicit-members.clcpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-implicit-members.clcpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -ast-dump -ast-dump-filter S | FileCheck 
-strict-whitespace %s
+
+struct S {};
+
+void f() {
+S i;
+i = i;
+}
+
+// CHECK: CXXConstructorDecl {{.*}} implicit used constexpr S 'void () 
__generic noexcept'
+// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (const 
__generic S &) __generic'
+// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (__generic S 
&&) __generic'
+// CHECK: CXXMethodDecl {{.*}} implicit used constexpr operator= '__generic S 
&(const __generic S &) __generic noexcept'
+// CHECK: CXXMethodDecl {{.*}} implicit constexpr operator= '__generic S 
&(__generic S &&) __generic'
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -14344,10 +14344,7 @@
 /* Diagnose */ false);
   }
 
-  // Build an exception specification pointing back at this member.
-  FunctionProtoType::ExtProtoInfo EPI =
-  getImplicitMethodEPI(*this, MoveAssignment);
-  MoveAssignment->setType(Context.getFunctionType(RetType, ArgType, EPI));
+  setupImplicitSpecialMemberType(MoveAssignment, RetType, ArgType);
 
   // Add the parameter to the operator.
   ParmVarDecl *FromParam = ParmVarDecl::Create(Context, MoveAssignment,


Index: clang/test/AST/ast-dump-implicit-members.clcpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-implicit-members.clcpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -ast-dump -ast-dump-filter S | FileCheck -strict-whitespace %s
+
+struct S {};
+
+void f() {
+S i;
+i = i;
+}
+
+// CHECK: CXXConstructorDecl {{.*}} implicit used constexpr S 'void () __generic noexcept'
+// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (const __generic S &) __generic'
+// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (__generic S &&) __generic'
+// CHECK: CXXMethodDecl {{.*}} implicit used constexpr operator= '__generic S &(const __generic S &) __generic noexcept'
+// CHECK: CXXMethodDecl {{.*}} implicit constexpr operator= '__generic S &(__generic S &&) __generic'
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -14344,10 +14344,7 @@
 /* Diagnose */ false);
   }
 
-  // Build an exception specification pointing back at this member.
-  FunctionProtoType::ExtProtoInfo EPI =
-  getImplicitMethodEPI(*this, MoveAssignment);
-  MoveAssignment->setType(Context.getFunctionType(RetType, ArgType, EPI));
+  setupImplicitSpecialMemberType(MoveAssignment, RetType, ArgType);
 
   // Add the parameter to the operator.
   ParmVarDecl *FromParam = ParmVarDecl::Create(Context, MoveAssignment,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103722: [clang] NFC: test for undefined behaviour in RawComment::getFormattedText()

2021-06-07 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 350205.
DmitryPolukhin added a comment.

Fix clang-tidy warning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103722

Files:
  clang/unittests/AST/CommentTextTest.cpp


Index: clang/unittests/AST/CommentTextTest.cpp
===
--- clang/unittests/AST/CommentTextTest.cpp
+++ clang/unittests/AST/CommentTextTest.cpp
@@ -124,4 +124,11 @@
   // clang-format on
 }
 
+TEST_F(CommentTextTest, EmptyFormattedText) {
+  // Test that empty formatted text doesn't cause crash.
+  const char *ExpectedOutput = "";
+  auto Formatted = formatComment("//!<");
+  EXPECT_EQ(ExpectedOutput, Formatted);
+}
+
 } // namespace clang


Index: clang/unittests/AST/CommentTextTest.cpp
===
--- clang/unittests/AST/CommentTextTest.cpp
+++ clang/unittests/AST/CommentTextTest.cpp
@@ -124,4 +124,11 @@
   // clang-format on
 }
 
+TEST_F(CommentTextTest, EmptyFormattedText) {
+  // Test that empty formatted text doesn't cause crash.
+  const char *ExpectedOutput = "";
+  auto Formatted = formatComment("//!<");
+  EXPECT_EQ(ExpectedOutput, Formatted);
+}
+
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103685: [clangd] Drop TestTUs dependency on gtest

2021-06-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 350206.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Use log + abort instead of llvm_unreachable to not rely on UB.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103685

Files:
  clang-tools-extra/clangd/index/Symbol.cpp
  clang-tools-extra/clangd/index/Symbol.h
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -17,7 +17,9 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/Utils.h"
 #include "llvm/ADT/ScopeExit.h"
-#include "gtest/gtest.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -69,14 +71,19 @@
 
 void initializeModuleCache(CompilerInvocation &CI) {
   llvm::SmallString<128> ModuleCachePath;
-  ASSERT_FALSE(
-  llvm::sys::fs::createUniqueDirectory("module-cache", ModuleCachePath));
+  if (llvm::sys::fs::createUniqueDirectory("module-cache", ModuleCachePath)) {
+llvm::errs() << "Failed to create temp directory for module-cache";
+std::abort();
+  }
   CI.getHeaderSearchOpts().ModuleCachePath = ModuleCachePath.c_str();
 }
 
 void deleteModuleCache(const std::string ModuleCachePath) {
   if (!ModuleCachePath.empty()) {
-ASSERT_FALSE(llvm::sys::fs::remove_directories(ModuleCachePath));
+if (llvm::sys::fs::remove_directories(ModuleCachePath)) {
+  llvm::errs() << "Failed to delete temp directory for module-cache";
+  std::abort();
+}
   }
 }
 
@@ -112,13 +119,13 @@
   auto AST = ParsedAST::build(testPath(Filename), Inputs, std::move(CI),
   Diags.take(), Preamble);
   if (!AST.hasValue()) {
-ADD_FAILURE() << "Failed to build code:\n" << Code;
-llvm_unreachable("Failed to build TestTU!");
+llvm::errs() << "Failed to build code:\n" << Code;
+std::abort();
   }
   if (!AST->getDiagnostics()) {
-ADD_FAILURE() << "TestTU should always build an AST with a fresh Preamble"
-  << Code;
-return std::move(*AST);
+llvm::errs() << "TestTU should always build an AST with a fresh Preamble"
+ << Code;
+std::abort();
   }
   // Check for error diagnostics and report gtest failures (unless expected).
   // This guards against accidental syntax errors silently subverting tests.
@@ -138,11 +145,11 @@
 // We always build AST with a fresh preamble in TestTU.
 for (const auto &D : *AST->getDiagnostics())
   if (D.Severity >= DiagnosticsEngine::Error) {
-ADD_FAILURE()
+llvm::errs()
 << "TestTU failed to build (suppress with /*error-ok*/): \n"
 << D << "\n\nFor code:\n"
 << Code;
-break; // Just report first error for simplicity.
+std::abort(); // Stop after first error for simplicity.
   }
   }
   return std::move(*AST);
@@ -176,16 +183,16 @@
 if (QName != (S.Scope + S.Name).str())
   continue;
 if (Result) {
-  ADD_FAILURE() << "Multiple symbols named " << QName << ":\n"
-<< *Result << "\n---\n"
-<< S;
+  llvm::errs() << "Multiple symbols named " << QName << ":\n"
+   << *Result << "\n---\n"
+   << S;
   assert(false && "QName is not unique");
 }
 Result = &S;
   }
   if (!Result) {
-ADD_FAILURE() << "No symbol named " << QName << " in "
-  << ::testing::PrintToString(Slab);
+llvm::errs() << "No symbol named " << QName << " in "
+ << llvm::to_string(Slab);
 assert(false && "No symbol with QName");
   }
   return *Result;
@@ -225,7 +232,7 @@
   Visitor.F = Filter;
   Visitor.TraverseDecl(AST.getASTContext().getTranslationUnitDecl());
   if (Visitor.Decls.size() != 1) {
-ADD_FAILURE() << Visitor.Decls.size() << " symbols matched.";
+llvm::errs() << Visitor.Decls.size() << " symbols matched.";
 assert(Visitor.Decls.size() == 1);
   }
   return *Visitor.Decls.front();
Index: clang-tools-extra/clangd/index/Symbol.h
===
--- clang-tools-extra/clangd/index/Symbol.h
+++ clang-tools-extra/clangd/index/Symbol.h
@@ -233,6 +233,8 @@
   std::vector Symbols;  // Sorted by SymbolID to allow lookup.
 };
 
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolSlab &Slab);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/index/Symbol.cpp
===
--- clang-tools-extra/clangd/index/Symbol.cpp
+++ clang-tools-extra/clangd/index/Symbol.cpp
@@ -67,5 +67,15 @@
   return SymbolSlab(std::move(NewArena), std::move(SortedSymbols));
 }
 
+llvm::raw

[PATCH] D103685: [clangd] Drop TestTUs dependency on gtest

2021-06-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/TestTU.cpp:75
+  if (llvm::sys::fs::createUniqueDirectory("module-cache", ModuleCachePath))
+llvm_unreachable("Failed to create temp directory for module-cache");
   CI.getHeaderSearchOpts().ModuleCachePath = ModuleCachePath.c_str();

sammccall wrote:
> I don't love using llvm_unreachable for error handling (esp environment 
> sensitive kind like this), it compiles down to UB in ndebug mode.
> 
> Log + abort would be preferable I think, though it's one extra line.
ah I thought it always compiled down to abort (and sometimes inserted a builtin 
to indicate noreturn). looks like i've missed the conditional macro definition.



Comment at: clang-tools-extra/clangd/unittests/TestTU.cpp:122
   if (!AST->getDiagnostics()) {
-ADD_FAILURE() << "TestTU should always build an AST with a fresh Preamble"
-  << Code;
+llvm::errs() << "TestTU should always build an AST with a fresh Preamble"
+ << Code;

sammccall wrote:
> this check is now a log message that could still let the test pass
> Make it an assert instead?
> 
> (I think assert without any early return is appropriate per normal llvm style)
aborting instead of just `assert(false)`, since the rest of the code assumes 
AST->getDiagnostics has a value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103685

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


[PATCH] D102760: [llvm] Let SmallVector construct from any Iterable

2021-06-07 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added a comment.

@Quuxplusone thx a lot for the comment. It is very relevant and I agree that 
this addition may be dangerous.
The intend was to prevent adding more constructors (and dependencies) to 
SmallVector in D102679 .
I can try to see what it takes to call `begin` and `end` explicitly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102760

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


[PATCH] D103501: [clang][AIX] Enable inlined quadword atomic operations

2021-06-07 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.cpp:336
 .Default(false);
+  Features["quadword-atomics"] = llvm::StringSwitch(CPU)
+ .Case("pwr10", true)

What about `ppc64`?

Also, seems there's no need to add `pwr10` here.



Comment at: clang/lib/Basic/Targets/PPC.h:442
+  void setMaxAtomicWidth() override {
+if (getTriple().isOSAIX() && getTriple().isArch64Bit() &&
+hasFeature("quadword-atomics"))

We don't need this at all for Linux?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103501

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


[PATCH] D103685: [clangd] Drop TestTUs dependency on gtest

2021-06-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/TestTU.cpp:122
   if (!AST->getDiagnostics()) {
-ADD_FAILURE() << "TestTU should always build an AST with a fresh Preamble"
-  << Code;
+llvm::errs() << "TestTU should always build an AST with a fresh Preamble"
+ << Code;

kadircet wrote:
> sammccall wrote:
> > this check is now a log message that could still let the test pass
> > Make it an assert instead?
> > 
> > (I think assert without any early return is appropriate per normal llvm 
> > style)
> aborting instead of just `assert(false)`, since the rest of the code assumes 
> AST->getDiagnostics has a value.
This is actually a can't-happen condition even if the test is messed up, and we 
normally assert on those before dereferencing a pointer. But up to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103685

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


[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux and the BSDs

2021-06-07 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added inline comments.



Comment at: clang/lib/Basic/Targets/Sparc.cpp:246-256
+  if (getTriple().getOS() == llvm::Triple::Linux) {
 Builder.defineMacro("__sparc_v9__");
-Builder.defineMacro("__sparcv9__");
+  } else {
+Builder.defineMacro("__sparcv9");
+// Solaris doesn't need these variants, but the BSDs do.
+if (getTriple().getOS() != llvm::Triple::Solaris) {
+  Builder.defineMacro("__sparc64__");

hvdijk wrote:
> brad wrote:
> > glaubitz wrote:
> > > glaubitz wrote:
> > > > ro wrote:
> > > > > glaubitz wrote:
> > > > > > jrtc27 wrote:
> > > > > > > This doesn't need changing, we can define more things than GCC to 
> > > > > > > keep it simple.
> > > > > > Well, my original intent was to match GCC to make sure we're 100% 
> > > > > > compatible and I would like to keep it that way.
> > > > > I agree with Jessica here: you're creating a complicated maze for no 
> > > > > real gain.  Besides, have you checked what `gcc` on the BSDs really 
> > > > > does?  They often neglect to get their changes upstream and what's in 
> > > > > the gcc repo doesn't necessarily represent what they actually use.
> > > > Yes, I have verified that GCC behaves the exact same way as this change 
> > > > and I don't see any reason not to mimic the exact same behavior in 
> > > > clang for maximum compatibility.
> > > FWIW, I meant GCC on the various BSDs. I do not think it's a wise idea to 
> > > have clang deviate from what GCC does as only this way we can guarantee 
> > > that everything that compiles with GCC will compile with clang.
> > > Besides, have you checked what `gcc` on the BSDs really does?  They often 
> > > neglect to get their changes upstream and what's in the gcc repo doesn't 
> > > necessarily represent what they actually use.
> > 
> > What is upstream is what we do. There are no local patches that change 
> > behavior in this particular area.
> (Copying here what I had already replied privately a while back) It worries 
> me that this switch statement only handles known operating systems (Linux, 
> FreeBSD, NetBSD, OpenBSD, Solaris) when we also have code to allow 
> SparcV9TargetInfo to be created without an operating system in 
> clang/lib/Basic/Targets.cpp. Either there should be a default case that is 
> properly handled, or if that actually cannot happen, there should be an 
> assert that it doesn't happen.
> 
> I agree with the earlier comments that there should be nothing wrong with 
> defining more macros than GCC, if the macros make sense. For the 
> SparcV9TargetInfo class, my impression is that the macros make sense. For the 
> SparcV8TargetInfo class with a V9 CPU, reading the discussion in D86621, if 
> Oracle say that `__sparcv9` is only for 64-bit mode, GCC also only defines it 
> for 64-bit mode, glibc assumes that `__sparcv9` implies 64-bit mode, etc. 
> then SparcV8TargetInfo should not be defining `__sparcv9`. Your changes to 
> SparcV8TargetInfo should be enough to fix bug 49562, right? If so, would it 
> be okay to update this diff with just that?
> Either there should be a default case that is properly handled, or if that 
> actually cannot happen, there should be an assert that it doesn't happen.

OK, I can enable all definitions by default.

> I agree with the earlier comments that there should be nothing wrong with 
> defining more macros than GCC, if the macros make sense.

My argument is that I don't want to break existing software. We are here 
because I ran into an FTBFS because GCC and Clang were deviating from what they 
are defining.

I fully agree that what GCC does it not necessarily logically correct. But if 
we mimic GCC are making sure that we don't break any existing software.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98574

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


[clang] b31f41e - [Clang] Support a user-defined __dso_handle

2021-06-07 Thread Andrew Savonichev via cfe-commits

Author: Andrew Savonichev
Date: 2021-06-07T12:54:08+03:00
New Revision: b31f41e78b2722785f3df1da0d77dfcd68125d15

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

LOG: [Clang] Support a user-defined __dso_handle

This fixes PR49198: Wrong usage of __dso_handle in user code leads to
a compiler crash.

When Init is an address of the global itself, we need to track it
across RAUW. Otherwise the initializer can be destroyed if the global
is replaced.

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

Added: 
clang/test/CodeGenCXX/dso-handle-custom.cpp

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 9b31ecdbd81a9..1f23ce7de52b7 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4284,7 +4284,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl 
*D,
   OpenMPRuntime->emitTargetGlobalVariable(D))
 return;
 
-  llvm::Constant *Init = nullptr;
+  llvm::TrackingVH Init;
   bool NeedsGlobalCtor = false;
   bool NeedsGlobalDtor =
   D->needsDestruction(getContext()) == QualType::DK_cxx_destructor;
@@ -4330,9 +4330,8 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl 
*D,
   } else {
 initializedGlobalDecl = GlobalDecl(D);
 emitter.emplace(*this);
-Init = emitter->tryEmitForInitializer(*InitDecl);
-
-if (!Init) {
+llvm::Constant *Initializer = emitter->tryEmitForInitializer(*InitDecl);
+if (!Initializer) {
   QualType T = InitExpr->getType();
   if (D->getType()->isReferenceType())
 T = D->getType();
@@ -4345,6 +4344,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl 
*D,
 Init = llvm::UndefValue::get(getTypes().ConvertType(T));
   }
 } else {
+  Init = Initializer;
   // We don't need an initializer, so remove the entry for the delayed
   // initializer position (just in case this entry was delayed) if we
   // also don't need to register a destructor.

diff  --git a/clang/test/CodeGenCXX/dso-handle-custom.cpp 
b/clang/test/CodeGenCXX/dso-handle-custom.cpp
new file mode 100644
index 0..a6bc34fe1c469
--- /dev/null
+++ b/clang/test/CodeGenCXX/dso-handle-custom.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fexceptions %s 
-o - | FileCheck %s --check-prefixes CHECK,CHECK-DEFAULT
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fexceptions %s 
-o - -DHIDDEN | FileCheck %s --check-prefixes CHECK,CHECK-HIDDEN
+
+class A {
+public:
+  ~A();
+} a;
+
+// CHECK-DEFAULT: @__dso_handle = global i8* bitcast (i8** @__dso_handle to 
i8*), align 8
+// CHECK-HIDDEN: @__dso_handle = hidden global i8* bitcast (i8** @__dso_handle 
to i8*), align 8
+// CHECK: define internal void @__cxx_global_var_init()
+// CHECK:   call i32 @__cxa_atexit({{.*}}, {{.*}}, i8* bitcast (i8** 
@__dso_handle to i8*))
+
+#ifdef HIDDEN
+void *__dso_handle __attribute__((__visibility__("hidden"))) = &__dso_handle;
+#else
+void *__dso_handle = &__dso_handle;
+#endif
+
+void use(void *);
+void use_dso_handle() {
+  use(__dso_handle);
+}



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


[PATCH] D101156: [Clang] Support a user-defined __dso_handle

2021-06-07 Thread Andrew Savonichev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb31f41e78b27: [Clang] Support a user-defined __dso_handle 
(authored by asavonic).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101156

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/dso-handle-custom.cpp


Index: clang/test/CodeGenCXX/dso-handle-custom.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dso-handle-custom.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fexceptions %s 
-o - | FileCheck %s --check-prefixes CHECK,CHECK-DEFAULT
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fexceptions %s 
-o - -DHIDDEN | FileCheck %s --check-prefixes CHECK,CHECK-HIDDEN
+
+class A {
+public:
+  ~A();
+} a;
+
+// CHECK-DEFAULT: @__dso_handle = global i8* bitcast (i8** @__dso_handle to 
i8*), align 8
+// CHECK-HIDDEN: @__dso_handle = hidden global i8* bitcast (i8** @__dso_handle 
to i8*), align 8
+// CHECK: define internal void @__cxx_global_var_init()
+// CHECK:   call i32 @__cxa_atexit({{.*}}, {{.*}}, i8* bitcast (i8** 
@__dso_handle to i8*))
+
+#ifdef HIDDEN
+void *__dso_handle __attribute__((__visibility__("hidden"))) = &__dso_handle;
+#else
+void *__dso_handle = &__dso_handle;
+#endif
+
+void use(void *);
+void use_dso_handle() {
+  use(__dso_handle);
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4284,7 +4284,7 @@
   OpenMPRuntime->emitTargetGlobalVariable(D))
 return;
 
-  llvm::Constant *Init = nullptr;
+  llvm::TrackingVH Init;
   bool NeedsGlobalCtor = false;
   bool NeedsGlobalDtor =
   D->needsDestruction(getContext()) == QualType::DK_cxx_destructor;
@@ -4330,9 +4330,8 @@
   } else {
 initializedGlobalDecl = GlobalDecl(D);
 emitter.emplace(*this);
-Init = emitter->tryEmitForInitializer(*InitDecl);
-
-if (!Init) {
+llvm::Constant *Initializer = emitter->tryEmitForInitializer(*InitDecl);
+if (!Initializer) {
   QualType T = InitExpr->getType();
   if (D->getType()->isReferenceType())
 T = D->getType();
@@ -4345,6 +4344,7 @@
 Init = llvm::UndefValue::get(getTypes().ConvertType(T));
   }
 } else {
+  Init = Initializer;
   // We don't need an initializer, so remove the entry for the delayed
   // initializer position (just in case this entry was delayed) if we
   // also don't need to register a destructor.


Index: clang/test/CodeGenCXX/dso-handle-custom.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dso-handle-custom.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fexceptions %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-DEFAULT
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fexceptions %s -o - -DHIDDEN | FileCheck %s --check-prefixes CHECK,CHECK-HIDDEN
+
+class A {
+public:
+  ~A();
+} a;
+
+// CHECK-DEFAULT: @__dso_handle = global i8* bitcast (i8** @__dso_handle to i8*), align 8
+// CHECK-HIDDEN: @__dso_handle = hidden global i8* bitcast (i8** @__dso_handle to i8*), align 8
+// CHECK: define internal void @__cxx_global_var_init()
+// CHECK:   call i32 @__cxa_atexit({{.*}}, {{.*}}, i8* bitcast (i8** @__dso_handle to i8*))
+
+#ifdef HIDDEN
+void *__dso_handle __attribute__((__visibility__("hidden"))) = &__dso_handle;
+#else
+void *__dso_handle = &__dso_handle;
+#endif
+
+void use(void *);
+void use_dso_handle() {
+  use(__dso_handle);
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4284,7 +4284,7 @@
   OpenMPRuntime->emitTargetGlobalVariable(D))
 return;
 
-  llvm::Constant *Init = nullptr;
+  llvm::TrackingVH Init;
   bool NeedsGlobalCtor = false;
   bool NeedsGlobalDtor =
   D->needsDestruction(getContext()) == QualType::DK_cxx_destructor;
@@ -4330,9 +4330,8 @@
   } else {
 initializedGlobalDecl = GlobalDecl(D);
 emitter.emplace(*this);
-Init = emitter->tryEmitForInitializer(*InitDecl);
-
-if (!Init) {
+llvm::Constant *Initializer = emitter->tryEmitForInitializer(*InitDecl);
+if (!Initializer) {
   QualType T = InitExpr->getType();
   if (D->getType()->isReferenceType())
 T = D->getType();
@@ -4345,6 +4344,7 @@
 Init = llvm::UndefValue::get(getTypes().ConvertType(T));
   }
 } else {
+  Init = Initializer;
   // We don't need an initializer, so remove the entry for the delayed
   // initializer position (just in case this entry was delayed) if we
   // also don't need to register a destructor.
__

[PATCH] D103796: [Clang][RISCV] Implement vlsseg.

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103796

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlsseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsseg.c

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


[clang] 30a89a7 - ASTConcept.h - remove unused include. NFCI.

2021-06-07 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-06-07T10:58:32+01:00
New Revision: 30a89a754af4a7bc8afd485021f9e68d5d70

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

LOG: ASTConcept.h - remove unused  include. NFCI.

Added: 


Modified: 
clang/include/clang/AST/ASTConcept.h

Removed: 




diff  --git a/clang/include/clang/AST/ASTConcept.h 
b/clang/include/clang/AST/ASTConcept.h
index 71bf14a87865..d0526f4fa5c5 100644
--- a/clang/include/clang/AST/ASTConcept.h
+++ b/clang/include/clang/AST/ASTConcept.h
@@ -14,12 +14,13 @@
 
 #ifndef LLVM_CLANG_AST_ASTCONCEPT_H
 #define LLVM_CLANG_AST_ASTCONCEPT_H
+
 #include "clang/AST/Expr.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SmallVector.h"
-#include 
 #include 
+
 namespace clang {
 class ConceptDecl;
 class ConceptSpecializationExpr;



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


[PATCH] D103797: [clang] Use resolved path for headers in decluse diagnostics

2021-06-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A header spelling in a source file could potentially mean multiple
sources, especially in projects with multiple include search paths. We
try to eliminate this ambiguity by using the resolved path in the
diagnostics. This should improve the life of both the developers and the
tooling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103797

Files:
  clang/lib/Lex/ModuleMap.cpp
  clang/test/Modules/declare-use1.cpp
  clang/test/Modules/declare-use2.cpp
  clang/test/Modules/declare-use3.cpp
  clang/test/Modules/header-attribs.cpp
  clang/test/Modules/strict-decluse-headers.cpp
  clang/test/Modules/strict-decluse.cpp
  clang/test/Modules/textual-headers.cpp

Index: clang/test/Modules/textual-headers.cpp
===
--- clang/test/Modules/textual-headers.cpp
+++ clang/test/Modules/textual-headers.cpp
@@ -6,13 +6,13 @@
 #include "k.h"
 
 #define GIMME_AN_L
-#include "l.h" // expected-error {{module XG does not depend on a module exporting 'l.h'}}
+#include "l.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}/l.h'}}
 
-#include "m2.h" // expected-error {{module XG does not depend on a module exporting 'm2.h'}}
+#include "m2.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}/m2.h'}}
 const int use_m = m; // expected-error {{undeclared identifier}}
 
 #define GIMME_AN_M
-#include "m.h" // expected-error {{use of private header from outside its module: 'm.h'}}
+#include "m.h" // expected-error-re {{use of private header from outside its module: '{{.*}}/m.h'}}
 const int use_m_2 = m;
 
 const int g = k + l;
Index: clang/test/Modules/strict-decluse.cpp
===
--- clang/test/Modules/strict-decluse.cpp
+++ clang/test/Modules/strict-decluse.cpp
@@ -3,7 +3,7 @@
 
 #include "g.h"
 #include "e.h"
-#include "f.h" // expected-error {{module XG does not depend on a module exporting 'f.h'}}
-#include "i.h" // expected-error {{module XG does not depend on a module exporting 'i.h'}}
+#include "f.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}/f.h'}}
+#include "i.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}/i.h'}}
 
 const int g2 = g1 + e + f + aux_i;
Index: clang/test/Modules/strict-decluse-headers.cpp
===
--- clang/test/Modules/strict-decluse-headers.cpp
+++ clang/test/Modules/strict-decluse-headers.cpp
@@ -14,4 +14,4 @@
 // Don't crash on this: (FIXME: we should produce an error that the specified file is not part of the specified module)
 // RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%t/map -I%t -fmodules-strict-decluse -fmodule-name=X -x c++ %t/foo.h
 //
-// CHECK: module X does not depend on a module exporting 'foo.h'
+// CHECK: module X does not depend on a module exporting '{{.*}}/foo.h'
Index: clang/test/Modules/header-attribs.cpp
===
--- clang/test/Modules/header-attribs.cpp
+++ clang/test/Modules/header-attribs.cpp
@@ -3,8 +3,8 @@
 // RUN: not %clang_cc1 -fmodules -I%S/Inputs/header-attribs -emit-module -x c++-module-map %S/Inputs/header-attribs/modular.modulemap -fmodules-cache-path=%t -fmodule-name=A 2>&1 | FileCheck %s --check-prefix BUILD-MODULAR
 
 #include "foo.h" // ok, stats match
-#include "bar.h" // expected-error {{does not depend on a module exporting 'bar.h'}}
-#include "baz.h" // expected-error {{does not depend on a module exporting 'baz.h'}}
+#include "bar.h" // expected-error-re {{does not depend on a module exporting '{{.*}}/bar.h'}}
+#include "baz.h" // expected-error-re {{does not depend on a module exporting '{{.*}}/baz.h'}}
 
 // FIXME: Explain why the 'bar.h' found on disk doesn't match the module map.
 // BUILD-MODULAR: error: header 'bar.h' not found
Index: clang/test/Modules/declare-use3.cpp
===
--- clang/test/Modules/declare-use3.cpp
+++ clang/test/Modules/declare-use3.cpp
@@ -1,4 +1,4 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -include "g.h" -include "e.h" -include "f.h" -include "i.h" -fimplicit-module-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
-// expected-error {{module XG does not depend on a module exporting 'f.h'}}
+// expected-error-re {{module XG does not depend on a module exporting '{{.*}}/f.h'}}
 const int g2 = g1 + e + f + aux_i;
Index: clang/test/Modules/declare-use2.cpp
===
--- clang/test/Modules/declare-use2.cpp
+++ clang/test/Modules/declare-use2.cpp
@@ -3,5 +3,5 @@
 
 #include "h.h"
 #include "e.h"
-#include "f.h" // expected-error {{module XH d

[PATCH] D103722: [clang] NFC: test for undefined behaviour in RawComment::getFormattedText()

2021-06-07 Thread Dmitry Polukhin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa0d7179bbb3: [clang] NFC: test for undefined behaviour in 
RawComment::getFormattedText() (authored by DmitryPolukhin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103722

Files:
  clang/unittests/AST/CommentTextTest.cpp


Index: clang/unittests/AST/CommentTextTest.cpp
===
--- clang/unittests/AST/CommentTextTest.cpp
+++ clang/unittests/AST/CommentTextTest.cpp
@@ -124,4 +124,11 @@
   // clang-format on
 }
 
+TEST_F(CommentTextTest, EmptyFormattedText) {
+  // Test that empty formatted text doesn't cause crash.
+  const char *ExpectedOutput = "";
+  auto Formatted = formatComment("//!<");
+  EXPECT_EQ(ExpectedOutput, Formatted);
+}
+
 } // namespace clang


Index: clang/unittests/AST/CommentTextTest.cpp
===
--- clang/unittests/AST/CommentTextTest.cpp
+++ clang/unittests/AST/CommentTextTest.cpp
@@ -124,4 +124,11 @@
   // clang-format on
 }
 
+TEST_F(CommentTextTest, EmptyFormattedText) {
+  // Test that empty formatted text doesn't cause crash.
+  const char *ExpectedOutput = "";
+  auto Formatted = formatComment("//!<");
+  EXPECT_EQ(ExpectedOutput, Formatted);
+}
+
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] aa0d717 - [clang] NFC: test for undefined behaviour in RawComment::getFormattedText()

2021-06-07 Thread Dmitry Polukhin via cfe-commits

Author: Dmitry Polukhin
Date: 2021-06-07T03:05:00-07:00
New Revision: aa0d7179bbb3fd24bc9eb1fd6203565dbd50e8d8

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

LOG: [clang] NFC: test for undefined behaviour in RawComment::getFormattedText()

This diff adds testcase for the issue fixed in https://reviews.llvm.org/D77468
but regression test was not added in the diff. On Clang 9 it caused
crash in cland during code completion.

Test Plan: check-clang-unit

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

Added: 


Modified: 
clang/unittests/AST/CommentTextTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/CommentTextTest.cpp 
b/clang/unittests/AST/CommentTextTest.cpp
index 3de6758e45b6e..b697828698d85 100644
--- a/clang/unittests/AST/CommentTextTest.cpp
+++ b/clang/unittests/AST/CommentTextTest.cpp
@@ -124,4 +124,11 @@ R"cpp(
   // clang-format on
 }
 
+TEST_F(CommentTextTest, EmptyFormattedText) {
+  // Test that empty formatted text doesn't cause crash.
+  const char *ExpectedOutput = "";
+  auto Formatted = formatComment("//!<");
+  EXPECT_EQ(ExpectedOutput, Formatted);
+}
+
 } // namespace clang



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


[PATCH] D102822: [Clang][CodeGen] Set the size of llvm.lifetime to unknown for scalable types.

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

LGTM, thanks @HsiangKai




Comment at: clang/test/CodeGen/RISCV/riscv-v-lifetime.cpp:3
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -std=c++11 -triple riscv64 -target-feature +experimental-v \
+// RUN:   -emit-llvm -O1 -o - %s | FileCheck %s

craig.topper wrote:
> sdesmalen wrote:
> > craig.topper wrote:
> > > Probably best to add -disable-llvm-passes so we don't run the optimizer.
> > nit: Does `-O1` still have any effect if `-disable-llvm-passes` is also set?
> Lifetime markers aren't emitted with -O0.
I didn't know that, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102822

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


[PATCH] D103685: [clangd] Drop TestTUs dependency on gtest

2021-06-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 350231.
kadircet added a comment.

- Assert for daigs rather than abort.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103685

Files:
  clang-tools-extra/clangd/index/Symbol.cpp
  clang-tools-extra/clangd/index/Symbol.h
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -17,7 +17,9 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/Utils.h"
 #include "llvm/ADT/ScopeExit.h"
-#include "gtest/gtest.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -69,14 +71,19 @@
 
 void initializeModuleCache(CompilerInvocation &CI) {
   llvm::SmallString<128> ModuleCachePath;
-  ASSERT_FALSE(
-  llvm::sys::fs::createUniqueDirectory("module-cache", ModuleCachePath));
+  if (llvm::sys::fs::createUniqueDirectory("module-cache", ModuleCachePath)) {
+llvm::errs() << "Failed to create temp directory for module-cache";
+std::abort();
+  }
   CI.getHeaderSearchOpts().ModuleCachePath = ModuleCachePath.c_str();
 }
 
 void deleteModuleCache(const std::string ModuleCachePath) {
   if (!ModuleCachePath.empty()) {
-ASSERT_FALSE(llvm::sys::fs::remove_directories(ModuleCachePath));
+if (llvm::sys::fs::remove_directories(ModuleCachePath)) {
+  llvm::errs() << "Failed to delete temp directory for module-cache";
+  std::abort();
+}
   }
 }
 
@@ -112,14 +119,11 @@
   auto AST = ParsedAST::build(testPath(Filename), Inputs, std::move(CI),
   Diags.take(), Preamble);
   if (!AST.hasValue()) {
-ADD_FAILURE() << "Failed to build code:\n" << Code;
-llvm_unreachable("Failed to build TestTU!");
-  }
-  if (!AST->getDiagnostics()) {
-ADD_FAILURE() << "TestTU should always build an AST with a fresh Preamble"
-  << Code;
-return std::move(*AST);
+llvm::errs() << "Failed to build code:\n" << Code;
+std::abort();
   }
+  assert(AST->getDiagnostics() &&
+ "TestTU should always build an AST with a fresh Preamble");
   // Check for error diagnostics and report gtest failures (unless expected).
   // This guards against accidental syntax errors silently subverting tests.
   // error-ok is awfully primitive - using clang -verify would be nicer.
@@ -138,11 +142,11 @@
 // We always build AST with a fresh preamble in TestTU.
 for (const auto &D : *AST->getDiagnostics())
   if (D.Severity >= DiagnosticsEngine::Error) {
-ADD_FAILURE()
+llvm::errs()
 << "TestTU failed to build (suppress with /*error-ok*/): \n"
 << D << "\n\nFor code:\n"
 << Code;
-break; // Just report first error for simplicity.
+std::abort(); // Stop after first error for simplicity.
   }
   }
   return std::move(*AST);
@@ -176,16 +180,16 @@
 if (QName != (S.Scope + S.Name).str())
   continue;
 if (Result) {
-  ADD_FAILURE() << "Multiple symbols named " << QName << ":\n"
-<< *Result << "\n---\n"
-<< S;
+  llvm::errs() << "Multiple symbols named " << QName << ":\n"
+   << *Result << "\n---\n"
+   << S;
   assert(false && "QName is not unique");
 }
 Result = &S;
   }
   if (!Result) {
-ADD_FAILURE() << "No symbol named " << QName << " in "
-  << ::testing::PrintToString(Slab);
+llvm::errs() << "No symbol named " << QName << " in "
+ << llvm::to_string(Slab);
 assert(false && "No symbol with QName");
   }
   return *Result;
@@ -225,7 +229,7 @@
   Visitor.F = Filter;
   Visitor.TraverseDecl(AST.getASTContext().getTranslationUnitDecl());
   if (Visitor.Decls.size() != 1) {
-ADD_FAILURE() << Visitor.Decls.size() << " symbols matched.";
+llvm::errs() << Visitor.Decls.size() << " symbols matched.";
 assert(Visitor.Decls.size() == 1);
   }
   return *Visitor.Decls.front();
Index: clang-tools-extra/clangd/index/Symbol.h
===
--- clang-tools-extra/clangd/index/Symbol.h
+++ clang-tools-extra/clangd/index/Symbol.h
@@ -233,6 +233,8 @@
   std::vector Symbols;  // Sorted by SymbolID to allow lookup.
 };
 
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolSlab &Slab);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/index/Symbol.cpp
===
--- clang-tools-extra/clangd/index/Symbol.cpp
+++ clang-tools-extra/clangd/index/Symbol.cpp
@@ -67,5 +67,15 @@
   return SymbolSlab(std::move(NewArena), std::move(SortedSymbols));
 }
 
+llvm::raw_ostream &operat

[clang] 9b14670 - [OpenCL] Add const attribute to ctz() builtins

2021-06-07 Thread Stuart Brady via cfe-commits

Author: Stuart Brady
Date: 2021-06-07T11:41:52+01:00
New Revision: 9b14670f3ca287ce949c4157e0f673c84da255a3

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

LOG: [OpenCL] Add const attribute to ctz() builtins

Reviewed By: svenvh

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

Added: 


Modified: 
clang/lib/Headers/opencl-c.h
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 9531e534a61bc..bfdd9b84dcede 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -9354,54 +9354,54 @@ ulong16 __ovld __cnfn clz(ulong16 x);
  * component type of x, if x is a vector.
  */
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-char __ovld ctz(char x);
-uchar __ovld ctz(uchar x);
-char2 __ovld ctz(char2 x);
-uchar2 __ovld ctz(uchar2 x);
-char3 __ovld ctz(char3 x);
-uchar3 __ovld ctz(uchar3 x);
-char4 __ovld ctz(char4 x);
-uchar4 __ovld ctz(uchar4 x);
-char8 __ovld ctz(char8 x);
-uchar8 __ovld ctz(uchar8 x);
-char16 __ovld ctz(char16 x);
-uchar16 __ovld ctz(uchar16 x);
-short __ovld ctz(short x);
-ushort __ovld ctz(ushort x);
-short2 __ovld ctz(short2 x);
-ushort2 __ovld ctz(ushort2 x);
-short3 __ovld ctz(short3 x);
-ushort3 __ovld ctz(ushort3 x);
-short4 __ovld ctz(short4 x);
-ushort4 __ovld ctz(ushort4 x);
-short8 __ovld ctz(short8 x);
-ushort8 __ovld ctz(ushort8 x);
-short16 __ovld ctz(short16 x);
-ushort16 __ovld ctz(ushort16 x);
-int __ovld ctz(int x);
-uint __ovld ctz(uint x);
-int2 __ovld ctz(int2 x);
-uint2 __ovld ctz(uint2 x);
-int3 __ovld ctz(int3 x);
-uint3 __ovld ctz(uint3 x);
-int4 __ovld ctz(int4 x);
-uint4 __ovld ctz(uint4 x);
-int8 __ovld ctz(int8 x);
-uint8 __ovld ctz(uint8 x);
-int16 __ovld ctz(int16 x);
-uint16 __ovld ctz(uint16 x);
-long __ovld ctz(long x);
-ulong __ovld ctz(ulong x);
-long2 __ovld ctz(long2 x);
-ulong2 __ovld ctz(ulong2 x);
-long3 __ovld ctz(long3 x);
-ulong3 __ovld ctz(ulong3 x);
-long4 __ovld ctz(long4 x);
-ulong4 __ovld ctz(ulong4 x);
-long8 __ovld ctz(long8 x);
-ulong8 __ovld ctz(ulong8 x);
-long16 __ovld ctz(long16 x);
-ulong16 __ovld ctz(ulong16 x);
+char __ovld __cnfn ctz(char x);
+uchar __ovld __cnfn ctz(uchar x);
+char2 __ovld __cnfn ctz(char2 x);
+uchar2 __ovld __cnfn ctz(uchar2 x);
+char3 __ovld __cnfn ctz(char3 x);
+uchar3 __ovld __cnfn ctz(uchar3 x);
+char4 __ovld __cnfn ctz(char4 x);
+uchar4 __ovld __cnfn ctz(uchar4 x);
+char8 __ovld __cnfn ctz(char8 x);
+uchar8 __ovld __cnfn ctz(uchar8 x);
+char16 __ovld __cnfn ctz(char16 x);
+uchar16 __ovld __cnfn ctz(uchar16 x);
+short __ovld __cnfn ctz(short x);
+ushort __ovld __cnfn ctz(ushort x);
+short2 __ovld __cnfn ctz(short2 x);
+ushort2 __ovld __cnfn ctz(ushort2 x);
+short3 __ovld __cnfn ctz(short3 x);
+ushort3 __ovld __cnfn ctz(ushort3 x);
+short4 __ovld __cnfn ctz(short4 x);
+ushort4 __ovld __cnfn ctz(ushort4 x);
+short8 __ovld __cnfn ctz(short8 x);
+ushort8 __ovld __cnfn ctz(ushort8 x);
+short16 __ovld __cnfn ctz(short16 x);
+ushort16 __ovld __cnfn ctz(ushort16 x);
+int __ovld __cnfn ctz(int x);
+uint __ovld __cnfn ctz(uint x);
+int2 __ovld __cnfn ctz(int2 x);
+uint2 __ovld __cnfn ctz(uint2 x);
+int3 __ovld __cnfn ctz(int3 x);
+uint3 __ovld __cnfn ctz(uint3 x);
+int4 __ovld __cnfn ctz(int4 x);
+uint4 __ovld __cnfn ctz(uint4 x);
+int8 __ovld __cnfn ctz(int8 x);
+uint8 __ovld __cnfn ctz(uint8 x);
+int16 __ovld __cnfn ctz(int16 x);
+uint16 __ovld __cnfn ctz(uint16 x);
+long __ovld __cnfn ctz(long x);
+ulong __ovld __cnfn ctz(ulong x);
+long2 __ovld __cnfn ctz(long2 x);
+ulong2 __ovld __cnfn ctz(ulong2 x);
+long3 __ovld __cnfn ctz(long3 x);
+ulong3 __ovld __cnfn ctz(ulong3 x);
+long4 __ovld __cnfn ctz(long4 x);
+ulong4 __ovld __cnfn ctz(ulong4 x);
+long8 __ovld __cnfn ctz(long8 x);
+ulong8 __ovld __cnfn ctz(ulong8 x);
+long16 __ovld __cnfn ctz(long16 x);
+ulong16 __ovld __cnfn ctz(ulong16 x);
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 /**

diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index efb540cd19679..2cd41b6c2bd32 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -606,7 +606,7 @@ let MinVersion = CL12 in {
 }
 let MinVersion = CL20 in {
   foreach name = ["ctz"] in {
-def : Builtin;
+def : Builtin;
   }
 }
 



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


[PATCH] D97725: [OpenCL] Add const attribute to ctz() builtin

2021-06-07 Thread Stuart Brady via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b14670f3ca2: [OpenCL] Add const attribute to ctz() builtins 
(authored by stuart).
Herald added subscribers: cfe-commits, ldrumm.

Changed prior to commit:
  https://reviews.llvm.org/D97725?vs=327261&id=350232#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97725

Files:
  clang/lib/Headers/opencl-c.h
  clang/lib/Sema/OpenCLBuiltins.td

Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -606,7 +606,7 @@
 }
 let MinVersion = CL20 in {
   foreach name = ["ctz"] in {
-def : Builtin;
+def : Builtin;
   }
 }
 
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -9354,54 +9354,54 @@
  * component type of x, if x is a vector.
  */
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-char __ovld ctz(char x);
-uchar __ovld ctz(uchar x);
-char2 __ovld ctz(char2 x);
-uchar2 __ovld ctz(uchar2 x);
-char3 __ovld ctz(char3 x);
-uchar3 __ovld ctz(uchar3 x);
-char4 __ovld ctz(char4 x);
-uchar4 __ovld ctz(uchar4 x);
-char8 __ovld ctz(char8 x);
-uchar8 __ovld ctz(uchar8 x);
-char16 __ovld ctz(char16 x);
-uchar16 __ovld ctz(uchar16 x);
-short __ovld ctz(short x);
-ushort __ovld ctz(ushort x);
-short2 __ovld ctz(short2 x);
-ushort2 __ovld ctz(ushort2 x);
-short3 __ovld ctz(short3 x);
-ushort3 __ovld ctz(ushort3 x);
-short4 __ovld ctz(short4 x);
-ushort4 __ovld ctz(ushort4 x);
-short8 __ovld ctz(short8 x);
-ushort8 __ovld ctz(ushort8 x);
-short16 __ovld ctz(short16 x);
-ushort16 __ovld ctz(ushort16 x);
-int __ovld ctz(int x);
-uint __ovld ctz(uint x);
-int2 __ovld ctz(int2 x);
-uint2 __ovld ctz(uint2 x);
-int3 __ovld ctz(int3 x);
-uint3 __ovld ctz(uint3 x);
-int4 __ovld ctz(int4 x);
-uint4 __ovld ctz(uint4 x);
-int8 __ovld ctz(int8 x);
-uint8 __ovld ctz(uint8 x);
-int16 __ovld ctz(int16 x);
-uint16 __ovld ctz(uint16 x);
-long __ovld ctz(long x);
-ulong __ovld ctz(ulong x);
-long2 __ovld ctz(long2 x);
-ulong2 __ovld ctz(ulong2 x);
-long3 __ovld ctz(long3 x);
-ulong3 __ovld ctz(ulong3 x);
-long4 __ovld ctz(long4 x);
-ulong4 __ovld ctz(ulong4 x);
-long8 __ovld ctz(long8 x);
-ulong8 __ovld ctz(ulong8 x);
-long16 __ovld ctz(long16 x);
-ulong16 __ovld ctz(ulong16 x);
+char __ovld __cnfn ctz(char x);
+uchar __ovld __cnfn ctz(uchar x);
+char2 __ovld __cnfn ctz(char2 x);
+uchar2 __ovld __cnfn ctz(uchar2 x);
+char3 __ovld __cnfn ctz(char3 x);
+uchar3 __ovld __cnfn ctz(uchar3 x);
+char4 __ovld __cnfn ctz(char4 x);
+uchar4 __ovld __cnfn ctz(uchar4 x);
+char8 __ovld __cnfn ctz(char8 x);
+uchar8 __ovld __cnfn ctz(uchar8 x);
+char16 __ovld __cnfn ctz(char16 x);
+uchar16 __ovld __cnfn ctz(uchar16 x);
+short __ovld __cnfn ctz(short x);
+ushort __ovld __cnfn ctz(ushort x);
+short2 __ovld __cnfn ctz(short2 x);
+ushort2 __ovld __cnfn ctz(ushort2 x);
+short3 __ovld __cnfn ctz(short3 x);
+ushort3 __ovld __cnfn ctz(ushort3 x);
+short4 __ovld __cnfn ctz(short4 x);
+ushort4 __ovld __cnfn ctz(ushort4 x);
+short8 __ovld __cnfn ctz(short8 x);
+ushort8 __ovld __cnfn ctz(ushort8 x);
+short16 __ovld __cnfn ctz(short16 x);
+ushort16 __ovld __cnfn ctz(ushort16 x);
+int __ovld __cnfn ctz(int x);
+uint __ovld __cnfn ctz(uint x);
+int2 __ovld __cnfn ctz(int2 x);
+uint2 __ovld __cnfn ctz(uint2 x);
+int3 __ovld __cnfn ctz(int3 x);
+uint3 __ovld __cnfn ctz(uint3 x);
+int4 __ovld __cnfn ctz(int4 x);
+uint4 __ovld __cnfn ctz(uint4 x);
+int8 __ovld __cnfn ctz(int8 x);
+uint8 __ovld __cnfn ctz(uint8 x);
+int16 __ovld __cnfn ctz(int16 x);
+uint16 __ovld __cnfn ctz(uint16 x);
+long __ovld __cnfn ctz(long x);
+ulong __ovld __cnfn ctz(ulong x);
+long2 __ovld __cnfn ctz(long2 x);
+ulong2 __ovld __cnfn ctz(ulong2 x);
+long3 __ovld __cnfn ctz(long3 x);
+ulong3 __ovld __cnfn ctz(ulong3 x);
+long4 __ovld __cnfn ctz(long4 x);
+ulong4 __ovld __cnfn ctz(ulong4 x);
+long8 __ovld __cnfn ctz(long8 x);
+ulong8 __ovld __cnfn ctz(ulong8 x);
+long16 __ovld __cnfn ctz(long16 x);
+ulong16 __ovld __cnfn ctz(ulong16 x);
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 
 /**
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103605: [analyzer] Introduce a new interface for tracking

2021-06-07 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D103605#2801681 , @NoQ wrote:

> Inlined defensive check suppressions are indeed pretty ugly; this problem 
> should ideally be solved in a completely different manner.
>
> That said, I strongly disagree that "when the tracker stops" is a 
> hard-to-understand concept. It's an extremely natural and intuitive question 
> to ask:
>
> //"Where does the value come from?"//
>
> It's fairly reasonable to wonder what happened during analysis that caused us 
> to produce this value for the first time, which then traveled down to our bug 
> point, and under what circumstances did it happen. Not much precise reasoning 
> can be based on this information but it's a very good piece of information to 
> drive imprecise reasoning and heuristics, such as (but not limited to) 
> inlined defensive check suppressions (where it bears a relatively precise 
> meaning that corresponds exactly to "state splits in nested stack frames are 
> intrinsically less reliable as they can't ever be derived from presumption of 
> no dead code").
>
> Another example: a value of a top-level parameter variable is much more 
> likely to be arbitrary than a return value of an unknown function call (if 
> the user wanted pre-conditions they could have added an assert), which in 
> turn is much more likely to be arbitrary than a value loaded from a heap 
> region after store invalidation from unknown function call (we're 99% sure 
> that the function doesn't touch this particular heap region so it's probably 
> just the old value). In this sense, I'm pretty tempted to suppress bug paths 
> where two branch conditions (ultimately going into opposite directions) are 
> based on different values of the same heap variable after different number of 
> invalidations. But I'm certainly against doing so for two different top-level 
> parameter values. You may say that in these cases the information is most 
> likely available from the structure of the symbol (`SymbolRegionValue` vs. 
> `SymbolConjured` vs. `SymbolDerived`) but it only confirms my point: origins 
> of values are so important that we even carry them as part of the value's 
> identity! Direct access to the structure of the symbol for determining 
> origins is also used a few times (eg., see call sites of `getOriginRegion()`).

OK, let's make a pause right here.  We again start to go into other topics.  
You come from a pure perspective that `track` explains how the value got here 
and does only that.  In this picture of the world, `track` has one starting 
point and one ending point.  If it ends to early (due to the lack of domain 
knowledge), the checker can pick up and restart the tracking if needed.  If it 
ends for real, this is the earliest where we got this value from and it can 
tell us about the warning and situation we are in.  The problem is that 
tracking is fundamentally **dirty** the way it is.  It is not linear, and when 
we track one simple value, it actually spawns a gigantic tree of traces.  Thus 
when we get to the point where it all ended, it actually ended 100 times.  It 
ended in multiple different visitors that were tracking all kinds of things not 
limited to the value itself.  `trackExpressionValue` is hard also because of 
this reason.  Inline defensive checks don't belong there and clutter it.

I DON'T KNOW how to simplify this ATM.  Probably we can decouple ONE VALUE 
TRACKING from the rest of it, but it's not what I'm trying to do.  I want to 
refactor the existing solution (with all of its inherent design flaws) into 
something more extensible.  And I think that again ATM, with the current state 
of things, the concept of "tracking stopped here" is doomed.

> What I'm trying to do here is to see a general direction in which we're 
> moving. We have the benefit of being able to predict things. We don't have to 
> be agile; our problem is well-defined from the start and will never really 
> change. There's a bit of flexibility required to support a variety of 
> different future checkers, yes, but that's about it. And then, again, it's 
> also not entirely arbitrary: we have a pretty good amount of data on what our 
> checkers typically do and it's unlikely to expand drastically in the near 
> future. So we don't always need to go for the most flexible solution, but 
> there's often benefit in going for a simpler solution that simply covers our 
> predictable needs and nothing else.
>
> As a historical example of such process, currently bug visitors perform a 
> single pass over the bug report, from bottom to top. This wasn't always this 
> way: originally visitors traversed the bug report multiple times 
> (occasionally 30+ times), adding new visitors along the way, until the set of 
> visitors attached to the bug report reached a fixed point. The original 
> solution was very flexible; it allowed us to backreference values at the 
> bottom in a flash of hindsight and have all visitors rest

[PATCH] D103802: [clang][modules][pch] Allow loading PCH with different modules cache path

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

It's useful to be able to load explicitly-built PCH files into an implicit 
build (e.g. during dependency scanning). That's currently impossible, since the 
explicitly-built PCH has an empty modules cache path, while the current 
compilation has (and needs to have) a valid path, triggering an error in the 
`PCHValidator`.

This patch adds a preprocessor option and command-line flag that can be used to 
omit this check.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103802

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/Serialization/ASTReader.cpp
  clang/test/Modules/Inputs/pch-typedef.h
  clang/test/Modules/module-pch-different-cache-path.c


Index: clang/test/Modules/module-pch-different-cache-path.c
===
--- /dev/null
+++ clang/test/Modules/module-pch-different-cache-path.c
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-typedef.h -o 
%t/pch-typedef.h.gch \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/one
+//
+// RUN: not %clang_cc1 -x objective-c -fsyntax-only %s -include-pch 
%t/pch-typedef.h.gch \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/two 2>&1 \
+// RUN:   | FileCheck %s -check-prefixes=CHECK-ERROR
+//
+// RUN: %clang_cc1 -x objective-c -fsyntax-only %s -include-pch 
%t/pch-typedef.h.gch \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/two 2>&1 
-fallow-pch-with-different-modules-cache-path \
+// RUN:   | FileCheck %s -check-prefixes=CHECK-SUCCESS -allow-empty
+
+pch_int x = 0;
+
+// CHECK-ERROR: PCH was compiled with module cache path '{{.*}}', but the path 
is currently '{{.*}}'
+// CHECK-SUCCESS-NOT: PCH was compiled with module cache path '{{.*}}', but 
the path is currently '{{.*}}'
Index: clang/test/Modules/Inputs/pch-typedef.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/pch-typedef.h
@@ -0,0 +1 @@
+typedef int pch_int;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -783,9 +783,11 @@
  StringRef SpecificModuleCachePath,
  StringRef ExistingModuleCachePath,
  DiagnosticsEngine *Diags,
- const LangOptions &LangOpts) {
+ const LangOptions &LangOpts,
+ const PreprocessorOptions &PPOpts) {
   if (LangOpts.Modules) {
-if (SpecificModuleCachePath != ExistingModuleCachePath) {
+if (SpecificModuleCachePath != ExistingModuleCachePath &&
+!PPOpts.AllowPCHWithDifferentModulesCachePath) {
   if (Diags)
 Diags->Report(diag::err_pch_modulecache_mismatch)
   << SpecificModuleCachePath << ExistingModuleCachePath;
@@ -802,7 +804,7 @@
   return checkHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
   
PP.getHeaderSearchInfo().getModuleCachePath(),
   Complain ? &Reader.Diags : nullptr,
-  PP.getLangOpts());
+  PP.getLangOpts(), PP.getPreprocessorOpts());
 }
 
 void PCHValidator::ReadCounter(const ModuleFile &M, unsigned Value) {
@@ -5142,8 +5144,8 @@
  StringRef SpecificModuleCachePath,
  bool Complain) override {
   return checkHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
-  ExistingModuleCachePath,
-  nullptr, ExistingLangOpts);
+  ExistingModuleCachePath, nullptr,
+  ExistingLangOpts, ExistingPPOpts);
 }
 
 bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
Index: clang/include/clang/Lex/PreprocessorOptions.h
===
--- clang/include/clang/Lex/PreprocessorOptions.h
+++ clang/include/clang/Lex/PreprocessorOptions.h
@@ -106,6 +106,10 @@
   /// When true, a PCH with compiler errors will not be rejected.
   bool AllowPCHWithCompilerErrors = false;
 
+  /// When true, a PCH with modules cache path different to the current
+  /// compilation will not be rejected.
+  bool AllowPCHWithDifferentModulesCachePath = false;
+
   /// Dump declarations that are deserialized from PCH, for testing.
   bo

[PATCH] D103802: [clang][modules][pch] Allow loading PCH with different modules cache path

2021-06-07 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 350243.
jansvoboda11 added a comment.

Mark as CC1Option


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103802

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/Serialization/ASTReader.cpp
  clang/test/Modules/Inputs/pch-typedef.h
  clang/test/Modules/module-pch-different-cache-path.c


Index: clang/test/Modules/module-pch-different-cache-path.c
===
--- /dev/null
+++ clang/test/Modules/module-pch-different-cache-path.c
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-typedef.h -o 
%t/pch-typedef.h.gch \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/one
+//
+// RUN: not %clang_cc1 -x objective-c -fsyntax-only %s -include-pch 
%t/pch-typedef.h.gch \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/two 2>&1 \
+// RUN:   | FileCheck %s -check-prefixes=CHECK-ERROR
+//
+// RUN: %clang_cc1 -x objective-c -fsyntax-only %s -include-pch 
%t/pch-typedef.h.gch \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/two 2>&1 
-fallow-pch-with-different-modules-cache-path \
+// RUN:   | FileCheck %s -check-prefixes=CHECK-SUCCESS -allow-empty
+
+pch_int x = 0;
+
+// CHECK-ERROR: PCH was compiled with module cache path '{{.*}}', but the path 
is currently '{{.*}}'
+// CHECK-SUCCESS-NOT: PCH was compiled with module cache path '{{.*}}', but 
the path is currently '{{.*}}'
Index: clang/test/Modules/Inputs/pch-typedef.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/pch-typedef.h
@@ -0,0 +1 @@
+typedef int pch_int;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -783,9 +783,11 @@
  StringRef SpecificModuleCachePath,
  StringRef ExistingModuleCachePath,
  DiagnosticsEngine *Diags,
- const LangOptions &LangOpts) {
+ const LangOptions &LangOpts,
+ const PreprocessorOptions &PPOpts) {
   if (LangOpts.Modules) {
-if (SpecificModuleCachePath != ExistingModuleCachePath) {
+if (SpecificModuleCachePath != ExistingModuleCachePath &&
+!PPOpts.AllowPCHWithDifferentModulesCachePath) {
   if (Diags)
 Diags->Report(diag::err_pch_modulecache_mismatch)
   << SpecificModuleCachePath << ExistingModuleCachePath;
@@ -802,7 +804,7 @@
   return checkHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
   
PP.getHeaderSearchInfo().getModuleCachePath(),
   Complain ? &Reader.Diags : nullptr,
-  PP.getLangOpts());
+  PP.getLangOpts(), PP.getPreprocessorOpts());
 }
 
 void PCHValidator::ReadCounter(const ModuleFile &M, unsigned Value) {
@@ -5142,8 +5144,8 @@
  StringRef SpecificModuleCachePath,
  bool Complain) override {
   return checkHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
-  ExistingModuleCachePath,
-  nullptr, ExistingLangOpts);
+  ExistingModuleCachePath, nullptr,
+  ExistingLangOpts, ExistingPPOpts);
 }
 
 bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
Index: clang/include/clang/Lex/PreprocessorOptions.h
===
--- clang/include/clang/Lex/PreprocessorOptions.h
+++ clang/include/clang/Lex/PreprocessorOptions.h
@@ -106,6 +106,10 @@
   /// When true, a PCH with compiler errors will not be rejected.
   bool AllowPCHWithCompilerErrors = false;
 
+  /// When true, a PCH with modules cache path different to the current
+  /// compilation will not be rejected.
+  bool AllowPCHWithDifferentModulesCachePath = false;
+
   /// Dump declarations that are deserialized from PCH, for testing.
   bool DumpDeserializedPCHDecls = false;
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5483,6 +5483,10 @@
   HelpText<"Accept a PCH file that was created with compiler errors">,
   MarshallingInfoFlag>,
   ImpliedByAnyOf<[fallow_pcm_with_errors.KeyPath]>;
+def fallow_pch_with_different_modules_cache_path :
+  Flag<["-"], "fallow-pch-with-different-modu

[PATCH] D103802: [clang][modules][pch] Allow loading PCH with different modules cache path

2021-06-07 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 350245.
jansvoboda11 added a comment.

Remove CC1Option


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103802

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/Serialization/ASTReader.cpp
  clang/test/Modules/Inputs/pch-typedef.h
  clang/test/Modules/module-pch-different-cache-path.c


Index: clang/test/Modules/module-pch-different-cache-path.c
===
--- /dev/null
+++ clang/test/Modules/module-pch-different-cache-path.c
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-typedef.h -o 
%t/pch-typedef.h.gch \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/one
+//
+// RUN: not %clang_cc1 -x objective-c -fsyntax-only %s -include-pch 
%t/pch-typedef.h.gch \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/two 2>&1 \
+// RUN:   | FileCheck %s -check-prefixes=CHECK-ERROR
+//
+// RUN: %clang_cc1 -x objective-c -fsyntax-only %s -include-pch 
%t/pch-typedef.h.gch \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/two 2>&1 
-fallow-pch-with-different-modules-cache-path \
+// RUN:   | FileCheck %s -check-prefixes=CHECK-SUCCESS -allow-empty
+
+pch_int x = 0;
+
+// CHECK-ERROR: PCH was compiled with module cache path '{{.*}}', but the path 
is currently '{{.*}}'
+// CHECK-SUCCESS-NOT: PCH was compiled with module cache path '{{.*}}', but 
the path is currently '{{.*}}'
Index: clang/test/Modules/Inputs/pch-typedef.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/pch-typedef.h
@@ -0,0 +1 @@
+typedef int pch_int;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -783,9 +783,11 @@
  StringRef SpecificModuleCachePath,
  StringRef ExistingModuleCachePath,
  DiagnosticsEngine *Diags,
- const LangOptions &LangOpts) {
+ const LangOptions &LangOpts,
+ const PreprocessorOptions &PPOpts) {
   if (LangOpts.Modules) {
-if (SpecificModuleCachePath != ExistingModuleCachePath) {
+if (SpecificModuleCachePath != ExistingModuleCachePath &&
+!PPOpts.AllowPCHWithDifferentModulesCachePath) {
   if (Diags)
 Diags->Report(diag::err_pch_modulecache_mismatch)
   << SpecificModuleCachePath << ExistingModuleCachePath;
@@ -802,7 +804,7 @@
   return checkHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
   
PP.getHeaderSearchInfo().getModuleCachePath(),
   Complain ? &Reader.Diags : nullptr,
-  PP.getLangOpts());
+  PP.getLangOpts(), PP.getPreprocessorOpts());
 }
 
 void PCHValidator::ReadCounter(const ModuleFile &M, unsigned Value) {
@@ -5142,8 +5144,8 @@
  StringRef SpecificModuleCachePath,
  bool Complain) override {
   return checkHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
-  ExistingModuleCachePath,
-  nullptr, ExistingLangOpts);
+  ExistingModuleCachePath, nullptr,
+  ExistingLangOpts, ExistingPPOpts);
 }
 
 bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
Index: clang/include/clang/Lex/PreprocessorOptions.h
===
--- clang/include/clang/Lex/PreprocessorOptions.h
+++ clang/include/clang/Lex/PreprocessorOptions.h
@@ -106,6 +106,10 @@
   /// When true, a PCH with compiler errors will not be rejected.
   bool AllowPCHWithCompilerErrors = false;
 
+  /// When true, a PCH with modules cache path different to the current
+  /// compilation will not be rejected.
+  bool AllowPCHWithDifferentModulesCachePath = false;
+
   /// Dump declarations that are deserialized from PCH, for testing.
   bool DumpDeserializedPCHDecls = false;
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5483,6 +5483,10 @@
   HelpText<"Accept a PCH file that was created with compiler errors">,
   MarshallingInfoFlag>,
   ImpliedByAnyOf<[fallow_pcm_with_errors.KeyPath]>;
+def fallow_pch_with_different_modules_cache_path :
+  Flag<["-"], "fallow-pch-with-different-modul

[clang] 60c9b5f - [AArch64][SVE] Improve codegen for dupq SVE ACLE intrinsics

2021-06-07 Thread Bradley Smith via cfe-commits

Author: Bradley Smith
Date: 2021-06-07T12:21:38+01:00
New Revision: 60c9b5f35caeb555f66d261bf5a657ab02a35fef

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

LOG: [AArch64][SVE] Improve codegen for dupq SVE ACLE intrinsics

Use llvm.experimental.vector.insert instead of storing into an alloca
when generating code for these intrinsics. This defers the codegen of
the generated vector to instruction selection, allowing existing
shufflevector style optimizations to apply.

Additionally, introduce a new target transform that can recognise fixed
predicate patterns in the svbool variants of these intrinsics.

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq_const.c
llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-cmpne.ll

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9fdf1df9734e2..1b30d44937f3e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -9061,33 +9061,32 @@ Value 
*CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
 if (IsBoolTy)
   EltTy = IntegerType::get(getLLVMContext(), SVEBitsPerBlock / NumOpnds);
 
-Address Alloca = CreateTempAlloca(llvm::ArrayType::get(EltTy, NumOpnds),
- CharUnits::fromQuantity(16));
+SmallVector VecOps;
 for (unsigned I = 0; I < NumOpnds; ++I)
-  Builder.CreateDefaultAlignedStore(
-  IsBoolTy ? Builder.CreateZExt(Ops[I], EltTy) : Ops[I],
-  Builder.CreateGEP(Alloca.getElementType(), Alloca.getPointer(),
-{Builder.getInt64(0), Builder.getInt64(I)}));
+VecOps.push_back(Builder.CreateZExt(Ops[I], EltTy));
+Value *Vec = BuildVector(VecOps);
 
 SVETypeFlags TypeFlags(Builtin->TypeModifier);
 Value *Pred = EmitSVEAllTruePred(TypeFlags);
 
 llvm::Type *OverloadedTy = getSVEVectorForElementType(EltTy);
-Function *F = CGM.getIntrinsic(Intrinsic::aarch64_sve_ld1rq, OverloadedTy);
-Value *Alloca0 = Builder.CreateGEP(
-Alloca.getElementType(), Alloca.getPointer(),
-{Builder.getInt64(0), Builder.getInt64(0)});
-Value *LD1RQ = Builder.CreateCall(F, {Pred, Alloca0});
+Value *InsertSubVec = Builder.CreateInsertVector(
+OverloadedTy, UndefValue::get(OverloadedTy), Vec, Builder.getInt64(0));
+
+Function *F =
+CGM.getIntrinsic(Intrinsic::aarch64_sve_dupq_lane, OverloadedTy);
+Value *DupQLane =
+Builder.CreateCall(F, {InsertSubVec, Builder.getInt64(0)});
 
 if (!IsBoolTy)
-  return LD1RQ;
+  return DupQLane;
 
 // For svdupq_n_b* we need to add an additional 'cmpne' with '0'.
 F = CGM.getIntrinsic(NumOpnds == 2 ? Intrinsic::aarch64_sve_cmpne
: Intrinsic::aarch64_sve_cmpne_wide,
  OverloadedTy);
-Value *Call =
-Builder.CreateCall(F, {Pred, LD1RQ, EmitSVEDupX(Builder.getInt64(0))});
+Value *Call = Builder.CreateCall(
+F, {Pred, DupQLane, EmitSVEDupX(Builder.getInt64(0))});
 return EmitSVEPredicateCast(Call, cast(Ty));
   }
 

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq-bfloat.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq-bfloat.c
index 05223d59ea1e9..086d753870ec8 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq-bfloat.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq-bfloat.c
@@ -24,16 +24,13 @@ svbfloat16_t test_svdupq_lane_bf16(svbfloat16_t data, 
uint64_t index) {
 svbfloat16_t test_svdupq_n_bf16(bfloat16_t x0, bfloat16_t x1, bfloat16_t x2, 
bfloat16_t x3,
 bfloat16_t x4, bfloat16_t x5, bfloat16_t x6, 
bfloat16_t x7) {
   // CHECK-LABEL: test_svdupq_n_bf16
-  // CHECK: %[[ALLOCA:.*]] = alloca [8 x bfloat], align 16
-  // CHECK-DAG: %[[BASE:.*]] = getelementptr inbounds [8 x bfloat], [8 x 
bfloat]* %[[ALLOCA]], i64 0, i64 0
-  // CHECK-DAG: store bfloat %x0, bfloat* %[[BASE]], align 16
-  // 
-  // CHECK-DAG: %[[GEP:.*]] = getelementptr inbounds [8 x bfloat], [8 x 
bfloat]* %[[ALLOCA]], i64 0, i64 7
-  // CHECK: store bfloat %x7, bfloat* %[[GEP]], align 2
-  // CHECK-NOT: store
-  // CHECK: call  @llvm.aarch64.sve.ptrue.nxv8i1(i32 31)
-  // CHECK: %[[LOAD:.*]] = call  
@llvm.aarch64.sve.ld1rq.nxv8bf16( %{{.*}}, bfloat* nonnull 
%[[BASE]])
-  // CHECK: ret  %[[LOAD]]
+  // CHECK: insertelement <8 x bfloat

[PATCH] D103082: [AArch64][SVE] Improve codegen for dupq SVE ACLE intrinsics

2021-06-07 Thread Bradley Smith via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG60c9b5f35cae: [AArch64][SVE] Improve codegen for dupq SVE 
ACLE intrinsics (authored by bsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103082

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq_const.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-cmpne.ll

Index: llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-cmpne.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-cmpne.ll
@@ -0,0 +1,397 @@
+; RUN: opt -S -instcombine < %s | FileCheck %s
+
+target triple = "aarch64-unknown-linux-gnu"
+
+; DUPQ b8
+
+define  @dupq_b_0() #0 {
+; CHECK-LABEL: @dupq_b_0(
+; CHECK: ret  zeroinitializer
+  %1 = tail call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
+  %2 = tail call  @llvm.experimental.vector.insert.nxv16i8.v16i8( undef,
+<16 x i8> , i64 0)
+  %3 = tail call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %2 , i64 0)
+  %4 = tail call  @llvm.aarch64.sve.dup.x.nxv2i64(i64 0)
+  %5 = tail call  @llvm.aarch64.sve.cmpne.wide.nxv16i8( %1,  %3,  %4)
+  ret  %5
+}
+
+define  @dupq_b_d() #0 {
+; CHECK-LABEL: @dupq_b_d(
+; CHECK: %1 = call  @llvm.aarch64.sve.ptrue.nxv2i1(i32 31)
+; CHECK-NEXT: %2 = call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %1)
+; CHECK-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
+  %2 = tail call  @llvm.experimental.vector.insert.nxv16i8.v16i8( undef,
+<16 x i8> , i64 0)
+  %3 = tail call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %2 , i64 0)
+  %4 = tail call  @llvm.aarch64.sve.dup.x.nxv2i64(i64 0)
+  %5 = tail call  @llvm.aarch64.sve.cmpne.wide.nxv16i8( %1,  %3,  %4)
+  ret  %5
+}
+
+define  @dupq_b_w() #0 {
+; CHECK-LABEL: @dupq_b_w(
+; CHECK: %1 = call  @llvm.aarch64.sve.ptrue.nxv4i1(i32 31)
+; CHECK-NEXT: %2 = call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %1)
+; CHECK-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
+  %2 = tail call  @llvm.experimental.vector.insert.nxv16i8.v16i8( undef,
+<16 x i8> , i64 0)
+  %3 = tail call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %2 , i64 0)
+  %4 = tail call  @llvm.aarch64.sve.dup.x.nxv2i64(i64 0)
+  %5 = tail call  @llvm.aarch64.sve.cmpne.wide.nxv16i8( %1,  %3,  %4)
+  ret  %5
+}
+
+define  @dupq_b_h() #0 {
+; CHECK-LABEL: @dupq_b_h(
+; CHECK: %1 = call  @llvm.aarch64.sve.ptrue.nxv8i1(i32 31)
+; CHECK-NEXT: %2 = call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %1)
+; CHECK-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
+  %2 = tail call  @llvm.experimental.vector.insert.nxv16i8.v16i8( undef,
+<16 x i8> , i64 0)
+  %3 = tail call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %2 , i64 0)
+  %4 = tail call  @llvm.aarch64.sve.dup.x.nxv2i64(i64 0)
+  %5 = tail call  @llvm.aarch64.sve.cmpne.wide.nxv16i8( %1,  %3,  %4)
+  ret  %5
+}
+
+define  @dupq_b_b() #0 {
+; CHECK-LABEL: @dupq_b_b(
+; CHECK: %1 = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
+; CHECK-NEXT: ret  %1
+  %1 = tail call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
+  %2 = tail call  @llvm.experimental.vector.insert.nxv16i8.v16i8( undef,
+<16 x i8> , i64 0)
+  %3 = tail call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %2 , i64 0)
+  %4 = tail call  @llvm.aarch64.sve.dup.x.nxv2i64(i64 0)
+  %5 = tail call  @llvm.aarch64.sve.cmpne.wide.nxv16i8( %1,  %3,  %4)
+  ret  %5
+}
+
+; DUPQ b16
+
+define  @dupq_h_0() #0 {
+; CHECK-LABEL: @dupq_h_0(
+; CHECK: ret  zeroinitializer
+  %1 = tail call  @llvm.aarch64.sve.ptrue.nxv8i1(i32 31)
+  %2 = tail call  @llvm.experimental.vector.insert.nxv8i16.v8i16( undef,
+<8 x i16> , i64 0)
+  %3 = tail call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %2 , i64 0)
+  %4 = tail call  @llvm.aarch64.sve.dup.x.nxv2i64(i64 0)
+  %5 = tail call  @llvm.aarch64.sve.cmpne.wide.nxv8i16( %1,  %3,  %4)
+  ret  %5
+}
+
+define  @dupq_h_d() #0 {
+; CHECK-LABEL: @dupq_h_d(
+; CHECK: %1 = call  @llvm.aarch64.sve.ptrue.nxv2i1(i32 31)
+; CHECK-NEXT: %2 = call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %1)
+; CHECK-NEXT: %3 = call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %2)
+; CHECK-NEXT: ret  %3
+  %1 = tail call  @llvm.aarch64.sve.ptrue.nxv8i1(i32 31)
+  %2 = tail call  @llvm.experimental.vector.insert.nxv8i16.v8i16( undef,
+<8 x i16> , i64 0)
+  %3 = tail call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %2 , i64 0)
+  %4 = tail call  @llvm.aarch64.sve.dup.x.nxv2i64(i64 0)
+  %5 = tail call  @llvm.aarch64.sve.cmpne.wide.nxv8i16( %1,  %3,  %4)
+  ret  %5
+}
+
+define  @dupq_h_w() #0

[PATCH] D103526: [clang][deps] Mark modules as file deps if they come from PCH

2021-06-07 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 350247.
jansvoboda11 added a comment.

Handle case when TU depends on a PCH module


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103526

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/modules-pch/cdb_pch.json
  clang/test/ClangScanDeps/Inputs/modules-pch/cdb_tu_with_common.json
  clang/test/ClangScanDeps/Inputs/modules-pch/mod_common_1.h
  clang/test/ClangScanDeps/Inputs/modules-pch/mod_common_2.h
  clang/test/ClangScanDeps/Inputs/modules-pch/mod_pch.h
  clang/test/ClangScanDeps/Inputs/modules-pch/mod_tu_with_common.h
  clang/test/ClangScanDeps/Inputs/modules-pch/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules-pch/pch.h
  clang/test/ClangScanDeps/Inputs/modules-pch/tu_with_common.c
  clang/test/ClangScanDeps/modules-pch.c

Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,10 +1,124 @@
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
+// Scan dependencies of the PCH:
+//
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb.json
+// RUN: echo -%t > %t/result_pch.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
+// RUN:   -generate-modules-path-args -module-files-dir %t/build -mode preprocess >> %t/result_pch.json
+// RUN: cat %t/result_pch.json | FileCheck %s -check-prefix=CHECK-PCH
+//
+// CHECK-PCH:  -[[PREFIX:.*]]
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "modules": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "clang-module-deps": [],
+// CHECK-PCH-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-PCH-NEXT:   "command-line": [
+// CHECK-PCH-NEXT: "-cc1"
+// CHECK-PCH:  "-emit-module"
+// CHECK-PCH:  "-fmodules"
+// CHECK-PCH:  "-fmodule-name=ModCommon1"
+// CHECK-PCH:  "-fno-implicit-modules"
+// CHECK-PCH:],
+// CHECK-PCH-NEXT:   "context-hash": "[[HASH_MOD_COMMON_1:.*]]",
+// CHECK-PCH-NEXT:   "file-deps": [
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_1.h",
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "name": "ModCommon1"
+// CHECK-PCH-NEXT: },
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "clang-module-deps": [],
+// CHECK-PCH-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-PCH-NEXT:   "command-line": [
+// CHECK-PCH-NEXT: "-cc1"
+// CHECK-PCH:  "-emit-module"
+// CHECK-PCH:  "-fmodules"
+// CHECK-PCH:  "-fmodule-name=ModCommon2"
+// CHECK-PCH:  "-fno-implicit-modules"
+// CHECK-PCH:],
+// CHECK-PCH-NEXT:   "context-hash": "[[HASH_MOD_COMMON_2:.*]]",
+// CHECK-PCH-NEXT:   "file-deps": [
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_2.h",
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "name": "ModCommon2"
+// CHECK-PCH-NEXT: },
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "clang-module-deps": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "context-hash": "[[HASH_MOD_COMMON_2]]",
+// CHECK-PCH-NEXT:   "module-name": "ModCommon2"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-PCH-NEXT:   "command-line": [
+// CHECK-PCH-NEXT: "-cc1"
+// CHECK-PCH:  "-fmodule-map-file=[[PREFIX]]/module.modulemap"
+// CHECK-PCH:  "-emit-module"
+// CHECK-PCH:  "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm"
+// CHECK-PCH:  "-fmodules"
+// CHECK-PCH:  "-fmodule-name=ModPCH"
+// CHECK-PCH:  "-fno-implicit-modules"
+// CHECK-PCH:],
+// CHECK-PCH-NEXT:   "context-hash": "[[HASH_MOD_PCH:.*]]",
+// CHECK-PCH-NEXT:   "file-deps": [
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_pch.h",
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "name": "ModPCH"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "translation-units": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "clang-context-hash": "[[HASH_PCH:.*]]",
+// CHECK-PCH-N

[clang-tools-extra] 4728aca - [clangd] Drop TestTUs dependency on gtest

2021-06-07 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-06-07T13:25:22+02:00
New Revision: 4728aca9a8adadc34590e3c930dcf8a32593d846

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

LOG: [clangd] Drop TestTUs dependency on gtest

TestTU now prints errors to llvm::errs and aborts on failures via
llvm_unreachable, rather than executing ASSERT_FALSE.

We'd like to make use of these testing libraries in different test suits that
might be compiling with a different gtest version than LLVM has.

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

Added: 


Modified: 
clang-tools-extra/clangd/index/Symbol.cpp
clang-tools-extra/clangd/index/Symbol.h
clang-tools-extra/clangd/unittests/TestTU.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Symbol.cpp 
b/clang-tools-extra/clangd/index/Symbol.cpp
index 4d9fdca6fe9dd..55d61826097d2 100644
--- a/clang-tools-extra/clangd/index/Symbol.cpp
+++ b/clang-tools-extra/clangd/index/Symbol.cpp
@@ -67,5 +67,15 @@ SymbolSlab SymbolSlab::Builder::build() && {
   return SymbolSlab(std::move(NewArena), std::move(SortedSymbols));
 }
 
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolSlab &Slab) {
+  OS << "{";
+  llvm::StringRef Sep = "";
+  for (const auto &S : Slab) {
+OS << Sep << S;
+Sep = ", ";
+  }
+  OS << "}";
+  return OS;
+}
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/index/Symbol.h 
b/clang-tools-extra/clangd/index/Symbol.h
index 2d2644e31a03d..5768877de895e 100644
--- a/clang-tools-extra/clangd/index/Symbol.h
+++ b/clang-tools-extra/clangd/index/Symbol.h
@@ -233,6 +233,8 @@ class SymbolSlab {
   std::vector Symbols;  // Sorted by SymbolID to allow lookup.
 };
 
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolSlab &Slab);
+
 } // namespace clangd
 } // namespace clang
 

diff  --git a/clang-tools-extra/clangd/unittests/TestTU.cpp 
b/clang-tools-extra/clangd/unittests/TestTU.cpp
index 36f4290bd5a3a..335993a18d6f0 100644
--- a/clang-tools-extra/clangd/unittests/TestTU.cpp
+++ b/clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -17,7 +17,9 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/Utils.h"
 #include "llvm/ADT/ScopeExit.h"
-#include "gtest/gtest.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -69,14 +71,19 @@ ParseInputs TestTU::inputs(MockFS &FS) const {
 
 void initializeModuleCache(CompilerInvocation &CI) {
   llvm::SmallString<128> ModuleCachePath;
-  ASSERT_FALSE(
-  llvm::sys::fs::createUniqueDirectory("module-cache", ModuleCachePath));
+  if (llvm::sys::fs::createUniqueDirectory("module-cache", ModuleCachePath)) {
+llvm::errs() << "Failed to create temp directory for module-cache";
+std::abort();
+  }
   CI.getHeaderSearchOpts().ModuleCachePath = ModuleCachePath.c_str();
 }
 
 void deleteModuleCache(const std::string ModuleCachePath) {
   if (!ModuleCachePath.empty()) {
-ASSERT_FALSE(llvm::sys::fs::remove_directories(ModuleCachePath));
+if (llvm::sys::fs::remove_directories(ModuleCachePath)) {
+  llvm::errs() << "Failed to delete temp directory for module-cache";
+  std::abort();
+}
   }
 }
 
@@ -112,14 +119,11 @@ ParsedAST TestTU::build() const {
   auto AST = ParsedAST::build(testPath(Filename), Inputs, std::move(CI),
   Diags.take(), Preamble);
   if (!AST.hasValue()) {
-ADD_FAILURE() << "Failed to build code:\n" << Code;
-llvm_unreachable("Failed to build TestTU!");
-  }
-  if (!AST->getDiagnostics()) {
-ADD_FAILURE() << "TestTU should always build an AST with a fresh Preamble"
-  << Code;
-return std::move(*AST);
+llvm::errs() << "Failed to build code:\n" << Code;
+std::abort();
   }
+  assert(AST->getDiagnostics() &&
+ "TestTU should always build an AST with a fresh Preamble");
   // Check for error diagnostics and report gtest failures (unless expected).
   // This guards against accidental syntax errors silently subverting tests.
   // error-ok is awfully primitive - using clang -verify would be nicer.
@@ -138,11 +142,11 @@ ParsedAST TestTU::build() const {
 // We always build AST with a fresh preamble in TestTU.
 for (const auto &D : *AST->getDiagnostics())
   if (D.Severity >= DiagnosticsEngine::Error) {
-ADD_FAILURE()
+llvm::errs()
 << "TestTU failed to build (suppress with /*error-ok*/): \n"
 << D << "\n\nFor code:\n"
 << Code;
-break; // Just report first error for simplicity.
+std::abort(); // Stop after first error for simplicity.
   }
   }
   return std::move(*AST);
@@ -176,16 +180,16 @@ const Symbol &findSymbol(const SymbolSla

[PATCH] D103685: [clangd] Drop TestTUs dependency on gtest

2021-06-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4728aca9a8ad: [clangd] Drop TestTUs dependency on gtest 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103685

Files:
  clang-tools-extra/clangd/index/Symbol.cpp
  clang-tools-extra/clangd/index/Symbol.h
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -17,7 +17,9 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/Utils.h"
 #include "llvm/ADT/ScopeExit.h"
-#include "gtest/gtest.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -69,14 +71,19 @@
 
 void initializeModuleCache(CompilerInvocation &CI) {
   llvm::SmallString<128> ModuleCachePath;
-  ASSERT_FALSE(
-  llvm::sys::fs::createUniqueDirectory("module-cache", ModuleCachePath));
+  if (llvm::sys::fs::createUniqueDirectory("module-cache", ModuleCachePath)) {
+llvm::errs() << "Failed to create temp directory for module-cache";
+std::abort();
+  }
   CI.getHeaderSearchOpts().ModuleCachePath = ModuleCachePath.c_str();
 }
 
 void deleteModuleCache(const std::string ModuleCachePath) {
   if (!ModuleCachePath.empty()) {
-ASSERT_FALSE(llvm::sys::fs::remove_directories(ModuleCachePath));
+if (llvm::sys::fs::remove_directories(ModuleCachePath)) {
+  llvm::errs() << "Failed to delete temp directory for module-cache";
+  std::abort();
+}
   }
 }
 
@@ -112,14 +119,11 @@
   auto AST = ParsedAST::build(testPath(Filename), Inputs, std::move(CI),
   Diags.take(), Preamble);
   if (!AST.hasValue()) {
-ADD_FAILURE() << "Failed to build code:\n" << Code;
-llvm_unreachable("Failed to build TestTU!");
-  }
-  if (!AST->getDiagnostics()) {
-ADD_FAILURE() << "TestTU should always build an AST with a fresh Preamble"
-  << Code;
-return std::move(*AST);
+llvm::errs() << "Failed to build code:\n" << Code;
+std::abort();
   }
+  assert(AST->getDiagnostics() &&
+ "TestTU should always build an AST with a fresh Preamble");
   // Check for error diagnostics and report gtest failures (unless expected).
   // This guards against accidental syntax errors silently subverting tests.
   // error-ok is awfully primitive - using clang -verify would be nicer.
@@ -138,11 +142,11 @@
 // We always build AST with a fresh preamble in TestTU.
 for (const auto &D : *AST->getDiagnostics())
   if (D.Severity >= DiagnosticsEngine::Error) {
-ADD_FAILURE()
+llvm::errs()
 << "TestTU failed to build (suppress with /*error-ok*/): \n"
 << D << "\n\nFor code:\n"
 << Code;
-break; // Just report first error for simplicity.
+std::abort(); // Stop after first error for simplicity.
   }
   }
   return std::move(*AST);
@@ -176,16 +180,16 @@
 if (QName != (S.Scope + S.Name).str())
   continue;
 if (Result) {
-  ADD_FAILURE() << "Multiple symbols named " << QName << ":\n"
-<< *Result << "\n---\n"
-<< S;
+  llvm::errs() << "Multiple symbols named " << QName << ":\n"
+   << *Result << "\n---\n"
+   << S;
   assert(false && "QName is not unique");
 }
 Result = &S;
   }
   if (!Result) {
-ADD_FAILURE() << "No symbol named " << QName << " in "
-  << ::testing::PrintToString(Slab);
+llvm::errs() << "No symbol named " << QName << " in "
+ << llvm::to_string(Slab);
 assert(false && "No symbol with QName");
   }
   return *Result;
@@ -225,7 +229,7 @@
   Visitor.F = Filter;
   Visitor.TraverseDecl(AST.getASTContext().getTranslationUnitDecl());
   if (Visitor.Decls.size() != 1) {
-ADD_FAILURE() << Visitor.Decls.size() << " symbols matched.";
+llvm::errs() << Visitor.Decls.size() << " symbols matched.";
 assert(Visitor.Decls.size() == 1);
   }
   return *Visitor.Decls.front();
Index: clang-tools-extra/clangd/index/Symbol.h
===
--- clang-tools-extra/clangd/index/Symbol.h
+++ clang-tools-extra/clangd/index/Symbol.h
@@ -233,6 +233,8 @@
   std::vector Symbols;  // Sorted by SymbolID to allow lookup.
 };
 
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolSlab &Slab);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/index/Symbol.cpp
===
--- clang-tools-extra/clangd/index/Symbol.cpp
+++ clang-tools-extra/clangd/index/Symbol.cpp
@@ -67,5 +67,15 @@
   return SymbolSlab(std::move(NewArena

[PATCH] D103773: [clang-cl] Add /permissive and /permissive-

2021-06-07 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

> I think adding /permissive- to make things more conforming is great. The docs 
> say "Starting in Visual Studio 2019 version 16.8, the /std:c++latest option 
> implicitly sets the /permissive- option." so maybe we should do that too 
> (doesn't have to be in this patch).

That's a very good idea, didn't think of that. Should definitely be done.

> Since things seem to mostly work without /permissive (without the -) I'm not 
> sure if we should add support for that. It'll make clang-cl less conforming, 
> and in practice things seem to be fine as-is (…right?). Part of the reason 
> why /permissive- doesn't expand to more flags in clang-cl 
> (https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-160
>  lists a whole bunch more) I imagine is because clang-cl already has the 
> stricter defaults there – which it can do because it's a newer compiler that 
> needs to support less old code.

clang-cl definitely has stricter defaults, and I think it should absolutely 
stay that way. Whether more of the /Zc: conformance options should be added, I 
don't know. But I think /permissive should be there to group them, at least for 
`/Zc:twoPhase`- and `-fno-operator-names`.

Regarding the later, there is actually no equivalent flag for the GNU style 
`-fno-operator-names` in clang-cl currently. In MSVC it's done via /permissive 
and /permissive-. The C++ operator keywords are one of the reason I wrote this 
patch. There is a Windows sdk header, Query.h, which due to a workaround inside 
of clang-cl can be included, but not fully used. It includes a struct that 
looks like the following (from Microsoft Docs):

  c
  struct tagRESTRICTION
  {
   ULONG rt;
   ULONG weight;
   /* [switch_is][switch_type] */ union _URes
   {
   /* [case()] */ NODERESTRICTION ar;
   /* [case()] */ NODERESTRICTION or;  // error C2059: syntax error: 
'||'
   /* [case()] */ NODERESTRICTION pxr;
   /* [case()] */ VECTORRESTRICTION vr;
   /* [case()] */ NOTRESTRICTION nr;
   /* [case()] */ CONTENTRESTRICTION cr;
   /* [case()] */ NATLANGUAGERESTRICTION nlr;
   /* [case()] */ PROPERTYRESTRICTION pr;
   /* [default] */  /* Empty union arm */
   } res;
  };

It includes a field called `or`. A short program that simply has `#include 
` will still compile with clang-cl, but that is due to a sort of 
"hack" here: 
https://github.com/llvm/llvm-project/blob/4f8bc7caf4e5fcc1620b3fd4980ec8d671e9345b/clang/lib/Lex/Preprocessor.cpp#L720.
 Basically any C++ operator keywords inside a system header is treated as 
identifier instead. This has caused quite a lot of issues as can be seen here:
https://bugs.llvm.org/show_bug.cgi?id=42427 and here 
https://github.com/nlohmann/json/issues/1818. It has also caused issues in 
libc++ which contains `and` and `or` in headers, and marks them as system 
header using `#pragma GCC system_header`. 
Additionally, in the Query.h example, if one where to try to access the `or` 
field in the above struct, one will instead get an error, as `or` is treated as 
a keyword in the source file. The MSVC documented way of fixing this would be 
/permissive. 
To be fully transparent however, in the header there is a macro called 
`QUERY_H_RESTRICTION_PERMISSIVE` which allows one to rename the field. This is 
sadly undocumented anywhere else but the header tho.

My intentions with /permissive were to be more consistent with MSVC as well as 
the advice given for the various SDK headers and make it possible to remove the 
above hack. I was going to put that into an additional patch however, as that 
is probably worth a discussion in itself since it's a possibly breaking change 
for users of Query.h.

> Details:
> docs say "You can pass specific /Zc options after /permissive- on the command 
> line to override this behavior" – does that work with this approach? We 
> should have a test for that

The test I added contains tests overwriting `/Zc:twoPhase` for both 
`/permissive` and `/permissive-` at line 11 on wards. I could add more tests if 
needed however.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103773

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


[PATCH] D103772: [clang-cl] Reenable /Zc:twoPhase by default if targetting MSVC 2017 Update 3 or newer

2021-06-07 Thread Markus Böck via Phabricator via cfe-commits
zero9178 abandoned this revision.
zero9178 added a comment.

Thanks for the info, seems like I was mislead after testing it again.


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

https://reviews.llvm.org/D103772

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


[clang] 8b58092 - ExternalASTSource.h - remove unused StringRef and includes. NFCI.

2021-06-07 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-06-07T12:28:31+01:00
New Revision: 8b58092de49b8be964e760c161585665e8d8c48f

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

LOG: ExternalASTSource.h - remove unused StringRef and  includes. NFCI.

Added: 


Modified: 
clang/include/clang/AST/ExternalASTSource.h

Removed: 




diff  --git a/clang/include/clang/AST/ExternalASTSource.h 
b/clang/include/clang/AST/ExternalASTSource.h
index 6ec6edb858e9..b1851afcda37 100644
--- a/clang/include/clang/AST/ExternalASTSource.h
+++ b/clang/include/clang/AST/ExternalASTSource.h
@@ -24,14 +24,12 @@
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/Support/PointerLikeTypeTraits.h"
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 namespace clang {



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


[PATCH] D103472: [clang] Fix a crash during code completion

2021-06-07 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG721476e6b211: [clang] Fix a crash during code completion 
(authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103472

Files:
  clang/lib/Sema/SemaLookup.cpp


Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3835,6 +3835,7 @@
 if (CXXRecordDecl *Class = dyn_cast(Ctx))
   Result.getSema().ForceDeclarationOfImplicitMembers(Class);
 
+llvm::SmallVector DeclsToVisit;
 // We sometimes skip loading namespace-level results (they tend to be 
huge).
 bool Load = LoadExternal ||
 !(isa(Ctx) || isa(Ctx));
@@ -3844,12 +3845,21 @@
   : Ctx->noload_lookups(/*PreserveInternalState=*/false)) {
   for (auto *D : R) {
 if (auto *ND = Result.getAcceptableDecl(D)) {
-  Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
-  Visited.add(ND);
+  // Rather than visit immediatelly, we put ND into a vector and visit
+  // all decls, in order, outside of this loop. The reason is that
+  // Consumer.FoundDecl() may invalidate the iterators used in the two
+  // loops above.
+  DeclsToVisit.push_back(ND);
 }
   }
 }
 
+for (auto *ND : DeclsToVisit) {
+  Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
+  Visited.add(ND);
+}
+DeclsToVisit.clear();
+
 // Traverse using directives for qualified name lookup.
 if (QualifiedNameLookup) {
   ShadowContextRAII Shadow(Visited);


Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3835,6 +3835,7 @@
 if (CXXRecordDecl *Class = dyn_cast(Ctx))
   Result.getSema().ForceDeclarationOfImplicitMembers(Class);
 
+llvm::SmallVector DeclsToVisit;
 // We sometimes skip loading namespace-level results (they tend to be huge).
 bool Load = LoadExternal ||
 !(isa(Ctx) || isa(Ctx));
@@ -3844,12 +3845,21 @@
   : Ctx->noload_lookups(/*PreserveInternalState=*/false)) {
   for (auto *D : R) {
 if (auto *ND = Result.getAcceptableDecl(D)) {
-  Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
-  Visited.add(ND);
+  // Rather than visit immediatelly, we put ND into a vector and visit
+  // all decls, in order, outside of this loop. The reason is that
+  // Consumer.FoundDecl() may invalidate the iterators used in the two
+  // loops above.
+  DeclsToVisit.push_back(ND);
 }
   }
 }
 
+for (auto *ND : DeclsToVisit) {
+  Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
+  Visited.add(ND);
+}
+DeclsToVisit.clear();
+
 // Traverse using directives for qualified name lookup.
 if (QualifiedNameLookup) {
   ShadowContextRAII Shadow(Visited);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 721476e - [clang] Fix a crash during code completion

2021-06-07 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2021-06-07T13:29:58+02:00
New Revision: 721476e6b2119a93033903109b54f429b6e8c91b

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

LOG: [clang] Fix a crash during code completion

During code completion, lookupInDeclContext() calls
CodeCompletionDeclConsumer::FoundDecl(),which can mutate StoredDeclsMap,
over which lookupInDeclContext() iterates. This can lead to invalidation
of iterators and an assert()-crash.

Example code where this happens:
 #include 
 int main() {
   std::list;
   std::^
 }
with code completion on ^ with -std=c++20.

I do not have a repro case that does not need standard library.

This fix stores pointers to NamedDecls in a temporary vector, then
visits them outside of the main loop, when StoredDeclsMap iterators are
gone.

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

Added: 


Modified: 
clang/lib/Sema/SemaLookup.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index db6a01543d76..4b3d7de04bf7 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -3835,6 +3835,7 @@ class LookupVisibleHelper {
 if (CXXRecordDecl *Class = dyn_cast(Ctx))
   Result.getSema().ForceDeclarationOfImplicitMembers(Class);
 
+llvm::SmallVector DeclsToVisit;
 // We sometimes skip loading namespace-level results (they tend to be 
huge).
 bool Load = LoadExternal ||
 !(isa(Ctx) || isa(Ctx));
@@ -3844,12 +3845,21 @@ class LookupVisibleHelper {
   : Ctx->noload_lookups(/*PreserveInternalState=*/false)) {
   for (auto *D : R) {
 if (auto *ND = Result.getAcceptableDecl(D)) {
-  Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
-  Visited.add(ND);
+  // Rather than visit immediatelly, we put ND into a vector and visit
+  // all decls, in order, outside of this loop. The reason is that
+  // Consumer.FoundDecl() may invalidate the iterators used in the two
+  // loops above.
+  DeclsToVisit.push_back(ND);
 }
   }
 }
 
+for (auto *ND : DeclsToVisit) {
+  Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
+  Visited.add(ND);
+}
+DeclsToVisit.clear();
+
 // Traverse using directives for qualified name lookup.
 if (QualifiedNameLookup) {
   ShadowContextRAII Shadow(Visited);



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


[PATCH] D103803: [analyzer] [NFC] Implement a wrapper SValBuilder::getCastedMemRegionVal for similar functionality on region cast

2021-06-07 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: NoQ, steakhal.
ASDenysPetrov added a project: clang.
Herald added subscribers: manas, martong, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.
Herald added a subscriber: cfe-commits.

Replaced code on region cast with a wrapper function 
SValBuilder::getCastedMemRegionVal.
This is a next step of code refining due to suggestions in D103319#2787995 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103803

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp


Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -268,6 +268,13 @@
   return loc::MemRegionVal(BD);
 }
 
+Optional
+SValBuilder::getCastedMemRegionVal(const MemRegion *R, QualType Ty) {
+  if (auto OptR = StateMgr.getStoreManager().castRegion(R, Ty))
+return loc::MemRegionVal(*OptR);
+  return None;
+}
+
 /// Return a memory region for the 'this' object reference.
 loc::MemRegionVal SValBuilder::getCXXThis(const CXXMethodDecl *D,
   const StackFrameContext *SFC) {
@@ -753,16 +760,16 @@
 if (const auto *SR = dyn_cast(R)) {
   QualType SRTy = SR->getSymbol()->getType();
   if (!hasSameUnqualifiedPointeeType(SRTy, CastTy)) {
-if (auto OptR = StateMgr.getStoreManager().castRegion(SR, CastTy))
-  return loc::MemRegionVal(*OptR);
+if (auto OptMemRegV = getCastedMemRegionVal(SR, CastTy))
+  return *OptMemRegV;
   }
 }
   }
   // Next fixes pointer dereference using type different from its initial
   // one. See PR37503 and PR49007 for details.
   if (const auto *ER = dyn_cast(R)) {
-if (auto OptR = StateMgr.getStoreManager().castRegion(ER, CastTy))
-  return loc::MemRegionVal(*OptR);
+if (auto OptMemRegV = getCastedMemRegionVal(ER, CastTy))
+  return *OptMemRegV;
   }
 
   return V;
@@ -807,8 +814,8 @@
 
 // Get the result of casting a region to a different type.
 const MemRegion *R = V.getRegion();
-if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
-  return loc::MemRegionVal(*OptR);
+if (auto OptMemRegV = getCastedMemRegionVal(R, CastTy))
+  return *OptMemRegV;
   }
 
   // Pointer to whatever else.
@@ -873,8 +880,8 @@
   if (!IsUnknownOriginalType && Loc::isLocType(CastTy) &&
   OriginalTy->isIntegralOrEnumerationType()) {
 if (const MemRegion *R = L.getAsRegion())
-  if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
-return loc::MemRegionVal(*OptR);
+  if (auto OptMemRegV = getCastedMemRegionVal(R, CastTy))
+return *OptMemRegV;
 return L;
   }
 
@@ -890,8 +897,8 @@
   // Delegate to store manager to get the result of casting a region to a
   // different type. If the MemRegion* returned is NULL, this expression
   // Evaluates to UnknownVal.
-  if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
-return loc::MemRegionVal(*OptR);
+  if (auto OptMemRegV = getCastedMemRegionVal(R, CastTy))
+return *OptMemRegV;
 }
   } else {
 if (Loc::isLocType(CastTy)) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -380,6 +380,10 @@
 return loc::ConcreteInt(BasicVals.getValue(integer));
   }
 
+  /// Return MemRegionVal on success cast, otherwise return None.
+  Optional getCastedMemRegionVal(const MemRegion *region,
+QualType type);
+
   /// Make an SVal that represents the given symbol. This follows the 
convention
   /// of representing Loc-type symbols (symbolic pointers and references)
   /// as Loc values wrapping the symbol rather than as plain symbol values.


Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -268,6 +268,13 @@
   return loc::MemRegionVal(BD);
 }
 
+Optional
+SValBuilder::getCastedMemRegionVal(const MemRegion *R, QualType Ty) {
+  if (auto OptR = StateMgr.getStoreManager().castRegion(R, Ty))
+return loc::MemRegionVal(*OptR);
+  return None;
+}
+
 /// Return a memory region for the 'this' object reference.
 loc::MemRegionVal SValBuilder::getCXXThis(const CXXMethodDecl *D,
   

[PATCH] D103393: [clangd] Bump recommended gRPC version (1.33.2 -> 1.36.3)

2021-06-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.

looks like the https://lab.llvm.org/buildbot/#/builders/131 is green after the 
version bump. thanks for taking care of this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103393

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


[PATCH] D103773: [clang-cl] Add /permissive and /permissive-

2021-06-07 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Since it's motivated by a concrete file, this makes sense to me. Wait maybe a 
day or so to see if anyone objects, but I think this (and dependencies) are 
good.

Do you have commit access?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103773

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


[PATCH] D103771: [clang][msvc] Define _HAS_STATIC_RTTI to 0, when compiling with -fno-rtti

2021-06-07 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

(same comment as on https://reviews.llvm.org/D103773)


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

https://reviews.llvm.org/D103771

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


[PATCH] D103806: [SystemZ][z/OS] Pass OpenFlags when creating tmp files

2021-06-07 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added subscribers: dexonsmith, hiraditya.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch https://reviews.llvm.org/D102876 caused some lit regressions on z/OS 
because tmp files were no longer being opened based on binary/text mode. This 
patch passes OpenFlags when creating tmp files so we can open files in 
different modes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103806

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/Support/Path.cpp


Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -1288,11 +1288,11 @@
   return Error::success();
 }
 
-Expected TempFile::create(const Twine &Model, unsigned Mode) {
+Expected TempFile::create(const Twine &Model, unsigned Mode,
+OpenFlags Flags) {
   int FD;
   SmallString<128> ResultPath;
-  if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  if (std::error_code EC = createUniqueFile(Model, FD, ResultPath, Flags, 
Mode))
 return errorCodeToError(EC);
 
   TempFile Ret(ResultPath, FD);
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -857,7 +857,8 @@
   /// This creates a temporary file with createUniqueFile and schedules it for
   /// deletion with sys::RemoveFileOnSignal.
   static Expected create(const Twine &Model,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags Flags = OF_Delete);
   TempFile(TempFile &&Other);
   TempFile &operator=(TempFile &&Other);
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -828,7 +828,10 @@
 TempPath += OutputExtension;
 TempPath += ".tmp";
 Expected ExpectedFile =
-llvm::sys::fs::TempFile::create(TempPath);
+llvm::sys::fs::TempFile::create(
+TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+llvm::sys::fs::OF_Delete |
+(Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text));
 
 llvm::Error E = handleErrors(
 ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error {


Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -1288,11 +1288,11 @@
   return Error::success();
 }
 
-Expected TempFile::create(const Twine &Model, unsigned Mode) {
+Expected TempFile::create(const Twine &Model, unsigned Mode,
+OpenFlags Flags) {
   int FD;
   SmallString<128> ResultPath;
-  if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  if (std::error_code EC = createUniqueFile(Model, FD, ResultPath, Flags, Mode))
 return errorCodeToError(EC);
 
   TempFile Ret(ResultPath, FD);
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -857,7 +857,8 @@
   /// This creates a temporary file with createUniqueFile and schedules it for
   /// deletion with sys::RemoveFileOnSignal.
   static Expected create(const Twine &Model,
-   unsigned Mode = all_read | all_write);
+   unsigned Mode = all_read | all_write,
+   OpenFlags Flags = OF_Delete);
   TempFile(TempFile &&Other);
   TempFile &operator=(TempFile &&Other);
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -828,7 +828,10 @@
 TempPath += OutputExtension;
 TempPath += ".tmp";
 Expected ExpectedFile =
-llvm::sys::fs::TempFile::create(TempPath);
+llvm::sys::fs::TempFile::create(
+TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+llvm::sys::fs::OF_Delete |
+(Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text));
 
 llvm::Error E = handleErrors(
 ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bi

[PATCH] D103789: [clangd] Type hints for C++14 return type deduction

2021-06-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:79
+  if (!Deduced.isNull()) {
+SourceRange R = D->getReturnTypeSourceRange();
+// For operator auto(), have to get location of `auto` a different way.

nit: bool TrailingReturnType = D->getReturnTypeSourceRange().isValid()?



Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:505
+  )cpp",
+  ExpectedHint{": int", "ret1a"}, ExpectedHint{": int", "ret1b"},
+  ExpectedHint{": int &", "ret2"}, ExpectedHint{": int", "retConv"});

This reads as "auto[: int] f1(int x);", which doesn't look much like familiar 
syntax, C++ or otherwise.

I guess we could try `auto f1(int x)[-> int];`?

(From playing with these in vscode, I'm not sure I find the punctuation very 
useful)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103789

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


[PATCH] D103807: [clang][deps] Ensure deterministic order of TU '-fmodule-file=' arguments

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

Translation units with multiple direct modular dependencies trigger a 
non-deterministic ordering in `clang-scan-deps`. This boils down to usage of 
`std::unordered_map`, which gets replaced by `std::map` in this patch.

Depends on D103526 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103807

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/test/ClangScanDeps/modules-pch.c


Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -87,9 +87,9 @@
 // CHECK-PCH-NEXT:   "command-line": [
 // CHECK-PCH-NEXT: "-fno-implicit-modules",
 // CHECK-PCH-NEXT: "-fno-implicit-module-maps",
-// CHECK-PCH-DAG:  
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
-// CHECK-PCH-DAG:  
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
-// CHECK-PCH-DAG:  
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
+// CHECK-PCH-NEXT: 
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
+// CHECK-PCH-NEXT: 
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
+// CHECK-PCH-NEXT: 
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -177,7 +177,7 @@
   private:
 std::vector Dependencies;
 std::vector PrebuiltModuleDeps;
-std::unordered_map ClangModuleDeps;
+std::map ClangModuleDeps;
 std::string ContextHash;
 std::vector OutputPaths;
 const llvm::StringSet<> &AlreadySeen;


Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -87,9 +87,9 @@
 // CHECK-PCH-NEXT:   "command-line": [
 // CHECK-PCH-NEXT: "-fno-implicit-modules",
 // CHECK-PCH-NEXT: "-fno-implicit-module-maps",
-// CHECK-PCH-DAG:  "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
-// CHECK-PCH-DAG:  "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
-// CHECK-PCH-DAG:  "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -177,7 +177,7 @@
   private:
 std::vector Dependencies;
 std::vector PrebuiltModuleDeps;
-std::unordered_map ClangModuleDeps;
+std::map ClangModuleDeps;
 std::string ContextHash;
 std::vector OutputPaths;
 const llvm::StringSet<> &AlreadySeen;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102760: [llvm] Let SmallVector construct from any Iterable

2021-06-07 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

@gchatelet: Thanks for the link to D102679  — 
that seems like very relevant background info I didn't have!  Having looked 
through D102679 , though, I don't see how it 
would benefit from D102760  — in fact, 
D102679  updates some tests to wisely 
//stop// depending on the ability to construct `SmallVector` from a range (and 
goes to using begin/end pairs instead — good!).
So I think D102679  is a good idea (modulo 
the review comments I just left), and I continue to think that this D102760 
 is a bad idea that should be abandoned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102760

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


[PATCH] D102723: [HIP] Tighten checks in hip-include-path.hip test case

2021-06-07 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D102723#2790047 , @bjope wrote:

> I relaxed the checks a bit again here: https://reviews.llvm.org/rGf0e10cc91bc4
> But it looks like the workers here 
> (https://lab.llvm.org/staging/#/workers/109) are paused so hard to tell if it 
> helped.

It helped; thanks. The bot has come back green: 
https://lab.llvm.org/staging/#/builders/126/builds/557


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102723

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


[PATCH] D99540: [clangd] Preserve diags between tweak enumeration and execution

2021-06-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D99540#2799159 , @kadircet wrote:

>> Sorry I've lost my context - did we decide to move forward with this patch?
>
> I don't think we've came to a conclusion, just decided to postpone until 
> needed. I believe the `cases` design is really a good fit for making tweaks 
> expose multiple code actions.
>
> But we've actually missed one thing while discussing this patch. It actually 
> allows data from `clang::Diagnostic` to be stashed into `clangd::Diag` for 
> use later on. Modules can actually stash this info while the AST is being 
> built, later on they can be retrieved directly from the 
> `ParsedAST::getDiagnostics()`. But this creates the N*M problem again, and 
> feels like a hack.
> What we can do instead is during `enumerateTweak`, we can group `data` in 
> diagnostics (making sure `data` stored in `diagnostic` is keyed by 
> `tweak::id`) and pass an additional array of json objects in 
> `tweak::prepare`.  This will make the problem N+M again and make the data 
> passing explicit.

Sorry, somehow I'm not following this (either the problem or the suggestion at 
all). Let's chat this week about it...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99540

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


[PATCH] D103773: [clang-cl] Add /permissive and /permissive-

2021-06-07 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

I shall do that.

I do have commit access, but thanks for asking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103773

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


[clang-tools-extra] ddda05a - [clang][NFC] Break out BaseUsingDecl from UsingDecl

2021-06-07 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2021-06-07T06:29:28-07:00
New Revision: ddda05add527f7f92a71f387b927f237334f46d9

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

LOG: [clang][NFC] Break out BaseUsingDecl from UsingDecl

This is a pre-patch for adding using-enum support.  It breaks out
the shadow decl handling of UsingDecl to a new intermediate base
class, BaseUsingDecl, altering the decl hierarchy to

def BaseUsing : DeclNode;
  def Using : DeclNode;
def UsingPack : DeclNode;
def UsingShadow : DeclNode;
  def ConstructorUsingShadow : DeclNode;

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DeclNodes.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/Sema/SemaAccess.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index c8eca4e7ca8c7..9068fffcbd402 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -193,9 +193,9 @@ struct TargetFinder {
   }
   Flags |= Rel::Alias; // continue with the alias
 } else if (const UsingShadowDecl *USD = dyn_cast(D)) {
-  // Include the using decl, but don't traverse it. This may end up
+  // Include the Introducing decl, but don't traverse it. This may end up
   // including *all* shadows, which we don't want.
-  report(USD->getUsingDecl(), Flags | Rel::Alias);
+  report(USD->getIntroducer(), Flags | Rel::Alias);
   // Shadow decls are synthetic and not themselves interesting.
   // Record the underlying decl instead, if allowed.
   D = USD->getTargetDecl();

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 5c7cdd67e3d32..c8095bb2ca2b3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -69,6 +69,7 @@ class FriendDecl;
 class FunctionTemplateDecl;
 class IdentifierInfo;
 class MemberSpecializationInfo;
+class BaseUsingDecl;
 class TemplateDecl;
 class TemplateParameterList;
 class UsingDecl;
@@ -3163,21 +3164,27 @@ class LifetimeExtendedTemporaryDecl final
   }
 };
 
-/// Represents a shadow declaration introduced into a scope by a
-/// (resolved) using declaration.
+/// Represents a shadow declaration implicitly introduced into a scope by a
+/// (resolved) using-declaration or using-enum-declaration to achieve
+/// the desired lookup semantics.
 ///
-/// For example,
+/// For example:
 /// \code
 /// namespace A {
 ///   void foo();
+///   void foo(int);
+///   struct foo {};
+///   enum bar { bar1, bar2 };
 /// }
 /// namespace B {
-///   using A::foo; // <- a UsingDecl
-/// // Also creates a UsingShadowDecl for A::foo() in B
+///   // add a UsingDecl and three UsingShadowDecls (named foo) to B.
+///   using A::foo;
+///   // adds UsingEnumDecl and two UsingShadowDecls (named bar1 and bar2) to 
B.
+///   using enum A::bar;
 /// }
 /// \endcode
 class UsingShadowDecl : public NamedDecl, public Redeclarable 
{
-  friend class UsingDecl;
+  friend class BaseUsingDecl;
 
   /// The referenced declaration.
   NamedDecl *Underlying = nullptr;
@@ -3204,7 +3211,8 @@ class UsingShadowDecl : public NamedDecl, public 
Redeclarable {
 
 protected:
   UsingShadowDecl(Kind K, ASTContext &C, DeclContext *DC, SourceLocation Loc,
-  UsingDecl *Using, NamedDecl *Target);
+  DeclarationName Name, BaseUsingDecl *Introducer,
+  NamedDecl *Target);
   UsingShadowDecl(Kind K, ASTContext &C, EmptyShell);
 
 public:
@@ -3212,9 +3220,10 @@ class UsingShadowDecl : public NamedDecl, public 
Redeclarable {
   friend class ASTDeclWriter;
 
   static UsingShadowDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation Loc, UsingDecl *Using,
- NamedDecl *Target) {
-return new (C, DC) UsingShadowDecl(UsingShadow, C, DC, Loc, Using, Target);
+ SourceLocation Loc, DeclarationName Name,
+ BaseUsingDecl *Introducer, NamedDecl *Target) 
{
+return new (C, DC)
+UsingShadowDecl(UsingShadow, C, DC, Loc, Name, Introducer, Target);
   }
 
   static UsingShadowDecl *CreateDeserialized(ASTContext &C, unsigned ID);
@@ -3252,8 +3261,9 @@ class UsingShadowDecl : public NamedDecl, public 
Redeclarable {
  

[PATCH] D101777: [clang] p1099 1/5: [NFC] Break out BaseUsingDecl from UsingDecl

2021-06-07 Thread Nathan Sidwell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
urnathan marked an inline comment as done.
Closed by commit rGddda05add527: [clang][NFC] Break out BaseUsingDecl from 
UsingDecl (authored by urnathan).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101777

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Sema/SemaAccess.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6541,7 +6541,7 @@
   }
 
   case Decl::Using:
-return MakeCursorOverloadedDeclRef(cast(D), D->getLocation(),
+return MakeCursorOverloadedDeclRef(cast(D), D->getLocation(),
TU);
 
   case Decl::UsingShadow:
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1870,7 +1870,7 @@
   Diag(KWLoc, diag::err_using_decl_conflict_reverse);
   Diag(Shadow->getTargetDecl()->getLocation(),
diag::note_using_decl_target);
-  Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
+  Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl) << 0;
   // Recover by ignoring the old declaration.
   PrevDecl = PrevClassTemplate = nullptr;
 }
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3732,7 +3732,7 @@
   // A shadow declaration that's created by a resolved using declaration
   // is not hidden by the same using declaration.
   if (isa(ND) && isa(D) &&
-  cast(ND)->getUsingDecl() == D)
+  cast(ND)->getIntroducer() == D)
 continue;
 
   // We've found a declaration that hides this one.
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7000,7 +7000,7 @@
   : S(S), UseLoc(UseLoc) {
 bool DiagnosedMultipleConstructedBases = false;
 CXXRecordDecl *ConstructedBase = nullptr;
-UsingDecl *ConstructedBaseUsing = nullptr;
+BaseUsingDecl *ConstructedBaseIntroducer = nullptr;
 
 // Find the set of such base class subobjects and check that there's a
 // unique constructed subobject.
@@ -7024,18 +7024,18 @@
   //   of type B, the program is ill-formed.
   if (!ConstructedBase) {
 ConstructedBase = DConstructedBase;
-ConstructedBaseUsing = D->getUsingDecl();
+ConstructedBaseIntroducer = D->getIntroducer();
   } else if (ConstructedBase != DConstructedBase &&
  !Shadow->isInvalidDecl()) {
 if (!DiagnosedMultipleConstructedBases) {
   S.Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
   << Shadow->getTargetDecl();
-  S.Diag(ConstructedBaseUsing->getLocation(),
-   diag::note_ambiguous_inherited_constructor_using)
+  S.Diag(ConstructedBaseIntroducer->getLocation(),
+ diag::note_ambiguous_inherited_constructor_using)
   << ConstructedBase;
   DiagnosedMultipleConstructedBases = true;
 }
-S.Diag(D->getUsingDecl()->getLocation(),
+S.Diag(D->getIntroducer()->getLocation(),
diag::note_ambiguous_inherited_constructor_using)
 << DConstructedBase;
   }
@@ -11640,7 +11640,7 @@
 
 /// Determines whether to create a using shadow decl for a particular
 /// decl, given the set of decls existing prior to this using lookup.
-bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig,
+bool Sema::CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Orig,
 const LookupResult &Previous,
 UsingShadowDecl *&PrevShadow) {
   // Diagnose finding a decl which is not from a base class of the
@@ -11662,35 +11662,36 @@
   // specialization.  The UsingShadowDecl in D then points directly
   // to A::foo, which will look well-formed when we instantiate.
   // The right solution is to not collapse the shadow-decl chain.
-  if (!getLangOpts().CPlusPlus11 && CurContext->isRecord()) {
-DeclContext *OrigDC = Orig->getDeclContext();
-
-// Handle enums and anonymous structs.
-if (i

[clang] 84ab315 - [clang][NFC] Break out enum completion from other type context completion

2021-06-07 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2021-06-07T06:29:29-07:00
New Revision: 84ab315574099dcac8f9fb89fe8558f8ccfbce5f

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

LOG: [clang][NFC] Break out enum completion from other type context completion

This prepatch for using-enum breaks out the enum completion that that
will need from the existing scope completion logic.

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCXXScopeSpec.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 57be1cb6d21c3..4e6d73cbc1aff 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6399,6 +6399,9 @@ class Sema final {
 
   // Marks SS invalid if it represents an incomplete type.
   bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC);
+  // Complete an enum decl, maybe without a scope spec.
+  bool RequireCompleteEnumDecl(EnumDecl *D, SourceLocation L,
+   CXXScopeSpec *SS = nullptr);
 
   DeclContext *computeDeclContext(QualType T);
   DeclContext *computeDeclContext(const CXXScopeSpec &SS,

diff  --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp 
b/clang/lib/Sema/SemaCXXScopeSpec.cpp
index a4421d2b68af3..87059eb450858 100644
--- a/clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -227,12 +227,20 @@ bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS,
 return true;
   }
 
-  // Fixed enum types are complete, but they aren't valid as scopes
-  // until we see a definition, so awkwardly pull out this special
-  // case.
-  auto *EnumD = dyn_cast(tag);
-  if (!EnumD)
-return false;
+  if (auto *EnumD = dyn_cast(tag))
+// Fixed enum types and scoped enum instantiations are complete, but they
+// aren't valid as scopes until we see or instantiate their definition.
+return RequireCompleteEnumDecl(EnumD, loc, &SS);
+
+  return false;
+}
+
+/// Require that the EnumDecl is completed with its enumerators defined or
+/// instantiated. SS, if provided, is the ScopeRef parsed.
+///
+bool Sema::RequireCompleteEnumDecl(EnumDecl *EnumD, SourceLocation L,
+   CXXScopeSpec *SS) {
+  assert (SS && "missing scope");
   if (EnumD->isCompleteDefinition()) {
 // If we know about the definition but it is not visible, complain.
 NamedDecl *SuggestedDef = nullptr;
@@ -241,8 +249,8 @@ bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS,
   // If the user is going to see an error here, recover by making the
   // definition visible.
   bool TreatAsComplete = !isSFINAEContext();
-  diagnoseMissingImport(loc, SuggestedDef, MissingImportKind::Definition,
-/*Recover*/TreatAsComplete);
+  diagnoseMissingImport(L, SuggestedDef, MissingImportKind::Definition,
+/*Recover*/ TreatAsComplete);
   return !TreatAsComplete;
 }
 return false;
@@ -253,19 +261,20 @@ bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS,
   if (EnumDecl *Pattern = EnumD->getInstantiatedFromMemberEnum()) {
 MemberSpecializationInfo *MSI = EnumD->getMemberSpecializationInfo();
 if (MSI->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) {
-  if (InstantiateEnum(loc, EnumD, Pattern,
+  if (InstantiateEnum(L, EnumD, Pattern,
   getTemplateInstantiationArgs(EnumD),
   TSK_ImplicitInstantiation)) {
-SS.SetInvalid(SS.getRange());
+SS->SetInvalid(SS->getRange());
 return true;
   }
   return false;
 }
   }
 
-  Diag(loc, diag::err_incomplete_nested_name_spec)
-<< type << SS.getRange();
-  SS.SetInvalid(SS.getRange());
+  Diag(L, diag::err_incomplete_nested_name_spec)
+  << QualType(EnumD->getTypeForDecl(), 0) << SS->getRange();
+  SS->SetInvalid(SS->getRange());
+
   return true;
 }
 



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


[PATCH] D102239: [clang][NFC] p1099 2/5: Break out enum completion from context completion

2021-06-07 Thread Nathan Sidwell via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG84ab31557409: [clang][NFC] Break out enum completion from 
other type context completion (authored by urnathan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102239

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCXXScopeSpec.cpp


Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -227,12 +227,20 @@
 return true;
   }
 
-  // Fixed enum types are complete, but they aren't valid as scopes
-  // until we see a definition, so awkwardly pull out this special
-  // case.
-  auto *EnumD = dyn_cast(tag);
-  if (!EnumD)
-return false;
+  if (auto *EnumD = dyn_cast(tag))
+// Fixed enum types and scoped enum instantiations are complete, but they
+// aren't valid as scopes until we see or instantiate their definition.
+return RequireCompleteEnumDecl(EnumD, loc, &SS);
+
+  return false;
+}
+
+/// Require that the EnumDecl is completed with its enumerators defined or
+/// instantiated. SS, if provided, is the ScopeRef parsed.
+///
+bool Sema::RequireCompleteEnumDecl(EnumDecl *EnumD, SourceLocation L,
+   CXXScopeSpec *SS) {
+  assert (SS && "missing scope");
   if (EnumD->isCompleteDefinition()) {
 // If we know about the definition but it is not visible, complain.
 NamedDecl *SuggestedDef = nullptr;
@@ -241,8 +249,8 @@
   // If the user is going to see an error here, recover by making the
   // definition visible.
   bool TreatAsComplete = !isSFINAEContext();
-  diagnoseMissingImport(loc, SuggestedDef, MissingImportKind::Definition,
-/*Recover*/TreatAsComplete);
+  diagnoseMissingImport(L, SuggestedDef, MissingImportKind::Definition,
+/*Recover*/ TreatAsComplete);
   return !TreatAsComplete;
 }
 return false;
@@ -253,19 +261,20 @@
   if (EnumDecl *Pattern = EnumD->getInstantiatedFromMemberEnum()) {
 MemberSpecializationInfo *MSI = EnumD->getMemberSpecializationInfo();
 if (MSI->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) {
-  if (InstantiateEnum(loc, EnumD, Pattern,
+  if (InstantiateEnum(L, EnumD, Pattern,
   getTemplateInstantiationArgs(EnumD),
   TSK_ImplicitInstantiation)) {
-SS.SetInvalid(SS.getRange());
+SS->SetInvalid(SS->getRange());
 return true;
   }
   return false;
 }
   }
 
-  Diag(loc, diag::err_incomplete_nested_name_spec)
-<< type << SS.getRange();
-  SS.SetInvalid(SS.getRange());
+  Diag(L, diag::err_incomplete_nested_name_spec)
+  << QualType(EnumD->getTypeForDecl(), 0) << SS->getRange();
+  SS->SetInvalid(SS->getRange());
+
   return true;
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -6399,6 +6399,9 @@
 
   // Marks SS invalid if it represents an incomplete type.
   bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC);
+  // Complete an enum decl, maybe without a scope spec.
+  bool RequireCompleteEnumDecl(EnumDecl *D, SourceLocation L,
+   CXXScopeSpec *SS = nullptr);
 
   DeclContext *computeDeclContext(QualType T);
   DeclContext *computeDeclContext(const CXXScopeSpec &SS,


Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -227,12 +227,20 @@
 return true;
   }
 
-  // Fixed enum types are complete, but they aren't valid as scopes
-  // until we see a definition, so awkwardly pull out this special
-  // case.
-  auto *EnumD = dyn_cast(tag);
-  if (!EnumD)
-return false;
+  if (auto *EnumD = dyn_cast(tag))
+// Fixed enum types and scoped enum instantiations are complete, but they
+// aren't valid as scopes until we see or instantiate their definition.
+return RequireCompleteEnumDecl(EnumD, loc, &SS);
+
+  return false;
+}
+
+/// Require that the EnumDecl is completed with its enumerators defined or
+/// instantiated. SS, if provided, is the ScopeRef parsed.
+///
+bool Sema::RequireCompleteEnumDecl(EnumDecl *EnumD, SourceLocation L,
+   CXXScopeSpec *SS) {
+  assert (SS && "missing scope");
   if (EnumD->isCompleteDefinition()) {
 // If we know about the definition but it is not visible, complain.
 NamedDecl *SuggestedDef = nullptr;
@@ -241,8 +249,8 @@
   // If the user is going to see 

[clang-tools-extra] d12000c - [clangd] Bump recommended gRPC version (1.33.2 -> 1.36.3)

2021-06-07 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-06-07T15:36:33+02:00
New Revision: d12000ca55d1cc8bc07f75457e3b4efbcd8ff657

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

LOG: [clangd] Bump recommended gRPC version (1.33.2 -> 1.36.3)

Context: https://github.com/clangd/clangd/pull/783

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/README.md

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/README.md 
b/clang-tools-extra/clangd/index/remote/README.md
index 0f9c01ab4bd53..5ae4dc98c906e 100644
--- a/clang-tools-extra/clangd/index/remote/README.md
+++ b/clang-tools-extra/clangd/index/remote/README.md
@@ -35,7 +35,7 @@ can easily uninstall gRPC or use 
diff erent versions.
 
 ```bash
 # Get source code.
-$ git clone -b v1.33.2 https://github.com/grpc/grpc
+$ git clone -b v1.36.3 https://github.com/grpc/grpc
 $ cd grpc
 $ git submodule update --init
 # Choose directory where you want gRPC installation to live.



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


[PATCH] D103393: [clangd] Bump recommended gRPC version (1.33.2 -> 1.36.3)

2021-06-07 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Changes 
Planned".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd12000ca55d1: [clangd] Bump recommended gRPC version (1.33.2 
-> 1.36.3) (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103393

Files:
  clang-tools-extra/clangd/index/remote/README.md


Index: clang-tools-extra/clangd/index/remote/README.md
===
--- clang-tools-extra/clangd/index/remote/README.md
+++ clang-tools-extra/clangd/index/remote/README.md
@@ -35,7 +35,7 @@
 
 ```bash
 # Get source code.
-$ git clone -b v1.33.2 https://github.com/grpc/grpc
+$ git clone -b v1.36.3 https://github.com/grpc/grpc
 $ cd grpc
 $ git submodule update --init
 # Choose directory where you want gRPC installation to live.


Index: clang-tools-extra/clangd/index/remote/README.md
===
--- clang-tools-extra/clangd/index/remote/README.md
+++ clang-tools-extra/clangd/index/remote/README.md
@@ -35,7 +35,7 @@
 
 ```bash
 # Get source code.
-$ git clone -b v1.33.2 https://github.com/grpc/grpc
+$ git clone -b v1.36.3 https://github.com/grpc/grpc
 $ cd grpc
 $ git submodule update --init
 # Choose directory where you want gRPC installation to live.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103807: [clang][deps] Ensure deterministic order of TU '-fmodule-file=' arguments

2021-06-07 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

llvm discourages the use of std::map:
https://llvm.org/docs/ProgrammersManual.html#map


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103807

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


[PATCH] D103809: [Clang][RISCV] Implement vloxseg and vluxseg.

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

Some test cases are not uploaded due to the size exceeds the limit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103809

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg.c

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


[PATCH] D101777: [clang] p1099 1/5: [NFC] Break out BaseUsingDecl from UsingDecl

2021-06-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

It seems this patch caused build failure:

FAILED: tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclCXX.cpp.o 
/usr/bin/c++ -DCLANG_ROUND_TRIP_CC1_ARGS=ON -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools/clang/lib/Sema 
-I/buildbot/llvm-project/clang/lib/Sema -I/buildbot/llvm-project/clang/include 
-Itools/clang/include -Iinclude -I/buildbot/llvm-project/llvm/include -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall 
-Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections 
-fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 
-DNDEBUG  -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclCXX.cpp.o -MF 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclCXX.cpp.o.d -o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclCXX.cpp.o -c 
/buildbot/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp
/buildbot/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp: In member function ‘bool 
clang::Sema::CheckUsingShadowDecl(clang::BaseUsingDecl*, clang::NamedDecl*, 
const clang::LookupResult&, clang::UsingShadowDecl*&)’:
/buildbot/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:11754:10: error: ‘Using’ 
was not declared in this scope

  Diag(Using->getLocation(), diag::err_using_decl_conflict);
   ^

/buildbot/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:11754:10: note: suggested 
alternative: ‘sinl’

  Diag(Using->getLocation(), diag::err_using_decl_conflict);
   ^
   sinl

https://lab.llvm.org/buildbot/#/builders/165/builds/1401


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101777

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


[PATCH] D101777: [clang] p1099 1/5: [NFC] Break out BaseUsingDecl from UsingDecl

2021-06-07 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added a comment.

In D101777#2802669 , @yaxunl wrote:

> It seems this patch caused build failure:

Yeah, I've pushed a fix -- I'd attached the fix to the wrong diff in the stack 
:(  Should be good now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101777

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


[clang] e1da329 - [flang][driver] Add support for the "-init-only" option

2021-06-07 Thread Andrzej Warzynski via cfe-commits

Author: Stuart Ellis
Date: 2021-06-07T15:40:26+01:00
New Revision: e1da3297d253b33be1ff941cf9ed9091dd332ea5

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

LOG: [flang][driver] Add support for the "-init-only" option

Adding the `-init-only` option and corresponding frontend action to
generate a diagnostic.

`-init-only` vs `-test-io`:
`-init-only` ignores the input (it never calls the prescanner)
`-test-io` is similar to `-init-only`, but does read and print the input
without calling the prescanner.

This patch also adds a Driver test to check this action.

Reviewed By: awarzynski, AMDChirag

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

Added: 
flang/test/Driver/init-only.f90

Modified: 
clang/include/clang/Driver/Options.td
flang/include/flang/Frontend/FrontendActions.h
flang/include/flang/Frontend/FrontendOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
flang/test/Driver/driver-help.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c2945fb0bf184..c92348d040712 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5273,8 +5273,6 @@ def analyze : Flag<["-"], "analyze">,
   HelpText<"Run static analysis engine">;
 def dump_tokens : Flag<["-"], "dump-tokens">,
   HelpText<"Run preprocessor, dump internal rep of tokens">;
-def init_only : Flag<["-"], "init-only">,
-  HelpText<"Only execute frontend initialization">;
 def fixit : Flag<["-"], "fixit">,
   HelpText<"Apply fix-it advice to the input source">;
 def fixit_EQ : Joined<["-"], "fixit=">,
@@ -5740,6 +5738,8 @@ let Group = Action_Group in {
 
 def emit_obj : Flag<["-"], "emit-obj">,
   HelpText<"Emit native object files">;
+def init_only : Flag<["-"], "init-only">,
+  HelpText<"Only execute frontend initialization">;
 
 } // let Group = Action_Group
 } // let Flags = [CC1Option, FC1Option, NoDriverOption]

diff  --git a/flang/include/flang/Frontend/FrontendActions.h 
b/flang/include/flang/Frontend/FrontendActions.h
index 619e83ad88c77..7a88382075741 100644
--- a/flang/include/flang/Frontend/FrontendActions.h
+++ b/flang/include/flang/Frontend/FrontendActions.h
@@ -38,6 +38,10 @@ class EmitObjAction : public FrontendAction {
   void ExecuteAction() override;
 };
 
+class InitOnlyAction : public FrontendAction {
+  void ExecuteAction() override;
+};
+
 
//===--===//
 // Prescan Actions
 
//===--===//

diff  --git a/flang/include/flang/Frontend/FrontendOptions.h 
b/flang/include/flang/Frontend/FrontendOptions.h
index e18fd961a55b0..9c34abb68f2d6 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -71,7 +71,10 @@ enum ActionKind {
   GetDefinition,
 
   /// Parse, run semantics and then dump symbol sources map
-  GetSymbolsSources
+  GetSymbolsSources,
+
+  /// Only execute frontend initialization
+  InitOnly
 
   /// TODO: RunPreprocessor, EmitLLVM, EmitLLVMOnly,
   /// EmitCodeGenOnly, EmitAssembly, (...)

diff  --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 6d9a3a7f31947..5098da42dfc0f 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -162,9 +162,12 @@ static bool ParseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
 case clang::driver::options::OPT_fget_definition:
   opts.programAction_ = GetDefinition;
   break;
+case clang::driver::options::OPT_init_only:
+  opts.programAction_ = InitOnly;
+  break;
 
   // TODO:
-  // case calng::driver::options::OPT_emit_llvm:
+  // case clang::driver::options::OPT_emit_llvm:
   // case clang::driver::options::OPT_emit_llvm_only:
   // case clang::driver::options::OPT_emit_codegen_only:
   // case clang::driver::options::OPT_emit_module:

diff  --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index de8a02753391b..f4ba515440d9b 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -447,3 +447,11 @@ void EmitObjAction::ExecuteAction() {
   clang::DiagnosticsEngine::Error, "code-generation is not available yet");
   ci.diagnostics().Report(DiagID);
 }
+
+void InitOnlyAction::ExecuteAction() {
+  CompilerInstance &ci = this->instance();
+  unsigned DiagID =
+  ci.diagnostics().getCustomDiagID(clang::DiagnosticsEngine::Warning,
+  "Use `-init-only` for testing purposes only");
+  ci.

[PATCH] D102849: [flang][driver] Add support for the "-init-only" option

2021-06-07 Thread Andrzej Warzynski via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1da3297d253: [flang][driver] Add support for the 
"-init-only" option (authored by stuartellis, committed by 
awarzynski).

Changed prior to commit:
  https://reviews.llvm.org/D102849?vs=349307&id=350287#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102849

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Driver/init-only.f90

Index: flang/test/Driver/init-only.f90
===
--- /dev/null
+++ flang/test/Driver/init-only.f90
@@ -0,0 +1,7 @@
+! Verify that -init-only flag generates a diagnostic as expected
+
+! REQUIRES: new-flang-driver
+
+! RUN: %flang_fc1 -init-only 2>&1 | FileCheck %s
+
+! CHECK: warning: Use `-init-only` for testing purposes only
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -104,6 +104,7 @@
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-FC1-NEXT: -help  Display available options
+! HELP-FC1-NEXT: -init-only Only execute frontend initialization
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-FC1-NEXT: -module-dir   Put MODULE files in 
 ! HELP-FC1-NEXT: -module-suffix  Use  as the suffix for module files (the default value is `.mod`)
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -73,6 +73,9 @@
   case GetSymbolsSources:
 return std::make_unique();
 break;
+  case InitOnly:
+return std::make_unique();
+break;
   default:
 break;
 // TODO:
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -447,3 +447,11 @@
   clang::DiagnosticsEngine::Error, "code-generation is not available yet");
   ci.diagnostics().Report(DiagID);
 }
+
+void InitOnlyAction::ExecuteAction() {
+  CompilerInstance &ci = this->instance();
+  unsigned DiagID =
+  ci.diagnostics().getCustomDiagID(clang::DiagnosticsEngine::Warning,
+  "Use `-init-only` for testing purposes only");
+  ci.diagnostics().Report(DiagID);
+}
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -162,9 +162,12 @@
 case clang::driver::options::OPT_fget_definition:
   opts.programAction_ = GetDefinition;
   break;
+case clang::driver::options::OPT_init_only:
+  opts.programAction_ = InitOnly;
+  break;
 
   // TODO:
-  // case calng::driver::options::OPT_emit_llvm:
+  // case clang::driver::options::OPT_emit_llvm:
   // case clang::driver::options::OPT_emit_llvm_only:
   // case clang::driver::options::OPT_emit_codegen_only:
   // case clang::driver::options::OPT_emit_module:
Index: flang/include/flang/Frontend/FrontendOptions.h
===
--- flang/include/flang/Frontend/FrontendOptions.h
+++ flang/include/flang/Frontend/FrontendOptions.h
@@ -71,7 +71,10 @@
   GetDefinition,
 
   /// Parse, run semantics and then dump symbol sources map
-  GetSymbolsSources
+  GetSymbolsSources,
+
+  /// Only execute frontend initialization
+  InitOnly
 
   /// TODO: RunPreprocessor, EmitLLVM, EmitLLVMOnly,
   /// EmitCodeGenOnly, EmitAssembly, (...)
Index: flang/include/flang/Frontend/FrontendActions.h
===
--- flang/include/flang/Frontend/FrontendActions.h
+++ flang/include/flang/Frontend/FrontendActions.h
@@ -38,6 +38,10 @@
   void ExecuteAction() override;
 };
 
+class InitOnlyAction : public FrontendAction {
+  void ExecuteAction() override;
+};
+
 //===--===//
 // Prescan Actions
 //===--===//
Index: clang/include/clang/Driver/Options.td
==

[PATCH] D103797: [clang] Use resolved path for headers in decluse diagnostics

2021-06-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 350288.
kadircet added a comment.

- handle windows paths in tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103797

Files:
  clang/lib/Lex/ModuleMap.cpp
  clang/test/Modules/declare-use1.cpp
  clang/test/Modules/declare-use2.cpp
  clang/test/Modules/declare-use3.cpp
  clang/test/Modules/header-attribs.cpp
  clang/test/Modules/strict-decluse-headers.cpp
  clang/test/Modules/strict-decluse.cpp
  clang/test/Modules/textual-headers.cpp

Index: clang/test/Modules/textual-headers.cpp
===
--- clang/test/Modules/textual-headers.cpp
+++ clang/test/Modules/textual-headers.cpp
@@ -6,13 +6,13 @@
 #include "k.h"
 
 #define GIMME_AN_L
-#include "l.h" // expected-error {{module XG does not depend on a module exporting 'l.h'}}
+#include "l.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}{{/|\\}}l.h'}}
 
-#include "m2.h" // expected-error {{module XG does not depend on a module exporting 'm2.h'}}
+#include "m2.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}{{/|\\}}m2.h'}}
 const int use_m = m; // expected-error {{undeclared identifier}}
 
 #define GIMME_AN_M
-#include "m.h" // expected-error {{use of private header from outside its module: 'm.h'}}
+#include "m.h" // expected-error-re {{use of private header from outside its module: '{{.*}}{{/|\\}}m.h'}}
 const int use_m_2 = m;
 
 const int g = k + l;
Index: clang/test/Modules/strict-decluse.cpp
===
--- clang/test/Modules/strict-decluse.cpp
+++ clang/test/Modules/strict-decluse.cpp
@@ -3,7 +3,7 @@
 
 #include "g.h"
 #include "e.h"
-#include "f.h" // expected-error {{module XG does not depend on a module exporting 'f.h'}}
-#include "i.h" // expected-error {{module XG does not depend on a module exporting 'i.h'}}
+#include "f.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}{{/|\\}}f.h'}}
+#include "i.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}{{/|\\}}i.h'}}
 
 const int g2 = g1 + e + f + aux_i;
Index: clang/test/Modules/strict-decluse-headers.cpp
===
--- clang/test/Modules/strict-decluse-headers.cpp
+++ clang/test/Modules/strict-decluse-headers.cpp
@@ -14,4 +14,4 @@
 // Don't crash on this: (FIXME: we should produce an error that the specified file is not part of the specified module)
 // RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%t/map -I%t -fmodules-strict-decluse -fmodule-name=X -x c++ %t/foo.h
 //
-// CHECK: module X does not depend on a module exporting 'foo.h'
+// CHECK: module X does not depend on a module exporting '{{.*}}{{/|\\}}foo.h'
Index: clang/test/Modules/header-attribs.cpp
===
--- clang/test/Modules/header-attribs.cpp
+++ clang/test/Modules/header-attribs.cpp
@@ -3,8 +3,8 @@
 // RUN: not %clang_cc1 -fmodules -I%S/Inputs/header-attribs -emit-module -x c++-module-map %S/Inputs/header-attribs/modular.modulemap -fmodules-cache-path=%t -fmodule-name=A 2>&1 | FileCheck %s --check-prefix BUILD-MODULAR
 
 #include "foo.h" // ok, stats match
-#include "bar.h" // expected-error {{does not depend on a module exporting 'bar.h'}}
-#include "baz.h" // expected-error {{does not depend on a module exporting 'baz.h'}}
+#include "bar.h" // expected-error-re {{does not depend on a module exporting '{{.*}}{{/|\\}}bar.h'}}
+#include "baz.h" // expected-error-re {{does not depend on a module exporting '{{.*}}{{/|\\}}baz.h'}}
 
 // FIXME: Explain why the 'bar.h' found on disk doesn't match the module map.
 // BUILD-MODULAR: error: header 'bar.h' not found
Index: clang/test/Modules/declare-use3.cpp
===
--- clang/test/Modules/declare-use3.cpp
+++ clang/test/Modules/declare-use3.cpp
@@ -1,4 +1,4 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -include "g.h" -include "e.h" -include "f.h" -include "i.h" -fimplicit-module-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
-// expected-error {{module XG does not depend on a module exporting 'f.h'}}
+// expected-error-re {{module XG does not depend on a module exporting '{{.*}}{{/|\\}}f.h'}}
 const int g2 = g1 + e + f + aux_i;
Index: clang/test/Modules/declare-use2.cpp
===
--- clang/test/Modules/declare-use2.cpp
+++ clang/test/Modules/declare-use2.cpp
@@ -3,5 +3,5 @@
 
 #include "h.h"
 #include "e.h"
-#include "f.h" // expected-error {{module XH does not depend on a module exporting 'f.h'}}
+#include "f.h" // expected-error-re {{module XH does not depend on a module exporting '{{.*}}{{/|\\}}f.h'}}
 const int h2 = h1+e+f;
Index: clang/test/Mo

[PATCH] D102760: [llvm] Let SmallVector construct from any Iterable

2021-06-07 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet abandoned this revision.
gchatelet added a comment.

In D102760#2802520 , @Quuxplusone 
wrote:

> @gchatelet: Thanks for the link to D102679  
> — that seems like very relevant background info I didn't have!  Having looked 
> through D102679 , though, I don't see how 
> it would benefit from D102760  — in fact, 
> D102679  updates some tests to wisely 
> //stop// depending on the ability to construct `SmallVector` from a range 
> (and goes to using begin/end pairs instead — good!).

Yes these (recent) changes are based on your comments : )

> So I think D102679  is a good idea (modulo 
> the review comments I just left), and I continue to think that this D102760 
>  is a bad idea that should be abandoned.

This is my plan indeed. Thx for your insights. I really appreciate it.
I wanted to see the impact of removing the constructor first, it's very minor 
so I'll go ahead and abandon this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102760

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


[PATCH] D103797: [clang] Use resolved path for headers in decluse diagnostics

2021-06-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a subscriber: rsmith.
sammccall added a comment.

This seems sensible to me but hard to know if it's going to be an improvement 
in practice. Can you paste a realistic example?

@rsmith any opinion about this diag?




Comment at: clang/test/Modules/declare-use1.cpp:6
 #include "e.h"
-#include "f.h" // expected-error {{module XG does not depend on a module 
exporting 'f.h'}}
+#include "f.h" // expected-error-re {{module XG does not depend on a module 
exporting '{{.*}}{{/|\\}}f.h'}}
 #include "i.h"

I'd be tempted to leave the slashes in the globs for readability


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103797

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


[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-06-07 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 350307.
mibintc added a comment.

This patch addresses all of @craig.topper comments and adds documentation for 
the new intrinsic to the language reference as requested by @LuoYuanke nke


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99675

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll
  llvm/test/CodeGen/X86/arithmetic_fence2.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence2.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
+
+define double @f1(double %a) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:movsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f2(double %a) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:addsd %xmm0, %xmm0
+; X86-NEXT:movapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addsd %xmm0, %xmm1
+; X86-NEXT:movsd %xmm1, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:addsd %xmm0, %xmm0
+; X64-NEXT:movapd %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addsd %xmm0, %xmm1
+; X64-NEXT:movapd %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f3(<2 x float> %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f4(<2 x float> %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:addps %xmm0, %xmm0
+; X86-NEXT:movaps %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addps %xmm0, %xmm1
+; X86-NEXT:movaps %xmm1, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:addps %xmm0, %xmm0
+; X64-NEXT:movaps %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addps %xmm0, %xmm1
+; X64-NEXT:movaps %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+define <8 x float> @f5(<8 x float> %a) {
+; X86-LABEL: f5:
+; X86:   # %bb.0:
+; X86-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X86-NEXT:mulps %xmm2, %xmm0
+; X86-NEXT:mulps %xmm2, %xmm1
+; X86-NEXT:retl
+;
+; X64-LABEL: f5:
+; X64:   # %bb.0:
+; X64-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X64-NEXT:mulps %xmm2, %xmm0
+; X64-NEXT:mulps %xmm2, %xmm1
+

[clang] 2b13ff6 - [Clang][CodeGen] Set the size of llvm.lifetime to unknown for scalable types.

2021-06-07 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2021-06-07T23:30:13+08:00
New Revision: 2b13ff69794680ea0764e516f5b69b80219771b7

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

LOG: [Clang][CodeGen] Set the size of llvm.lifetime to unknown for scalable 
types.

If the memory object is scalable type, we do not know the exact size of
it at compile time. Set the size of lifetime marker to unknown if the
object is scalable one.

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

Added: 
clang/test/CodeGen/RISCV/riscv-v-lifetime.cpp

Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index beb6b0ff464b8..1cd972f32f3ff 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4683,7 +4683,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
 } else {
   SRetPtr = CreateMemTemp(RetTy, "tmp", &SRetAlloca);
   if (HaveInsertPoint() && ReturnValue.isUnused()) {
-uint64_t size =
+llvm::TypeSize size =
 CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(RetTy));
 UnusedReturnSizePtr = EmitLifetimeStart(size, SRetAlloca.getPointer());
   }
@@ -4844,7 +4844,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   IRCallArgs[FirstIRArg] = AI.getPointer();
 
   // Emit lifetime markers for the temporary alloca.
-  uint64_t ByvalTempElementSize =
+  llvm::TypeSize ByvalTempElementSize =
   CGM.getDataLayout().getTypeAllocSize(AI.getElementType());
   llvm::Value *LifetimeSize =
   EmitLifetimeStart(ByvalTempElementSize, AI.getPointer());

diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 3be0f6a79b804..7948f431299c7 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1318,7 +1318,7 @@ void CodeGenFunction::EmitAutoVarDecl(const VarDecl &D) {
 /// Emit a lifetime.begin marker if some criteria are satisfied.
 /// \return a pointer to the temporary size Value if a marker was emitted, null
 /// otherwise
-llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size,
+llvm::Value *CodeGenFunction::EmitLifetimeStart(llvm::TypeSize Size,
 llvm::Value *Addr) {
   if (!ShouldEmitLifetimeMarkers)
 return nullptr;
@@ -1326,7 +1326,8 @@ llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t 
Size,
   assert(Addr->getType()->getPointerAddressSpace() ==
  CGM.getDataLayout().getAllocaAddrSpace() &&
  "Pointer should be in alloca address space");
-  llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size);
+  llvm::Value *SizeV = llvm::ConstantInt::get(
+  Int64Ty, Size.isScalable() ? -1 : Size.getFixedValue());
   Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy);
   llvm::CallInst *C =
   Builder.CreateCall(CGM.getLLVMLifetimeStartFn(), {SizeV, Addr});
@@ -1549,12 +1550,9 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
 // is rare.
 if (!Bypasses.IsBypassed(&D) &&
 !(!getLangOpts().CPlusPlus && hasLabelBeenSeenInCurrentScope())) {
-  llvm::TypeSize size =
-  CGM.getDataLayout().getTypeAllocSize(allocaTy);
+  llvm::TypeSize Size = CGM.getDataLayout().getTypeAllocSize(allocaTy);
   emission.SizeForLifetimeMarkers =
-  size.isScalable() ? EmitLifetimeStart(-1, 
AllocaAddr.getPointer())
-: EmitLifetimeStart(size.getFixedSize(),
-AllocaAddr.getPointer());
+  EmitLifetimeStart(Size, AllocaAddr.getPointer());
 }
   } else {
 assert(!emission.useLifetimeMarkers());

diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 3fdb8aaaec46c..5fdfa28984f74 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -276,7 +276,7 @@ void AggExprEmitter::withReturnValueSlot(
 RetAddr = Dest.getAddress();
   } else {
 RetAddr = CGF.CreateMemTemp(RetTy, "tmp", &RetAllocaAddr);
-uint64_t Size =
+llvm::TypeSize Size =
 CGF.CGM.getDataLayout().getTypeAllocSize(CGF.ConvertTypeForMem(RetTy));
 LifetimeSizePtr = CGF.EmitLifetimeStart(Size, RetAllocaAddr.getPointer());
 if (LifetimeSizePtr) {

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index b799ebc15c2c8..564063d6b7c84 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -2872,7 +2872,7 @@ class CodeGenFunction : public C

[PATCH] D102822: [Clang][CodeGen] Set the size of llvm.lifetime to unknown for scalable types.

2021-06-07 Thread Hsiangkai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b13ff697946: [Clang][CodeGen] Set the size of llvm.lifetime 
to unknown for scalable types. (authored by HsiangKai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102822

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/RISCV/riscv-v-lifetime.cpp

Index: clang/test/CodeGen/RISCV/riscv-v-lifetime.cpp
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-v-lifetime.cpp
@@ -0,0 +1,25 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -std=c++11 -triple riscv64 -target-feature +experimental-v \
+// RUN:   -O1 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+vint32m1_t Baz();
+
+// CHECK-LABEL: @_Z4Testv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A:%.*]] = alloca *, align 8
+// CHECK-NEXT:[[REF_TMP:%.*]] = alloca , align 4
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast ** [[A]] to i8*
+// CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 8, i8* [[TMP0]]) #[[ATTR3:[0-9]+]]
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast * [[REF_TMP]] to i8*
+// CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 -1, i8* [[TMP1]]) #[[ATTR3]]
+// CHECK: [[TMP4:%.*]] = bitcast * [[REF_TMP]] to i8*
+// CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 -1, i8* [[TMP4]]) #[[ATTR3]]
+// CHECK-NEXT:[[TMP5:%.*]] = bitcast ** [[A]] to i8*
+// CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 8, i8* [[TMP5]]) #[[ATTR3]]
+//
+vint32m1_t Test() {
+  const vint32m1_t &a = Baz();
+  return a;
+}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2872,7 +2872,7 @@
   void EmitSehTryScopeBegin();
   void EmitSehTryScopeEnd();
 
-  llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
+  llvm::Value *EmitLifetimeStart(llvm::TypeSize Size, llvm::Value *Addr);
   void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
 
   llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -276,7 +276,7 @@
 RetAddr = Dest.getAddress();
   } else {
 RetAddr = CGF.CreateMemTemp(RetTy, "tmp", &RetAllocaAddr);
-uint64_t Size =
+llvm::TypeSize Size =
 CGF.CGM.getDataLayout().getTypeAllocSize(CGF.ConvertTypeForMem(RetTy));
 LifetimeSizePtr = CGF.EmitLifetimeStart(Size, RetAllocaAddr.getPointer());
 if (LifetimeSizePtr) {
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -1318,7 +1318,7 @@
 /// Emit a lifetime.begin marker if some criteria are satisfied.
 /// \return a pointer to the temporary size Value if a marker was emitted, null
 /// otherwise
-llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size,
+llvm::Value *CodeGenFunction::EmitLifetimeStart(llvm::TypeSize Size,
 llvm::Value *Addr) {
   if (!ShouldEmitLifetimeMarkers)
 return nullptr;
@@ -1326,7 +1326,8 @@
   assert(Addr->getType()->getPointerAddressSpace() ==
  CGM.getDataLayout().getAllocaAddrSpace() &&
  "Pointer should be in alloca address space");
-  llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size);
+  llvm::Value *SizeV = llvm::ConstantInt::get(
+  Int64Ty, Size.isScalable() ? -1 : Size.getFixedValue());
   Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy);
   llvm::CallInst *C =
   Builder.CreateCall(CGM.getLLVMLifetimeStartFn(), {SizeV, Addr});
@@ -1549,12 +1550,9 @@
 // is rare.
 if (!Bypasses.IsBypassed(&D) &&
 !(!getLangOpts().CPlusPlus && hasLabelBeenSeenInCurrentScope())) {
-  llvm::TypeSize size =
-  CGM.getDataLayout().getTypeAllocSize(allocaTy);
+  llvm::TypeSize Size = CGM.getDataLayout().getTypeAllocSize(allocaTy);
   emission.SizeForLifetimeMarkers =
-  size.isScalable() ? EmitLifetimeStart(-1, AllocaAddr.getPointer())
-: EmitLifetimeStart(size.getFixedSize(),
-AllocaAddr.getPointer());
+  EmitLifetimeStart(Size, AllocaAddr.getPointer());
 }
   } else {
 assert(!emission.useLifetimeMarkers());
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -4683,7 +4683,7 @@
 } else {
   SRetPtr = Creat

[PATCH] D103797: [clang] Use resolved path for headers in decluse diagnostics

2021-06-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

It is the absolute path of the header. e.g:

`module TestTU does not depend on a module exporting 
'/work/llvm/clang-tools-extra/clangd/AST.h'`

rather than

`module TestTU does not depend on a module exporting 'AST.h'`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103797

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


[PATCH] D97869: [OpenCL] Add OpenCL builtin test generator

2021-06-07 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 350314.
svenvh marked an inline comment as done.
svenvh retitled this revision from "[OpenCL][Draft] Add OpenCL builtin test 
generator" to "[OpenCL] Add OpenCL builtin test generator".
svenvh added a comment.

Improve comments.


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

https://reviews.llvm.org/D97869

Files:
  clang/test/Headers/lit.local.cfg
  clang/test/Headers/opencl-builtins.cl
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -122,6 +122,8 @@
 
 void EmitClangOpenCLBuiltins(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
+void EmitClangOpenCLBuiltinTests(llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
 
 void EmitClangDataCollectors(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -63,6 +63,7 @@
   GenClangCommentCommandInfo,
   GenClangCommentCommandList,
   GenClangOpenCLBuiltins,
+  GenClangOpenCLBuiltinTests,
   GenArmNeon,
   GenArmFP16,
   GenArmBF16,
@@ -194,6 +195,8 @@
"documentation comments"),
 clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
"Generate OpenCL builtin declaration handlers"),
+clEnumValN(GenClangOpenCLBuiltinTests, "gen-clang-opencl-builtin-tests",
+   "Generate OpenCL builtin declaration tests"),
 clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
 clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
 clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
@@ -371,6 +374,9 @@
   case GenClangOpenCLBuiltins:
 EmitClangOpenCLBuiltins(Records, OS);
 break;
+  case GenClangOpenCLBuiltinTests:
+EmitClangOpenCLBuiltinTests(Records, OS);
+break;
   case GenClangSyntaxNodeList:
 EmitClangSyntaxNodeList(Records, OS);
 break;
Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -228,6 +228,64 @@
   // same entry ().
   MapVector SignatureListMap;
 };
+
+// OpenCL builtin test generator.  This class processes the same TableGen input
+// as BuiltinNameEmitter, but generates a .cl file that contains a call to each
+// builtin function described in the .td input.
+class OpenCLBuiltinTestEmitter {
+public:
+  OpenCLBuiltinTestEmitter(RecordKeeper &Records, raw_ostream &OS)
+  : Records(Records), OS(OS) {}
+
+  // Entrypoint to generate the functions for testing all OpenCL builtin
+  // functions.
+  void emit();
+
+private:
+  struct TypeFlags {
+TypeFlags() : IsConst(false), IsVolatile(false), IsPointer(false) {}
+bool IsConst : 1;
+bool IsVolatile : 1;
+bool IsPointer : 1;
+StringRef AddrSpace;
+  };
+
+  // Return a string representation of the given type, such that it can be
+  // used as a type in OpenCL C code.
+  std::string getTypeString(const Record *Type, TypeFlags Flags,
+int VectorSize) const;
+
+  // Return the type(s) and vector size(s) for the given type.  For
+  // non-GenericTypes, the resulting vectors will contain 1 element.  For
+  // GenericTypes, the resulting vectors typically contain multiple elements.
+  void getTypeLists(Record *Type, TypeFlags &Flags,
+std::vector &TypeList,
+std::vector &VectorList) const;
+
+  // Expand the TableGen Records representing a builtin function signature into
+  // one or more function signatures.  Return them as a vector of a vector of
+  // strings, with each string containing an OpenCL C type and optional
+  // qualifiers.
+  //
+  // The Records may contain GenericTypes, which expand into multiple
+  // signatures.  Repeated occurrences of GenericType in a signature expand to
+  // the same types.  For example [char, FGenType, FGenType] expands to:
+  //   [char, float, float]
+  //   [char, float2, float2]
+  //   [char, float3, float3]
+  //   ...
+  void
+  expandTypesInSignature(const std::vector &Signature,
+ SmallVectorImpl> &Types);
+
+  // Contains OpenCL builtin functions and related information, stored as
+  // Record instances. They are coming from the associated TableGen file.
+  RecordKeeper &Records;
+
+  // The output file.
+  raw_ostream &OS;
+};
+
 } // namespace
 
 void BuiltinNameEmitter::E

[PATCH] D97869: [OpenCL] Add OpenCL builtin test generator

2021-06-07 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp:969
+
+void OpenCLBuiltinTestEmitter::getTypeLists(
+Record *Type, TypeFlags &Flags, std::vector &TypeList,

Anastasia wrote:
> I would add a documentation for this function, it is not very obvious.
Not sure what documentation you are expecting?  Are there any particular lines 
that are "not very obvious"?
Note that there is already a comment for this method up in the class 
declaration.



Comment at: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp:1004
+SmallVectorImpl> &Types) {
+  // Find out if there are any GenTypes in this signature, and if so, calculate
+  // into how many signatures they will expand.

Anastasia wrote:
> Maybe this should be lifted as documentation of the header of this function?
This comment only applies to the first loop-nest.  It documents an 
implementation detail, so I don't think this comment should be lifted to the 
method's declaration comment.



Comment at: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp:1033
+for (unsigned ArgNum = 0; ArgNum < Signature.size(); ArgNum++) {
+  // For differently-sized GenTypes in a parameter list, the smaller
+  // GenTypes just repeat.

Anastasia wrote:
> I don't get this comment and its exact reference to the code.
I have expanded the comment, and also factored out an index into a variable.  
Hopefully that makes it clear?


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

https://reviews.llvm.org/D97869

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


[PATCH] D101630: [HIP] Add --gpu-bundle-output

2021-06-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 350318.
yaxunl retitled this revision from "[HIP] Fix device-only compilation" to 
"[HIP] Add --gpu-bundle-output".
yaxunl edited the summary of this revision.
yaxunl added a comment.

use --gpu-bundle-output to control bundling/unbundling output of HIP device 
only compilation


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

https://reviews.llvm.org/D101630

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-output-file-name.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-rdc-device-only.hip
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -117,6 +117,9 @@
 /// The index of the host input in the list of inputs.
 static unsigned HostInputIndex = ~0u;
 
+/// Whether not having host target is allowed.
+static bool AllowNoHost = false;
+
 /// Path to the current binary.
 static std::string BundlerExecutable;
 
@@ -839,9 +842,10 @@
   }
 
   // Get the file handler. We use the host buffer as reference.
-  assert(HostInputIndex != ~0u && "Host input index undefined??");
+  assert((HostInputIndex != ~0u || AllowNoHost) &&
+ "Host input index undefined??");
   Expected> FileHandlerOrErr =
-  CreateFileHandler(*InputBuffers[HostInputIndex]);
+  CreateFileHandler(*InputBuffers[AllowNoHost ? 0 : HostInputIndex]);
   if (!FileHandlerOrErr)
 return FileHandlerOrErr.takeError();
 
@@ -1108,6 +1112,7 @@
   // have exactly one host target.
   unsigned Index = 0u;
   unsigned HostTargetNum = 0u;
+  bool HIPOnly = true;
   llvm::DenseSet ParsedTargets;
   for (StringRef Target : TargetNames) {
 if (ParsedTargets.contains(Target)) {
@@ -1149,12 +1154,21 @@
   HostInputIndex = Index;
 }
 
+if (Kind != "hip" && Kind != "hipv4")
+  HIPOnly = false;
+
 ++Index;
   }
 
+  // HIP uses clang-offload-bundler to bundle device-only compilation results
+  // for multiple GPU archs, therefore allow no host target if all entries
+  // are for HIP.
+  AllowNoHost = HIPOnly;
+
   // Host triple is not really needed for unbundling operation, so do not
   // treat missing host triple as error if we do unbundling.
-  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
+  if ((Unbundle && HostTargetNum > 1) ||
+  (!Unbundle && HostTargetNum != 1 && !AllowNoHost)) {
 reportError(createStringError(errc::invalid_argument,
   "expecting exactly one host target but got " +
   Twine(HostTargetNum)));
Index: clang/test/Driver/hip-rdc-device-only.hip
===
--- clang/test/Driver/hip-rdc-device-only.hip
+++ clang/test/Driver/hip-rdc-device-only.hip
@@ -6,7 +6,7 @@
 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
 // RUN:   -c -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
-// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
 
 // With `-emit-llvm`, the output should be the same as the aforementioned line
@@ -16,14 +16,14 @@
 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
 // RUN:   -c -emit-llvm -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
-// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
 
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
 // RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
-// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITLL %s
 
 // With `-emit-llvm`, the output should be the same as the aforementioned line
@@ -33,7 +33,7 @@
 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
 // RUN:   -S -emit-llvm -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
-// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITLL %s
 
 // With `-save-temps`, commane lines for each steps are dumped. For assembly
@@ -44,9 +44,17 @@
 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-a

[PATCH] D103825: [clang] Do not crash when ArgTy is null in CheckArgAlignment

2021-06-07 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

No repro case just yet. I only observed a crash like this and noticed
ArgTy-Value = 0 in coredump.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103825

Files:
  clang/lib/Sema/SemaChecking.cpp


Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4571,8 +4571,9 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ArgTy.isNull() || ParamTy->isIncompleteType() ||
+  ArgTy->isIncompleteType() || ParamTy->isUndeducedType() ||
+  ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);


Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4571,8 +4571,9 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ArgTy.isNull() || ParamTy->isIncompleteType() ||
+  ArgTy->isIncompleteType() || ParamTy->isUndeducedType() ||
+  ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103806: [SystemZ][z/OS] Pass OpenFlags when creating tmp files

2021-06-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I see, thanks.




Comment at: llvm/lib/Support/Path.cpp:1295
   SmallString<128> ResultPath;
-  if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  if (std::error_code EC = createUniqueFile(Model, FD, ResultPath, Flags, 
Mode))
 return errorCodeToError(EC);

Instead of requiring the caller to add `OF_Delete`, I think it would be better 
to pass `OF_Delete | Flags` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103806

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


[PATCH] D103745: [dfsan] Add full fast8 support

2021-06-07 Thread stephan.yichao.zhao via Phabricator via cfe-commits
stephan.yichao.zhao added a comment.

How did we fix that alignment error from compiler-rt/test/dfsan/origin_ldst.c?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103745

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


[PATCH] D103771: [clang][msvc] Define _HAS_STATIC_RTTI to 0, when compiling with -fno-rtti

2021-06-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

Seems reasonable to me.

Here is where it is defined in MSVC's yvals_core.h for the curious:
https://github.com/microsoft/STL/blob/3cafa97eecdbfde41ea5c09126f877a7eb97f9e9/stl/inc/yvals_core.h#L569


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

https://reviews.llvm.org/D103771

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


[PATCH] D98798: Produce warning for performing pointer arithmetic on a null pointer.

2021-06-07 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser added a comment.

@rsmith I separated the C and C++ messages in response to your comments and 
changed the C++ message to state that "performing pointer subtraction with a 
null pointer may have undefined behavior" to address your concerns.  Are you 
satisfied?  @thakis, the warning no longer fires in the MS headers according to 
@hans and there is separate option control over this warning.  Is this 
sufficient?  @efriedma, thank you for reviewing/approving the original but 
these changes were sufficiently different that I thought a new review would be 
beneficial.  Are you still satisfied with the resulting changes?


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

https://reviews.llvm.org/D98798

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


[PATCH] D103806: [SystemZ][z/OS] Pass OpenFlags when creating tmp files

2021-06-07 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: llvm/lib/Support/Path.cpp:1295
   SmallString<128> ResultPath;
-  if (std::error_code EC =
-  createUniqueFile(Model, FD, ResultPath, OF_Delete, Mode))
+  if (std::error_code EC = createUniqueFile(Model, FD, ResultPath, Flags, 
Mode))
 return errorCodeToError(EC);

rnk wrote:
> Instead of requiring the caller to add `OF_Delete`, I think it would be 
> better to pass `OF_Delete | Flags` here.
Sure, I'll make that change. Do you think we should change the name to 
"ExtraFlags" to indicate there is a default, or is the current name is fine?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103806

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


[PATCH] D101630: [HIP] Add --gpu-bundle-output

2021-06-07 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/Driver.cpp:2903
 bool GPUSanitize;
+Optional BundleOutput;
 

We should document the behavior we expect from the `--gpu-bundle-output` option 
in one place. This may be a good place for it. 

Some day we should add CUDA/HIP section to clang manual. We already have tons 
of options that users do need to know about.


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

https://reviews.llvm.org/D101630

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


[PATCH] D103663: [AMDGPU] Add gfx1013 target

2021-06-07 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp:4697
+  if (!ST.hasGFX10_AEncoding()) {
+DiagnosticInfoUnsupported BadIntrin(B.getMF().getFunction(), "intrinsic 
not supported on subtarget",
+MI.getDebugLoc());

80 chars per line.



Comment at: llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp:4700
+B.getMF().getFunction().getContext().diagnose(BadIntrin);
+B.buildUndef(MI.getOperand(0));
+MI.eraseFromParent();

Just return false like in other places.



Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:7341
+if (!Subtarget->hasGFX10_AEncoding())
+  emitRemovedIntrinsicError(DAG, DL, Op.getValueType());
+

return emitRemovedIntrinsicError();



Comment at: llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.intersect_ray.ll:4
+; RUN: llc -global-isel -march=amdgcn -mcpu=gfx1013 -verify-machineinstrs < %s 
| FileCheck -check-prefix=GCN %s
+; RUN: not llc -global-isel -march=amdgcn -mcpu=gfx1012 -verify-machineinstrs 
< %s -o /dev/null 2>&1 | FileCheck -check-prefix=ERR %s
 

not --crash llc ...



Comment at: llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.intersect_ray.ll:4
+; RUN: llc -global-isel -march=amdgcn -mcpu=gfx1013 -verify-machineinstrs < %s 
| FileCheck -check-prefix=GCN %s
+; RUN: llc -global-isel -march=amdgcn -mcpu=gfx1012 -verify-machineinstrs < %s 
| FileCheck -check-prefix=GCN %s
 

bcahoon wrote:
> rampitec wrote:
> > rampitec wrote:
> > > foad wrote:
> > > > This test surely should not pass for gfx1012, since it does not have 
> > > > these instructions. And with your patch as written it should fail for 
> > > > gfx1013 too, since they are predicated on HasGFX10_BEncoding.
> > > > 
> > > > @rampitec any idea what is wrong here? Apparently the backend will 
> > > > happily generate image_bvh_intersect_ray instructions even for gfx900!
> > > Indeed. MIMG_IntersectRay has this:
> > > 
> > > ```
> > >   let SubtargetPredicate = HasGFX10_BEncoding,
> > >   AssemblerPredicate = HasGFX10_BEncoding,
> > > ```
> > > but apparently SubtargetPredicate did not work. It needs to be fixed.
> > > 
> > > gfx1012 does not have it, gfx1013 does though. That is what GFX10_A 
> > > encoding is about, 10_B it has to be replaced with 10_A in BVH and MSAA 
> > > load.
> > Image lowering and selection is not really done like everything else. For 
> > BVH it just lowers intrinsic to opcode. I think the easiest fix is to add 
> > to SIISelLowering.cpp where we lower 
> > Intrinsic::amdgcn_image_bvh_intersect_ray something like this:
> > 
> > 
> > ```
> >   if (!Subtarget->hasGFX10_AEncoding())
> > report_fatal_error(
> > "requested image instruction is not supported on this GPU");
> > ```
> I ended up using emitRemovedIntrinsicError, which uses 
> DiagnosticInfoUnsupported. This way the failure isn't a crash dump.
> I ended up using emitRemovedIntrinsicError, which uses 
> DiagnosticInfoUnsupported. This way the failure isn't a crash dump.

Diagnostics is a good thing, but we still have to fail the compilation.



Comment at: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.intersect_ray.ll:3
+; RUN: llc -march=amdgcn -mcpu=gfx1013 -verify-machineinstrs < %s | FileCheck 
-check-prefix=GCN %s
+; RUN: not llc -march=amdgcn -mcpu=gfx1012 -verify-machineinstrs < %s 2>&1 | 
FileCheck -check-prefix=ERR %s
 

not --crash llc


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

https://reviews.llvm.org/D103663

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


[clang] fd11a26 - [AArch64] handle -Wa,-march=

2021-06-07 Thread Jian Cai via cfe-commits

Author: Jian Cai
Date: 2021-06-07T10:15:53-07:00
New Revision: fd11a26d368c5a909fb88548fef2cee7a6c2c931

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

LOG: [AArch64] handle -Wa,-march=

This fixed PR#48894 for AArch64. The issue has been fixed for Arm in
https://reviews.llvm.org/D95872

The following rules apply to -Wa,-march with this change:
  - Only compiler options apply to non assembly files
  - Compiler and assembler options apply to assembly files
  - For assembly files, we prefer the assembler option(s) if we have both kinds 
of option
  - Of the options that apply (or are preferred), the last value wins (it's not 
additive)

Reviewed By: DavidSpickett, nickdesaulniers

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

Added: 
clang/test/Driver/aarch64-target-as-march.s

Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Driver/ToolChains/Arch/AArch64.h
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 503685ab533a0..cb98d423ed2b0 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -185,12 +185,20 @@ getAArch64MicroArchFeaturesFromMcpu(const Driver &D, 
StringRef Mcpu,
 void aarch64::getAArch64TargetFeatures(const Driver &D,
const llvm::Triple &Triple,
const ArgList &Args,
-   std::vector &Features) {
+   std::vector &Features,
+   bool ForAS) {
   Arg *A;
   bool success = true;
   // Enable NEON by default.
   Features.push_back("+neon");
-  if ((A = Args.getLastArg(options::OPT_march_EQ)))
+  if (ForAS &&
+  (A = Args.getLastArg(options::OPT_Wa_COMMA, options::OPT_Xassembler))) {
+llvm::StringRef WaMArch;
+for (StringRef Value : A->getValues())
+  if (Value.startswith("-march="))
+WaMArch = Value.substr(7);
+success = getAArch64ArchFeaturesFromMarch(D, WaMArch, Args, Features);
+  } else if ((A = Args.getLastArg(options::OPT_march_EQ)))
 success = getAArch64ArchFeaturesFromMarch(D, A->getValue(), Args, 
Features);
   else if ((A = Args.getLastArg(options::OPT_mcpu_EQ)))
 success = getAArch64ArchFeaturesFromMcpu(D, A->getValue(), Args, Features);

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.h 
b/clang/lib/Driver/ToolChains/Arch/AArch64.h
index 713af870d69fb..d47c402d4a42d 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.h
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.h
@@ -22,7 +22,8 @@ namespace aarch64 {
 
 void getAArch64TargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
-  std::vector &Features);
+  std::vector &Features,
+  bool ForAS);
 
 std::string getAArch64TargetCPU(const llvm::opt::ArgList &Args,
 const llvm::Triple &Triple, llvm::opt::Arg 
*&A);

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index a0e1208fd709c..6fdd7e2dd21e7 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -344,7 +344,7 @@ static void getTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_32:
   case llvm::Triple::aarch64_be:
-aarch64::getAArch64TargetFeatures(D, Triple, Args, Features);
+aarch64::getAArch64TargetFeatures(D, Triple, Args, Features, ForAS);
 break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:

diff  --git a/clang/test/Driver/aarch64-target-as-march.s 
b/clang/test/Driver/aarch64-target-as-march.s
new file mode 100644
index 0..a9301ade43351
--- /dev/null
+++ b/clang/test/Driver/aarch64-target-as-march.s
@@ -0,0 +1,46 @@
+/// These tests make sure that options passed to the assembler
+/// via -Wa or -Xassembler are applied correctly to assembler inputs.
+
+/// Does not apply to non assembly files
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=armv8.1-a \
+// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefix=TARGET-FEATURE-1 
%s
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Xassembler 
-march=armv8.1-a \
+// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefix=TARGET-FEATURE-1 
%s
+
+// TARGET-FEATURE-1-NOT: "-target-feature" "+v8.1a"
+
+/// Does apply to assembler input
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=armv8.2-a %s 
2>&1 | \
+// RUN: FileCheck --check-prefix=TARGET-FEATURE-2 

[PATCH] D103184: [AArch64] handle -Wa,-march=

2021-06-07 Thread Jian Cai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfd11a26d368c: [AArch64] handle -Wa,-march= (authored by 
jcai19).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103184

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aarch64-target-as-march.s

Index: clang/test/Driver/aarch64-target-as-march.s
===
--- /dev/null
+++ clang/test/Driver/aarch64-target-as-march.s
@@ -0,0 +1,46 @@
+/// These tests make sure that options passed to the assembler
+/// via -Wa or -Xassembler are applied correctly to assembler inputs.
+
+/// Does not apply to non assembly files
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=armv8.1-a \
+// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefix=TARGET-FEATURE-1 %s
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Xassembler -march=armv8.1-a \
+// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefix=TARGET-FEATURE-1 %s
+
+// TARGET-FEATURE-1-NOT: "-target-feature" "+v8.1a"
+
+/// Does apply to assembler input
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=armv8.2-a %s 2>&1 | \
+// RUN: FileCheck --check-prefix=TARGET-FEATURE-2 %s
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Xassembler -march=armv8.2-a %s 2>&1 | \
+// RUN: FileCheck --check-prefix=TARGET-FEATURE-2 %s
+
+// TARGET-FEATURE-2: "-target-feature" "+v8.2a"
+
+/// No unused argument warnings when there are multiple values
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=armv8.1-a -Wa,-march=armv8.2-a %s 2>&1 | \
+// RUN: FileCheck --check-prefix=UNUSED-WARNING %s
+
+// UNUSED-WARNING-NOT: warning: argument unused during compilation
+
+/// Last march to assembler wins
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=armv8.2-a -Wa,-march=armv8.1-a %s 2>&1 | \
+// RUN: FileCheck --check-prefix=MULTIPLE-VALUES %s
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=armv8.2-a,-march=armv8.1-a %s 2>&1 | \
+// RUN: FileCheck --check-prefix=MULTIPLE-VALUES %s
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Xassembler -march=armv8.2-a -Xassembler \
+// RUN: -march=armv8.1-a %s 2>&1 | FileCheck --check-prefix=MULTIPLE-VALUES %s
+
+// MULTIPLE-VALUES: "-target-feature" "+v8.1a
+// MULTIPLE-VALUES-NOT: "-target-feature" "+v8.2a
+
+/// march to compiler and assembler, we choose the one suited to the input file type
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=armv8.3-a -march=armv8.4-a %s 2>&1 | \
+// RUN: FileCheck --check-prefix=TARGET-FEATURE-3 %s
+// RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=armv8.3-a -march=armv8.4-a \
+// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefix=TARGET-FEATURE-4 %s
+
+// TARGET-FEATURE-3: "-target-feature" "+v8.3a"
+// TARGET-FEATURE-3-NOT: "-target-feature" "+v8.4a"
+// TARGET-FEATURE-4: "-target-feature" "+v8.4a"
+// TARGET-FEATURE-4-NOT: "-target-feature" "+v8.3a"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -344,7 +344,7 @@
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_32:
   case llvm::Triple::aarch64_be:
-aarch64::getAArch64TargetFeatures(D, Triple, Args, Features);
+aarch64::getAArch64TargetFeatures(D, Triple, Args, Features, ForAS);
 break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
Index: clang/lib/Driver/ToolChains/Arch/AArch64.h
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.h
+++ clang/lib/Driver/ToolChains/Arch/AArch64.h
@@ -22,7 +22,8 @@
 
 void getAArch64TargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
-  std::vector &Features);
+  std::vector &Features,
+  bool ForAS);
 
 std::string getAArch64TargetCPU(const llvm::opt::ArgList &Args,
 const llvm::Triple &Triple, llvm::opt::Arg *&A);
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -185,12 +185,20 @@
 void aarch64::getAArch64TargetFeatures(const Driver &D,
const llvm::Triple &Triple,
const ArgList &Args,
-   std::vector &Features) {
+   std::vector &Features,
+   bool ForAS) {
  

[PATCH] D103452: [clang] Fix reading long doubles with va_arg on x86_64 mingw

2021-06-07 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: clang/test/CodeGen/mingw-long-double.c:56-58
+  // GNU32: bitcast i8* %argp.cur to x86_fp80*
+  // GNU64: bitcast i8* %argp.cur to x86_fp80**
+  // MSC64: bitcast i8* %argp.cur to double*

mstorsjo wrote:
> rnk wrote:
> > These tests will stop working after opaque pointers happens, which I hope 
> > comes in the next year. If you look for a load of the pointer type, that 
> > should be resilient to opaque pointers.
> Hmm, good point, but the test feels more brittle to me in that form:
> 
> ```
>   // GNU32: load x86_fp80, x86_fp80*
>   // GNU64: load x86_fp80*, x86_fp80**
>   // GNU64: load x86_fp80, x86_fp80*
>   // MSC64: load double, double*
> ```
> 
> That wouldn't notice if GNU32 also used an indirect pointer for this case (as 
> it would still match the second load - but it would notice if GNU64 stopped 
> using an indirect pointer as the first load wouldn't be matched). I guess 
> it'd be safer if I'd use more named regex patterns in the test to follow the 
> chain from the argp, but then we end up with a pattern covering the bits that 
> change due to opaque pointers too.
@rnk - WDYT about how to write the test patterns - see above?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103452

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


[PATCH] D103803: [analyzer] [NFC] Implement a wrapper SValBuilder::getCastedMemRegionVal for similar functionality on region cast

2021-06-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103803

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


[PATCH] D103317: [Analyzer][engine][solver] Simplify complex constraints

2021-06-07 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@vsavchenko

I appologize for my immaturity and for the audacity of my infantile 
assumptions. I admit any constructive criticism. Thank you for referencing the 
theory. I will thoroughly study the domain in all.

As for the **assignments** and why I brought them up, that's because I just 
tried to look at the problem from another angle. Consider two snippets:

  void f(int a, int b, int c, int x, int y){
a = b;
x = y;
c = a;
// What can you say about a, x, c?
// `a` equals to `b` and 'c'
// `x` equals to `y`
// `c` equals to `a` and `b`
  }

and

  void f(int a, int b, int c, int x, int y){
if(a == b) {
  if(x == y) {
if(c == a) {
  // What can you say about a, x, c?
  // `a` equals to `b` and 'c'
  // `x` equals to `y`
  // `c` equals to `a` and `b`
}
  }
}
  }

They both generates the same relationship between the variables. **Assignment** 
seemed to me as just a special case in a //true// branch of `==` operator and 
can be substituted with it in calculations. So, I decided to make some 
assumptions in this way. Digging more, it opened a lot of gaps and lacks for me.
Next time I will investigate deeper to present a finalized solution and not 
wasting your time explaining me the basics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103317

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


[PATCH] D101237: [lldb] Fix [[no_unique_address]] and libstdc++ 11's std::unique_ptr

2021-06-07 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil updated this revision to Diff 350361.
jankratochvil added a comment.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, sstefan1, 
martong, hiraditya.
Herald added a reviewer: shafik.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: shafik.
Herald added projects: clang, LLVM.

`DW_AT_byte_size 0` implementation as suggested by @teemperor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101237

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/test/Shell/Expr/no_unique_address.cpp
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1603,12 +1603,16 @@
   } else {
 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset);
   }
+  assert(!(DT->getFlags() & DINode::FlagIsZeroSize) &&
+ "bitfields cannot have [[no_unique_address]]");
 } else {
   // This is not a bitfield.
   OffsetInBytes = DT->getOffsetInBits() / 8;
   if (AlignInBytes)
 addUInt(MemberDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
 AlignInBytes);
+  if (DT->getFlags() & DINode::FlagIsZeroSize)
+addUInt(MemberDie, dwarf::DW_AT_byte_size, None, 0);
 }
 
 if (DD->getDwarfVersion() <= 2) {
Index: llvm/include/llvm/IR/DebugInfoFlags.def
===
--- llvm/include/llvm/IR/DebugInfoFlags.def
+++ llvm/include/llvm/IR/DebugInfoFlags.def
@@ -58,6 +58,8 @@
 HANDLE_DI_FLAG((1 << 27), BigEndian)
 HANDLE_DI_FLAG((1 << 28), LittleEndian)
 HANDLE_DI_FLAG((1 << 29), AllCallsDescribed)
+// FIXME: Move it to ReservedBit4?
+HANDLE_DI_FLAG((1 << 30), IsZeroSize)
 
 // To avoid needing a dedicated value for IndirectVirtualBase, we use
 // the bitwise or of Virtual and FwdDecl, which does not otherwise
@@ -67,7 +69,7 @@
 #ifdef DI_FLAG_LARGEST_NEEDED
 // intended to be used with ADT/BitmaskEnum.h
 // NOTE: always must be equal to largest flag, check this when adding new flag
-HANDLE_DI_FLAG((1 << 29), Largest)
+HANDLE_DI_FLAG((1 << 30), Largest)
 #undef DI_FLAG_LARGEST_NEEDED
 #endif
 
Index: lldb/test/Shell/Expr/no_unique_address.cpp
===
--- /dev/null
+++ lldb/test/Shell/Expr/no_unique_address.cpp
@@ -0,0 +1,15 @@
+// Test LLDB does not assert on miscalculated field offsets.
+
+// RUN: %clang_host %s -g -c -o %t.o
+// RUN: %lldb %t.o -o "p c.c" -o exit | FileCheck %s
+
+// CHECK: (lldb) p c.c
+// CHECK-NEXT: (char) $0 = '\0'
+
+struct A {};
+struct B {
+  [[no_unique_address]] A a;
+};
+struct C : B {
+  char c;
+} c;
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -843,11 +843,10 @@
CompilerType *child_type = nullptr);
 
   // Modifying RecordType
-  static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type,
-llvm::StringRef name,
-const CompilerType &field_type,
-lldb::AccessType access,
-uint32_t bitfield_bit_size);
+  static clang::FieldDecl *
+  AddFieldToRecordType(const CompilerType &type, llvm::StringRef name,
+   const CompilerType &field_type, lldb::AccessType access,
+   uint32_t bitfield_bit_size, bool IsZeroSize = false);
 
   static void BuildIndirectFields(const CompilerType &type);
 
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7164,7 +7164,7 @@
 clang::FieldDecl *TypeSystemClang::AddFieldToRecordType(
 const CompilerType &type, llvm::StringRef name,
 const CompilerType &field_clang_type, AccessType access,
-uint32_t bitfield_bit_size) {
+uint32_t bitfield_bit_size, bool IsZeroSize) {
   if (!type.IsValid() || !field_clang_type.IsValid())
 re

[PATCH] D101237: [lldb] Fix [[no_unique_address]] and libstdc++ 11's std::unique_ptr

2021-06-07 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil added inline comments.



Comment at: llvm/include/llvm/IR/DebugInfoFlags.def:62
+// FIXME: Move it to ReservedBit4?
+HANDLE_DI_FLAG((1 << 30), IsZeroSize)
 

This would need to be handled better if approved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101237

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


[PATCH] D89055: [analyzer] Wrong type cast occures during pointer dereferencing after type punning

2021-06-07 Thread Chris Hamilton via Phabricator via cfe-commits
chrish_ericsson_atx added inline comments.
Herald added a subscriber: manas.



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:763-765
+  if (const auto *ER = dyn_cast(R)) {
+R = StateMgr.getStoreManager().castRegion(ER, CastTy);
+return loc::MemRegionVal(R);

This causes new false-positive static analysis warnings from 
core.CallAndMessage and core.UndefinedBinaryOperatorResult, (and possibly 
others?), possibly because of loss of array extent information.  See 
https://bugs.llvm.org/show_bug.cgi?id=50604.  



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89055

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


[PATCH] D101237: [lldb] Fix [[no_unique_address]] and libstdc++ 11's std::unique_ptr

2021-06-07 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil added a comment.

[Dwarf-Discuss] How to map [[no_unique_address]] into DWARF: 
http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/2021-June/004825.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101237

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


[PATCH] D103750: [analyzer][WIP] Handle std::make_unique for SmartPtrModeling

2021-06-07 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 350362.
RedDocMD added a comment.

Made stylistic refactors


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103750

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

Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -35,9 +35,15 @@
 using namespace ento;
 
 namespace {
+
+enum class MakeUniqueKind {
+  Regular,  // ie, std::make_unique
+  ForOverwrite, // ie, std::make_unique_for_overwrite
+};
+
 class SmartPtrModeling
 : public Checker {
+ check::LiveSymbols, check::Bind> {
 
   bool isBoolConversionMethod(const CallEvent &Call) const;
 
@@ -56,6 +62,7 @@
   void printState(raw_ostream &Out, ProgramStateRef State, const char *NL,
   const char *Sep) const override;
   void checkLiveSymbols(ProgramStateRef State, SymbolReaper &SR) const;
+  void checkBind(SVal L, SVal V, const Stmt *S, CheckerContext &C) const;
 
 private:
   void handleReset(const CallEvent &Call, CheckerContext &C) const;
@@ -76,10 +83,27 @@
   {{"release"}, &SmartPtrModeling::handleRelease},
   {{"swap", 1}, &SmartPtrModeling::handleSwap},
   {{"get"}, &SmartPtrModeling::handleGet}};
+  const CallDescription StdMakeUniqueCall{{"std", "make_unique"}};
+  const CallDescription StdMakeUniqueForOverwriteCall{
+  {"std", "make_unique_for_overwrite"}};
 };
 } // end of anonymous namespace
 
+class MakeUniqueKindWrapper {
+  const MakeUniqueKind Kind;
+
+public:
+  MakeUniqueKindWrapper(MakeUniqueKind Kind) : Kind(Kind) {}
+  MakeUniqueKind get() const { return Kind; }
+  void Profile(llvm::FoldingSetNodeID &ID) const {
+ID.AddInteger(static_cast(Kind));
+  }
+  bool operator==(const MakeUniqueKind &RHS) const { return Kind == RHS; }
+  bool operator!=(const MakeUniqueKind &RHS) const { return Kind != RHS; }
+};
+
 REGISTER_MAP_WITH_PROGRAMSTATE(TrackedRegionMap, const MemRegion *, SVal)
+REGISTER_LIST_WITH_PROGRAMSTATE(MakeUniqueKindList, MakeUniqueKindWrapper)
 
 // Define the inter-checker API.
 namespace clang {
@@ -177,7 +201,21 @@
 
 bool SmartPtrModeling::evalCall(const CallEvent &Call,
 CheckerContext &C) const {
+
   ProgramStateRef State = C.getState();
+
+  if (Call.isCalled(StdMakeUniqueCall)) {
+State = State->add(MakeUniqueKind::Regular);
+C.addTransition(State);
+return true;
+  }
+
+  if (Call.isCalled(StdMakeUniqueForOverwriteCall)) {
+State = State->add(MakeUniqueKind::ForOverwrite);
+C.addTransition(State);
+return true;
+  }
+
   if (!smartptr::isStdSmartPtrCall(Call))
 return false;
 
@@ -272,6 +310,46 @@
   return C.isDifferent();
 }
 
+bool isUniquePtrType(QualType QT) {
+  if (QT.isNull())
+return false;
+  const auto *Decl = QT->getAsCXXRecordDecl();
+  if (!Decl || !Decl->getDeclContext()->isStdNamespace())
+return false;
+  const IdentifierInfo *ID = Decl->getIdentifier();
+  if (!ID)
+return false;
+  const StringRef Name = ID->getName();
+  return Name == "unique_ptr";
+}
+
+void SmartPtrModeling::checkBind(SVal L, SVal V, const Stmt *S,
+ CheckerContext &C) const {
+  const auto *TVR = dyn_cast_or_null(L.getAsRegion());
+  if (!TVR)
+return;
+  if (!isUniquePtrType(TVR->getValueType()))
+return;
+  const auto *ThisRegion = dyn_cast(TVR);
+  if (!ThisRegion)
+return;
+
+  ProgramStateRef State = C.getState();
+  auto KindList = State->get();
+  assert(!KindList.isEmpty() &&
+ "Expected list to contain the kind of the last make_unique");
+  auto Kind = KindList.getHead();
+  if (Kind == MakeUniqueKind::ForOverwrite) {
+auto RHSVal = C.getSValBuilder().makeNull();
+State = State->set(ThisRegion, RHSVal);
+  } else {
+// TODO: Encode information that the inner pointer for
+// unique_ptr made by std::make_unique is *not* null
+  }
+  State = State->set(KindList.getTail());
+  C.addTransition(State);
+}
+
 void SmartPtrModeling::checkDeadSymbols(SymbolReaper &SymReaper,
 CheckerContext &C) const {
   ProgramStateRef State = C.getState();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103750: [analyzer][WIP] Handle std::make_unique for SmartPtrModeling

2021-06-07 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD marked 3 inline comments as done.
RedDocMD added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:337
+
+bool isUniquePtrType(QualType QT) {
+  const auto *T = QT.getTypePtr();

NoQ wrote:
> Please merge with `isStdSmartPtrCall`.
I don't think that can be done because `isStdSmartPtrCall` checks //calls// 
like `a.foo()`, checking if `a` is a smart-ptr. On the other hand I need to 
check for statements like `a = foo()` and ensure that `a` is a smart-ptr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103750

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


[PATCH] D103750: [analyzer][WIP] Handle std::make_unique for SmartPtrModeling

2021-06-07 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD marked an inline comment as done.
RedDocMD added a comment.

In D103750#2801555 , @NoQ wrote:

> Yes I think you should totally do an `evalCall()` here. The function has no 
> other side effects apart from making a pointer so it's valuable to fully 
> model it so that to avoid unnecessary store invalidations.

Am I not doing that now? I didn't get this point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103750

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


[PATCH] D103745: [dfsan] Add full fast8 support

2021-06-07 Thread George Balatsouras via Phabricator via cfe-commits
gbalats marked an inline comment as done.
gbalats added inline comments.



Comment at: clang/docs/DataFlowSanitizer.rst:172-178
 assert(ij_label == 3);  // Verifies all of the above
 
+// Or, equivalently:
+assert(dfsan_has_label(ij_label, i_label));
+assert(dfsan_has_label(ij_label, j_label));
+assert(!dfsan_has_label(ij_label, k_label));
+

stephan.yichao.zhao wrote:
> If we swap assert(ij_label == 3) with the 3 dfsan_has_label, the two 
> equivalent blocks are close to each other.
I think this way is better to demonstrate the differences:
- the first block exposes dfsan internals (the integer representation) and 
makes explicit statements about label values
- the second block uses dfsan_has_label to abstract the internals, not exposing 
the integer representation (or the fact that labels are OR'd).



Comment at: clang/docs/DataFlowSanitizerDesign.rst:60
 
-As stated above, the tool must track a large number of taint
-labels. This poses an implementation challenge, as most multiple-label
-tainting systems assign one label per bit to shadow storage, and
-union taint labels using a bitwise or operation. This will not scale
-to clients which use hundreds or thousands of taint labels, as the
-label union operation becomes O(n) in the number of supported labels,
-and data associated with it will quickly dominate the live variable
-set, causing register spills and hampering performance.
-
-Instead, a low overhead approach is proposed which is best-case O(log\
-:sub:`2` n) during execution. The underlying assumption is that
-the required space of label unions is sparse, which is a reasonable
-assumption to make given that we are optimizing for the case where
-applications mostly copy data from one place to another, without often
-invoking the need for an actual union operation. The representation
-of a taint label is a 16-bit integer, and new labels are allocated
-sequentially from a pool. The label identifier 0 is special, and means
-that the data item is unlabelled.
-
-When a label union operation is requested at a join point (any
-arithmetic or logical operation with two or more operands, such as
-addition), the code checks whether a union is required, whether the
-same union has been requested before, and whether one union label
-subsumes the other. If so, it returns the previously allocated union
-label. If not, it allocates a new union label from the same pool used
-for new labels.
-
-Specifically, the instrumentation pass will insert code like this
-to decide the union label ``lu`` for a pair of labels ``l1``
-and ``l2``:
-
-.. code-block:: c
-
-  if (l1 == l2)
-lu = l1;
-  else
-lu = __dfsan_union(l1, l2);
-
-The equality comparison is outlined, to provide an early exit in
-the common cases where the program is processing unlabelled data, or
-where the two data items have the same label.  ``__dfsan_union`` is
-a runtime library function which performs all other union computation.
+We use an 8-bit unsigned integers for the representation of a
+label. The label identifier 0 is special, and means that the data item

stephan.yichao.zhao wrote:
> integer
Done.



Comment at: clang/docs/DataFlowSanitizerDesign.rst:65
+join point (any arithmetic or logical operation with two or more
+operands, such as addition), we can simply OR the two labels in O(1).
 

stephan.yichao.zhao wrote:
> the labels, and each OR is in O(1).
Not sure how this changes the meaning, since the two labels would need one OR 
instruction.



Comment at: clang/docs/DataFlowSanitizerDesign.rst:68
+Users are responsible for managing the 8 integer labels (i.e., keeping
+track of what labels they have used so far, pick one that is yet
+unused, etc).

stephan.yichao.zhao wrote:
> picking
Done.



Comment at: clang/docs/DataFlowSanitizerDesign.rst:74
 
 The following is the current memory layout for Linux/x86\_64:
 

stephan.yichao.zhao wrote:
> memory layout
Done.



Comment at: clang/docs/DataFlowSanitizerDesign.rst:99
 associated directly with registers.  Loads will result in a union of
-all shadow labels corresponding to bytes loaded (which most of the
-time will be short circuited by the initial comparison) and stores will
-result in a copy of the label to the shadow of all bytes stored to.
+all shadow labels corresponding to bytes loaded and stores will result
+in a copy of the label to the shadow of all bytes stored to.

stephan.yichao.zhao wrote:
> , and
Done



Comment at: clang/docs/DataFlowSanitizerDesign.rst:100
+all shadow labels corresponding to bytes loaded and stores will result
+in a copy of the label to the shadow of all bytes stored to.
 

stephan.yichao.zhao wrote:
> the label of a stored value
Done.



Comment at: compiler-rt/lib/dfsan/dfsan.cpp:209
 
-// Like 

[PATCH] D103495: [static initializers] Don't put ordered dynamic initializers of static variables into global_ctors

2021-06-07 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp updated this revision to Diff 350364.
wolfgangp added a comment.
Herald added subscribers: llvm-commits, jdoerfert, pengfei, jrtc27, 
fedor.sergeev, hiraditya, jyknight, dschuff.
Herald added a project: LLVM.

Following the suggestion to define an order of initialization for the entries 
in llvm.global_ctors and llvm.global_dtors this is mainly a documentation 
change, as well as a simple reversed emission of global_ctors/dtors entries 
when InitArray is not used. 
3 test cases are affected, 2 of them just by a reversed order of emission of 
priority-suffixed sections. I added a couple of entries to the third test case 
to verify in-order emission of entries with equal priority.


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

https://reviews.llvm.org/D103495

Files:
  llvm/docs/LangRef.rst
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/test/CodeGen/SPARC/constructor.ll
  llvm/test/CodeGen/X86/2011-08-29-InitOrder.ll
  llvm/test/CodeGen/X86/constructor.ll

Index: llvm/test/CodeGen/X86/constructor.ll
===
--- llvm/test/CodeGen/X86/constructor.ll
+++ llvm/test/CodeGen/X86/constructor.ll
@@ -9,7 +9,7 @@
 ; RUN: llc -mtriple i586-intel-elfiamcu -use-ctors < %s | FileCheck %s --check-prefix=MCU-CTORS
 ; RUN: llc -mtriple i586-intel-elfiamcu < %s | FileCheck %s --check-prefix=MCU-INIT-ARRAY
 ; RUN: llc -mtriple x86_64-win32-gnu < %s | FileCheck --check-prefix=COFF-CTOR %s
-@llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @f, i8* null}, { i32, void ()*, i8* } { i32 15, void ()* @g, i8* @v }, { i32, void ()*, i8* } { i32 5, void ()* @h, i8* @v }]
+@llvm.global_ctors = appending global [5 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @f, i8* null}, { i32, void ()*, i8* } { i32 15, void ()* @g, i8* @v }, { i32, void ()*, i8* } { i32 5, void ()* @h, i8* @v }, { i32, void ()*, i8* } { i32 65535, void ()* @i, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @j, i8* null }]
 
 @v = weak_odr global i8 0
 
@@ -28,15 +28,27 @@
   ret void
 }
 
-; CTOR:		.section	.ctors.65520,"aGw",@progbits,v,comdat
+define void @i() {
+entry:
+  ret void
+}
+
+define void @j() {
+entry:
+  ret void
+}
+
+; CTOR:	.section	.ctors,"aw",@progbits
 ; CTOR-NEXT:	.p2align	3
-; CTOR-NEXT:	.quad	g
+; CTOR-NEXT:	.quad	j
+; CTOR-NEXT:	.quad	i
+; CTOR-NEXT:	.quad	f
 ; CTOR-NEXT:	.section	.ctors.09980,"aGw",@progbits,v,comdat
 ; CTOR-NEXT:	.p2align	3
 ; CTOR-NEXT:	.quad	h
-; CTOR-NEXT:	.section	.ctors,"aw",@progbits
+; CTOR-NEXT:	.section	.ctors.65520,"aGw",@progbits,v,comdat
 ; CTOR-NEXT:	.p2align	3
-; CTOR-NEXT:	.quad	f
+; CTOR-NEXT:	.quad	g
 
 ; INIT-ARRAY:		.section	.init_array.15,"aGw",@init_array,v,comdat
 ; INIT-ARRAY-NEXT:	.p2align	3
@@ -47,6 +59,8 @@
 ; INIT-ARRAY-NEXT:	.section	.init_array,"aw",@init_array
 ; INIT-ARRAY-NEXT:	.p2align	3
 ; INIT-ARRAY-NEXT:	.quad	f
+; INIT-ARRAY-NEXT:	.quad	i
+; INIT-ARRAY-NEXT:	.quad	j
 
 ; NACL:		.section	.init_array.15,"aGw",@init_array,v,comdat
 ; NACL-NEXT:	.p2align	2
@@ -57,6 +71,8 @@
 ; NACL-NEXT:	.section	.init_array,"aw",@init_array
 ; NACL-NEXT:	.p2align	2
 ; NACL-NEXT:	.long	f
+; NACL-NEXT:	.long	i
+; NACL-NEXT:	.long	j
 
 ; MCU-CTORS: .section.ctors,"aw",@progbits
 ; MCU-INIT-ARRAY:.section.init_array,"aw",@init_array
@@ -70,3 +86,5 @@
 ; COFF-CTOR-NEXT:	.section	.ctors,"dw"
 ; COFF-CTOR-NEXT:	.p2align	3
 ; COFF-CTOR-NEXT:	.quad	f
+; COFF-CTOR-NEXT:	.quad	i
+; COFF-CTOR-NEXT:	.quad	j
Index: llvm/test/CodeGen/X86/2011-08-29-InitOrder.ll
===
--- llvm/test/CodeGen/X86/2011-08-29-InitOrder.ll
+++ llvm/test/CodeGen/X86/2011-08-29-InitOrder.ll
@@ -3,24 +3,24 @@
 ; PR5329
 
 @llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 2000, void ()* @construct_2, i8* null }, { i32, void ()*, i8* } { i32 3000, void ()* @construct_3, i8* null }, { i32, void ()*, i8* } { i32 1000, void ()* @construct_1, i8* null }]
-; CHECK-DEFAULT: .section.ctors.64535,"aw",@progbits
-; CHECK-DEFAULT: .long construct_1
-; CHECK-DEFAULT: .section.ctors.63535,"aw",@progbits
-; CHECK-DEFAULT: .long construct_2
 ; CHECK-DEFAULT: .section.ctors.62535,"aw",@progbits
 ; CHECK-DEFAULT: .long construct_3
+; CHECK-DEFAULT: .section.ctors.63535,"aw",@progbits
+; CHECK-DEFAULT: .long construct_2
+; CHECK-DEFAULT: .section.ctors.64535,"aw",@progbits
+; CHECK-DEFAULT: .long construct_1
 
 ; CHECK-DARWIN: .long _construct_1
 ; CHECK-DARWIN-NEXT: .long _construct_2
 ; CHECK-DARWIN-NEXT: .long _construct_3
 
 @llvm.global_dtors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 2000, void ()* @destruct_2, i8* null }, { i32, void ()*, i8* } { i32 1000, void ()* @destruct_1, i8* null }, { i32, void ()*, i8* } { i32 3000, void ()* @destruct_3,

[PATCH] D103611: Correct the behavior of va_arg checking in C++

2021-06-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15783
+  // test for typesAreCompatible() will already properly consider those to
+  // be compatible types.
+  if (Context.getLangOpts().CPlusPlus && !PromoteType.isNull() &&

This explanation doesn't seem right.  Signed and unsigned types are never 
considered "compatible".

If I'm understanding correctly, the case this code addresses is promotion 
according to `[conv.prom]`p3: "A prvalue of an unscoped enumeration type whose 
underlying type is not fixed [...]".  Somehow, the enum ends up with an 
unsigned underlying type, but we promote to int?  And this doesn't happen in C 
somehow?


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

https://reviews.llvm.org/D103611

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


[PATCH] D103750: [analyzer][WIP] Handle std::make_unique for SmartPtrModeling

2021-06-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Ugh, this entire `checkBind` hack was so unexpected that I didn't even 
recognize `evalCall`. What prevents you from doing everything in `evalCall`? No 
state traits, no nothing, just directly take the this-region and attach the 
value to it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103750

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


[PATCH] D97085: [OpenMP] libomp: implement OpenMP 5.1 inoutset task dependence type

2021-06-07 Thread Andrey Churbanov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa1f550e05254: [OpenMP] libomp: implement OpenMP 5.1 inoutset 
task dependence type (authored by AndreyChurbanov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97085

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/depobj_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  clang/test/OpenMP/task_codegen.c
  clang/test/OpenMP/task_codegen.cpp
  clang/test/OpenMP/task_if_codegen.cpp
  openmp/runtime/src/kmp.h
  openmp/runtime/src/kmp_taskdeps.cpp
  openmp/runtime/src/kmp_taskdeps.h
  openmp/runtime/test/tasking/bug_nested_proxy_task.c
  openmp/runtime/test/tasking/bug_proxy_task_dep_waiting.c
  openmp/runtime/test/tasking/hidden_helper_task/common.h
  openmp/runtime/test/tasking/hidden_helper_task/depend.cpp
  openmp/runtime/test/tasking/hidden_helper_task/gtid.cpp
  openmp/runtime/test/tasking/omp51_task_dep_inoutset.c

Index: openmp/runtime/test/tasking/omp51_task_dep_inoutset.c
===
--- /dev/null
+++ openmp/runtime/test/tasking/omp51_task_dep_inoutset.c
@@ -0,0 +1,258 @@
+// RUN: %libomp-compile-and-run
+// RUN: %libomp-cxx-compile-and-run
+// UNSUPPORTED: gcc
+
+// Tests OMP 5.0 task dependences "mutexinoutset" and 5.1 "inoutset",
+// emulates compiler codegen for new dep kinds
+// Mutually exclusive tasks get same input dependency info array
+//
+// Task tree created:
+//  task0 - task1 (in)
+// \
+//task2 - task3 (inoutset)
+// /
+//  task3 - task4 (in)
+//   /
+//  task6 <-->task7  (mutexinoutset)
+//   \/
+//   task8 (in)
+//
+#include 
+#include 
+
+#ifdef _WIN32
+#include 
+#define mysleep(n) Sleep(n)
+#else
+#include 
+#define mysleep(n) usleep((n)*1000)
+#endif
+
+// to check the # of concurrent tasks (must be 1 for MTX, <3 for other kinds)
+static int volatile checker = 0;
+static int err = 0;
+#ifndef DELAY
+#define DELAY 100
+#endif
+
+// ---
+// internal data to emulate compiler codegen
+typedef struct DEP {
+  size_t addr;
+  size_t len;
+  int flags;
+} dep;
+typedef struct task {
+  void** shareds;
+  void* entry;
+  int part_id;
+  void* destr_thunk;
+  int priority;
+  long long device_id;
+  int f_priv;
+} task_t;
+#define TIED 1
+typedef int(*entry_t)(int, task_t*);
+typedef struct ID {
+  int reserved_1;
+  int flags;
+  int reserved_2;
+  int reserved_3;
+  char *psource;
+} id;
+// thunk routine for tasks with MTX dependency
+int thunk_m(int gtid, task_t* ptask) {
+  int th = omp_get_thread_num();
+  #pragma omp atomic
+++checker;
+  printf("task _%d, th %d\n", ptask->f_priv, th);
+  if (checker != 1) { // no more than 1 task at a time
+err++;
+printf("Error1, checker %d != 1\n", checker);
+  }
+  mysleep(DELAY);
+  if (checker != 1) { // no more than 1 task at a time
+err++;
+printf("Error2, checker %d != 1\n", checker);
+  }
+  #pragma omp atomic
+--checker;
+  return 0;
+}
+// thunk routine for tasks with inoutset dependency
+int thunk_s(int gtid, task_t* ptask) {
+  int th = omp_get_thread_num();
+  #pragma omp atomic
+++checker;
+  printf("task _%d, th %d\n", ptask->f_priv, th);
+  if (checker > 2) { // no more than 2 tasks concurrently
+err++;
+printf("Error1, checker %d > 2\n", checker);
+  }
+  mysleep(DELAY);
+  if (checker > 2) { // no more than 2 tasks concurrently
+err++;
+printf("Error2, checker %d > 2\n", checker);
+  }
+  #pragma omp atomic
+--checker;
+  return 0;
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+int __kmpc_global_thread_num(id*);
+extern task_t* __kmpc_omp_task_alloc(id *loc, int gtid, int flags,
+ size_t sz, size_t shar, entry_t rtn);
+int
+__kmpc_omp_task_with_deps(id *loc, int gtid, task_t *task, int nd, dep *dep_lst,
+  int nd_noalias, dep *noalias_dep_lst);
+static id loc = {0, 2, 0, 0, ";file;func;0;0;;"};
+#ifdef __cplusplus
+} // extern "C"
+#endif
+// End of internal data
+// ---
+
+int main()
+{
+  int i1,i2,i3;
+  omp_set_num_threads(4);
+  omp_set_dynamic(0);
+  #pragma omp parallel
+  {
+#pragma omp single nowait
+{
+  dep sdep[2];
+  task_t *ptr;
+  int gtid = __kmpc_global_thread_num(&loc);
+  int t = omp_get_thread_num();
+  #pragma omp task depend(in: i1, i2)
+  { int th = omp_get_thread_num();
+printf("task 0_%d, th %d\n", t, th);
+#pragma omp atomic
+  ++checker;
+if (checker > 2) { // no more than 2 tasks concurrently
+   

[PATCH] D103184: [AArch64] handle -Wa,-march=

2021-06-07 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests on arm macs: http://45.33.8.238/macm1/10931/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103184

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


  1   2   >