[PATCH] D127578: [clang-format] Handle deprecated options in dump_format_style.py

2022-06-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay 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/D127578/new/

https://reviews.llvm.org/D127578

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


[PATCH] D127484: [clang-format] Use tabs on GNU style

2022-06-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D127484#3576061 , @a4lg wrote:

> Interesting.
>
> I measured some development branch (targeting `*.c`, `*.cc`, `*.cpp` and 
> `*.h`):
>
> | Program   | prefix: 8 spaces | prefix: 1 tab | 8sp percentage |
> | Coreutils | 23494| 461   | 98.08% |
> |

All of the 461 lines with a tab prefix are in a single header file: 
coreutils/src/longlong.h. So probably by accident.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127484

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


[PATCH] D127589: [RISCV] Compatible with more RISCV related ld in the test

2022-06-12 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce created this revision.
Herald added subscribers: VincentWu, luke957, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
sunshaoce requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD.
Herald added a project: clang.

When `riscv64-unknown-linux-gnu-ld` is in the PATH, `clang -### -fuse-ld=ld 
--target=riscv64-unknown-linux-gnu` will use unknown-linux-gnu-ld first, which 
causes the error in the lit test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127589

Files:
  clang/test/Driver/riscv64-toolchain.c


Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -21,7 +21,7 @@
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 
-no-pie \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64 %s
 
-// C-RV64-BAREMETAL-LP64: 
"{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}bin{{/|}}riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/riscv64-unknown-elf{{.*}}ld"
 // C-RV64-BAREMETAL-LP64: 
"--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
 // C-RV64-BAREMETAL-LP64: 
"{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
 // C-RV64-BAREMETAL-LP64: 
"{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
@@ -36,7 +36,7 @@
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-NOSYSROOT-LP64 %s
 
-// C-RV64-BAREMETAL-NOSYSROOT-LP64: 
"{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}bin{{/|}}riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/riscv64-unknown-elf{{.*}}ld"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: 
"{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}riscv64-unknown-elf/lib{{/|}}crt0.o"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: 
"{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: 
"-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
@@ -51,7 +51,7 @@
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-LP64 %s
 
 // CXX-RV64-BAREMETAL-LP64: "-internal-isystem" 
"{{.*}}Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++{{/|}}8.0.1"
-// CXX-RV64-BAREMETAL-LP64: 
"{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}bin{{/|}}riscv64-unknown-elf-ld"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}/riscv64-unknown-elf{{.*}}ld"
 // CXX-RV64-BAREMETAL-LP64: 
"--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
 // CXX-RV64-BAREMETAL-LP64: 
"{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
 // CXX-RV64-BAREMETAL-LP64: 
"{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
@@ -67,7 +67,7 @@
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-NOSYSROOT-LP64 %s
 
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "-internal-isystem" 
"{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}riscv64-unknown-elf/include/c++{{/|}}8.0.1"
-// CXX-RV64-BAREMETAL-NOSYSROOT-LP64: 
"{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}bin{{/|}}riscv64-unknown-elf-ld"
+// CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/riscv64-unknown-elf{{.*}}ld"
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: 
"{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}riscv64-unknown-elf/lib{{/|}}crt0.o"
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: 
"{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: 
"-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
@@ -81,7 +81,7 @@
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64 %s
 
-// C-RV64-LINUX-MULTI-LP64: 
"{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../..{{/|}}..{{/|}}riscv64-unknown-linux-gnu/bin{{/|}}ld"
+// C-RV64-LINUX-MULTI-LP64: "{{.*}}/riscv64-unknown-linux-gnu{{.*}}ld"
 // C-RV64-LINUX-MULTI-LP64: 
"--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
 // C-RV64-LINUX-MULTI-LP64: "-m" "elf64lriscv"
 // C-RV64-LINUX-MULTI-LP64: "-dynamic-linker" "/lib/ld-linux-riscv64-lp64.so.1"
@@ -96,7 +96,7 @@
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&

[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

2022-06-12 Thread Javier Alvarez via Phabricator via cfe-commits
Javier-varez created this revision.
Herald added a project: All.
Javier-varez requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

>From [class.copy.ctor]:

  A non-template constructor for class X is a copy constructor if its first
  parameter is of type X&, const X&, volatile X& or const volatile X&, and
  either there are no other parameters or else all other parameters have
  default arguments (9.3.4.7).
  
  A copy/move constructor for class X is trivial if it is not user-provided and 
if:
  - class X has no virtual functions (11.7.3) and no virtual base classes 
(11.7.2), and
  - the constructor selected to copy/move each direct base class subobject is 
trivial, and
  - or each non-static data member of X that is of class type (or array 
thereof),
the constructor selected to copy/move that member is trivial;
  
  otherwise the copy/move constructor is non-trivial.

So `T(T&) = default`; should be trivial assuming that the previous
provisions are met.

This works in GCC, but not in Clang at the moment:
https://godbolt.org/z/fTGe71b6P


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127593

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/special/class.copy/p12-0x.cpp
  clang/test/CXX/special/class.copy/p25-0x.cpp


Index: clang/test/CXX/special/class.copy/p25-0x.cpp
===
--- clang/test/CXX/special/class.copy/p25-0x.cpp
+++ clang/test/CXX/special/class.copy/p25-0x.cpp
@@ -31,7 +31,22 @@
 struct NonConstCopy {
   NonConstCopy &operator=(NonConstCopy &) = default;
 };
-using _ = not_trivially_assignable;
+static_assert(__has_trivial_assign(NonConstCopy), "");
+static_assert(__is_trivially_assignable(NonConstCopy&, NonConstCopy&), "");
+static_assert(!__is_trivially_assignable(NonConstCopy&, const NonConstCopy &), 
"");
+static_assert(!__is_trivially_assignable(NonConstCopy&, NonConstCopy), "");
+static_assert(!__is_trivially_assignable(NonConstCopy&, NonConstCopy&&), "");
+static_assert(__is_trivially_assignable(NonConstCopy&&, NonConstCopy&), "");
+static_assert(!__is_trivially_assignable(NonConstCopy&&, const NonConstCopy 
&), "");
+static_assert(!__is_trivially_assignable(NonConstCopy&&, NonConstCopy), "");
+static_assert(!__is_trivially_assignable(NonConstCopy&&, NonConstCopy&&), "");
+
+struct DefaultedSpecialMembers {
+  DefaultedSpecialMembers &operator=(const DefaultedSpecialMembers &) = 
default;
+  DefaultedSpecialMembers &operator=(DefaultedSpecialMembers &) = default;
+  DefaultedSpecialMembers &operator=(DefaultedSpecialMembers &&) = default;
+};
+using _ = trivially_assignable;
 
 // class X has no virtual functions
 struct VFn {
Index: clang/test/CXX/special/class.copy/p12-0x.cpp
===
--- clang/test/CXX/special/class.copy/p12-0x.cpp
+++ clang/test/CXX/special/class.copy/p12-0x.cpp
@@ -28,7 +28,18 @@
 struct NonConstCopy {
   NonConstCopy(NonConstCopy &) = default;
 };
-using _ = not_trivially_copyable;
+static_assert(__has_trivial_copy(NonConstCopy), "");
+static_assert(__is_trivially_constructible(NonConstCopy, NonConstCopy&), "");
+static_assert(!__is_trivially_constructible(NonConstCopy, NonConstCopy), "");
+static_assert(!__is_trivially_constructible(NonConstCopy, const NonConstCopy 
&), "");
+static_assert(!__is_trivially_constructible(NonConstCopy, NonConstCopy &&), 
"");
+
+struct DefaultedSpecialMembers {
+  DefaultedSpecialMembers(const DefaultedSpecialMembers&) = default;
+  DefaultedSpecialMembers(DefaultedSpecialMembers &) = default;
+  DefaultedSpecialMembers(DefaultedSpecialMembers &&) = default;
+};
+using _ = trivially_copyable;
 
 // class X has no virtual functions
 struct VFn {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9772,11 +9772,9 @@
 
   case CXXCopyConstructor:
   case CXXCopyAssignment: {
-// Trivial copy operations always have const, non-volatile parameter types.
-ConstArg = true;
 const ParmVarDecl *Param0 = MD->getParamDecl(0);
 const ReferenceType *RT = Param0->getType()->getAs();
-if (!RT || RT->getPointeeType().getCVRQualifiers() != Qualifiers::Const) {
+if (!RT) {
   if (Diagnose)
 Diag(Param0->getLocation(), diag::note_nontrivial_param_type)
   << Param0->getSourceRange() << Param0->getType()
@@ -9784,6 +9782,10 @@
Context.getRecordType(RD).withConst());
   return false;
 }
+
+if (RT && ((RT->getPointeeType().getCVRQualifiers() & Qualifiers::Const) 
== Qualifiers::Const)) {
+  ConstArg = true;
+}
 break;
   }
 


Index: clang/test/CXX/special/class.copy/p25-0x.cpp
===
--- clang/test/CXX/special/class.copy/p25-0x.cpp
+++ clang/test/CXX/special/class.copy/p25-0x.cpp
@@ -3

[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

2022-06-12 Thread Javier Alvarez via Phabricator via cfe-commits
Javier-varez updated this revision to Diff 436207.
Javier-varez added a comment.
Herald added a project: clang-tools-extra.

Fix clang-tidy tests and run clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127593

Files:
  clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-const.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/special/class.copy/p12-0x.cpp
  clang/test/CXX/special/class.copy/p25-0x.cpp

Index: clang/test/CXX/special/class.copy/p25-0x.cpp
===
--- clang/test/CXX/special/class.copy/p25-0x.cpp
+++ clang/test/CXX/special/class.copy/p25-0x.cpp
@@ -31,7 +31,22 @@
 struct NonConstCopy {
   NonConstCopy &operator=(NonConstCopy &) = default;
 };
-using _ = not_trivially_assignable;
+static_assert(__has_trivial_assign(NonConstCopy), "");
+static_assert(__is_trivially_assignable(NonConstCopy &, NonConstCopy &), "");
+static_assert(!__is_trivially_assignable(NonConstCopy &, const NonConstCopy &), "");
+static_assert(!__is_trivially_assignable(NonConstCopy &, NonConstCopy), "");
+static_assert(!__is_trivially_assignable(NonConstCopy &, NonConstCopy &&), "");
+static_assert(__is_trivially_assignable(NonConstCopy &&, NonConstCopy &), "");
+static_assert(!__is_trivially_assignable(NonConstCopy &&, const NonConstCopy &), "");
+static_assert(!__is_trivially_assignable(NonConstCopy &&, NonConstCopy), "");
+static_assert(!__is_trivially_assignable(NonConstCopy &&, NonConstCopy &&), "");
+
+struct DefaultedSpecialMembers {
+  DefaultedSpecialMembers &operator=(const DefaultedSpecialMembers &) = default;
+  DefaultedSpecialMembers &operator=(DefaultedSpecialMembers &) = default;
+  DefaultedSpecialMembers &operator=(DefaultedSpecialMembers &&) = default;
+};
+using _ = trivially_assignable;
 
 // class X has no virtual functions
 struct VFn {
Index: clang/test/CXX/special/class.copy/p12-0x.cpp
===
--- clang/test/CXX/special/class.copy/p12-0x.cpp
+++ clang/test/CXX/special/class.copy/p12-0x.cpp
@@ -28,7 +28,18 @@
 struct NonConstCopy {
   NonConstCopy(NonConstCopy &) = default;
 };
-using _ = not_trivially_copyable;
+static_assert(__has_trivial_copy(NonConstCopy), "");
+static_assert(__is_trivially_constructible(NonConstCopy, NonConstCopy &), "");
+static_assert(!__is_trivially_constructible(NonConstCopy, NonConstCopy), "");
+static_assert(!__is_trivially_constructible(NonConstCopy, const NonConstCopy &), "");
+static_assert(!__is_trivially_constructible(NonConstCopy, NonConstCopy &&), "");
+
+struct DefaultedSpecialMembers {
+  DefaultedSpecialMembers(const DefaultedSpecialMembers &) = default;
+  DefaultedSpecialMembers(DefaultedSpecialMembers &) = default;
+  DefaultedSpecialMembers(DefaultedSpecialMembers &&) = default;
+};
+using _ = trivially_copyable;
 
 // class X has no virtual functions
 struct VFn {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9772,11 +9772,9 @@
 
   case CXXCopyConstructor:
   case CXXCopyAssignment: {
-// Trivial copy operations always have const, non-volatile parameter types.
-ConstArg = true;
 const ParmVarDecl *Param0 = MD->getParamDecl(0);
 const ReferenceType *RT = Param0->getType()->getAs();
-if (!RT || RT->getPointeeType().getCVRQualifiers() != Qualifiers::Const) {
+if (!RT) {
   if (Diagnose)
 Diag(Param0->getLocation(), diag::note_nontrivial_param_type)
   << Param0->getSourceRange() << Param0->getType()
@@ -9784,6 +9782,11 @@
Context.getRecordType(RD).withConst());
   return false;
 }
+
+if (RT && ((RT->getPointeeType().getCVRQualifiers() & Qualifiers::Const) ==
+   Qualifiers::Const)) {
+  ConstArg = true;
+}
 break;
   }
 
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-const.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-const.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-const.cpp
@@ -10,12 +10,12 @@
 };
 
 // This class is non-trivially copyable because the copy-constructor and copy
-// assignment take non-const references.
+// assignment take non-const references and are user-provided.
 struct ModifiesRightSide {
   ModifiesRightSide() = default;
-  ModifiesRightSide(ModifiesRightSide &) = default;
+  ModifiesRightSide(ModifiesRightSide &);
   bool operator<(ModifiesRightSide &) const;
-  ModifiesRightSide &operator=(ModifiesRightSide &) = default;
+  ModifiesRightSide &operator=(ModifiesRightSide &);
 };
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/lis

[PATCH] D126682: [Interpreter][ClangRepl] Implement undo command

2022-06-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/lib/Interpreter/IncrementalParser.cpp:180
   DiagnosticsEngine &Diags = getCI()->getDiagnostics();
   if (Diags.hasErrorOccurred()) {
 TranslationUnitDecl *MostRecentTU = C.getTranslationUnitDecl();

junaire wrote:
> v.g.vassilev wrote:
> > We should call Restore here. 
> Though there are many logic duplicates with `Restore`, I'm not sure if we can 
> refactor it. We have done more here than `Restore`, and `Restore` need to 
> pass a PTU, but we only have `TranslationDecl` here.
I think we can/should be able to construct the `PartialTranslationUnit` with 
only a `TranslationUnitDecl` having `TheModule` as `nullptr`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126682

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


[PATCH] D122768: [Clang][C++20] Support capturing structured bindings in lambdas

2022-06-12 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 436212.
cor3ntin added a comment.

- Rebase
- Cleanup codegen test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122768

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/LambdaCapture.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Analysis/AnalysisDeclContext.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/ScopeInfo.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/test/CodeGenCXX/cxx20-decomposition.cpp
  clang/test/SemaCXX/cxx1z-decomposition.cpp
  clang/test/SemaCXX/cxx20-decomposition.cpp
  clang/test/SemaCXX/decomposition-blocks.cpp
  clang/test/SemaCXX/decomposition-openmp.cpp
  clang/tools/libclang/CIndex.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1144,7 +1144,7 @@
 
   Structured binding extensions
   https://wg21.link/p1091r3";>P1091R3
-  Partial
+  Clang 15
 
   
 https://wg21.link/p1381r1";>P1381R1
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3449,9 +3449,11 @@
C != CEnd; ++C) {
 if (!C->capturesVariable())
   continue;
-
-if (Visit(MakeCursorVariableRef(C->getCapturedVar(), C->getLocation(),
-TU)))
+// TODO: hamdle structured bindings here ?
+if (!isa(C->getCapturedVar()))
+  continue;
+if (Visit(MakeCursorVariableRef(cast(C->getCapturedVar()),
+C->getLocation(), TU)))
   return true;
   }
   // Visit init captures
Index: clang/test/SemaCXX/decomposition-openmp.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/decomposition-openmp.cpp
@@ -0,0 +1,13 @@
+
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -fopenmp %s
+
+// FIXME: OpenMP should support capturing structured bindings
+auto f() {
+  int i[2] = {};
+  auto [a, b] = i; // expected-note 2{{declared here}}
+  return [=, &a] {
+// expected-error@-1 {{capturing a structured binding is not yet supported in OpenMP}}
+return a + b;
+// expected-error@-1 {{capturing a structured binding is not yet supported in OpenMP}}
+  };
+}
Index: clang/test/SemaCXX/decomposition-blocks.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/decomposition-blocks.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s -fblocks
+
+struct S {
+  int i : 1;
+  int j;
+};
+
+void run(void (^)());
+void test() {
+  auto [i, j] = S{1, 42}; // expected-note {{'i' declared here}}
+  run(^{
+(void)i; // expected-error {{reference to local binding 'i' declared in enclosing function 'test'}}
+  });
+}
Index: clang/test/SemaCXX/cxx20-decomposition.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-decomposition.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+template 
+constexpr bool is_same = false;
+template 
+constexpr bool is_same = true;
+
+struct S {
+  int i;
+  int &j;
+};
+
+void check_category() {
+  int a = 42;
+  {
+auto [v, r] = S{1, a};
+(void)[ v, r ] {
+  static_assert(is_same);
+  static_assert(is_same);
+};
+  }
+  {
+auto [v, r] = S{1, a};
+(void)[&v, &r ] {
+  static_assert(is_same);
+  static_assert(is_same);
+};
+  }
+  {
+S s{1, a};
+const auto &[v, r] = s;
+(void)[ v, r ] {
+  static_assert(is_same);
+  static_assert(is_same);
+};
+  }
+  {
+S s{1, a};
+const auto &[v

[PATCH] D127270: [clang-format] Add space in placement new expression

2022-06-12 Thread omar ahmed via Phabricator via cfe-commits
omarahmed added inline comments.



Comment at: clang/lib/Format/Format.cpp:1314
   LLVMStyle.SpaceBeforeParensOptions.AfterIfMacros = true;
+  LLVMStyle.SpaceBeforeParensOptions.AfterPlacementNew = true;
   LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true;

HazardyKnusperkeks wrote:
> This isn't needed, because the default CTor initializes it with true.
> Or you change that, I don't know right now why all other attributes are 
> initialized with false.
I think they are initialized with false so that when we come to [this 
case](https://github.com/llvm/llvm-project/blob/54ae4ca7550a81fd1fa9e484904d553af8fbb2fd/clang/lib/Format/Format.cpp#L1155),
 it breaks while all of them are false. (I am not sure so) I will try to add a 
test to cover 'SBPO_Never' but after converting it to enum.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3399
+  return Style.SpaceBeforeParensOptions.AfterPlacementNew ||
+ spaceRequiredBeforeParens(Right);
 if (Line.Type == LT_ObjCDecl)

MyDeveloperDay wrote:
> what case is covered here by spaceRequiredBeforeParens(Right)?
I intended to cover this case: `new (buf) T` so basically placement new 
expressions, excluding the overloaded new operator function 
declarations/definitions like `T *operator new(size_t size) {}` and excluding 
function declarations/definitions named new like `T *new();`



Comment at: clang/unittests/Format/FormatTest.cpp:15276
 
+  FormatStyle SpacePlacementNew = getLLVMStyle();
+  SpacePlacementNew.SpaceBeforeParens = FormatStyle::SBPO_Custom;

MyDeveloperDay wrote:
> curdeius wrote:
> > Are there any tests with `AfterPlacementNew = false;`? Could you add those 
> > please?
> you should probably give yourself your own test, for SpacePlacementNew
I was thinking of covering `placement delete` too and adding the tests for this 
patch to [this 
test](https://github.com/llvm/llvm-project/blob/54ae4ca7550a81fd1fa9e484904d553af8fbb2fd/clang/unittests/Format/FormatTest.cpp#L10153)
 as it should add more cases to new/delete operators. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127270

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


[PATCH] D126682: [Interpreter][ClangRepl] Implement undo command

2022-06-12 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 436214.
junaire added a comment.

Address Vassil's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126682

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/Interpreter/code-undo.cpp
  clang/test/Interpreter/execute.cpp
  clang/test/Interpreter/plugins.cpp
  clang/test/Interpreter/sanity.c
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -92,8 +92,14 @@
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
 while (llvm::Optional Line = LE.readLine()) {
-  if (*Line == "quit")
+  if (*Line == R"(%quit)")
 break;
+  if (*Line == R"(%undo)") {
+if (auto Err = Interp->Undo())
+  llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+continue;
+  }
+
   if (auto Err = Interp->ParseAndExecute(*Line))
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
 }
Index: clang/test/Interpreter/sanity.c
===
--- clang/test/Interpreter/sanity.c
+++ clang/test/Interpreter/sanity.c
@@ -15,4 +15,4 @@
 // CHECK-NEXT: UnaryOperator{{.*}} 'int' lvalue prefix '++'
 // CHECK-NEXT:   DeclRefExpr{{.*}} 'int' lvalue Var [[var_ptr]] 'TestVar' 'int'
 
-quit
+% quit
Index: clang/test/Interpreter/plugins.cpp
===
--- clang/test/Interpreter/plugins.cpp
+++ clang/test/Interpreter/plugins.cpp
@@ -6,9 +6,8 @@
 int i = 10;
 extern "C" int printf(const char*,...);
 auto r1 = printf("i = %d\n", i);
-quit
+% quit
 
-
-// CHECK: top-level-decl: "i"
-// CHECK-NEXT: top-level-decl: "r1"
-// CHECK-NEXT: i = 10
+// CHECK: top-level-decl: "i"
+// CHECK-NEXT: top-level-decl: "r1"
+// CHECK-NEXT: i = 10
Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -17,4 +17,4 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
-quit
+% quit
Index: clang/test/Interpreter/code-undo.cpp
===
--- clang/test/Interpreter/code-undo.cpp
+++ clang/test/Interpreter/code-undo.cpp
@@ -5,16 +5,14 @@
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
-int i = 42;
-auto r1 = printf("i = %d\n", i);
-// CHECK: i = 42
+int x1 = 42;
+% undo int x1 = 24;
+auto r1 = printf("x1 = %d\n", x1);
+// CHECK: x1 = 24
 
-struct S { float f = 1.0; S *m = nullptr;} s;
+int foo() { return 1; }
+% undo int foo() { return 2; }
+auto r2 = printf("foo() = %d\n", foo());
+// CHECK-NEXT: foo() = 2
 
-auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast(s.m));
-// CHECK-NEXT: S[f=1.00, m=0x0]
-
-inline int foo() { return 42; }
-int r3 = foo();
-
-quit
+% quit
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -218,8 +218,7 @@
 if (Err)
   return Err;
   }
-  // FIXME: Add a callback to retain the llvm::Module once the JIT is done.
-  if (auto Err = IncrExecutor->addModule(std::move(T.TheModule)))
+  if (auto Err = IncrExecutor->addModule(T))
 return Err;
 
   if (auto Err = IncrExecutor->runCtors())
@@ -228,6 +227,10 @@
   return llvm::Error::success();
 }
 
+void Interpreter::Restore(PartialTranslationUnit &PTU) {
+  IncrParser->Restore(PTU);
+}
+
 llvm::Expected
 Interpreter::getSymbolAddress(GlobalDecl GD) const {
   if (!IncrExecutor)
@@ -257,3 +260,18 @@
 
   return IncrExecutor->getSymbolAddress(Name, IncrementalExecutor::LinkerName);
 }
+
+llvm::Error Interpreter::Undo(unsigned N) {
+  auto &PTUs = IncrParser->getPTUs();
+  if (N > PTUs.size())
+return llvm::make_error("Operation failed, "
+   "too many undos",
+   std::error_code());
+  for (unsigned I = 0; I < N; I++) {
+if (llvm::Error Err = IncrExecutor->removeModule(PTUs.back()))
+  return Err;
+Restore(PTUs.back());
+PTUs.pop_back();
+  }
+  return llvm::Error::success();
+}
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@

[PATCH] D126599: [docs][clang] Fix a broken link on the APINotes doc

2022-06-12 Thread Yuki Okushi via Phabricator via cfe-commits
JohnTitor added a comment.

> It seems that other docs are following the GitHub URLs as well. I wish we 
> could do the relative document link instead of embedding the URL, but if that 
> is not possible, then this makes sense to do.

I couldn't find the URL serving that file and I'm not familiar with doing that. 
Let's use a GitHub URL for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126599

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


[clang] e43a85a - [docs][clang] Fix a broken link on the APINotes doc

2022-06-12 Thread Yuki Okushi via cfe-commits

Author: Yuki Okushi
Date: 2022-06-12T22:53:32+09:00
New Revision: e43a85a363cfd2a4c533fa427d9dbecf0d5c5261

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

LOG: [docs][clang] Fix a broken link on the APINotes doc

This patch replaces a link with a GitHub one.

Fixes llvm#55748

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

Added: 


Modified: 
clang/docs/APINotes.rst

Removed: 




diff  --git a/clang/docs/APINotes.rst b/clang/docs/APINotes.rst
index 4ac4c01cdefba..a6e200e8bffde 100644
--- a/clang/docs/APINotes.rst
+++ b/clang/docs/APINotes.rst
@@ -22,11 +22,11 @@ the compiler.
 That's API notes.
 
 API notes use a YAML-based file format. YAML is a format best explained by
-example, so here is a `small example`__ from the compiler test suite of API
+example, so here is a `small example
+`_
+from the compiler test suite of API
 notes for a hypothetical "SomeKit" framework.
 
-__ test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
-
 
 Usage
 =



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


[PATCH] D126599: [docs][clang] Fix a broken link on the APINotes doc

2022-06-12 Thread Yuki Okushi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe43a85a363cf: [docs][clang] Fix a broken link on the 
APINotes doc (authored by JohnTitor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126599

Files:
  clang/docs/APINotes.rst


Index: clang/docs/APINotes.rst
===
--- clang/docs/APINotes.rst
+++ clang/docs/APINotes.rst
@@ -22,11 +22,11 @@
 That's API notes.
 
 API notes use a YAML-based file format. YAML is a format best explained by
-example, so here is a `small example`__ from the compiler test suite of API
+example, so here is a `small example
+`_
+from the compiler test suite of API
 notes for a hypothetical "SomeKit" framework.
 
-__ test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
-
 
 Usage
 =


Index: clang/docs/APINotes.rst
===
--- clang/docs/APINotes.rst
+++ clang/docs/APINotes.rst
@@ -22,11 +22,11 @@
 That's API notes.
 
 API notes use a YAML-based file format. YAML is a format best explained by
-example, so here is a `small example`__ from the compiler test suite of API
+example, so here is a `small example
+`_
+from the compiler test suite of API
 notes for a hypothetical "SomeKit" framework.
 
-__ test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
-
 
 Usage
 =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127589: [RISCV] Compatible with more RISCV related ld in the test

2022-06-12 Thread luxufan via Phabricator via cfe-commits
StephenFan added a comment.

Why not use `env PATH=` in the lit run line to clear the `PATH` env variable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127589

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


[PATCH] D126479: [Clang] Allow 'Complex float __attribute__((mode(HC)))'

2022-06-12 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen updated this revision to Diff 436217.
jolanta.jensen added a comment.

Correcting my buggy computation of RealTypeUsesObjCFPRet bit-field.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126479

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/test/CodeGen/aarch64-attr-mode-complex.c
  clang/test/CodeGen/aarch64-attr-mode-float.c
  clang/test/Sema/attr-mode-vector-types.c
  clang/test/Sema/attr-mode.c

Index: clang/test/Sema/attr-mode.c
===
--- clang/test/Sema/attr-mode.c
+++ clang/test/Sema/attr-mode.c
@@ -37,6 +37,11 @@
 __attribute__((mode(QI))) int invalid_func(void) { return 1; } // expected-error{{'mode' attribute only applies to variables, enums, typedefs, and non-static data members}}
 enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' attribute only applies to}}
 
+typedef _Complex float c16a __attribute((mode(HC)));
+int c16a_test[sizeof(c16a) == 4 ? 1 : -1];
+typedef _Complex double c16b __attribute((mode(HC)));
+int c16b_test[sizeof(c16b) == 4 ? 1 : -1];
+
 typedef _Complex double c32 __attribute((mode(SC)));
 int c32_test[sizeof(c32) == 8 ? 1 : -1];
 typedef _Complex float c64 __attribute((mode(DC)));
Index: clang/test/Sema/attr-mode-vector-types.c
===
--- clang/test/Sema/attr-mode-vector-types.c
+++ clang/test/Sema/attr-mode-vector-types.c
@@ -22,8 +22,7 @@
 // expected-error@-1{{unsupported machine mode 'QC'}}
 // expected-error@-2{{type of machine mode does not match type of base type}}
 typedef _Complex float __attribute__((mode(HC))) __attribute__((vector_size(256))) vec_t9;
-// expected-error@-1{{unsupported machine mode 'HC'}}
-// expected-error@-2{{invalid vector element type '_Complex float'}}
+// expected-error@-1{{invalid vector element type '_Complex float'}}
 typedef int __attribute__((mode(SC))) __attribute__((vector_size(256))) vec_t10;
 // expected-error@-1{{type of machine mode does not match type of base type}}
 // expected-error@-2{{type of machine mode does not support base vector types}}
Index: clang/test/CodeGen/aarch64-attr-mode-float.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-attr-mode-float.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+typedef float f16a __attribute((mode(HF)));
+typedef double f16b __attribute((mode(HF)));
+typedef float f32a __attribute((mode(SF)));
+typedef double f32b __attribute((mode(SF)));
+typedef float f64a __attribute((mode(DF)));
+typedef double f64b __attribute((mode(DF)));
+f16b tmp;
+
+// CHECK: define{{.*}} ptr @f16_test(ptr noundef {{.*}})
+// CHECK:   store half {{.*}}, ptr @tmp, align 2
+// CHECK:   ret ptr @tmp
+f16b *f16_test(f16a *x) {
+  tmp = *x + *x;
+  return &tmp;
+}
+
+// CHECK: define{{.*}} float @f32_test(float noundef {{.*}})
+// CHECK:   ret float {{.*}}
+f32b f32_test(f32a x) {
+  return x + x;
+}
+
+// CHECK: define{{.*}} double @f64_test(double noundef {{.*}})
+// CHECK:   ret double {{.*}}
+f64b f64_test(f64a x) {
+  return x + x;
+}
Index: clang/test/CodeGen/aarch64-attr-mode-complex.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-attr-mode-complex.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+typedef _Complex float c16a __attribute((mode(HC)));
+typedef _Complex double c16b __attribute((mode(HC)));
+typedef _Complex float c32a __attribute((mode(SC)));
+typedef _Complex double c32b __attribute((mode(SC)));
+typedef _Complex float c64a __attribute((mode(DC)));
+typedef _Complex double c64b __attribute((mode(DC)));
+
+// CHECK: define{{.*}} { half, half } @c16_test([2 x half] noundef {{.*}}
+// CHECK:   ret { half, half } {{.*}}
+c16b c16_test(c16a x) {
+  return x + x;
+}
+
+// CHECK: define{{.*}} { float, float } @c32_test([2 x float] noundef {{.*}})
+// CHECK:   ret { float, float } {{.*}}
+c32b c32_test(c32a x) {
+  return x + x;
+}
+
+// CHECK: define{{.*}} { double, double } @c64_test([2 x double] noundef {{.*}})
+// CHECK:   ret { double, double } {{.*}}
+c64b c64_test(c64a x) {
+  return x + x;
+}
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -284,6 +284,8 @@
 
 FloatModeKind TargetInfo::getRealTypeByWidth(unsigned BitWidth,
  FloatModeKind ExplicitType) const {
+  if (getHalfWidth() == BitWidth)
+return FloatModeKind::Half;
   if (getFloatWidth() == BitWidth)
 return FloatModeKind::Float;
   if (getDoubleWidth() == BitWidth)
Index: clang/lib/AST/ASTContext

[PATCH] D126682: [Interpreter][ClangRepl] Implement undo command

2022-06-12 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 436219.
junaire added a comment.

Fix the unintentional format by clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126682

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/Interpreter/code-undo.cpp
  clang/test/Interpreter/execute.cpp
  clang/test/Interpreter/plugins.cpp
  clang/test/Interpreter/sanity.c
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -92,8 +92,14 @@
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
 while (llvm::Optional Line = LE.readLine()) {
-  if (*Line == "quit")
+  if (*Line == R"(%quit)")
 break;
+  if (*Line == R"(%undo)") {
+if (auto Err = Interp->Undo())
+  llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+continue;
+  }
+
   if (auto Err = Interp->ParseAndExecute(*Line))
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
 }
Index: clang/test/Interpreter/sanity.c
===
--- clang/test/Interpreter/sanity.c
+++ clang/test/Interpreter/sanity.c
@@ -15,4 +15,4 @@
 // CHECK-NEXT: UnaryOperator{{.*}} 'int' lvalue prefix '++'
 // CHECK-NEXT:   DeclRefExpr{{.*}} 'int' lvalue Var [[var_ptr]] 'TestVar' 'int'
 
-quit
+%quit
Index: clang/test/Interpreter/plugins.cpp
===
--- clang/test/Interpreter/plugins.cpp
+++ clang/test/Interpreter/plugins.cpp
@@ -6,8 +6,7 @@
 int i = 10;
 extern "C" int printf(const char*,...);
 auto r1 = printf("i = %d\n", i);
-quit
-
+%quit
 
 // CHECK: top-level-decl: "i"
 // CHECK-NEXT: top-level-decl: "r1"
Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -17,4 +17,4 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
-quit
+%quit
Index: clang/test/Interpreter/code-undo.cpp
===
--- clang/test/Interpreter/code-undo.cpp
+++ clang/test/Interpreter/code-undo.cpp
@@ -5,16 +5,14 @@
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
-int i = 42;
-auto r1 = printf("i = %d\n", i);
-// CHECK: i = 42
+int x1 = 42;
+%undo int x1 = 24;
+auto r1 = printf("x1 = %d\n", x1);
+// CHECK: x1 = 24
 
-struct S { float f = 1.0; S *m = nullptr;} s;
+int foo() { return 1; }
+%undo int foo() { return 2; }
+auto r2 = printf("foo() = %d\n", foo());
+// CHECK-NEXT: foo() = 2
 
-auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast(s.m));
-// CHECK-NEXT: S[f=1.00, m=0x0]
-
-inline int foo() { return 42; }
-int r3 = foo();
-
-quit
+%quit
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -218,8 +218,7 @@
 if (Err)
   return Err;
   }
-  // FIXME: Add a callback to retain the llvm::Module once the JIT is done.
-  if (auto Err = IncrExecutor->addModule(std::move(T.TheModule)))
+  if (auto Err = IncrExecutor->addModule(T))
 return Err;
 
   if (auto Err = IncrExecutor->runCtors())
@@ -228,6 +227,10 @@
   return llvm::Error::success();
 }
 
+void Interpreter::Restore(PartialTranslationUnit &PTU) {
+  IncrParser->Restore(PTU);
+}
+
 llvm::Expected
 Interpreter::getSymbolAddress(GlobalDecl GD) const {
   if (!IncrExecutor)
@@ -257,3 +260,18 @@
 
   return IncrExecutor->getSymbolAddress(Name, IncrementalExecutor::LinkerName);
 }
+
+llvm::Error Interpreter::Undo(unsigned N) {
+  auto &PTUs = IncrParser->getPTUs();
+  if (N > PTUs.size())
+return llvm::make_error("Operation failed, "
+   "too many undos",
+   std::error_code());
+  for (unsigned I = 0; I < N; I++) {
+if (llvm::Error Err = IncrExecutor->removeModule(PTUs.back()))
+  return Err;
+Restore(PTUs.back());
+PTUs.pop_back();
+  }
+  return llvm::Error::success();
+}
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,10 @@
   ///\returns the mangled name of a \c GD.
   llvm::StringRef GetMangledName(GlobalDecl GD) con

[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-12 Thread Jez Ng 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 rGef501bf85d8c: [MC] Omit DWARF unwind info if compact unwind 
is present where eligible (authored by int3).

Changed prior to commit:
  https://reviews.llvm.org/D122258?vs=427509&id=436220#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/femit-dwarf-unwind.c
  clang/test/Driver/femit-dwarf-unwind.s
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
  llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
  llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDwarf.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/MCTargetOptions.cpp
  llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/MC/MachO/emit-dwarf-unwind.s
  llvm/test/MC/X86/compact-unwind-mode-dwarf.s

Index: llvm/test/MC/X86/compact-unwind-mode-dwarf.s
===
--- /dev/null
+++ llvm/test/MC/X86/compact-unwind-mode-dwarf.s
@@ -0,0 +1,50 @@
+// RUN: llvm-mc -triple x86_64-apple-macos10.6 -filetype=obj %s -o %t.o
+// RUN: llvm-objdump --macho --unwind-info --dwarf=frames %t.o | FileCheck %s
+
+/// For functions whose unwind info cannot be encoded with compact unwind, make
+/// sure that we encode them using DWARF unwind, and make sure we emit a compact
+/// unwind entry that indicates that a DWARF encoding is being used.
+
+_f:
+  .cfi_startproc
+  ## This encodes DW_CFA_GNU_args_size which cannot be expressed using compact
+  ## unwind, so we must use DWARF unwind instead.
+  .cfi_escape 0x2e, 0x10
+  ret
+  .cfi_endproc
+
+_g:
+  .cfi_startproc
+  ## This encodes DW_CFA_GNU_args_size which cannot be expressed using compact
+  ## unwind, so we must use DWARF unwind instead.
+  .cfi_escape 0x2e, 0x10
+  ret
+  .cfi_endproc
+
+// CHECK: Contents of __compact_unwind section:
+// CHECK:   Entry at offset 0x0:
+// CHECK: start:0x[[#%x,F:]] _f
+// CHECK: length:   0x1
+// CHECK: compact encoding: 0x0400
+// CHECK:   Entry at offset 0x20:
+// CHECK: start:0x[[#%x,G:]] _g
+// CHECK: length:   0x1
+// CHECK: compact encoding: 0x0400
+
+// CHECK: .eh_frame contents:
+// CHECK:  0014  CIE
+// CHECK:   Format:DWARF32
+// CHECK:   Version:   1
+// CHECK:   Augmentation:  "zR"
+// CHECK:   Code alignment factor: 1
+// CHECK:   Data alignment factor: -8
+// CHECK:   Return address column: 16
+// CHECK:   Augmentation data: 10
+
+// CHECK: FDE cie= pc=[[#%.8x,F]]...
+// CHECK:   Format:   DWARF32
+// CHECK:   DW_CFA_GNU_args_size: +16
+
+// CHECK: FDE cie= pc=[[#%.8x,G]]...
+// CHECK:   Format:   DWARF32
+// CHECK:   DW_CFA_GNU_args_size: +16
Index: llvm/test/MC/MachO/emit-dwarf-unwind.s
===
--- /dev/null
+++ llvm/test/MC/MachO/emit-dwarf-unwind.s
@@ -0,0 +1,33 @@
+// RUN: rm -rf %t; mkdir %t
+// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o
+// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix TWO-FDES
+// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o
+// RUN: llvm-objdump --macho --dwarf=frames %t/arm64.o | FileCheck %s --check-prefix ONE-FDE
+// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind no-compact-unwind -o %t/x86_64-no-dwarf.o
+// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix ONE-FDE
+// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o
+// RUN: llvm-objdump --macho --dwarf=frames %t/arm64-dwarf.o | FileCheck %s --check-prefix TWO-FDES
+
+// TWO-FDES: FDE
+// TWO-FDES: FDE
+
+// ONE-FDE-NOT: FDE
+// ONE-FDE: FDE
+// ONE-FDE-NOT: FDE
+
+_main:
+  .cfi_startproc
+  .cfi_def_cfa_offset 16
+  ret
+  .cfi_endproc
+
+_foo:
+  .cfi_startproc
+  .cfi_def_cfa_offset 16
+  /// This encodes DW_CFA_GNU_args_size which cannot be expressed using compact
+  /// unwind, so we must use DWARf unwind for this function.
+  .cfi_escape 0x2e, 0x10
+  ret
+  .cfi_endproc
+
+.subsections_via_symbols
Index: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

[clang] ef501bf - [MC] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-12 Thread Jez Ng via cfe-commits

Author: Jez Ng
Date: 2022-06-12T10:03:56-04:00
New Revision: ef501bf85d8c869248e51371f0e74bcec0e7b229

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

LOG: [MC] Omit DWARF unwind info if compact unwind is present where eligible

Previously, omitting unnecessary DWARF unwinds was only done in two
cases:
* For Darwin + aarch64, if no DWARF unwind info is needed for all the
  functions in a TU, then the `__eh_frame` section would be omitted
  entirely. If any one function needed DWARF unwind, then MC would emit
  DWARF unwind entries for all the functions in the TU.
* For watchOS, MC would omit DWARF unwind on a per-function basis, as
  long as compact unwind was available for that function.

This diff makes it so that we omit DWARF unwind on a per-function basis
for Darwin + aarch64 as well. In addition, we introduce the flag
`--emit-dwarf-unwind=` which can toggle between `always`,
`no-compact-unwind` (only emit DWARF when CU cannot be emitted for a
given function), and the target platform `default`.  `no-compact-unwind`
is particularly useful for newer x86_64 platforms: we don't want to omit
DWARF unwind for x86_64 in general due to possible backwards compat
issues, but we should make it possible for people to opt into this
behavior if they are only targeting newer platforms.

**Motivation:** I'm working on adding support for `__eh_frame` to LLD,
but I'm concerned that we would suffer a perf hit. Processing compact
unwind is already expensive, and that's a simpler format than EH frames.
Given that MC currently produces one EH frame entry for every compact
unwind entry, I don't think processing them will be cheap. I tried to do
something clever on LLD's end to drop the unnecessary EH frames at parse
time, but this made the code significantly more complex. So I'm looking
at fixing this at the MC level instead.

**Addendum:** It turns out that there was a latent bug in the X86
backend when `OmitDwarfIfHaveCompactUnwind` is naively enabled, which is
not too surprising given that this combination has not been heretofore
used.

For functions that have unwind info that cannot be encoded with CU, MC
would end up dropping both the compact unwind entry (OK; existing
behavior) as well as the DWARF entries (not OK).  This diff fixes things
so that we emit the DWARF entry, as well as a CU entry with encoding
`UNWIND_X86_MODE_DWARF` -- this basically tells the unwinder to look for
the DWARF entry. I'm not 100% sure the `UNWIND_X86_MODE_DWARF` CU entry
is necessary, this was the simplest fix. ld64 seems to be able to handle
both the absence and presence of this CU entry. Ultimately ld64 (and
LLD) will synthesize `UNWIND_X86_MODE_DWARF` if it is absent, so there
is no impact to the final binary size.

Reviewed By: davide, lhames

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

Added: 
clang/test/Driver/femit-dwarf-unwind.c
clang/test/Driver/femit-dwarf-unwind.s
llvm/test/MC/MachO/emit-dwarf-unwind.s
llvm/test/MC/X86/compact-unwind-mode-dwarf.s

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/tools/driver/cc1as_main.cpp
llvm/include/llvm/MC/MCContext.h
llvm/include/llvm/MC/MCTargetOptions.h
llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
llvm/lib/CodeGen/LLVMTargetMachine.cpp
llvm/lib/CodeGen/MachineModuleInfo.cpp
llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/MC/MCDwarf.cpp
llvm/lib/MC/MCObjectFileInfo.cpp
llvm/lib/MC/MCTargetOptions.cpp
llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index d8f667dc387bb..8e89106993c26 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -114,6 +114,10 @@ CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when 
-fstack-size-section is enabl
 CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
   ///< enabled.
 
+///< Set when -femit-dwarf-unwind is passed.
+ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
+llvm::EmitDwarfUnwindType::Default)
+
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 95840760f7746..002cd6cc8cb17 100644
--- a/clang/i

[PATCH] D126479: [Clang] Allow 'Complex float __attribute__((mode(HC)))'

2022-06-12 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen added inline comments.



Comment at: clang/include/clang/Basic/TargetInfo.h:223-224
   unsigned HasAlignMac68kSupport : 1;
-  unsigned RealTypeUsesObjCFPRet : 3;
+  unsigned RealTypeUsesObjCFPRet : (1 << (int)FloatModeKind::Float) |
+   (1 << (int)FloatModeKind::Double);
   unsigned ComplexLongDoubleUsesFP2Ret : 1;

tahonermann wrote:
> This doesn't look right to me. The size of the bit field would be `(1 << 1) | 
> (1 << 2)` which is `0b110` which is 6, but more by coincidence than by 
> construction. I think what we want is:
>   unsigned RealTypeUsesObjCFPRet  : (int)FloatModeKind::Last + 1;
Sorry. I mixed things up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126479

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


[PATCH] D127599: [clang] small speed improvement of Sema::AddArgumentDependentLookupCandidates

2022-06-12 Thread Kókai Péter via Phabricator via cfe-commits
Kokan created this revision.
Kokan added a reviewer: clang.
Herald added a project: All.
Kokan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[clang] Improve speed of Sema::AddArgumentDependentLookupCandidates

The Sema::AddArgumentDependentLookupCandidates compile the list of
overload candidates found via ADL.

Also it makes sure not to include candidates if already found via not
ADL. It achives that distinct list via looping over candidates and
removing them from the ADL candidates(Fns).

When there is no candidate found via ADL, there is no need to loop over
the candidate list as Fns is empty so there is nothing to remove from
that.

Disclaimer: I do not have compile time measurement, but not doing a loop

  should be faster.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127599

Files:
  clang/include/clang/Sema/Lookup.h
  clang/lib/Sema/SemaOverload.cpp


Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9389,6 +9389,9 @@
   // FIXME: Pass in the explicit template arguments?
   ArgumentDependentLookup(Name, Loc, Args, Fns);

+  if (Fns.empty())
+ return;
+
   // Erase all of the candidates we already knew about.
   for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(),
CandEnd = CandidateSet.end();
Index: clang/include/clang/Sema/Lookup.h
===
--- clang/include/clang/Sema/Lookup.h
+++ clang/include/clang/Sema/Lookup.h
@@ -814,6 +814,10 @@
 Decls.erase(cast(D->getCanonicalDecl()));
   }

+  bool empty(void) {
+return Decls.empty();
+  }
+
   using iterator =
   llvm::mapped_iterator;



Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9389,6 +9389,9 @@
   // FIXME: Pass in the explicit template arguments?
   ArgumentDependentLookup(Name, Loc, Args, Fns);

+  if (Fns.empty())
+ return;
+
   // Erase all of the candidates we already knew about.
   for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(),
CandEnd = CandidateSet.end();
Index: clang/include/clang/Sema/Lookup.h
===
--- clang/include/clang/Sema/Lookup.h
+++ clang/include/clang/Sema/Lookup.h
@@ -814,6 +814,10 @@
 Decls.erase(cast(D->getCanonicalDecl()));
   }

+  bool empty(void) {
+return Decls.empty();
+  }
+
   using iterator =
   llvm::mapped_iterator;

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


[clang] d941d59 - Revert "[MC] Omit DWARF unwind info if compact unwind is present where eligible"

2022-06-12 Thread Jez Ng via cfe-commits

Author: Jez Ng
Date: 2022-06-12T10:47:08-04:00
New Revision: d941d597837d9e1405086f008c9bd6a71e7263c9

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

LOG: Revert "[MC] Omit DWARF unwind info if compact unwind is present where 
eligible"

This reverts commit ef501bf85d8c869248e51371f0e74bcec0e7b229.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/tools/driver/cc1as_main.cpp
llvm/include/llvm/MC/MCContext.h
llvm/include/llvm/MC/MCTargetOptions.h
llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
llvm/lib/CodeGen/LLVMTargetMachine.cpp
llvm/lib/CodeGen/MachineModuleInfo.cpp
llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/MC/MCDwarf.cpp
llvm/lib/MC/MCObjectFileInfo.cpp
llvm/lib/MC/MCTargetOptions.cpp
llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Removed: 
clang/test/Driver/femit-dwarf-unwind.c
clang/test/Driver/femit-dwarf-unwind.s
llvm/test/MC/MachO/emit-dwarf-unwind.s
llvm/test/MC/X86/compact-unwind-mode-dwarf.s



diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 8e89106993c26..d8f667dc387bb 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -114,10 +114,6 @@ CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when 
-fstack-size-section is enabl
 CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
   ///< enabled.
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 002cd6cc8cb17..95840760f7746 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3044,13 +3044,6 @@ def fmacro_prefix_map_EQ
 defm force_dwarf_frame : BoolFOption<"force-dwarf-frame",
   CodeGenOpts<"ForceDwarfFrameSection">, DefaultFalse,
   PosFlag, 
NegFlag>;
-def femit_dwarf_unwind_EQ : Joined<["-"], "femit-dwarf-unwind=">,
-  Group, Flags<[CC1Option, CC1AsOption]>,
-  HelpText<"When to emit DWARF unwind (EH frame) info">,
-  Values<"always,no-compact-unwind,default">,
-  NormalizedValues<["Always", "NoCompactUnwind", "Default"]>,
-  NormalizedValuesScope<"llvm::EmitDwarfUnwindType">,
-  MarshallingInfoEnum, "Default">;
 def g_Flag : Flag<["-"], "g">, Group,
   HelpText<"Generate source-level debug information">;
 def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 4b294c254e476..0de15b1e48078 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -453,7 +453,6 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   }
 
   Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
-  Options.MCOptions.EmitDwarfUnwind = CodeGenOpts.getEmitDwarfUnwind();
   Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
   Options.MCOptions.MCUseDwarfDirectory =

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 62e891ce38c49..ceac142653ebe 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2518,8 +2518,6 @@ static void CollectArgsForIntegratedAssembler(Compilation 
&C,
DefaultIncrementalLinkerCompatible))
 CmdArgs.push_back("-mincremental-linker-compatible");
 
-  Args.AddLastArg(CmdArgs, options::OPT_femit_dwarf_unwind_EQ);
-
   // If you add more args here, also add them to the block below that
   // starts with "// If CollectArgsForIntegratedAssembler() isn't called 
below".
 
@@ -4624,7 +4622,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 }
 Args.ClaimAllArgs(options::OPT_Wa_COMMA);
 Args.ClaimAllArgs(options::OPT_Xassembler);
-Args.ClaimAllArgs(options::OPT_femit_dwarf_unwind_EQ);
   }
 
   if (isa(JA)) {

diff  --git a/clang/test/Driver/femit-dwarf-unwind.c 
b/clang/test/Driver/femit-dwarf-unwind.c
deleted file mode 100644
index 3101e1db7b9d4..0
--- a/clang/test/Driver/femit-dwarf-unwind.c
+++ /de

[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-12 Thread Jez Ng via Phabricator via cfe-commits
int3 added a comment.

Buildbots gave me a bunch of errors of the form

/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/llvm-mc:
 error: unable to get target for 'arm64-apple-macos11.0', see --version and 
--triple.

I'm wondering if I'm just missing a REQUIRES line, but then again I don't see 
any other tests under MC/MachO that use REQUIRES...

Or should I be using `darwin` instead of `macos`? Does it matter?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[PATCH] D107082: [X86][RFC] Enable `_Float16` type support on X86 following the psABI

2022-06-12 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

This broke the bot here: 
https://lab.llvm.org/buildbot/#/builders/61/builds/27616

The cmake invocation includes some GPU specific options that you can omit 
(`-DMLIR_ENABLE_CUDA_RUNNER=1` , 
`-DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc`, 
`-DMLIR_ENABLE_VULKAN_RUNNER=1`, `-DMLIR_RUN_CUDA_TENSOR_CORE_TESTS=ON`), which 
should leave out:

  cmake ../llvm.src/llvm -DLLVM_BUILD_EXAMPLES=ON 
'-DLLVM_TARGETS_TO_BUILD=host;NVPTX' -DLLVM_ENABLE_PROJECTS=mlir  
-DMLIR_INCLUDE_INTEGRATION_TESTS=ON  -DBUILD_SHARED_LIBS=ON 
-DLLVM_CCACHE_BUILD=ON -DMLIR_ENABLE_BINDINGS_PYTHON=ON  
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON '-DLLVM_LIT_ARGS=-v -vv' 
-GNinja

*y


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107082

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


[PATCH] D126682: [Interpreter][ClangRepl] Implement undo command

2022-06-12 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 436229.
junaire added a comment.

Fix the build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126682

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/Interpreter/code-undo.cpp
  clang/test/Interpreter/execute.cpp
  clang/test/Interpreter/plugins.cpp
  clang/test/Interpreter/sanity.c
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -92,8 +92,14 @@
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
 while (llvm::Optional Line = LE.readLine()) {
-  if (*Line == "quit")
+  if (*Line == R"(%quit)")
 break;
+  if (*Line == R"(%undo)") {
+if (auto Err = Interp->Undo())
+  llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+continue;
+  }
+
   if (auto Err = Interp->ParseAndExecute(*Line))
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
 }
Index: clang/test/Interpreter/sanity.c
===
--- clang/test/Interpreter/sanity.c
+++ clang/test/Interpreter/sanity.c
@@ -15,4 +15,4 @@
 // CHECK-NEXT: UnaryOperator{{.*}} 'int' lvalue prefix '++'
 // CHECK-NEXT:   DeclRefExpr{{.*}} 'int' lvalue Var [[var_ptr]] 'TestVar' 'int'
 
-quit
+%quit
Index: clang/test/Interpreter/plugins.cpp
===
--- clang/test/Interpreter/plugins.cpp
+++ clang/test/Interpreter/plugins.cpp
@@ -6,8 +6,7 @@
 int i = 10;
 extern "C" int printf(const char*,...);
 auto r1 = printf("i = %d\n", i);
-quit
-
+%quit
 
 // CHECK: top-level-decl: "i"
 // CHECK-NEXT: top-level-decl: "r1"
Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -17,4 +17,4 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
-quit
+%quit
Index: clang/test/Interpreter/code-undo.cpp
===
--- clang/test/Interpreter/code-undo.cpp
+++ clang/test/Interpreter/code-undo.cpp
@@ -5,16 +5,16 @@
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
-int i = 42;
-auto r1 = printf("i = %d\n", i);
-// CHECK: i = 42
+int x1 = 42;
+%undo
+int x1 = 24;
+auto r1 = printf("x1 = %d\n", x1);
+// CHECK: x1 = 24
 
-struct S { float f = 1.0; S *m = nullptr;} s;
+int foo() { return 1; }
+%undo
+int foo() { return 2; }
+auto r2 = printf("foo() = %d\n", foo());
+// CHECK-NEXT: foo() = 2
 
-auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast(s.m));
-// CHECK-NEXT: S[f=1.00, m=0x0]
-
-inline int foo() { return 42; }
-int r3 = foo();
-
-quit
+%quit
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -218,8 +218,7 @@
 if (Err)
   return Err;
   }
-  // FIXME: Add a callback to retain the llvm::Module once the JIT is done.
-  if (auto Err = IncrExecutor->addModule(std::move(T.TheModule)))
+  if (auto Err = IncrExecutor->addModule(T))
 return Err;
 
   if (auto Err = IncrExecutor->runCtors())
@@ -228,6 +227,10 @@
   return llvm::Error::success();
 }
 
+void Interpreter::Restore(PartialTranslationUnit &PTU) {
+  IncrParser->Restore(PTU);
+}
+
 llvm::Expected
 Interpreter::getSymbolAddress(GlobalDecl GD) const {
   if (!IncrExecutor)
@@ -257,3 +260,18 @@
 
   return IncrExecutor->getSymbolAddress(Name, IncrementalExecutor::LinkerName);
 }
+
+llvm::Error Interpreter::Undo(unsigned N) {
+  auto &PTUs = IncrParser->getPTUs();
+  if (N > PTUs.size())
+return llvm::make_error("Operation failed, "
+   "too many undos",
+   std::error_code());
+  for (unsigned I = 0; I < N; I++) {
+if (llvm::Error Err = IncrExecutor->removeModule(PTUs.back()))
+  return Err;
+Restore(PTUs.back());
+PTUs.pop_back();
+  }
+  return llvm::Error::success();
+}
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,10 @@
   ///\returns the mangled name of a \c GD.
   llvm::StringRef GetMangledName(GlobalDecl GD) const;
 
+  void Restore(Partial

[PATCH] D127599: [clang] small speed improvement of Sema::AddArgumentDependentLookupCandidates

2022-06-12 Thread Kókai Péter via Phabricator via cfe-commits
Kokan updated this revision to Diff 436234.
Kokan added a comment.

clang-format applied


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

https://reviews.llvm.org/D127599

Files:
  clang/include/clang/Sema/Lookup.h
  clang/lib/Sema/SemaOverload.cpp


Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9389,6 +9389,9 @@
   // FIXME: Pass in the explicit template arguments?
   ArgumentDependentLookup(Name, Loc, Args, Fns);

+  if (Fns.empty())
+return;
+
   // Erase all of the candidates we already knew about.
   for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(),
CandEnd = CandidateSet.end();
Index: clang/include/clang/Sema/Lookup.h
===
--- clang/include/clang/Sema/Lookup.h
+++ clang/include/clang/Sema/Lookup.h
@@ -814,6 +814,8 @@
 Decls.erase(cast(D->getCanonicalDecl()));
   }

+  bool empty(void) { return Decls.empty(); }
+
   using iterator =
   llvm::mapped_iterator;



Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9389,6 +9389,9 @@
   // FIXME: Pass in the explicit template arguments?
   ArgumentDependentLookup(Name, Loc, Args, Fns);

+  if (Fns.empty())
+return;
+
   // Erase all of the candidates we already knew about.
   for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(),
CandEnd = CandidateSet.end();
Index: clang/include/clang/Sema/Lookup.h
===
--- clang/include/clang/Sema/Lookup.h
+++ clang/include/clang/Sema/Lookup.h
@@ -814,6 +814,8 @@
 Decls.erase(cast(D->getCanonicalDecl()));
   }

+  bool empty(void) { return Decls.empty(); }
+
   using iterator =
   llvm::mapped_iterator;

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


[clang] f13019f - [clang] Use any_of and none_of (NFC)

2022-06-12 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-12T10:17:12-07:00
New Revision: f13019f8367a417075e70effb13dcf58024090b2

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

LOG: [clang] Use any_of and none_of (NFC)

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index d1f407259cb6e..16384969f68e4 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1926,9 +1926,9 @@ def NonNull : InheritableParamAttr {
 bool isNonNull(unsigned IdxAST) const {
   if (!args_size())
 return true;
-  return args_end() != std::find_if(
-  args_begin(), args_end(),
-  [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; });
+  return llvm::any_of(args(), [=](const ParamIdx &Idx) {
+return Idx.getASTIndex() == IdxAST;
+  });
 }
   }];
   // FIXME: We should merge duplicates into a single nonnull attribute.

diff  --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp 
b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index a7b0a1ac98a78..bffa66c2d9448 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -199,11 +199,11 @@ struct LocationFileChecker {
 // Try to reduce the include name the same way we tried to include it.
 bool IsQuoted = false;
 if (auto IncludeName = getRelativeIncludeName(CI, FileName, &IsQuoted))
-  if (llvm::find_if(KnownFiles,
-[&IsQuoted, &IncludeName](const auto &KnownFile) {
-  return KnownFile.first.equals(*IncludeName) &&
- KnownFile.second == IsQuoted;
-}) != KnownFiles.end()) {
+  if (llvm::any_of(KnownFiles,
+   [&IsQuoted, &IncludeName](const auto &KnownFile) {
+ return KnownFile.first.equals(*IncludeName) &&
+KnownFile.second == IsQuoted;
+   })) {
 KnownFileEntries.insert(File);
 return true;
   }

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 569b226da9233..214332e53c0f0 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -8617,10 +8617,10 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
 int(1)))
   return true;
 
-if (llvm::find_if(RD->friends(), [&](const FriendDecl *F) {
+if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
   return FD->getCanonicalDecl() ==
  F->getFriendDecl()->getCanonicalDecl();
-}) == RD->friends().end()) {
+})) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
   Diag(RD->getCanonicalDecl()->getLocation(), diag::note_declared_at);

diff  --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp 
b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
index 528284ca89858..9ee6ef4f9519f 100644
--- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -480,9 +480,7 @@ static void isOptionContainedIn(const CmdLineOptionList 
&OptionList,
 return Opt.OptionName == SuppliedOption;
   };
 
-  const auto *OptionIt = llvm::find_if(OptionList, SameOptName);
-
-  if (OptionIt == OptionList.end()) {
+  if (llvm::none_of(OptionList, SameOptName)) {
 Diags.Report(diag::err_analyzer_checker_option_unknown)
 << SuppliedChecker << SuppliedOption;
 return;



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


[PATCH] D126215: [analyzer] Deprecate `-analyzer-store region` flag

2022-06-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(As long as this builds and passes tests, I don't have an opinion on this 
change.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126215

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


[clang] 4dd1bff - [clang][CodeGen] Switch a few placeholders from UndefValue to PoisonValue

2022-06-12 Thread Nuno Lopes via cfe-commits

Author: Nuno Lopes
Date: 2022-06-12T19:07:59+01:00
New Revision: 4dd1bffc9dac02b34bd1de78808edd9a5955c987

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

LOG: [clang][CodeGen] Switch a few placeholders from UndefValue to PoisonValue
This change is cosmetic, as these are dummy values that are not observable, but 
it
gets us closer to removing undef.
NFC

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/ConstantInitBuilder.cpp
clang/test/CodeGen/arm-swiftcall.c
clang/test/CodeGen/cmse-clear-arg.c
clang/test/CodeGen/windows-swiftcall.c
clang/test/CodeGenCXX/arm-swiftcall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 0d838b9aeb529..57eb8b2d93d26 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3466,7 +3466,7 @@ llvm::Value 
*CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
   int CharsPerElt =
   ATy->getArrayElementType()->getScalarSizeInBits() / CharWidth;
   int MaskIndex = 0;
-  llvm::Value *R = llvm::UndefValue::get(ATy);
+  llvm::Value *R = llvm::PoisonValue::get(ATy);
   for (int I = 0, N = ATy->getArrayNumElements(); I != N; ++I) {
 uint64_t Mask = buildMultiCharMask(Bits, MaskIndex, CharsPerElt, CharWidth,
DataLayout.isBigEndian());
@@ -3640,7 +3640,7 @@ void CodeGenFunction::EmitFunctionEpilog(const 
CGFunctionInfo &FI,
   // Construct a return type that lacks padding elements.
   llvm::Type *returnType = RetAI.getUnpaddedCoerceAndExpandType();
 
-  RV = llvm::UndefValue::get(returnType);
+  RV = llvm::PoisonValue::get(returnType);
   for (unsigned i = 0, e = results.size(); i != e; ++i) {
 RV = Builder.CreateInsertValue(RV, results[i], i);
   }
@@ -3747,7 +3747,7 @@ static AggValueSlot createPlaceholderSlot(CodeGenFunction 
&CGF,
   // placeholders.
   llvm::Type *IRTy = CGF.ConvertTypeForMem(Ty);
   llvm::Type *IRPtrTy = IRTy->getPointerTo();
-  llvm::Value *Placeholder = llvm::UndefValue::get(IRPtrTy->getPointerTo());
+  llvm::Value *Placeholder = llvm::PoisonValue::get(IRPtrTy->getPointerTo());
 
   // FIXME: When we generate this IR in one pass, we shouldn't need
   // this win32-specific alignment hack.

diff  --git a/clang/lib/CodeGen/ConstantInitBuilder.cpp 
b/clang/lib/CodeGen/ConstantInitBuilder.cpp
index 24e3ca19709cb..06d3e44f01b1a 100644
--- a/clang/lib/CodeGen/ConstantInitBuilder.cpp
+++ b/clang/lib/CodeGen/ConstantInitBuilder.cpp
@@ -114,7 +114,7 @@ void ConstantInitBuilderBase::abandon(size_t newEnd) {
   if (newEnd == 0) {
 for (auto &entry : SelfReferences) {
   auto dummy = entry.Dummy;
-  dummy->replaceAllUsesWith(llvm::UndefValue::get(dummy->getType()));
+  dummy->replaceAllUsesWith(llvm::PoisonValue::get(dummy->getType()));
   dummy->eraseFromParent();
 }
 SelfReferences.clear();

diff  --git a/clang/test/CodeGen/arm-swiftcall.c 
b/clang/test/CodeGen/arm-swiftcall.c
index bd85e7a9aed04..000602819ee01 100644
--- a/clang/test/CodeGen/arm-swiftcall.c
+++ b/clang/test/CodeGen/arm-swiftcall.c
@@ -121,7 +121,7 @@ TEST(struct_1);
 // CHECK:   [[THIRD:%.*]] = load float, float* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* 
[[CAST_TMP]], i32 0, i32 4
 // CHECK:   [[FOURTH:%.*]] = load float, float* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i16, float, float }]] 
undef, i32 [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i16, float, float }]] 
poison, i32 [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i16 [[SECOND]], 1
 // CHECK:   [[T2:%.*]] = insertvalue [[UAGG]] [[T1]], float [[THIRD]], 2
 // CHECK:   [[T3:%.*]] = insertvalue [[UAGG]] [[T2]], float [[FOURTH]], 3
@@ -186,7 +186,7 @@ TEST(struct_2);
 // CHECK:   [[THIRD:%.*]] = load float, float* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* 
[[CAST_TMP]], i32 0, i32 3
 // CHECK:   [[FOURTH:%.*]] = load float, float* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i32, float, float }]] 
undef, i32 [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i32, float, float }]] 
poison, i32 [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
 // CHECK:   [[T2:%.*]] = insertvalue [[UAGG]] [[T1]], float [[THIRD]], 2
 // CHECK:   [[T3:%.*]] = insertvalue [[UAGG]] [[T2]], float [[FOURTH]], 3
@@ -250,7 +250,7 @@ TEST(struct_misaligned_1)
 // CHECK:   [[FIRST:%.*]] = load i32, i32* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* 
[[CAST_TMP]], i32 0, i32 1
 // CHECK:   [[SECOND:%.*]] = load i8, i8* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i3

[clang] 571ae1a - fix test expected output (fixes arm buildbot failure) [NFC]

2022-06-12 Thread Nuno Lopes via cfe-commits

Author: Nuno Lopes
Date: 2022-06-12T19:29:00+01:00
New Revision: 571ae1abebb6b102cc2e95e3abf8e81757fba35a

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

LOG: fix test expected output (fixes arm buildbot failure) [NFC]

Added: 


Modified: 
clang/test/CodeGen/64bit-swiftcall.c

Removed: 




diff  --git a/clang/test/CodeGen/64bit-swiftcall.c 
b/clang/test/CodeGen/64bit-swiftcall.c
index a027129a4bbb..f1fb8e10dc0a 100644
--- a/clang/test/CodeGen/64bit-swiftcall.c
+++ b/clang/test/CodeGen/64bit-swiftcall.c
@@ -125,7 +125,7 @@ TEST(struct_1);
 // CHECK:   [[T0:%.*]] = load i64, i64* [[GEP0]], align 4
 // CHECK:   [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* 
[[CAST]], i32 0, i32 1
 // CHECK:   [[T1:%.*]] = load i64, i64* [[GEP1]], align 4
-// CHECK:   [[R0:%.*]] = insertvalue { i64, i64 } undef, i64 [[T0]], 0
+// CHECK:   [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0
 // CHECK:   [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1
 // CHECK:   ret { i64, i64 } [[R1]]
 // CHECK: }
@@ -174,7 +174,7 @@ TEST(struct_2);
 // CHECK:   [[T0:%.*]] = load i64, i64* [[GEP0]], align 4
 // CHECK:   [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* 
[[CAST]], i32 0, i32 1
 // CHECK:   [[T1:%.*]] = load i64, i64* [[GEP1]], align 4
-// CHECK:   [[R0:%.*]] = insertvalue { i64, i64 } undef, i64 [[T0]], 0
+// CHECK:   [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0
 // CHECK:   [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1
 // CHECK:   ret { i64, i64 } [[R1]]
 // CHECK: }
@@ -395,7 +395,7 @@ TEST(int8)
 // CHECK:   [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* 
[[CAST_TMP]], i32 0, i32 1
 // CHECK:   [[SECOND:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] undef, 
<4 x i32> [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] poison, 
<4 x i32> [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], <4 x i32> [[SECOND]], 1
 // CHECK:   ret [[UAGG]] [[T1]]
 // CHECK-LABEL: define {{.*}} @take_int8(<4 x i32> %0, <4 x i32> %1)
@@ -439,7 +439,7 @@ TEST(int5)
 // CHECK:   [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* 
[[CAST_TMP]], i32 0, i32 1
 // CHECK:   [[SECOND:%.*]] = load i32, i32* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] undef, <4 x 
i32> [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] poison, <4 x 
i32> [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
 // CHECK:   ret [[UAGG]] [[T1]]
 // CHECK-LABEL: define {{.*}} @take_int5(<4 x i32> %0, i32 %1)



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


[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

2022-06-12 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson requested changes to this revision.
royjacobson added a reviewer: clang-language-wg.
royjacobson added a comment.
This revision now requires changes to proceed.

Hi Javier, thank you for submitting this patch!

As far as I could tell, this patch implements the CWG2171 defect report from 
2016: https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2171. That 
means that you'll have to add a test inside clang/test/CXX/drs/dr21xx.cpp to 
make sure it shows on the DRs status page.

This change is also a large ABI break, which means it has to be considered 
carefully. I think the best approach here would be to revert to the previous 
behavior when the -fclang-abi-compat flag is used for clang <= 14, but I'm not 
sure about this. I would like the approval of someone with more ABI experience 
here.

The code itself and the tests look good! If you'll need help with the changes I 
mentioned please let me know.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:9786-9789
+if (RT && ((RT->getPointeeType().getCVRQualifiers() & Qualifiers::Const) ==
+   Qualifiers::Const)) {
+  ConstArg = true;
+}

I think this should work instead? No need to check for RT since we already 
returned if !RT.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127593

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I think it should work if you put the test in llvm/test/MC/MachO/AArch64 
instead of in llvm/test/MC/MachO, because of:

  % cat llvm/test/MC/MachO/AArch64/lit.local.cfg 
  if not 'AArch64' in config.root.targets:
  config.unsupported = True


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[PATCH] D126694: [C++20][Modules] Implementation of GMF decl elision.

2022-06-12 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 436245.
iains edited the summary of this revision.
iains added a comment.

this is a rework of the implementation.

it now passes all test-cases except one - which is one of the cases added
by D113545 ; that test-case now seems to 
produce multiple error messages for
each of the cases that it is required to (i.e. the lines that should error
do produce an error - but they also produce a number of similar or duplicated
errors).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126694

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/AST/ast-dump-decl.c
  clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
  clang/test/Modules/cxx-templates.cpp
  clang/test/Modules/cxx20-10-4-ex2.cpp
  clang/test/Modules/template-function-specialization.cpp

Index: clang/test/Modules/template-function-specialization.cpp
===
--- clang/test/Modules/template-function-specialization.cpp
+++ clang/test/Modules/template-function-specialization.cpp
@@ -51,7 +51,9 @@
   foo2(); // expected-error {{missing '#include'; 'foo2' must be declared before it is used}}
  // expected-note@* {{declaration here is not visible}}
   foo2();   // expected-error {{missing '#include'; 'foo2' must be declared before it is used}}
+ // expected-error@-1 {{missing '#include'; explicit specialization of 'foo2' must be declared before it is used}}
  // expected-note@* {{declaration here is not visible}}
+ // expected-note@* {{explicit specialization declared here is not reachable}}
   foo3();
   foo3();
 
Index: clang/test/Modules/cxx20-10-4-ex2.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-10-4-ex2.cpp
@@ -0,0 +1,60 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 std-10-4-ex2-interface.cpp \
+// RUN:  -emit-module-interface -o M.pcm -Wno-unused-value
+// RUN: %clang_cc1 -std=c++20 std-10-4-ex2-implementation.cpp \
+// RUN:  -fmodule-file=M.pcm -fsyntax-only -verify
+//--- std-10-4-ex2.h
+
+namespace N {
+struct X {};
+int d();
+int e();
+inline int f(X, int = d()) { return e(); }
+int g(X);
+int h(X);
+} // namespace N
+
+//--- std-10-4-ex2-interface.cpp
+
+module;
+
+#include "std-10-4-ex2.h"
+
+export module M;
+
+template  int use_f() {
+  N::X x;   // N::X, N, and  ::  are decl-reachable from use_f
+  return f(x, 123); // N::f is decl-reachable from use_f,
+// N::e is indirectly decl-reachable from use_f
+//   because it is decl-reachable from N::f, and
+// N::d is decl-reachable from use_f
+//   because it is decl-reachable from N::f
+//   even though it is not used in this call
+}
+
+template  int use_g() {
+  N::X x; // N::X, N, and :: are decl-reachable from use_g
+  return g((T(), x)); // N::g is not decl-reachable from use_g
+}
+
+template  int use_h() {
+  N::X x; // N::X, N, and :: are decl-reachable from use_h
+  return h((T(), x)); // N::h is not decl-reachable from use_h, but
+  // N::h is decl-reachable from use_h
+}
+
+int k = use_h();
+// use_h is decl-reachable from k, so
+// N::h is decl-reachable from k
+
+//--- std-10-4-ex2-implementation.cpp
+
+module M;
+
+int a = use_f();
+int b = use_g(); // expected-er...@std-10-4-ex2-interface.cpp:20 {{use of undeclared identifier 'g'}}
+  // expected-note@-1 {{in instantiation of function template specialization 'use_g' requested here}}
+int c = use_h();
Index: clang/test/Modules/cxx-templates.cpp
===
--- clang/test/Modules/cxx-templates.cpp
+++ clang/test/Modules/cxx-templates.cpp
@@ -252,7 +252,7 @@
 // CHECK-DUMP:  ClassTemplateDecl {{.*}} <{{.*[/\\]}}cxx-templates-common.h:1:1, {{.*}}>  col:{{.*}} in cxx_templates_common SomeTemplate
 // CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate
 // CHECK-DUMP-NEXT: TemplateArgument type 'char[2]'
-// CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} SomeTemplate definition
+// CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} SomeTe

[PATCH] D126694: [C++20][Modules] Implementation of GMF decl elision.

2022-06-12 Thread Iain Sandoe via Phabricator via cfe-commits
iains marked 3 inline comments as done.
iains added a comment.

@ChuanqiXu - I changed the module ownership name to "ModuleDiscardable" - 
because, while we are permitted to discard these, we might choose not to (to 
give your better diagnostics) - but we still need to treat them as 
non-reachable and non-visible.  Please could you examine what is happening with 
`Modules/explicitly-specialized-template.cpp` where there a multiple error 
messages for each (intentionally) failing line .. add the test from the std.

@rsmith
 this seems like an awful lot of work that has to be done for every decl we 
mark used in the module purview - we cannot even short-cut ones that are not in 
the GMF, since the provisions of [module.global.frag] p3.5 seem to allow this 
to happen for indirect reaching.  I wonder if I misread the std.
 I am also wondering what is supposed to happen when an interface makes a type 
reachable, but that type is not visible to the implementation .. it seems to 
mean that interfaces would have to add using declarations for each such type.




Comment at: clang/include/clang/AST/DeclBase.h:240
+/// GMF is part.
+ModuleUnreachable
   };

ChuanqiXu wrote:
> Would you like to use the term 'ModuleDiscarded'? My point is that not all 
> unreachable declaration in modules are in GMF. And the term `discard` is used 
> in standard to describe it. So it looks better.
`ModuleDiscardable` Is better, it says we have permission to discard it (so 
that it cannot be used or reached) but allows for the case we elect to keep 
them around for better diagnostics.  You might want to consider renaming the 
wrapper function similarly?





Comment at: clang/include/clang/AST/DeclBase.h:647
+  bool isDiscardedInGlobalModuleFragment() const {
+   return getModuleOwnershipKind() == ModuleOwnershipKind::ModuleUnreachable;
+  }

ChuanqiXu wrote:
> iains wrote:
> > ChuanqiXu wrote:
> > > Maybe we need to check if the owning module is global module or not.
> > The only place that the ownership is `ModuleUnreachable` is in the GMF - so 
> > that we do not need to do an additional test.
> > 
> It is more robust and clear to add the additional check to me. Since the 
> constraint now lives in the comment only. If anyone goes to change it, the 
> codes wouldn't complain.
I am very concerned about the amount of work this (GMF decl elision) adds, so 
would like to minimise this - what I have done is to add an assert at the point 
we might make a change to the ownership that tests to see the decl is in the 
fragment we expect.



Comment at: clang/lib/Sema/SemaModule.cpp:1009
+  : VD->getASTContext().getUnqualifiedObjCPointerType(VD->getType());
+T.dump();
+  }

ChuanqiXu wrote:
> Remove dump
of course, as noted, the patch here is for comment on approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126694

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-12 Thread Jez Ng via Phabricator via cfe-commits
int3 added a comment.

d'oh, I see it now. And of course the parent `llvm/test/MC/MachO` directory is 
gated to x86-only. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[clang] d4bcb45 - [MC][re-land] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-12 Thread Jez Ng via cfe-commits

Author: Jez Ng
Date: 2022-06-12T17:24:19-04:00
New Revision: d4bcb45db78dc7ca371224cb01bea8dcb14e0698

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

LOG: [MC][re-land] Omit DWARF unwind info if compact unwind is present where 
eligible

This reverts commit d941d597837d9e1405086f008c9bd6a71e7263c9.

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

Added: 
clang/test/Driver/femit-dwarf-unwind.c
clang/test/Driver/femit-dwarf-unwind.s
llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
llvm/test/MC/X86/compact-unwind-mode-dwarf.s

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/tools/driver/cc1as_main.cpp
llvm/include/llvm/MC/MCContext.h
llvm/include/llvm/MC/MCTargetOptions.h
llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
llvm/lib/CodeGen/LLVMTargetMachine.cpp
llvm/lib/CodeGen/MachineModuleInfo.cpp
llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/MC/MCDwarf.cpp
llvm/lib/MC/MCObjectFileInfo.cpp
llvm/lib/MC/MCTargetOptions.cpp
llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index d8f667dc387bb..8e89106993c26 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -114,6 +114,10 @@ CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when 
-fstack-size-section is enabl
 CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
   ///< enabled.
 
+///< Set when -femit-dwarf-unwind is passed.
+ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
+llvm::EmitDwarfUnwindType::Default)
+
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 95840760f7746..002cd6cc8cb17 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3044,6 +3044,13 @@ def fmacro_prefix_map_EQ
 defm force_dwarf_frame : BoolFOption<"force-dwarf-frame",
   CodeGenOpts<"ForceDwarfFrameSection">, DefaultFalse,
   PosFlag, 
NegFlag>;
+def femit_dwarf_unwind_EQ : Joined<["-"], "femit-dwarf-unwind=">,
+  Group, Flags<[CC1Option, CC1AsOption]>,
+  HelpText<"When to emit DWARF unwind (EH frame) info">,
+  Values<"always,no-compact-unwind,default">,
+  NormalizedValues<["Always", "NoCompactUnwind", "Default"]>,
+  NormalizedValuesScope<"llvm::EmitDwarfUnwindType">,
+  MarshallingInfoEnum, "Default">;
 def g_Flag : Flag<["-"], "g">, Group,
   HelpText<"Generate source-level debug information">;
 def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 0de15b1e48078..4b294c254e476 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -453,6 +453,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   }
 
   Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
+  Options.MCOptions.EmitDwarfUnwind = CodeGenOpts.getEmitDwarfUnwind();
   Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
   Options.MCOptions.MCUseDwarfDirectory =

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ceac142653ebe..62e891ce38c49 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2518,6 +2518,8 @@ static void CollectArgsForIntegratedAssembler(Compilation 
&C,
DefaultIncrementalLinkerCompatible))
 CmdArgs.push_back("-mincremental-linker-compatible");
 
+  Args.AddLastArg(CmdArgs, options::OPT_femit_dwarf_unwind_EQ);
+
   // If you add more args here, also add them to the block below that
   // starts with "// If CollectArgsForIntegratedAssembler() isn't called 
below".
 
@@ -4622,6 +4624,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 }
 Args.ClaimAllArgs(options::OPT_Wa_COMMA);
 Args.ClaimAllArgs(options::OPT_Xassembler);
+Args.ClaimAllArgs(options::OPT_femit_dwarf_unwind_EQ);
   }
 
   if (isa(JA)) {

diff  --git a/clang/test/Driver/femit-dwarf-unwind.c 
b/clang/test/Driver/femit-dwarf-unwind.c
new file mode 100644
index 0..6057c

[PATCH] D107082: [X86][RFC] Enable `_Float16` type support on X86 following the psABI

2022-06-12 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D107082#3576355 , @mehdi_amini 
wrote:

> This broke the bot here: 
> https://lab.llvm.org/buildbot/#/builders/61/builds/27616
>
> The cmake invocation includes some GPU specific options that you can omit 
> (`-DMLIR_ENABLE_CUDA_RUNNER=1` , 
> `-DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc`, 
> `-DMLIR_ENABLE_VULKAN_RUNNER=1`, `-DMLIR_RUN_CUDA_TENSOR_CORE_TESTS=ON`), 
> which should leave out:
>
>   cmake ../llvm.src/llvm -DLLVM_BUILD_EXAMPLES=ON 
> '-DLLVM_TARGETS_TO_BUILD=host;NVPTX' -DLLVM_ENABLE_PROJECTS=mlir  
> -DMLIR_INCLUDE_INTEGRATION_TESTS=ON  -DBUILD_SHARED_LIBS=ON 
> -DLLVM_CCACHE_BUILD=ON -DMLIR_ENABLE_BINDINGS_PYTHON=ON  
> -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON '-DLLVM_LIT_ARGS=-v 
> -vv' -GNinja
>
> You can probably leave out other options too:
>
>   cmake ../llvm.src/llvm '-DLLVM_TARGETS_TO_BUILD=host' 
> -DLLVM_ENABLE_PROJECTS=mlir  -DMLIR_INCLUDE_INTEGRATION_TESTS=ON 
> -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON '-DLLVM_LIT_ARGS=-v 
> -vv' -GNinja

@mehdi_amini Thanks for the commands, I can reproduce it on my local now. Will 
look into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107082

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


[PATCH] D125402: [clang][diag] warn if function returns class type by-const-value

2022-06-12 Thread Namgoo Lee via Phabricator via cfe-commits
nlee added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6632
+  "const qualifying the return value prevents move semantics">,
+  InGroup, DefaultIgnore;
+def note_pessimizing_return_by_const : Note<

aaron.ballman wrote:
> Given that this is a `DefaultIgnore`, I'm still not quite sure this belongs 
> in Clang rather than continuing to be covered by clang-tidy.
> 
> If you leave it on by default, how many Clang tests break as a result? Do the 
> new warnings all look like true positives? (Basically, I'm trying to see how 
> far away we are from being able to enable this diagnostic by default.)
> how many Clang tests break as a result?
All Clang tests pass without breaking.

> Do the new warnings all look like true positives?
When applied to Clang source code, it does catch some cases as programmed. One 
problem I see is that it also catches for classes with only primitive member 
variables where move assignment(which is copy) has no advantage over copy 
assignment.



Comment at: clang/test/SemaCXX/warn-pessimizing-return-by-const.cpp:50
+
+const S3 f3_const() { // do not warn if move assignment operator is deleted
+  return S3{};

aaron.ballman wrote:
> We should also have a test for an explicitly deleted move assignment, and 
> another one where a member of the class is not movable (and thus the move 
> assignment should be deleted that way as well).
I'll add those cases.


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

https://reviews.llvm.org/D125402

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


[PATCH] D125875: [RISCV] Add vread_csr and vwrite_csr to riscv_vector.h

2022-06-12 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125875

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


[PATCH] D127471: [Coroutines] Convert coroutine.presplit to enum attr

2022-06-12 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@rjmccall Does this look good to you? I am afraid to break swift's codes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127471

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


[PATCH] D125875: [RISCV] Add vread_csr and vwrite_csr to riscv_vector.h

2022-06-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125875

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-12 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm updated this revision to Diff 436274.
srishti-pm added a comment.

Addressed all the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

Files:
  clang/docs/tools/clang-formatted-files.txt
  mlir/include/mlir/Transforms/CommutativityUtils.h
  mlir/lib/Transforms/Utils/CMakeLists.txt
  mlir/lib/Transforms/Utils/CommutativityUtils.cpp
  mlir/test/Transforms/test-commutativity-utils.mlir
  mlir/test/lib/Dialect/Test/TestOps.td
  mlir/test/lib/Transforms/CMakeLists.txt
  mlir/test/lib/Transforms/TestCommutativityUtils.cpp
  mlir/tools/mlir-opt/mlir-opt.cpp

Index: mlir/tools/mlir-opt/mlir-opt.cpp
===
--- mlir/tools/mlir-opt/mlir-opt.cpp
+++ mlir/tools/mlir-opt/mlir-opt.cpp
@@ -57,6 +57,7 @@
 void registerVectorizerTestPass();
 
 namespace test {
+void registerCommutativityUtils();
 void registerConvertCallOpPass();
 void registerInliner();
 void registerMemRefBoundCheck();
@@ -150,6 +151,7 @@
   registerVectorizerTestPass();
   registerTosaTestQuantUtilAPIPass();
 
+  mlir::test::registerCommutativityUtils();
   mlir::test::registerConvertCallOpPass();
   mlir::test::registerInliner();
   mlir::test::registerMemRefBoundCheck();
Index: mlir/test/lib/Transforms/TestCommutativityUtils.cpp
===
--- /dev/null
+++ mlir/test/lib/Transforms/TestCommutativityUtils.cpp
@@ -0,0 +1,56 @@
+//===- TestCommutativityUtils.cpp - Pass to test the commutativity utility-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This pass tests the functionality of the commutativity utility.
+//
+//===--===//
+
+#include "mlir/Transforms/CommutativityUtils.h"
+
+#include "TestDialect.h"
+#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+using namespace mlir;
+using namespace arith;
+using namespace test;
+
+namespace {
+
+struct CommutativityUtils
+: public PassWrapper> {
+  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CommutativityUtils)
+
+  StringRef getArgument() const final { return "test-commutativity-utils"; }
+  StringRef getDescription() const final {
+return "Test the functionality of the commutativity utility";
+  }
+
+  void runOnOperation() override {
+auto func = getOperation();
+auto *context = &getContext();
+
+RewritePatternSet patterns(context);
+patterns.add,
+ mlir::SortCommutativeOperands,
+ mlir::SortCommutativeOperands,
+ mlir::SortCommutativeOperands,
+ mlir::SortCommutativeOperands>(
+context);
+
+(void)applyPatternsAndFoldGreedily(func, std::move(patterns));
+  }
+};
+} // namespace
+
+namespace mlir {
+namespace test {
+void registerCommutativityUtils() { PassRegistration(); }
+} // namespace test
+} // namespace mlir
Index: mlir/test/lib/Transforms/CMakeLists.txt
===
--- mlir/test/lib/Transforms/CMakeLists.txt
+++ mlir/test/lib/Transforms/CMakeLists.txt
@@ -1,5 +1,6 @@
 # Exclude tests from libMLIR.so
 add_mlir_library(MLIRTestTransforms
+  TestCommutativityUtils.cpp
   TestConstantFold.cpp
   TestControlFlowSink.cpp
   TestInlining.cpp
Index: mlir/test/lib/Dialect/Test/TestOps.td
===
--- mlir/test/lib/Dialect/Test/TestOps.td
+++ mlir/test/lib/Dialect/Test/TestOps.td
@@ -1172,11 +1172,21 @@
   let hasFolder = 1;
 }
 
+def TestAddIOp : TEST_Op<"addi"> {
+  let arguments = (ins I32:$op1, I32:$op2);
+  let results = (outs I32);
+}
+
 def TestCommutativeOp : TEST_Op<"op_commutative", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4);
   let results = (outs I32);
 }
 
+def TestLargeCommutativeOp : TEST_Op<"op_large_commutative", [Commutative]> {
+  let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4, I32:$op5, I32:$op6, I32:$op7);
+  let results = (outs I32);
+}
+
 def TestCommutative2Op : TEST_Op<"op_commutative2", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2);
   let results = (outs I32);
Index: mlir/test/Transforms/test-commutativity-utils.mlir
===
--- /dev/null
+++ mlir/test/Transforms/test-commutativity-utils.mlir
@@ -0,0 +1,116 @@
+// RUN: mlir-opt %s -test-commutativity-utils | FileCheck %s
+
+// CHECK-LABEL: @test_small_pattern_1
+func.func @test_small_pattern_1(%arg0 : i32) -> i32 {
+  // CHECK-NEXT: %[[ARITH_CONST:.*]] = arith

[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-12 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added a comment.

I haven't thought too hard about the algorithm itself yet. I'm in the camp of 
"let's move forward if it works". I have mostly trivial comments.




Comment at: clang/docs/tools/clang-formatted-files.txt:8451
 mlir/lib/Transforms/SymbolPrivatize.cpp
+mlir/lib/Transforms/Utils/CommutativityUtils.cpp
 mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp

I don't think this file needs to be modified.



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:24
+/// Declares various types of operations and block argument.
+enum BlockArgumentOrOpType {
+  /// Pertains to a block argument.

Why do all of these need to be exposed publicly? I think this file should only 
contain `SortCommutativeOperands`.



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:34
+/// Stores the "key" associated with a block argument or an operation.
+struct BlockArgumentOrOpKey {
+  /// Holds `BLOCK_ARGUMENT`, `NON_CONSTANT_OP`, or `CONSTANT_OP`, depending on

`using BlockArgumentOrOpKey = std::pair`

The default `operator<` for `std::pair` should work for you.



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:140
+/// operand refers to one which has not been assigned a sorted position yet.
+bool hasAtLeastOneUnassignedOperand(SmallVector 
bfsOfOperands);
+

`ArrayRef`



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:161
+/// (C) `secondKey` < `firstKey` condition is defined likewise.
+int compareKeys(SmallVector firstKey,
+SmallVector secondKey);

Pass these both by `ArrayRef`



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:174
+void getIndicesOfUnassignedOperandsWithSmallestAndLargestKeys(
+SmallVector bfsOfOperands,
+DenseSet &smallestKeyIndices,

`ArrayRef`



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:186
+/// progression of the traversal.
+void updateKeys(SmallVector bfsOfOperands);
+

`ArrayRef`



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:194
+DenseSet keyIndices, bool isTheOnlyKey,
+SmallVector &sortedOperands,
+unsigned positionToAssign, Operation *op);

`SmallVectorImpl`



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:201
+void popFrontAndPushAdjacentUnvisitedAncestors(
+SmallVector bfsOfOperands);
+

`ArrayRef`



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:211
+// If `op` is not commutative, do nothing.
+if (!op->template hasTrait())
+  return failure();

Please move the body `matchAndRewrite` into a source file. It only needs 
`Operation *`. And then all the structs/enum/utility functions in the header 
can be moved there as well.



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:226
+for (Value operand : op->getOperands()) {
+  OperandBFS *bfsOfOperand = new OperandBFS();
+  bfsOfOperand->pushAncestor(operand.getDefiningOp());

memory leak?



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:242
+// At first, all elements in it are initialized as null.
+SmallVector sortedOperands;
+for (unsigned i = 0; i < numOperands; i++)

`sortedOperands(numOperands, nullptr);`



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:275
+  // sorting).
+  for (auto indexedBfsOfOperand : llvm::enumerate(bfsOfOperands)) {
+OperandBFS *bfsOfOperand = indexedBfsOfOperand.value();





Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:296
+  // to assign it a sorted position if possible (ensuring stable sorting).
+  for (auto indexedBfsOfOperand :
+   llvm::enumerate(llvm::reverse(bfsOfOperands))) {





Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:17
+
+#define DEBUG_TYPE "commutativity-utils"
+

unused?



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:51
+/// (C) `secondKey` < `firstKey` condition is defined likewise.
+int mlir::compareKeys(SmallVector firstKey,
+  SmallVector secondKey) {

The doc of a public function shouldn't be repeated above the implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-12 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:211
+// If `op` is not commutative, do nothing.
+if (!op->template hasTrait())
+  return failure();

Mogball wrote:
> Please move the body `matchAndRewrite` into a source file. It only needs 
> `Operation *`. And then all the structs/enum/utility functions in the header 
> can be moved there as well.
This could stand to be a `static_assert`



Comment at: mlir/include/mlir/Transforms/CommutativityUtils.h:257
+  // smallest.
+  DenseSet smallestKeyIndices;
+  // Stores the indices of the unassigned operands whose key is the 
largest.

Could you not change `getIndicesOfUnassigned...` to populate two lists of 
operands and pass these to `assignSortedPositionTo` instead of using a set to 
track the indices. You could put the operand index inside `OperandBFS` to keep 
track.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:24
+bool mlir::hasAtLeastOneUnassignedOperand(
+SmallVector bfsOfOperands) {
+  for (OperandBFS *bfsOfOperand : bfsOfOperands) {

This function doesn't seem like it pays for itself -- `llvm::any_of`?



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:92
+  // of `bfsOfOperands`.
+  SmallVector smallestKey, largestKey;
+  for (OperandBFS *bfsOfOperand : bfsOfOperands) {

These could all be `ArrayRef`s since you aren't modifying them



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:167
+  // which is the key associated with a block argument.
+  mlir::BlockArgumentOrOpKey blockArgumentOrOpKey;
+  blockArgumentOrOpKey.type = BLOCK_ARGUMENT;

drop mlir::



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:201
+  unsigned positionToAssign, Operation *op) {
+  if (keyIndices.contains(indexOfOperand) &&
+  (isTheOnlyKey || bfsOfOperand->ancestorQueue.empty())) {

This function doesn't seem like it pays for itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D126694: [C++20][Modules] Implementation of GMF decl elision.

2022-06-12 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D126694#3576602 , @iains wrote:

> @ChuanqiXu - I changed the module ownership name to "ModuleDiscardable" - 
> because, while we are permitted to discard these, we might choose not to (to 
> give your better diagnostics) - but we still need to treat them as 
> non-reachable and non-visible.  Please could you examine what is happening 
> with `Modules/explicitly-specialized-template.cpp` where there a multiple 
> error messages for each (intentionally) failing line .. add the test from the 
> std.

I've looked into this. The multiple duplicated diagnostic message is a legacy 
problem. I tried to fix it but it is hard (change it would break many other 
tests). To filter out the redundant duplicated diagnostic message, you could 
use '+1' suffix after `expected-error`. For example: 
https://github.com/llvm/llvm-project/blob/16ca490f450ea3ceaeda92addd8546967af4b2e1/clang/test/Modules/cxx-templates.cpp#L215-L232
 BTW, after I filtered out the duplicated diagnostic message, I find the 
complains the use of `foo` in the module purview, which is not right and 
should be a bug of this revision.

> @rsmith
>  this seems like an awful lot of work that has to be done for every decl we 
> mark used in the module purview - we cannot even short-cut ones that are not 
> in the GMF, since the provisions of [module.global.frag] p3.5 seem to allow 
> this to happen for indirect reaching.  I wonder if I misread the std.

Yeah, and I am not sure what is better idea here. I tried to implement GMF decl 
elision before. My first idea is similar to your first revision. But I tried to 
implement indirect discarding that time. So I chose to traverse the decls in 
GMF until a fixed point when we handle the end of the TU. It looks bad clearly 
(the time complexity is not satisfying). So I didn't post it up.

> I am also wondering what is supposed to happen when an interface makes a type 
> reachable, but that type is not visible to the implementation .. it seems to 
> mean that interfaces would have to add using declarations for each such type.

@rsmith should be the best to answer here. But I am trying to answer it. If  
'the implementation' means the implementation unit, I think the type is 
naturally visible to the implementation unit. We could find the example in: 
module.interface-example5  .




Comment at: clang/include/clang/AST/DeclBase.h:240
+/// GMF is part.
+ModuleUnreachable
   };

iains wrote:
> ChuanqiXu wrote:
> > Would you like to use the term 'ModuleDiscarded'? My point is that not all 
> > unreachable declaration in modules are in GMF. And the term `discard` is 
> > used in standard to describe it. So it looks better.
> `ModuleDiscardable` Is better, it says we have permission to discard it (so 
> that it cannot be used or reached) but allows for the case we elect to keep 
> them around for better diagnostics.  You might want to consider renaming the 
> wrapper function similarly?
> 
> 
From my reading, it looks like the std says "we should discard things in 
following cases... although there are some cases we could make decision by 
ourself". So it looks like `ModuleDiscarded` is better than `ModuleDiscardable` 
to me.



Comment at: clang/include/clang/AST/DeclBase.h:647
+  bool isDiscardedInGlobalModuleFragment() const {
+   return getModuleOwnershipKind() == ModuleOwnershipKind::ModuleUnreachable;
+  }

iains wrote:
> ChuanqiXu wrote:
> > iains wrote:
> > > ChuanqiXu wrote:
> > > > Maybe we need to check if the owning module is global module or not.
> > > The only place that the ownership is `ModuleUnreachable` is in the GMF - 
> > > so that we do not need to do an additional test.
> > > 
> > It is more robust and clear to add the additional check to me. Since the 
> > constraint now lives in the comment only. If anyone goes to change it, the 
> > codes wouldn't complain.
> I am very concerned about the amount of work this (GMF decl elision) adds, so 
> would like to minimise this - what I have done is to add an assert at the 
> point we might make a change to the ownership that tests to see the decl is 
> in the fragment we expect.
How about something like:
```
assert (getModuleOwnershipKind() != ModuleOwnershipKind::ModuleDiscardable || 
getOwningModule()->isGlobalModule);
return getModuleOwnershipKind() == ModuleOwnershipKind::ModuleDiscardable;
```

So that we could get the clear semantics  and the performance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126694

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


[PATCH] D113545: [C++20] [Module] Support reachable definition initially/partially

2022-06-12 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@iains Given @rsmith is too busy, would you like to review this one?


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

https://reviews.llvm.org/D113545

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-12 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm updated this revision to Diff 436281.
srishti-pm added a comment.

Minor changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

Files:
  clang/docs/tools/clang-formatted-files.txt
  mlir/include/mlir/Transforms/CommutativityUtils.h
  mlir/lib/Transforms/Utils/CMakeLists.txt
  mlir/lib/Transforms/Utils/CommutativityUtils.cpp
  mlir/test/Transforms/test-commutativity-utils.mlir
  mlir/test/lib/Dialect/Test/TestOps.td
  mlir/test/lib/Transforms/CMakeLists.txt
  mlir/test/lib/Transforms/TestCommutativityUtils.cpp
  mlir/tools/mlir-opt/mlir-opt.cpp

Index: mlir/tools/mlir-opt/mlir-opt.cpp
===
--- mlir/tools/mlir-opt/mlir-opt.cpp
+++ mlir/tools/mlir-opt/mlir-opt.cpp
@@ -57,6 +57,7 @@
 void registerVectorizerTestPass();
 
 namespace test {
+void registerCommutativityUtils();
 void registerConvertCallOpPass();
 void registerInliner();
 void registerMemRefBoundCheck();
@@ -150,6 +151,7 @@
   registerVectorizerTestPass();
   registerTosaTestQuantUtilAPIPass();
 
+  mlir::test::registerCommutativityUtils();
   mlir::test::registerConvertCallOpPass();
   mlir::test::registerInliner();
   mlir::test::registerMemRefBoundCheck();
Index: mlir/test/lib/Transforms/TestCommutativityUtils.cpp
===
--- /dev/null
+++ mlir/test/lib/Transforms/TestCommutativityUtils.cpp
@@ -0,0 +1,56 @@
+//===- TestCommutativityUtils.cpp - Pass to test the commutativity utility-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This pass tests the functionality of the commutativity utility.
+//
+//===--===//
+
+#include "mlir/Transforms/CommutativityUtils.h"
+
+#include "TestDialect.h"
+#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+using namespace mlir;
+using namespace arith;
+using namespace test;
+
+namespace {
+
+struct CommutativityUtils
+: public PassWrapper> {
+  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CommutativityUtils)
+
+  StringRef getArgument() const final { return "test-commutativity-utils"; }
+  StringRef getDescription() const final {
+return "Test the functionality of the commutativity utility";
+  }
+
+  void runOnOperation() override {
+auto func = getOperation();
+auto *context = &getContext();
+
+RewritePatternSet patterns(context);
+patterns.add,
+ mlir::SortCommutativeOperands,
+ mlir::SortCommutativeOperands,
+ mlir::SortCommutativeOperands,
+ mlir::SortCommutativeOperands>(
+context);
+
+(void)applyPatternsAndFoldGreedily(func, std::move(patterns));
+  }
+};
+} // namespace
+
+namespace mlir {
+namespace test {
+void registerCommutativityUtils() { PassRegistration(); }
+} // namespace test
+} // namespace mlir
Index: mlir/test/lib/Transforms/CMakeLists.txt
===
--- mlir/test/lib/Transforms/CMakeLists.txt
+++ mlir/test/lib/Transforms/CMakeLists.txt
@@ -1,5 +1,6 @@
 # Exclude tests from libMLIR.so
 add_mlir_library(MLIRTestTransforms
+  TestCommutativityUtils.cpp
   TestConstantFold.cpp
   TestControlFlowSink.cpp
   TestInlining.cpp
Index: mlir/test/lib/Dialect/Test/TestOps.td
===
--- mlir/test/lib/Dialect/Test/TestOps.td
+++ mlir/test/lib/Dialect/Test/TestOps.td
@@ -1172,11 +1172,21 @@
   let hasFolder = 1;
 }
 
+def TestAddIOp : TEST_Op<"addi"> {
+  let arguments = (ins I32:$op1, I32:$op2);
+  let results = (outs I32);
+}
+
 def TestCommutativeOp : TEST_Op<"op_commutative", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4);
   let results = (outs I32);
 }
 
+def TestLargeCommutativeOp : TEST_Op<"op_large_commutative", [Commutative]> {
+  let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4, I32:$op5, I32:$op6, I32:$op7);
+  let results = (outs I32);
+}
+
 def TestCommutative2Op : TEST_Op<"op_commutative2", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2);
   let results = (outs I32);
Index: mlir/test/Transforms/test-commutativity-utils.mlir
===
--- /dev/null
+++ mlir/test/Transforms/test-commutativity-utils.mlir
@@ -0,0 +1,116 @@
+// RUN: mlir-opt %s -test-commutativity-utils | FileCheck %s
+
+// CHECK-LABEL: @test_small_pattern_1
+func.func @test_small_pattern_1(%arg0 : i32) -> i32 {
+  // CHECK-NEXT: %[[ARITH_CONST:.*]] = arith.constant
+  

[clang] b1c300f - [clang-format] Handle deprecated options in dump_format_style.py

2022-06-12 Thread via cfe-commits

Author: owenca
Date: 2022-06-12T23:35:48-07:00
New Revision: b1c300fe6849a053482d117c7d3fa425da9a7430

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

LOG: [clang-format] Handle deprecated options in dump_format_style.py

Also add two deprecated options as comments back to Format.h.

Added: 


Modified: 
clang/docs/tools/dump_format_style.py
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/tools/dump_format_style.py 
b/clang/docs/tools/dump_format_style.py
index fb074435e753e..e8bf29cfd2bee 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -267,6 +267,9 @@ class State:
   name = re.sub(r'struct\s+(\w+)\s*\{', '\\1', line)
   nested_struct = NestedStruct(name, comment)
 elif line.endswith(';'):
+  prefix = '// '
+  if line.startswith(prefix):
+line = line[len(prefix):]
   state = State.InStruct
   field_type, field_name = re.match(r'([<>:\w(,\s)]+)\s+(\w+);',
 line).groups()

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index bbd96af6154a4..8249060dc7c04 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -395,6 +395,11 @@ struct FormatStyle {
   /// \version 9
   bool AllowAllArgumentsOnNextLine;
 
+  /// This option is **deprecated**. See ``NextLine`` of
+  /// ``PackConstructorInitializers``.
+  /// \version 9
+  // bool AllowAllConstructorInitializersOnNextLine;
+
   /// If the function declaration doesn't fit on a line,
   /// allow putting all parameters of a function declaration onto
   /// the next line even if ``BinPackParameters`` is ``false``.
@@ -1878,6 +1883,11 @@ struct FormatStyle {
   /// \version 5
   bool CompactNamespaces;
 
+  /// This option is **deprecated**. See ``CurrentLine`` of
+  /// ``PackConstructorInitializers``.
+  /// \version 3.7
+  // bool ConstructorInitializerAllOnOneLineOrOnePerLine;
+
   /// The number of characters to use for indentation of constructor
   /// initializer lists as well as inheritance lists.
   /// \version 3.7



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


[PATCH] D127578: [clang-format] Handle deprecated options in dump_format_style.py

2022-06-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan closed this revision.
owenpan added a comment.

Landed in b1c300f 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127578

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


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-06-12 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:847-849
+} else if (const auto Iface =
+   dyn_cast(Decl)) {
+  if (Iface->isThisDeclarationADefinition())

dgoldman wrote:
> Do we need similar code for ObjCProtocolDecl? Also should ObjCImplDecl be 
> considered definitions here?
Possibly. I know next to nothing about Objective C, so I'll just do as I'm told 
here. On a related note, the code above regarding ObjCMethodDecl does not seem 
to do anything, i.e. none of the constructs that to my eye appear to be 
Objective-C methods get the "def" modifier. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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