[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-01-16 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 489468.
pmatos added a comment.

Updating tests after some changes to previous diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/builtins-table.c
  clang/test/CodeGen/WebAssembly/table.c
  clang/test/Sema/builtins-wasm.c
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs-and-tables.cpp
  clang/test/SemaCXX/wasm-refs.cpp
  llvm/include/llvm/CodeGen/WasmAddressSpaces.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp

Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
@@ -62,8 +62,9 @@
   for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
 PtrToIntInst *PTI = dyn_cast(&*I);
 IntToPtrInst *ITP = dyn_cast(&*I);
-if (!(PTI && WebAssembly::isRefType(PTI->getPointerOperand()->getType())) &&
-!(ITP && WebAssembly::isRefType(ITP->getDestTy(
+if (!(PTI &&
+  PTI->getPointerOperand()->getType()->isWebAssemblyReferenceType()) &&
+!(ITP && ITP->getDestTy()->isWebAssemblyReferenceType()))
   continue;
 
 UndefValue *U = UndefValue::get(I->getType());
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1202,7 +1202,7 @@
   // Lastly, if this is a call to a funcref we need to add an instruction
   // table.set to the chain and transform the call.
   if (CLI.CB &&
-  WebAssembly::isFuncrefType(CLI.CB->getCalledOperand()->getType())) {
+  CLI.CB->getCalledOperand()->getType()->isWebAssemblyFuncrefType()) {
 // In the absence of function references proposal where a funcref call is
 // lowered to call_ref, using reference types we generate a table.set to set
 // the funcref to a special table used solely for this purpose, followed by
Index: llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
===
--- llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
+++ llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
@@ -45,43 +45,6 @@
   Multivalue = 0x,
 };
 
-enum WasmAddressSpace : unsigned {
-  // Default address space, for pointers to linear memory (stack, heap, data).
-  WASM_ADDRESS_SPACE_DEFAULT = 0,
-  // A non-integral address space for pointers to named objects outside of
-  // linear memory: WebAssembly globals or WebAssembly locals.  Loads and stores
-  // to these pointers are lowered to global.get / global.set or local.get /
-  // local.set, as appropriate.
-  WASM_ADDRESS_SPACE_VAR = 1,
-  // A non-integral address space for externref values
-  WASM_ADDRESS_SPACE_EXTERNREF = 10,
-  // A non-integral address space for funcref values
-  WASM_ADDRESS_SPACE_FUNCREF = 20,
-};
-
-inline bool isDefaultAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_DEFAULT;
-}
-inline bool isWasmVarAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_VAR;
-}
-inline bool isValidAddressSpace(unsigned AS) {
-  return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS);
-}
-inline bool isFuncrefType(const Type *Ty) {
-  return isa(Ty) &&
- Ty->getPointerAddressSpace() ==
- WasmAddressSpace::WASM_ADDRESS_SPACE_FUNCREF;
-}
-inline bool isExternrefType(const Type *Ty) {
-  return isa(Ty) &&
- Ty->getPointerAddressSpace() ==
- 

[clang] 15ad244 - Add test for an invalid requirement in requires expr.

2023-01-16 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2023-01-16T12:28:49+01:00
New Revision: 15ad244670a9ef0bf93b7c8a598586d4a841b197

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

LOG: Add test for an invalid requirement in requires expr.

The one introduced in D140547 was brittle. Fixing max template depth to
a small value would still test the same issue without causing actual
stack exhaustion.

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

Added: 
clang/test/SemaCXX/invalid-requirement-requires-expr.cpp

Modified: 


Removed: 




diff  --git a/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp 
b/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
new file mode 100644
index ..097ada3caa13
--- /dev/null
+++ b/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang -fsyntax-only -std=c++2a -Xclang -verify -ftemplate-depth=5 
-ftemplate-backtrace-limit=4 %s
+
+// RequiresExpr contains invalid requirement. (Eg. Highly recurisive template).
+template
+struct A { static constexpr bool far(); };
+class B {
+bool data_member;
+friend struct A<1>;
+};
+
+template<>
+constexpr bool A<0>::far() { return true; }
+
+template
+constexpr bool A::far() {
+return requires(B b) {
+  b.data_member;
+  requires A::far(); // #Invalid
+  // expected-error@#Invalid {{recursive template instantiation exceeded 
maximum depth}}
+  // expected-note@#Invalid {{in instantiation}}
+  // expected-note@#Invalid 2 {{while}}
+  // expected-note@#Invalid {{contexts in backtrace}}
+  // expected-note@#Invalid {{increase recursive template instantiation 
depth}}
+};
+}
+static_assert(A<1>::far());
+static_assert(!A<6>::far()); // expected-note {{in instantiation of member 
function}}



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


[PATCH] D141818: Add test for an invalid requirement in requires expr.

2023-01-16 Thread Utkarsh Saxena via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG15ad244670a9: Add test for an invalid requirement in 
requires expr. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141818

Files:
  clang/test/SemaCXX/invalid-requirement-requires-expr.cpp


Index: clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang -fsyntax-only -std=c++2a -Xclang -verify -ftemplate-depth=5 
-ftemplate-backtrace-limit=4 %s
+
+// RequiresExpr contains invalid requirement. (Eg. Highly recurisive template).
+template
+struct A { static constexpr bool far(); };
+class B {
+bool data_member;
+friend struct A<1>;
+};
+
+template<>
+constexpr bool A<0>::far() { return true; }
+
+template
+constexpr bool A::far() {
+return requires(B b) {
+  b.data_member;
+  requires A::far(); // #Invalid
+  // expected-error@#Invalid {{recursive template instantiation exceeded 
maximum depth}}
+  // expected-note@#Invalid {{in instantiation}}
+  // expected-note@#Invalid 2 {{while}}
+  // expected-note@#Invalid {{contexts in backtrace}}
+  // expected-note@#Invalid {{increase recursive template instantiation 
depth}}
+};
+}
+static_assert(A<1>::far());
+static_assert(!A<6>::far()); // expected-note {{in instantiation of member 
function}}


Index: clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang -fsyntax-only -std=c++2a -Xclang -verify -ftemplate-depth=5 -ftemplate-backtrace-limit=4 %s
+
+// RequiresExpr contains invalid requirement. (Eg. Highly recurisive template).
+template
+struct A { static constexpr bool far(); };
+class B {
+bool data_member;
+friend struct A<1>;
+};
+
+template<>
+constexpr bool A<0>::far() { return true; }
+
+template
+constexpr bool A::far() {
+return requires(B b) {
+  b.data_member;
+  requires A::far(); // #Invalid
+  // expected-error@#Invalid {{recursive template instantiation exceeded maximum depth}}
+  // expected-note@#Invalid {{in instantiation}}
+  // expected-note@#Invalid 2 {{while}}
+  // expected-note@#Invalid {{contexts in backtrace}}
+  // expected-note@#Invalid {{increase recursive template instantiation depth}}
+};
+}
+static_assert(A<1>::far());
+static_assert(!A<6>::far()); // expected-note {{in instantiation of member function}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141297: [OpenCL] Allow undefining header-only features

2023-01-16 Thread Sven van Haastregt 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 rGa60b8f468119: [OpenCL] Allow undefining header-only features 
(authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141297

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/SemaOpenCL/features.cl


Index: clang/test/SemaOpenCL/features.cl
===
--- clang/test/SemaOpenCL/features.cl
+++ clang/test/SemaOpenCL/features.cl
@@ -26,6 +26,15 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 
+// For OpenCL C 3.0, header-only features can be disabled using macros.
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header \
+// RUN:-D__undef___opencl_c_work_group_collective_functions=1 \
+// RUN:-D__undef___opencl_c_atomic_order_seq_cst=1 \
+// RUN:-D__undef___opencl_c_atomic_scope_device=1 \
+// RUN:-D__undef___opencl_c_atomic_scope_all_devices=1 \
+// RUN:-D__undef___opencl_c_read_write_images=1 \
+// RUN:   | FileCheck %s --check-prefix=NO-HEADERONLY-FEATURES
+
 // Note that __opencl_c_int64 is always defined assuming
 // always compiling for FULL OpenCL profile
 
@@ -43,14 +52,20 @@
 // FEATURES: #define __opencl_c_subgroups 1
 
 // NO-FEATURES: #define __opencl_c_int64 1
-// NO-FEATURES-NOT: __opencl_c_3d_image_writes
-// NO-FEATURES-NOT: __opencl_c_atomic_order_acq_rel
-// NO-FEATURES-NOT: __opencl_c_atomic_order_seq_cst
-// NO-FEATURES-NOT: __opencl_c_device_enqueue
-// NO-FEATURES-NOT: __opencl_c_fp64
-// NO-FEATURES-NOT: __opencl_c_generic_address_space
-// NO-FEATURES-NOT: __opencl_c_images
-// NO-FEATURES-NOT: __opencl_c_pipes
-// NO-FEATURES-NOT: __opencl_c_program_scope_global_variables
-// NO-FEATURES-NOT: __opencl_c_read_write_images
-// NO-FEATURES-NOT: __opencl_c_subgroups
+// NO-FEATURES-NOT: #define __opencl_c_3d_image_writes
+// NO-FEATURES-NOT: #define __opencl_c_atomic_order_acq_rel
+// NO-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst
+// NO-FEATURES-NOT: #define __opencl_c_device_enqueue
+// NO-FEATURES-NOT: #define __opencl_c_fp64
+// NO-FEATURES-NOT: #define __opencl_c_generic_address_space
+// NO-FEATURES-NOT: #define __opencl_c_images
+// NO-FEATURES-NOT: #define __opencl_c_pipes
+// NO-FEATURES-NOT: #define __opencl_c_program_scope_global_variables
+// NO-FEATURES-NOT: #define __opencl_c_read_write_images
+// NO-FEATURES-NOT: #define __opencl_c_subgroups
+
+// NO-HEADERONLY-FEATURES-NOT: #define 
__opencl_c_work_group_collective_functions
+// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst
+// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_device
+// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_all_devices
+// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_read_write_images
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -74,6 +74,25 @@
 #define __opencl_c_atomic_scope_all_devices 1
 #define __opencl_c_read_write_images 1
 #endif // defined(__SPIR__)
+
+// Undefine any feature macros that have been explicitly disabled using
+// an __undef_ macro.
+#ifdef __undef___opencl_c_work_group_collective_functions
+#undef __opencl_c_work_group_collective_functions
+#endif
+#ifdef __undef___opencl_c_atomic_order_seq_cst
+#undef __opencl_c_atomic_order_seq_cst
+#endif
+#ifdef __undef___opencl_c_atomic_scope_device
+#undef __opencl_c_atomic_scope_device
+#endif
+#ifdef __undef___opencl_c_atomic_scope_all_devices
+#undef __opencl_c_atomic_scope_all_devices
+#endif
+#ifdef __undef___opencl_c_read_write_images
+#undef __opencl_c_read_write_images
+#endif
+
 #endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 #if !defined(__opencl_c_generic_address_space)


Index: clang/test/SemaOpenCL/features.cl
===
--- clang/test/SemaOpenCL/features.cl
+++ clang/test/SemaOpenCL/features.cl
@@ -26,6 +26,15 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 
+// For OpenCL C 3.0, header-only features can be disabled using macros.
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header \
+// RUN:-D__undef___opencl_c_work_group_collective_functions=1 \
+// RUN:-D__undef___opencl_c_atomic_order_seq_cst=1 \
+// RUN:-D__undef___opencl_c_atomic_scope_device=1 \
+// RUN:-D__undef___opencl_c_atomic_scope_all_devices=1 

[PATCH] D138655: [clang-tidy] Fix `cppcoreguidelines-init-variables` for invalid vardecl

2023-01-16 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

Hi, Could anyone please review this diff?


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

https://reviews.llvm.org/D138655

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


[clang] 1506839 - [NFC] Fixed a typo in clang help docs

2023-01-16 Thread Jolanta Jensen via cfe-commits

Author: Jolanta Jensen
Date: 2023-01-16T11:50:58Z
New Revision: 15068394858e2e27bf6893bd2adb04c74b384290

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

LOG: [NFC] Fixed a typo in clang help docs

Fixed minor typo in clang help docs.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 38f2f68b93860..a163c77fdb13c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1954,7 +1954,7 @@ def ffp_contract : Joined<["-"], "ffp-contract=">, 
Group,
   " fast (fuses across statements disregarding pragmas)"
   " | on (only fuses in the same statement unless dictated by pragmas)"
   " | off (never fuses)"
-  " | fast-honor-pragmas (fuses across statements unless diectated by 
pragmas)."
+  " | fast-honor-pragmas (fuses across statements unless dictated by pragmas)."
   " Default is 'fast' for CUDA, 'fast-honor-pragmas' for HIP, and 'on' 
otherwise.">,
   HelpText<"Form fused FP ops (e.g. FMAs)">,
   Values<"fast,on,off,fast-honor-pragmas">;



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


[PATCH] D141507: [NFC] Fixed a typo in clang help docs

2023-01-16 Thread Jolanta Jensen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG15068394858e: [NFC] Fixed a typo in clang help docs 
(authored by jolanta.jensen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141507

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1954,7 +1954,7 @@
   " fast (fuses across statements disregarding pragmas)"
   " | on (only fuses in the same statement unless dictated by pragmas)"
   " | off (never fuses)"
-  " | fast-honor-pragmas (fuses across statements unless diectated by 
pragmas)."
+  " | fast-honor-pragmas (fuses across statements unless dictated by pragmas)."
   " Default is 'fast' for CUDA, 'fast-honor-pragmas' for HIP, and 'on' 
otherwise.">,
   HelpText<"Form fused FP ops (e.g. FMAs)">,
   Values<"fast,on,off,fast-honor-pragmas">;


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1954,7 +1954,7 @@
   " fast (fuses across statements disregarding pragmas)"
   " | on (only fuses in the same statement unless dictated by pragmas)"
   " | off (never fuses)"
-  " | fast-honor-pragmas (fuses across statements unless diectated by pragmas)."
+  " | fast-honor-pragmas (fuses across statements unless dictated by pragmas)."
   " Default is 'fast' for CUDA, 'fast-honor-pragmas' for HIP, and 'on' otherwise.">,
   HelpText<"Form fused FP ops (e.g. FMAs)">,
   Values<"fast,on,off,fast-honor-pragmas">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141788: [NFC] Use `llvm::enumerate` in llvm/unittests/Object

2023-01-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 489499.
barannikov88 added a comment.

Use `auto` instead of `const auto &`
Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141788

Files:
  clang/docs/tools/clang-formatted-files.txt
  llvm/unittests/Object/ELFObjectFileTest.cpp

Index: llvm/unittests/Object/ELFObjectFileTest.cpp
===
--- llvm/unittests/Object/ELFObjectFileTest.cpp
+++ llvm/unittests/Object/ELFObjectFileTest.cpp
@@ -7,8 +7,9 @@
 //===--===//
 
 #include "llvm/Object/ELFObjectFile.h"
-#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ObjectYAML/yaml2obj.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gtest/gtest.h"
@@ -86,38 +87,33 @@
 TEST(ELFObjectFileTest, MachineTestForNoneOrUnused) {
   std::array Formats = {"elf32-unknown", "elf32-unknown",
   "elf64-unknown", "elf64-unknown"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_NONE))
-checkFormatAndArch(D, Formats[I++], Triple::UnknownArch);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_NONE)))
+checkFormatAndArch(Data, Formats[Idx], Triple::UnknownArch);
 
   // Test an arbitrary unused EM_* value (255).
-  I = 0;
-  for (const DataForTest  : generateData(255))
-checkFormatAndArch(D, Formats[I++], Triple::UnknownArch);
+  for (auto [Idx, Data] : enumerate(generateData(255)))
+checkFormatAndArch(Data, Formats[Idx], Triple::UnknownArch);
 }
 
 TEST(ELFObjectFileTest, MachineTestForVE) {
   std::array Formats = {"elf32-unknown", "elf32-unknown",
   "elf64-ve", "elf64-ve"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_VE))
-checkFormatAndArch(D, Formats[I++], Triple::ve);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_VE)))
+checkFormatAndArch(Data, Formats[Idx], Triple::ve);
 }
 
 TEST(ELFObjectFileTest, MachineTestForX86_64) {
   std::array Formats = {"elf32-x86-64", "elf32-x86-64",
   "elf64-x86-64", "elf64-x86-64"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_X86_64))
-checkFormatAndArch(D, Formats[I++], Triple::x86_64);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_X86_64)))
+checkFormatAndArch(Data, Formats[Idx], Triple::x86_64);
 }
 
 TEST(ELFObjectFileTest, MachineTestFor386) {
   std::array Formats = {"elf32-i386", "elf32-i386", "elf64-i386",
   "elf64-i386"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_386))
-checkFormatAndArch(D, Formats[I++], Triple::x86);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_386)))
+checkFormatAndArch(Data, Formats[Idx], Triple::x86);
 }
 
 TEST(ELFObjectFileTest, MachineTestForMIPS) {
@@ -125,27 +121,22 @@
   "elf64-mips"};
   std::array Archs = {Triple::mipsel, Triple::mips,
Triple::mips64el, Triple::mips64};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_MIPS)) {
-checkFormatAndArch(D, Formats[I], Archs[I]);
-++I;
-  }
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_MIPS)))
+checkFormatAndArch(Data, Formats[Idx], Archs[Idx]);
 }
 
 TEST(ELFObjectFileTest, MachineTestForAMDGPU) {
   std::array Formats = {"elf32-amdgpu", "elf32-amdgpu",
   "elf64-amdgpu", "elf64-amdgpu"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_AMDGPU))
-checkFormatAndArch(D, Formats[I++], Triple::UnknownArch);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_AMDGPU)))
+checkFormatAndArch(Data, Formats[Idx], Triple::UnknownArch);
 }
 
 TEST(ELFObjectFileTest, MachineTestForIAMCU) {
   std::array Formats = {"elf32-iamcu", "elf32-iamcu",
   "elf64-unknown", "elf64-unknown"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_IAMCU))
-checkFormatAndArch(D, Formats[I++], Triple::x86);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_IAMCU)))
+checkFormatAndArch(Data, Formats[Idx], Triple::x86);
 }
 
 TEST(ELFObjectFileTest, MachineTestForAARCH64) {
@@ -154,11 +145,8 @@
   "elf64-bigaarch64"};
   std::array Archs = {Triple::aarch64, Triple::aarch64_be,
Triple::aarch64, Triple::aarch64_be};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_AARCH64)) {
-checkFormatAndArch(D, Formats[I], Archs[I]);
-++I;
-  }
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_AARCH64)))
+checkFormatAndArch(Data, Formats[Idx], 

[PATCH] D141381: [codegen] Store address of indirect arguments on the stack

2023-01-16 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve updated this revision to Diff 489502.
fdeazeve added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141381

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/CodeGen/aarch64-ls64.c
  clang/test/CodeGen/atomic-arm64.c
  clang/test/CodeGenCXX/amdgcn-func-arg.cpp
  clang/test/CodeGenCXX/debug-info.cpp
  clang/test/CodeGenCXX/derived-to-base-conv.cpp
  clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
  clang/test/CodeGenCoroutines/coro-params.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_firstprivate_codegen.cpp

Index: clang/test/OpenMP/teams_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/teams_firstprivate_codegen.cpp
+++ clang/test/OpenMP/teams_firstprivate_codegen.cpp
@@ -557,8 +557,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
 // CHECK9-NEXT:call void @_ZN1SIfEC2ERKS0_2St(ptr nonnull align 4 dereferenceable(4) [[THIS1]], ptr nonnull align 4 dereferenceable(4) [[TMP0]], ptr [[T]])
@@ -784,8 +786,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[F:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[THIS1]], i32 0, i32 0
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
@@ -932,8 +936,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
 // CHECK9-NEXT:call void @_ZN1SIiEC2ERKS0_2St(ptr nonnull align 4 dereferenceable(4) [[THIS1]], ptr nonnull align 4 dereferenceable(4) [[TMP0]], ptr [[T]])
@@ -1012,8 +1018,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[F:%.*]] = getelementptr inbounds [[STRUCT_S_0:%.*]], ptr [[THIS1]], i32 0, i32 0
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
@@ -1318,8 +1326,10 @@
 // CHECK11-NEXT:  entry:
 // CHECK11-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 4
 // CHECK11-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 4
+// CHECK11-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 4
 // CHECK11-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 4
 // CHECK11-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 4
+// CHECK11-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], 

[PATCH] D131915: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2023-01-16 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 489510.
TIFitis added a comment.

Removed use of VariadicOfVariadic. Added new I64ArrayAttr for map_types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131915

Files:
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
  mlir/test/Dialect/OpenMP/ops.mlir

Index: mlir/test/Dialect/OpenMP/ops.mlir
===
--- mlir/test/Dialect/OpenMP/ops.mlir
+++ mlir/test/Dialect/OpenMP/ops.mlir
@@ -451,6 +451,26 @@
 return
 }
 
+// CHECK-LABEL: omp_target_data
+func.func @omp_target_data (%if_cond : i1, %device : si32, %device_ptr: memref, %device_addr: memref, %map1: memref, %map2: memref) -> () {
+// CHECK: omp.target_data if(%[[VAL_0:.*]] : i1) device(%[[VAL_1:.*]] : si32) map((6 : i64 -> always , from : %[[VAL_2:.*]] : memref))
+omp.target_data if(%if_cond : i1) device(%device : si32) map((6 -> always , from : %map1 : memref)){}
+
+// CHECK: omp.target_data use_device_ptr(%[[VAL_3:.*]] : memref) use_device_addr(%[[VAL_4:.*]] : memref) map((6 : i64 -> always , from : %[[VAL_2:.*]] : memref))
+omp.target_data use_device_ptr(%device_ptr : memref) use_device_addr(%device_addr : memref) map((6 -> always , from : %map1 : memref)){}
+
+// CHECK: omp.target_data map((6 : i64 -> always , from : %[[VAL_2]] : memref), (0 : i64 -> none , alloc : %[[VAL_5:.*]] : memref))
+omp.target_data map((6 -> always , from : %map1 : memref), (0 -> none , alloc : %map2 : memref)){}
+
+// CHECK: omp.target_enter_data if(%[[VAL_0]] : i1) device(%[[VAL_1]] : si32) nowait map((0 : i64 -> none , alloc : %[[VAL_2]] : memref))
+omp.target_enter_data if(%if_cond : i1) device(%device : si32) nowait map((0 -> none , alloc : %map1 : memref))
+
+// CHECK: omp.target_exit_data if(%[[VAL_0]] : i1) device(%[[VAL_1]] : si32) nowait map((0 : i64 -> none , release : %[[VAL_5]] : memref))
+omp.target_exit_data if(%if_cond : i1) device(%device : si32) nowait map((0 -> none , release : %map2 : memref))
+
+return
+}
+
 // CHECK-LABEL: omp_target_pretty
 func.func @omp_target_pretty(%if_cond : i1, %device : si32,  %num_threads : i32) -> () {
 // CHECK: omp.target if({{.*}}) device({{.*}})
Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -22,6 +22,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/TypeSwitch.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include 
 
 #include "mlir/Dialect/OpenMP/OpenMPOpsDialect.cpp.inc"
@@ -536,6 +537,154 @@
   return success();
 }
 
+//===--===//
+// Parser, printer and verifier for Target Data
+//===--===//
+static ParseResult
+parseMapClause(OpAsmParser ,
+   SmallVectorImpl _operands,
+   SmallVectorImpl _operand_types, ArrayAttr _types) {
+  StringRef mapTypeMod, mapType;
+  OpAsmParser::UnresolvedOperand arg1;
+  IntegerAttr arg2;
+  Type arg2Type;
+  SmallVector mapTypesVec;
+  auto parseKeyword = [&]() -> ParseResult {
+if (parser.parseLParen() || parser.parseAttribute(arg2) ||
+parser.parseArrow() || parser.parseKeyword() ||
+parser.parseComma() || parser.parseKeyword() ||
+parser.parseColon() || parser.parseOperand(arg1) ||
+parser.parseColon() || parser.parseType(arg2Type) ||
+parser.parseRParen())
+  return failure();
+map_operands.push_back(arg1);
+map_operand_types.push_back(arg2Type);
+mapTypesVec.push_back(arg2);
+return success();
+  };
+  if (parser.parseCommaSeparatedList(parseKeyword))
+return failure();
+  SmallVector mapTypesAttr(mapTypesVec.begin(), mapTypesVec.end());
+  map_types = ArrayAttr::get(parser.getContext(), mapTypesAttr);
+  return success();
+}
+
+static void printMapClause(OpAsmPrinter , Operation *op,
+   OperandRange map_operands,
+   TypeRange map_operand_types, ArrayAttr map_types) {
+
+  // Helper function to get bitwise AND of `value` and 'flag'
+  auto bitAnd = [](int64_t value,
+   llvm::omp::OpenMPOffloadMappingFlags flag) -> bool {
+return value &
+   static_cast<
+   std::underlying_type_t>(
+   flag);
+  };
+
+  assert(map_operands.size() == map_types.size());
+
+  for (unsigned i = 0, e = map_operands.size(); i < e; i++) {
+int64_t mapTypeBits = 0x00;
+auto mapOp = map_operands[i];
+auto mapTypeOp = map_types[i];
+
+if (mapTypeOp.isa())
+  mapTypeBits = mapTypeOp.cast().getInt();
+
+bool always = bitAnd(mapTypeBits,
+ 

[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-16 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D133574#4053647 , @aaron.ballman 
wrote:

> I'll take care of fixing this up on Tuesday (Mon is a holiday here), but if 
> anyone wants to get to it sooner, what I plan to do is:
>
> - Add a new `Extension` diagnostic about allowing you to define a type in 
> `__builtin_offsetof`
> - Replace the error in C with the extension warning (C++ will continue to err)
> - Add documentation to the extensions manual for the builtin
> - Update the release note and tests accordingly

It might be worth to revert the patch in the meantime to reduce the impact on 
adopters that are using current `main` for testing. Among other things, it also 
breaks building the gcc workload or SPEC2017


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D141700: AMDGPU: Move enqueued block handling into clang

2023-01-16 Thread Juan Manuel Martinez Caamaño via Phabricator via cfe-commits
jmmartinez added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:12581
+  Mod, HandleTy,
+  /*isConstant=*/true, llvm::GlobalValue::InternalLinkage,
+  /*Initializer=*/RuntimeHandleInitializer, RuntimeHandleName,

Just a cosmetical remark: Is there any reason to keep the `/*isConstant=*/`, 
`/*Initializer=*/`, ... comments? I think it would be better to avoid them.


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

https://reviews.llvm.org/D141700

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


[PATCH] D141826: [WIP][clang][TemplateBase] Add IsDefaulted bit to TemplateArgument

2023-01-16 Thread Michael Buch via Phabricator via cfe-commits
Michael137 created this revision.
Michael137 added reviewers: erichkeane, aaron.ballman, dblaikie.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

**Summary**

This patch adds a `IsDefaulted` field to `clang::TemplateArgument`.

To prevent memory footprint increase we still 1 bit from `ArgKind`.

**Background**

In LLDB we construct ASTs from debug-info and hand it to clang
to perform actions such as printing/formatting a typenames.
Some debug formats, specifically DWARF, may only encode information
about class template instantiations, losing the structure of the generic
class definition. However, the `clang::TypePrinter` needs a properly
constructed `ClassTemplateDecl` with generic default argument decls
to be able to deduce whether a `ClassTemplateSpecializationDecl` was
instantiatiated with `TemplateArgument`s that correspond to the
defaults. LLDB does know whether a particular template argument was
defaulted, but can't currently tell clang about it.

This patch allows LLDB to set the defaulted-ness of a `TemplateArgument`
and thus benefit more from `clang::TypePrinter`.

See discussion in https://reviews.llvm.org/D140423

**Testing**

- TODO


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141826

Files:
  clang/include/clang/AST/TemplateBase.h
  clang/lib/AST/TemplateBase.cpp

Index: clang/lib/AST/TemplateBase.cpp
===
--- clang/lib/AST/TemplateBase.cpp
+++ clang/lib/AST/TemplateBase.cpp
@@ -162,6 +162,7 @@
 TemplateArgument::TemplateArgument(ASTContext , const llvm::APSInt ,
QualType Type) {
   Integer.Kind = Integral;
+  Integer.IsDefaulted = false;
   // Copy the APSInt value into our decomposed form.
   Integer.BitWidth = Value.getBitWidth();
   Integer.IsUnsigned = Value.isUnsigned();
Index: clang/include/clang/AST/TemplateBase.h
===
--- clang/include/clang/AST/TemplateBase.h
+++ clang/include/clang/AST/TemplateBase.h
@@ -103,12 +103,14 @@
   /// The kind of template argument we're storing.
 
   struct DA {
-unsigned Kind;
+unsigned Kind : 31;
+unsigned IsDefaulted : 1;
 void *QT;
 ValueDecl *D;
   };
   struct I {
-unsigned Kind;
+unsigned Kind : 31;
+unsigned IsDefaulted : 1;
 // We store a decomposed APSInt with the data allocated by ASTContext if
 // BitWidth > 64. The memory may be shared between multiple
 // TemplateArgument instances.
@@ -124,17 +126,20 @@
 void *Type;
   };
   struct A {
-unsigned Kind;
+unsigned Kind : 31;
+unsigned IsDefaulted : 1;
 unsigned NumArgs;
 const TemplateArgument *Args;
   };
   struct TA {
-unsigned Kind;
+unsigned Kind : 31;
+unsigned IsDefaulted : 1;
 unsigned NumExpansions;
 void *Name;
   };
   struct TV {
-unsigned Kind;
+unsigned Kind : 31;
+unsigned IsDefaulted : 1;
 uintptr_t V;
   };
   union {
@@ -147,11 +152,12 @@
 
 public:
   /// Construct an empty, invalid template argument.
-  constexpr TemplateArgument() : TypeOrValue({Null, 0}) {}
+  constexpr TemplateArgument() : TypeOrValue({Null, /* IsDefaulted */ 0, 0}) {}
 
   /// Construct a template type argument.
   TemplateArgument(QualType T, bool isNullPtr = false) {
 TypeOrValue.Kind = isNullPtr ? NullPtr : Type;
+TypeOrValue.IsDefaulted = false;
 TypeOrValue.V = reinterpret_cast(T.getAsOpaquePtr());
   }
 
@@ -161,6 +167,7 @@
   TemplateArgument(ValueDecl *D, QualType QT) {
 assert(D && "Expected decl");
 DeclArg.Kind = Declaration;
+DeclArg.IsDefaulted = false;
 DeclArg.QT = QT.getAsOpaquePtr();
 DeclArg.D = D;
   }
@@ -186,6 +193,7 @@
   /// \param Name The template name.
   TemplateArgument(TemplateName Name) {
 TemplateArg.Kind = Template;
+TemplateArg.IsDefaulted = false;
 TemplateArg.Name = Name.getAsVoidPointer();
 TemplateArg.NumExpansions = 0;
   }
@@ -203,6 +211,7 @@
   /// instantiating
   TemplateArgument(TemplateName Name, Optional NumExpansions) {
 TemplateArg.Kind = TemplateExpansion;
+TemplateArg.IsDefaulted = false;
 TemplateArg.Name = Name.getAsVoidPointer();
 if (NumExpansions)
   TemplateArg.NumExpansions = *NumExpansions + 1;
@@ -217,6 +226,7 @@
   /// occur in a non-dependent, canonical template argument list.
   TemplateArgument(Expr *E) {
 TypeOrValue.Kind = Expression;
+TypeOrValue.IsDefaulted = false;
 TypeOrValue.V = reinterpret_cast(E);
   }
 
@@ -226,6 +236,7 @@
   /// outlives the TemplateArgument itself.
   explicit TemplateArgument(ArrayRef Args) {
 this->Args.Kind = Pack;
+this->Args.IsDefaulted = false;
 this->Args.Args = Args.data();
 this->Args.NumArgs = Args.size();
   }
@@ -334,6 +345,10 @@
 Integer.Type = T.getAsOpaquePtr();
   }
 
+  void setIsDefaulted(bool v) { 

[PATCH] D140423: [WIP][clang] Add PrintingPolicy callback for identifying default template arguments

2023-01-16 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

In D140423#4052442 , @aaron.ballman 
wrote:

> In D140423#4052271 , @dblaikie 
> wrote:
>
>> In D140423#4051262 , 
>> @aaron.ballman wrote:
>>
 Add something like a bool IsDefaulted somewhere in Clang, e.g., in 
 TemplateArgument and consult it from the TypePrinter. This would be much 
 simpler but requires adding a field on one of the Clang types
>>>
>>> I think this might be worth exploring as a cleaner solution to the problem. 
>>> `TemplateArgument` has a union of structures for the various kinds of 
>>> template arguments it represents 
>>> (https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/TemplateBase.h#L140).
>>>  All of the structures in that union start with an `unsigned Kind` field to 
>>> discriminate between the members. There are only 8 kinds currently 
>>> (https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/TemplateBase.h#L63),
>>>  so we could turn `Kind` into a bit-field and then steal a bit for 
>>> `IsDefaulted` without increasing memory overhead. Do you think that's a 
>>> reasonable approach to try instead?
>>
>> FWIW, I Think I discouraged @Michael137 from going down that direction since 
>> it felt weird to me to add that sort of thing to the Clang ASTs for an 
>> lldb-only use case, and a callback seemed more suitable. But this is hardly 
>> my wheelhouse - if you reckon that's the better direction, carry on, I 
>> expect @Michael137 will be on board with that.
>
> Adding in @erichkeane as templates code owner in case he has opinions.
>
> I agree it's a bit weird to modify the AST only for lldb only, but adding a 
> callback to the printing policy is basically an lldb-only change as well (I 
> don't imagine folks would use that callback all that often). So my thinking 
> is that if we can encode the information in the AST for effectively zero 
> cost, that helps every consumer of the AST (thinking about things like 
> clang-tidy) and not just people printing. However, this is not a strongly 
> held position, so if there's a preference for the current approach, it seems 
> workable to me.

Thanks for taking a look @aaron.ballman

I prepared an alternative draft patch series with your suggestion of adding an 
`IsDefaulted` bit to `TemplateArgument`:

- https://reviews.llvm.org/D141826
- https://reviews.llvm.org/D141827

Is this what you had in mind?

This *significantly* simplifies the LLDB support: 
https://reviews.llvm.org/D141828

So I'd prefer this over the callback approach TBH.

> A Class template instantiation SHOULD have its link back to the class 
> template, and should be able to calculate whether the template argument is 
> defaulted, right? At least if it is the SAME as the default (that is, I'm not 
> sure how well we can tell the difference between a defaulted arg, and a arg 
> set to the default value).
>
> I wouldn't expect a bool to be necessary, and I see 
> isSubstitutedDefaultArgument seems to do that work, right?

As @dblaikie mentioned, unfortunately LLDB currently isn't able to construct 
the `ClassTemplateDecl` in a way where this `isSubstitutedDefaultArgument` 
would correctly deduce whether a template instantiation has defaulted 
arguments. In DWARF we only have info about a template instantiation, but the 
structure of the generic template parameters is not encoded. So we can't supply 
`(Non)TypeTemplateParamDecl::setDefaultArgument` with the generic arguments 
Clang expects. The `ClassTemplateDecl` parameters are set up here: 
https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L1391-L1402

Regardless of how complex the template parameters get, LLDB just turns each 
into a plain `(Non)TypeTemplateParamDecl`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140423

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


[clang] a60b8f4 - [OpenCL] Allow undefining header-only features

2023-01-16 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2023-01-16T11:32:12Z
New Revision: a60b8f468119065f8a6cb4a16598263cb00de0b5

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

LOG: [OpenCL] Allow undefining header-only features

`opencl-c-base.h` always defines 5 particular feature macros for
SPIR-V, making it impossible to disable those features.

To allow disabling any of those features, let the header recognize
`__undef_` macros.  The user can then pass the
`-D__undef_` flag on the command line to disable a specific
feature.  The __undef macro could potentially also be set from
`-cl-ext=-feature`, but for now only change the header and only
provide __undef macros for the 5 features that are always enabled in
`opencl-c-base.h`.

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

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/test/SemaOpenCL/features.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index c433b4f7eb1af..fad2f9c0272bf 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -74,6 +74,25 @@
 #define __opencl_c_atomic_scope_all_devices 1
 #define __opencl_c_read_write_images 1
 #endif // defined(__SPIR__)
+
+// Undefine any feature macros that have been explicitly disabled using
+// an __undef_ macro.
+#ifdef __undef___opencl_c_work_group_collective_functions
+#undef __opencl_c_work_group_collective_functions
+#endif
+#ifdef __undef___opencl_c_atomic_order_seq_cst
+#undef __opencl_c_atomic_order_seq_cst
+#endif
+#ifdef __undef___opencl_c_atomic_scope_device
+#undef __opencl_c_atomic_scope_device
+#endif
+#ifdef __undef___opencl_c_atomic_scope_all_devices
+#undef __opencl_c_atomic_scope_all_devices
+#endif
+#ifdef __undef___opencl_c_read_write_images
+#undef __opencl_c_read_write_images
+#endif
+
 #endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 #if !defined(__opencl_c_generic_address_space)

diff  --git a/clang/test/SemaOpenCL/features.cl 
b/clang/test/SemaOpenCL/features.cl
index af058b5e69828..3f59b4ea3b5ae 100644
--- a/clang/test/SemaOpenCL/features.cl
+++ b/clang/test/SemaOpenCL/features.cl
@@ -26,6 +26,15 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 
+// For OpenCL C 3.0, header-only features can be disabled using macros.
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header \
+// RUN:-D__undef___opencl_c_work_group_collective_functions=1 \
+// RUN:-D__undef___opencl_c_atomic_order_seq_cst=1 \
+// RUN:-D__undef___opencl_c_atomic_scope_device=1 \
+// RUN:-D__undef___opencl_c_atomic_scope_all_devices=1 \
+// RUN:-D__undef___opencl_c_read_write_images=1 \
+// RUN:   | FileCheck %s --check-prefix=NO-HEADERONLY-FEATURES
+
 // Note that __opencl_c_int64 is always defined assuming
 // always compiling for FULL OpenCL profile
 
@@ -43,14 +52,20 @@
 // FEATURES: #define __opencl_c_subgroups 1
 
 // NO-FEATURES: #define __opencl_c_int64 1
-// NO-FEATURES-NOT: __opencl_c_3d_image_writes
-// NO-FEATURES-NOT: __opencl_c_atomic_order_acq_rel
-// NO-FEATURES-NOT: __opencl_c_atomic_order_seq_cst
-// NO-FEATURES-NOT: __opencl_c_device_enqueue
-// NO-FEATURES-NOT: __opencl_c_fp64
-// NO-FEATURES-NOT: __opencl_c_generic_address_space
-// NO-FEATURES-NOT: __opencl_c_images
-// NO-FEATURES-NOT: __opencl_c_pipes
-// NO-FEATURES-NOT: __opencl_c_program_scope_global_variables
-// NO-FEATURES-NOT: __opencl_c_read_write_images
-// NO-FEATURES-NOT: __opencl_c_subgroups
+// NO-FEATURES-NOT: #define __opencl_c_3d_image_writes
+// NO-FEATURES-NOT: #define __opencl_c_atomic_order_acq_rel
+// NO-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst
+// NO-FEATURES-NOT: #define __opencl_c_device_enqueue
+// NO-FEATURES-NOT: #define __opencl_c_fp64
+// NO-FEATURES-NOT: #define __opencl_c_generic_address_space
+// NO-FEATURES-NOT: #define __opencl_c_images
+// NO-FEATURES-NOT: #define __opencl_c_pipes
+// NO-FEATURES-NOT: #define __opencl_c_program_scope_global_variables
+// NO-FEATURES-NOT: #define __opencl_c_read_write_images
+// NO-FEATURES-NOT: #define __opencl_c_subgroups
+
+// NO-HEADERONLY-FEATURES-NOT: #define 
__opencl_c_work_group_collective_functions
+// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst
+// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_device
+// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_all_devices
+// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_read_write_images



___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D138958: [clang] Better UX for Clang’s unwind-affecting attributes

2023-01-16 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added a comment.

The issue is the function call, not the stores.
Stores are valid as long as they are to local memory (stack or allocated by the 
function).

Because of the call, you can't tag it as `memory(none)`. But you may be able to 
tag it with inaccessiblemem if the call is also marked as such. Otherwise, no.

Performance wise it shouldn't matter much. How many functions are tagged with 
pure/const in source code? So here I would lean towards correctness.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138958

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


[PATCH] D138958: [clang] Better UX for Clang’s unwind-affecting attributes

2023-01-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

@jdoerfert can you please clarify, do you believe we are fine as-is, or need to 
change attributes we emit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138958

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


[PATCH] D140972: [flang] Add -fstack-arrays flag

2023-01-16 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.
Herald added a subscriber: sunshaoce.



Comment at: clang/include/clang/Driver/Options.td:5056-5060
+def fstack_arrays : Flag<["-"], "fstack-arrays">, Group,
+  HelpText<"Attempt to allocate array temporaries on the stack, no matter 
their size">;
+def fno_stack_arrays : Flag<["-"], "fno-stack-arrays">, Group,
+  HelpText<"Allocate array temporaries on the heap (default)">;
+

We should avoid duplicating options like this and use multiclasses instead. For 
example, see how [[ 
https://github.com/llvm/llvm-project/blob/b6ceadf3b663427f3cc233bbfdb5e35017cabd9e/clang/include/clang/Driver/Options.td#L6464-L6467
 | debug_pass_manager ]] is defined.



Comment at: flang/docs/FlangDriver.md:573
+`-O3 -ffast-math -fstack-arrays -fno-semantic-interposition`.
 `-fno-semantic-interposition` is not used because clang does not enable this as
 part of `-Ofast` as the default behaviour is similar.

[nit] "Clang" is a sub-project. It's not clear what "clang" would be - also a 
sub-project or the binary?



Comment at: flang/include/flang/Tools/CLOptions.inc:159
 inline void createDefaultFIROptimizerPassPipeline(
-mlir::PassManager , llvm::OptimizationLevel optLevel = defaultOptLevel) 
{
+mlir::PassManager , bool stackArrays = false, llvm::OptimizationLevel 
optLevel = defaultOptLevel) {
   // simplify the IR

CLANG-FORMAT-ME :) Same for other long lines here.



Comment at: flang/include/flang/Tools/CLOptions.inc:216
 inline void createMLIRToLLVMPassPipeline(
-mlir::PassManager , llvm::OptimizationLevel optLevel = defaultOptLevel) 
{
+mlir::PassManager , bool stackArrays = false, llvm::OptimizationLevel 
optLevel = defaultOptLevel) {
   // Add default optimizer pass pipeline.

[nit] To me, it would make more sense to put `stackArrays` at the end. 
`optLevel`is a more powerful flag. 



Comment at: flang/test/Transforms/stack-arrays.f90:3
 
+! We have to check llvm ir here to force flang to run the whole mlir pipeline
+! this is just to check that -fstack-arrays enables the stack-arrays pass so

Also, I don't quite follow this comment:

>  We have to check llvm ir here to force flang to run the whole mlir pipeline

Why is checking LLVM IR going to force Flang to run anything?



Comment at: flang/test/Transforms/stack-arrays.f90:6
+! only check the first example
+! RUN: %flang_fc1 -emit-llvm -o - -fstack-arrays %s | FileCheck 
--check-prefix=CHECK-LLVM %s
+





Comment at: flang/tools/bbc/bbc.cpp:276
 // Add O2 optimizer pass pipeline.
-fir::createDefaultFIROptimizerPassPipeline(pm, 
llvm::OptimizationLevel::O2);
+fir::createDefaultFIROptimizerPassPipeline(pm, false,
+   llvm::OptimizationLevel::O2);

Similar suggestion below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140972

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


[PATCH] D141827: [WIP][clang][TypePrinter] Test TemplateArgument::IsDefaulted when omitting default arguments

2023-01-16 Thread Michael Buch via Phabricator via cfe-commits
Michael137 created this revision.
Michael137 added reviewers: erichkeane, aaron.ballman, dblaikie.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

**Summary**

This patch allows clients who can't properly construct
a `ClassTemplateDecl` to still benefit from the `clang::TypePrinter`s
ability to skip printing defaulted template arguments. The
clients simply have to call `TemplateArgument::setIsDefaulted`
in advance.

See discussion in https://reviews.llvm.org/D140423

**Testing**

- TODO


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141827

Files:
  clang/lib/AST/TypePrinter.cpp


Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -2090,11 +2090,19 @@
 llvm::SmallVector OrigArgs;
 for (const TA  : Args)
   OrigArgs.push_back(getArgument(A));
-while (!Args.empty() &&
-   isSubstitutedDefaultArgument(Ctx, getArgument(Args.back()),
-TPL->getParam(Args.size() - 1),
-OrigArgs, TPL->getDepth()))
+while (!Args.empty()) {
+  const auto  = getArgument(Args.back());
+
+  const bool IsDefaulted = CurrArg.getIsDefaulted() ||
+   isSubstitutedDefaultArgument(
+   Ctx, CurrArg, TPL->getParam(Args.size() - 
1),
+   OrigArgs, TPL->getDepth());
+
+  if (!IsDefaulted)
+break;
+
   Args = Args.drop_back();
+}
   }
 
   const char *Comma = Policy.MSVCFormatting ? "," : ", ";


Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -2090,11 +2090,19 @@
 llvm::SmallVector OrigArgs;
 for (const TA  : Args)
   OrigArgs.push_back(getArgument(A));
-while (!Args.empty() &&
-   isSubstitutedDefaultArgument(Ctx, getArgument(Args.back()),
-TPL->getParam(Args.size() - 1),
-OrigArgs, TPL->getDepth()))
+while (!Args.empty()) {
+  const auto  = getArgument(Args.back());
+
+  const bool IsDefaulted = CurrArg.getIsDefaulted() ||
+   isSubstitutedDefaultArgument(
+   Ctx, CurrArg, TPL->getParam(Args.size() - 1),
+   OrigArgs, TPL->getDepth());
+
+  if (!IsDefaulted)
+break;
+
   Args = Args.drop_back();
+}
   }
 
   const char *Comma = Policy.MSVCFormatting ? "," : ", ";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a subscriber: mgorny.
fpetrogalli added a comment.

FWIW, the change in this patch solves the issue with standalone build of 
`clang` reported in 
https://reviews.llvm.org/rGac1ffd3caca12c254e0b8c847aa8ce8e51b6cfbf. (FYI, 
@mgorny )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[clang] 9a3f3a9 - [clang][Interp][NFC] Use range for loop

2023-01-16 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-16T10:39:13+01:00
New Revision: 9a3f3a9a08d8ee37e6bf7f6f418c4c64bccee3f3

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

LOG: [clang][Interp][NFC] Use range for loop

Added: 


Modified: 
clang/lib/AST/Interp/InterpFrame.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/InterpFrame.cpp 
b/clang/lib/AST/Interp/InterpFrame.cpp
index 9bdb71237b5d5..619c56fe4bf7a 100644
--- a/clang/lib/AST/Interp/InterpFrame.cpp
+++ b/clang/lib/AST/Interp/InterpFrame.cpp
@@ -130,17 +130,17 @@ void print(llvm::raw_ostream , const Pointer , 
ASTContext ,
   }
 
   printDesc(P.getDeclDesc());
-  for (auto It = Levels.rbegin(); It != Levels.rend(); ++It) {
-if (It->inArray()) {
-  OS << "[" << It->expand().getIndex() << "]";
+  for (const auto  : Levels) {
+if (It.inArray()) {
+  OS << "[" << It.expand().getIndex() << "]";
   continue;
 }
-if (auto Index = It->getIndex()) {
+if (auto Index = It.getIndex()) {
   OS << " + " << Index;
   continue;
 }
 OS << ".";
-printDesc(It->getFieldDesc());
+printDesc(It.getFieldDesc());
   }
 }
 



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


[PATCH] D141831: [clang][Interp] Fix double-printing InterpFrame::describe()

2023-01-16 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We add the pointer we want to print itself to the `Levels` array anyway, but 
then we print it once via `printDesc(P.getDeclDesc())` and in the loop again 
via `printDesc(It.getFieldDesc())`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141831

Files:
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/test/AST/Interp/constexpr-nqueens.cpp


Index: clang/test/AST/Interp/constexpr-nqueens.cpp
===
--- clang/test/AST/Interp/constexpr-nqueens.cpp
+++ clang/test/AST/Interp/constexpr-nqueens.cpp
@@ -6,9 +6,6 @@
 /// Board constructors.
 /// This tests that InterpFrame::describe().
 
-// FIXME: With the new interpreter, most of the described frames are
-//  currently broken in one way or another.
-
 typedef unsigned long uint64_t;
 
 struct Board {
@@ -52,17 +49,17 @@
   return Row == N ? Board(0, true) :
  B.ok(Row, Col) ?
  tryBoard(buildBoardRecurse(N, Col + 1, B.addQueen(Row, Col)), // 
ref-note {{in call to '()->addQueen(0, 0)}} \
-   // 
expected-note {{in call to '().Board()->addQueen(0, 0)}}
+   // 
expected-note {{in call to '()->addQueen(0, 0)}}
   N, Col, Row+1, B) :
  buildBoardScan(N, Col, Row + 1, B);
 }
 constexpr Board buildBoardRecurse(int N, int Col, const Board ) {
   return Col == N ? B : buildBoardScan(N, Col, 0, B); // ref-note {{in call to 
'buildBoardScan(8, 0, 0, Board())'}} \
-  // expected-note {{in 
call to 'buildBoardScan(8, 0, 0, Board().Board())}}
+  // expected-note {{in 
call to 'buildBoardScan(8, 0, 0, Board())}}
 }
 constexpr Board buildBoard(int N) {
   return buildBoardRecurse(N, 0, Board()); // ref-note {{in call to 
'buildBoardRecurse(8, 0, Board())'}} \
-   // expected-note {{in call to 
'buildBoardRecurse(8, 0, Board().Board())'}}
+   // expected-note {{in call to 
'buildBoardRecurse(8, 0, Board())'}}
 }
 
 constexpr Board q8 = buildBoard(8); // ref-error {{must be initialized by a 
constant expression}} \
Index: clang/lib/AST/Interp/InterpFrame.cpp
===
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -120,6 +120,9 @@
 F = F.isArrayElement() ? F.getArray().expand() : F.getBase();
   }
 
+  // Drop the first pointer since we print it unconditionally anyway.
+  Levels.erase(Levels.begin());
+
   printDesc(P.getDeclDesc());
   for (const auto  : Levels) {
 if (It.inArray()) {


Index: clang/test/AST/Interp/constexpr-nqueens.cpp
===
--- clang/test/AST/Interp/constexpr-nqueens.cpp
+++ clang/test/AST/Interp/constexpr-nqueens.cpp
@@ -6,9 +6,6 @@
 /// Board constructors.
 /// This tests that InterpFrame::describe().
 
-// FIXME: With the new interpreter, most of the described frames are
-//  currently broken in one way or another.
-
 typedef unsigned long uint64_t;
 
 struct Board {
@@ -52,17 +49,17 @@
   return Row == N ? Board(0, true) :
  B.ok(Row, Col) ?
  tryBoard(buildBoardRecurse(N, Col + 1, B.addQueen(Row, Col)), // ref-note {{in call to '()->addQueen(0, 0)}} \
-   // expected-note {{in call to '().Board()->addQueen(0, 0)}}
+   // expected-note {{in call to '()->addQueen(0, 0)}}
   N, Col, Row+1, B) :
  buildBoardScan(N, Col, Row + 1, B);
 }
 constexpr Board buildBoardRecurse(int N, int Col, const Board ) {
   return Col == N ? B : buildBoardScan(N, Col, 0, B); // ref-note {{in call to 'buildBoardScan(8, 0, 0, Board())'}} \
-  // expected-note {{in call to 'buildBoardScan(8, 0, 0, Board().Board())}}
+  // expected-note {{in call to 'buildBoardScan(8, 0, 0, Board())}}
 }
 constexpr Board buildBoard(int N) {
   return buildBoardRecurse(N, 0, Board()); // ref-note {{in call to 'buildBoardRecurse(8, 0, Board())'}} \
-   // expected-note {{in call to 'buildBoardRecurse(8, 0, Board().Board())'}}
+   // expected-note {{in call to 'buildBoardRecurse(8, 0, Board())'}}
 }
 
 constexpr Board q8 = buildBoard(8); // ref-error {{must be initialized by a constant expression}} \
Index: 

[PATCH] D141838: [clang-tidy] fix a false positive of `cppcoreguidelines-avoid-non-const-global-variables`

2023-01-16 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry created this revision.
v1nh1shungry added reviewers: carlosgalvezp, gribozavr2.
Herald added subscribers: shchenz, kbarton, xazax.hun, nemanjai.
Herald added a reviewer: njames93.
Herald added a project: All.
v1nh1shungry requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Currently this checker will report the non-const static
private/protected member of a class/struct.

Fixes https://github.com/llvm/llvm-project/issues/57919


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141838

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-non-const-global-variables.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-non-const-global-variables.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-non-const-global-variables.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-non-const-global-variables.cpp
@@ -228,6 +228,20 @@
 template 
 constexpr T templateVariable = T(0L);
 
+// CHECKING FOR NON-CONST STATIC PRIVATE/PROTECTED CLASS MEMBERS //
+class Foo {
+  static int nonConstStaticPrivateMember;
+protected:
+  static int nonConstStaticProtectedMember;
+};
+
+struct Bar {
+private:
+  static int nonConstStaticPrivateMember;
+protected:
+  static int nonConstStaticProtectedMember;
+};
+
 // CHECKING AGAINST FALSE POSITIVES INSIDE FUNCTION SCOPE /
 int main() {
   for (int i = 0; i < 3; ++i) {
Index: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
+++ 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
@@ -24,6 +24,7 @@
   hasGlobalStorage(),
   unless(anyOf(
   isLocalVarDecl(), isConstexpr(), hasType(isConstQualified()),
+  isPrivate(), isProtected(),
   hasType(referenceType(); // References can't be changed, only the
// data they reference can be changed.
 


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-non-const-global-variables.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-non-const-global-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-non-const-global-variables.cpp
@@ -228,6 +228,20 @@
 template 
 constexpr T templateVariable = T(0L);
 
+// CHECKING FOR NON-CONST STATIC PRIVATE/PROTECTED CLASS MEMBERS //
+class Foo {
+  static int nonConstStaticPrivateMember;
+protected:
+  static int nonConstStaticProtectedMember;
+};
+
+struct Bar {
+private:
+  static int nonConstStaticPrivateMember;
+protected:
+  static int nonConstStaticProtectedMember;
+};
+
 // CHECKING AGAINST FALSE POSITIVES INSIDE FUNCTION SCOPE /
 int main() {
   for (int i = 0; i < 3; ++i) {
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
@@ -24,6 +24,7 @@
   hasGlobalStorage(),
   unless(anyOf(
   isLocalVarDecl(), isConstexpr(), hasType(isConstQualified()),
+  isPrivate(), isProtected(),
   hasType(referenceType(); // References can't be changed, only the
// data they reference can be changed.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

2023-01-16 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

In D24888#4025382 , @bam wrote:

> I'm sorry, could we bring it to the finish line?
> It's a pity the standard C++ Core Guidelines rule suppression syntax is still 
> not supported, as Clang-tidy is one of the main tools supporting the 
> Guidelines..
>
> Happy new year to all!

Hi @bam, this is currently not on my priority list. Feel free to take over the 
PR!


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

https://reviews.llvm.org/D24888

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-16 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 489520.
pmatos marked 7 inline comments as done.
pmatos added a comment.

Rebase on main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Transforms/Utils/Mem2Reg.cpp

Index: llvm/lib/Transforms/Utils/Mem2Reg.cpp
===
--- llvm/lib/Transforms/Utils/Mem2Reg.cpp
+++ llvm/lib/Transforms/Utils/Mem2Reg.cpp
@@ -74,15 +74,19 @@
 struct PromoteLegacyPass : public FunctionPass {
   // Pass identification, replacement for typeid
   static char ID;
+  bool ForcePass; /// If true, forces pass to execute, instead of skipping.
 
-  PromoteLegacyPass() : FunctionPass(ID) {
+  PromoteLegacyPass() : FunctionPass(ID), ForcePass(false) {
+initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
+  }
+  PromoteLegacyPass(bool IsForced) : FunctionPass(ID), ForcePass(IsForced) {
 initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
   // runOnFunction - To run this pass, first we calculate the alloca
   // instructions that are safe for promotion, then we promote each one.
   bool runOnFunction(Function ) override {
-if (skipFunction(F))
+if (!ForcePass && skipFunction(F))
   return false;
 
 DominatorTree  = getAnalysis().getDomTree();
@@ -96,6 +100,7 @@
 AU.addRequired();
 AU.setPreservesCFG();
   }
+
 };
 
 } // end anonymous namespace
@@ -111,6 +116,6 @@
 false, false)
 
 // createPromoteMemoryToRegister - Provide an entry point to create this pass.
-FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
-  return new PromoteLegacyPass();
+FunctionPass *llvm::createPromoteMemoryToRegisterPass(bool IsForced) {
+  return new PromoteLegacyPass(IsForced);
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -16,6 +16,7 @@
 #include "TargetInfo/WebAssemblyTargetInfo.h"
 #include "Utils/WebAssemblyUtilities.h"
 #include "WebAssembly.h"
+#include "WebAssemblyISelLowering.h"
 #include "WebAssemblyMachineFunctionInfo.h"
 #include "WebAssemblyTargetObjectFile.h"
 #include "WebAssemblyTargetTransformInfo.h"
@@ -464,6 +465,14 @@
 }
 
 void WebAssemblyPassConfig::addISelPrepare() {
+  WebAssemblyTargetMachine *WasmTM = static_cast(TM);
+  const WebAssemblySubtarget *Subtarget = WasmTM
+->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+   std::string(WasmTM->getTargetFeatureString()));
+  if(Subtarget->hasReferenceTypes()) {
+// We need to remove allocas for reference types
+addPass(createPromoteMemoryToRegisterPass(true));
+  }
   // Lower atomics and TLS if necessary
   addPass(new CoalesceFeaturesAndStripAtomics(()));
 
Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -306,6 +306,18 @@
   return getInt64Ty(C)->getPointerTo(AS);
 }
 
+Type *Type::getWasm_ExternrefTy(LLVMContext ) {
+  // opaque 

[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-16 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

I feel like the latest patch addresses all concerns until now. What do you 
think?




Comment at: clang/include/clang/Basic/WebAssemblyReferenceTypes.def:16
+//
+//  - Name is the name of the builtin type.  MangledName is the mangled name.
+//

aaron.ballman wrote:
> aaron.ballman wrote:
> > What kind of mangling is this name? Itanium? Microsoft? Something else?
> Still wondering about this.
This is just a generic name to base the actual mangling on tbh.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

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


[PATCH] D141056: [SVE][CGBuiltins] Remove need for instcombine from ACLE tests.

2023-01-16 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

I removed -O1 from clang sve tests a while ago. The intent was always to remove 
instcombine and tailcallelim too, but I never got around to it. Feel free to 
remove -O1 from the other sve2 tests too, they ideally shouldn't test the 
entire pipeline from clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141056

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


[PATCH] D141670: [include-cleaner] FindHeaders respects IWYU export pragma for standard headers.

2023-01-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 489448.
hokein marked 2 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141670

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/lib/Record.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
  clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
@@ -11,6 +11,7 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Testing/TestAST.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -432,6 +433,21 @@
   PI.getExporters(SM.getFileEntryForID(SM.getMainFileID()), FM).empty());
 }
 
+TEST_F(PragmaIncludeTest, IWYUExportForStandardHeaders) {
+  Inputs.Code = R"cpp(
+#include "export.h"
+  )cpp";
+  Inputs.ExtraFiles["export.h"] = R"cpp(
+#include  // IWYU pragma: export
+  )cpp";
+  Inputs.ExtraFiles["string"] = "";
+  Inputs.ExtraArgs = {"-isystem."};
+  TestAST Processed = build();
+  auto  = Processed.fileManager();
+  EXPECT_THAT(PI.getExporters(*tooling::stdlib::Header::named(""), FM),
+  testing::UnorderedElementsAre(FileNamed("export.h")));
+}
+
 TEST_F(PragmaIncludeTest, IWYUExportBlock) {
   Inputs.Code = R"cpp(// Line 1
#include "normal.h"
Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Testing/TestAST.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -107,6 +108,23 @@
   UnorderedElementsAre(physicalHeader("exporter.h")));
 }
 
+TEST_F(FindHeadersTest, IWYUExportForStandardHeaders) {
+  Inputs.Code = R"cpp(
+#include "exporter.h"
+  )cpp";
+  Inputs.ExtraFiles["exporter.h"] = guard(R"cpp(
+#include  // IWYU pragma: export
+  )cpp");
+  Inputs.ExtraFiles["string"] = guard("");
+  Inputs.ExtraArgs.push_back("-isystem.");
+  buildAST();
+  tooling::stdlib::Symbol StdString =
+  *tooling::stdlib::Symbol::named("std::", "string");
+  EXPECT_THAT(
+  include_cleaner::findHeaders(StdString, AST->sourceManager(), ),
+  UnorderedElementsAre(physicalHeader("exporter.h"), StdString.header()));
+}
+
 TEST_F(FindHeadersTest, SelfContained) {
   Inputs.Code = R"cpp(
 #include "header.h"
Index: clang-tools-extra/include-cleaner/lib/Record.cpp
===
--- clang-tools-extra/include-cleaner/lib/Record.cpp
+++ clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -18,6 +18,7 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 
 namespace clang::include_cleaner {
 namespace {
@@ -188,12 +189,20 @@
   SrcMgr::CharacteristicKind FileKind) override {
 FileID HashFID = SM.getFileID(HashLoc);
 int HashLine = SM.getLineNumber(HashFID, SM.getFileOffset(HashLoc));
-checkForExport(HashFID, HashLine, File ? >getFileEntry() : nullptr);
+std::optional IncludedHeader;
+if (IsAngled)
+  if (auto StandardHeader =
+  tooling::stdlib::Header::named("<" + FileName.str() + ">")) {
+IncludedHeader = *StandardHeader;
+  }
+if (!IncludedHeader && File)
+  IncludedHeader = >getFileEntry();
+checkForExport(HashFID, HashLine, std::move(IncludedHeader));
 checkForKeep(HashLine);
   }
 
   void checkForExport(FileID IncludingFile, int HashLine,
-  const FileEntry *IncludedHeader) {
+  std::optional IncludedHeader) {
 if (ExportStack.empty())
   return;
 auto  = ExportStack.back();
@@ -202,9 +211,20 @@
 // Make sure current include is covered by the export pragma.
 if ((Top.Block && HashLine > Top.SeenAtLine) ||
 Top.SeenAtLine == HashLine) {
-  if (IncludedHeader)
-Out->IWYUExportBy[IncludedHeader->getUniqueID()].push_back(
-Top.Path);
+  if (IncludedHeader) {
+switch 

[PATCH] D140377: [clang][Interp] Compound assign operators for FP values

2023-01-16 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140377

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


[PATCH] D137944: [ObjC][ARC] Teach the OptimizeSequences step of ObjCARCOpts about WinEH funclet tokens

2023-01-16 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz added a comment.

This review belongs to a series of patches. I am planning to land  it towards 
the end of next week, so that it's ready for the next release branching in 
February. If you have any more remarks, please let me know soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137944

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


[PATCH] D131915: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2023-01-16 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 489515.
TIFitis added a comment.

Minor indentation changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131915

Files:
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
  mlir/test/Dialect/OpenMP/ops.mlir

Index: mlir/test/Dialect/OpenMP/ops.mlir
===
--- mlir/test/Dialect/OpenMP/ops.mlir
+++ mlir/test/Dialect/OpenMP/ops.mlir
@@ -451,6 +451,26 @@
 return
 }
 
+// CHECK-LABEL: omp_target_data
+func.func @omp_target_data (%if_cond : i1, %device : si32, %device_ptr: memref, %device_addr: memref, %map1: memref, %map2: memref) -> () {
+// CHECK: omp.target_data if(%[[VAL_0:.*]] : i1) device(%[[VAL_1:.*]] : si32) map((6 : i64 -> always , from : %[[VAL_2:.*]] : memref))
+omp.target_data if(%if_cond : i1) device(%device : si32) map((6 -> always , from : %map1 : memref)){}
+
+// CHECK: omp.target_data use_device_ptr(%[[VAL_3:.*]] : memref) use_device_addr(%[[VAL_4:.*]] : memref) map((6 : i64 -> always , from : %[[VAL_2:.*]] : memref))
+omp.target_data use_device_ptr(%device_ptr : memref) use_device_addr(%device_addr : memref) map((6 -> always , from : %map1 : memref)){}
+
+// CHECK: omp.target_data map((6 : i64 -> always , from : %[[VAL_2]] : memref), (0 : i64 -> none , alloc : %[[VAL_5:.*]] : memref))
+omp.target_data map((6 -> always , from : %map1 : memref), (0 -> none , alloc : %map2 : memref)){}
+
+// CHECK: omp.target_enter_data if(%[[VAL_0]] : i1) device(%[[VAL_1]] : si32) nowait map((0 : i64 -> none , alloc : %[[VAL_2]] : memref))
+omp.target_enter_data if(%if_cond : i1) device(%device : si32) nowait map((0 -> none , alloc : %map1 : memref))
+
+// CHECK: omp.target_exit_data if(%[[VAL_0]] : i1) device(%[[VAL_1]] : si32) nowait map((0 : i64 -> none , release : %[[VAL_5]] : memref))
+omp.target_exit_data if(%if_cond : i1) device(%device : si32) nowait map((0 -> none , release : %map2 : memref))
+
+return
+}
+
 // CHECK-LABEL: omp_target_pretty
 func.func @omp_target_pretty(%if_cond : i1, %device : si32,  %num_threads : i32) -> () {
 // CHECK: omp.target if({{.*}}) device({{.*}})
Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -22,6 +22,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/TypeSwitch.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include 
 
 #include "mlir/Dialect/OpenMP/OpenMPOpsDialect.cpp.inc"
@@ -536,6 +537,157 @@
   return success();
 }
 
+//===--===//
+// Parser, printer and verifier for Target Data
+//===--===//
+static ParseResult
+parseMapClause(OpAsmParser ,
+   SmallVectorImpl _operands,
+   SmallVectorImpl _operand_types, ArrayAttr _types) {
+  StringRef mapTypeMod, mapType;
+  OpAsmParser::UnresolvedOperand arg1;
+  IntegerAttr arg2;
+  Type arg2Type;
+  SmallVector mapTypesVec;
+
+  auto parseKeyword = [&]() -> ParseResult {
+if (parser.parseLParen() || parser.parseAttribute(arg2) ||
+parser.parseArrow() || parser.parseKeyword() ||
+parser.parseComma() || parser.parseKeyword() ||
+parser.parseColon() || parser.parseOperand(arg1) ||
+parser.parseColon() || parser.parseType(arg2Type) ||
+parser.parseRParen())
+  return failure();
+map_operands.push_back(arg1);
+map_operand_types.push_back(arg2Type);
+mapTypesVec.push_back(arg2);
+return success();
+  };
+
+  if (parser.parseCommaSeparatedList(parseKeyword))
+return failure();
+
+  SmallVector mapTypesAttr(mapTypesVec.begin(), mapTypesVec.end());
+  map_types = ArrayAttr::get(parser.getContext(), mapTypesAttr);
+  return success();
+}
+
+static void printMapClause(OpAsmPrinter , Operation *op,
+   OperandRange map_operands,
+   TypeRange map_operand_types, ArrayAttr map_types) {
+
+  // Helper function to get bitwise AND of `value` and 'flag'
+  auto bitAnd = [](int64_t value,
+   llvm::omp::OpenMPOffloadMappingFlags flag) -> bool {
+return value &
+   static_cast<
+   std::underlying_type_t>(
+   flag);
+  };
+
+  assert(map_operands.size() == map_types.size());
+
+  for (unsigned i = 0, e = map_operands.size(); i < e; i++) {
+int64_t mapTypeBits = 0x00;
+auto mapOp = map_operands[i];
+auto mapTypeOp = map_types[i];
+
+if (mapTypeOp.isa())
+  mapTypeBits = mapTypeOp.cast().getInt();
+
+bool always = bitAnd(mapTypeBits,
+ 

[PATCH] D141716: [clang][dataflow] Add (initial) debug printing for `Value` and `Environment`.

2023-01-16 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev accepted this revision.
sgatev added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:792
+  // fields are printed.
+  llvm::dbgs() << "DeclToLoc:\n";
+  for (auto [D, L] : DeclToLoc)

Shouldn't this be `OS`? Same for those below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141716

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


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141654

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


[PATCH] D141698: doc: Rewrite opening paragraph of CFI Design Doc

2023-01-16 Thread Bastian Kersting via Phabricator via cfe-commits
1c3t3a added a comment.

Hi @pcc and @sunshaoce, I picked you as reviewers since you recently committed 
to the file. Please feel free to re-route this patch to the correct reviewer :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141698

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


[clang] 046a991 - Add Release Notes and Doc for -fmodule-output

2023-01-16 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-01-16T17:01:41+08:00
New Revision: 046a9910c31e6eeb04f54f59574c74773292d3f0

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

LOG: Add Release Notes and Doc for -fmodule-output

As the summary explained in https://reviews.llvm.org/D137058,
the design of `-fmodule-output` changes relatively frequently
so I skipped the release notes and docs for -fmodule-output in the
the patches. And the patches get accepted and landed. The patch adds
the related release notes and docs.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/StandardCPlusPlusModules.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 09133f967f01..3bbab951e8a8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -537,6 +537,11 @@ New Compiler Flags
   int b[0]; // NOT a flexible array member.
 };
 
+- Added ``-fmodule-output`` to enable the one-phase compilation model for
+  standard C++ modules. See
+  `Standard C++ Modules 
`_
+  for more information.
+
 Deprecated Compiler Flags
 -
 - ``-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang``

diff  --git a/clang/docs/StandardCPlusPlusModules.rst 
b/clang/docs/StandardCPlusPlusModules.rst
index c7c04767c7b8..1010948ae91b 100644
--- a/clang/docs/StandardCPlusPlusModules.rst
+++ b/clang/docs/StandardCPlusPlusModules.rst
@@ -223,7 +223,27 @@ The ``-fmodules-ts`` option is deprecated and is planned 
to be removed.
 How to produce a BMI
 
 
-It is possible to generate a BMI for an importable module unit by specifying 
the ``--precompile`` option.
+We can generate a BMI for an importable module unit by either ``--precompile``
+or ``-fmodule-output`` flags.
+
+The ``--precompile`` option generates the BMI as the output of the compilation 
and the output path
+can be specified using the ``-o`` option. 
+
+The ``-fmodule-output`` option generates the BMI as a by-product of the 
compilation.
+If ``-fmodule-output=`` is specified, the BMI will be emitted the specified 
location. Then if
+``-fmodule-output`` and ``-c`` are specified, the BMI will be emitted in the 
directory of the
+output file with the name of the input file with the new extension ``.pcm``. 
Otherwise, the BMI
+will be emitted in the working directory with the name of the input file with 
the new extension
+``.pcm``.
+
+The style to generate BMIs by ``--precompile`` is called two-phase compilation 
since it takes
+2 steps to compile a source file to an object file. The style to generate BMIs 
by ``-fmodule-output``
+is called one-phase compilation respectively. The one-phase compilation model 
is simpler
+for build systems to implement and the two-phase compilation has the potential 
to compile faster due
+to higher parallelism. As an example, if there are two module units A and B, 
and B depends on A, the
+one-phase compilation model would need to compile them serially, whereas the 
two-phase compilation
+model may be able to compile them simultaneously if the compilation from A.pcm 
to A.o takes a long
+time.
 
 File name requirement
 ~



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


[clang-tools-extra] f4a7448 - [include-cleaner] FindHeaders respects IWYU export pragma for standard headers.

2023-01-16 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-01-16T10:09:18+01:00
New Revision: f4a744865349ed3c5b069ce39b0abcb5f0130fd3

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

LOG: [include-cleaner] FindHeaders respects IWYU export pragma for standard 
headers.

Fixes https://github.com/llvm/llvm-project/issues/59927

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

Added: 


Modified: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
clang-tools-extra/include-cleaner/lib/Record.cpp
clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h 
b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
index cf01e3416dec2..140713bf12807 100644
--- a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
+++ b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
@@ -66,6 +66,8 @@ class PragmaIncludes {
   /// Returns empty if there is none.
   llvm::SmallVector getExporters(const FileEntry *File,
 FileManager ) const;
+  llvm::SmallVector getExporters(tooling::stdlib::Header,
+FileManager ) const;
 
   /// Returns true if the given file is a self-contained file.
   bool isSelfContained(const FileEntry *File) const;
@@ -100,6 +102,9 @@ class PragmaIncludes {
   llvm::DenseMap>
   IWYUExportBy;
+  llvm::DenseMap>
+  StdIWYUExportBy;
 
   /// Contains all non self-contained files detected during the parsing.
   llvm::DenseSet NonSelfContainedFiles;

diff  --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp 
b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
index 8f38c95375fc3..fccba48056eed 100644
--- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -45,8 +45,11 @@ llvm::SmallVector findHeaders(const SymbolLocation 
,
 return Results;
   }
   case SymbolLocation::Standard: {
-for (const auto  : Loc.standard().headers())
+for (const auto  : Loc.standard().headers()) {
   Results.push_back(H);
+  for (const auto *Export : PI->getExporters(H, SM.getFileManager()))
+Results.push_back(Header(Export));
+}
 return Results;
   }
   }

diff  --git a/clang-tools-extra/include-cleaner/lib/Record.cpp 
b/clang-tools-extra/include-cleaner/lib/Record.cpp
index 54350df0b00f9..51fd39300d7c7 100644
--- a/clang-tools-extra/include-cleaner/lib/Record.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -18,6 +18,7 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 
 namespace clang::include_cleaner {
 namespace {
@@ -188,12 +189,20 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, 
public CommentHandler {
   SrcMgr::CharacteristicKind FileKind) override {
 FileID HashFID = SM.getFileID(HashLoc);
 int HashLine = SM.getLineNumber(HashFID, SM.getFileOffset(HashLoc));
-checkForExport(HashFID, HashLine, File ? >getFileEntry() : nullptr);
+std::optional IncludedHeader;
+if (IsAngled)
+  if (auto StandardHeader =
+  tooling::stdlib::Header::named("<" + FileName.str() + ">")) {
+IncludedHeader = *StandardHeader;
+  }
+if (!IncludedHeader && File)
+  IncludedHeader = >getFileEntry();
+checkForExport(HashFID, HashLine, std::move(IncludedHeader));
 checkForKeep(HashLine);
   }
 
   void checkForExport(FileID IncludingFile, int HashLine,
-  const FileEntry *IncludedHeader) {
+  std::optional IncludedHeader) {
 if (ExportStack.empty())
   return;
 auto  = ExportStack.back();
@@ -202,9 +211,20 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, 
public CommentHandler {
 // Make sure current include is covered by the export pragma.
 if ((Top.Block && HashLine > Top.SeenAtLine) ||
 Top.SeenAtLine == HashLine) {
-  if (IncludedHeader)
-Out->IWYUExportBy[IncludedHeader->getUniqueID()].push_back(
-Top.Path);
+  if (IncludedHeader) {
+switch (IncludedHeader->kind()) {
+case Header::Physical:
+  Out->IWYUExportBy[IncludedHeader->physical()->getUniqueID()]
+  .push_back(Top.Path);
+  break;
+case Header::Standard:
+  Out->StdIWYUExportBy[IncludedHeader->standard()].push_back(Top.Path);
+  

[PATCH] D141670: [include-cleaner] FindHeaders respects IWYU export pragma for standard headers.

2023-01-16 Thread Haojian Wu 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 rGf4a744865349: [include-cleaner] FindHeaders respects IWYU 
export pragma for standard headers. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D141670?vs=489448=489449#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141670

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/lib/Record.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
  clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
@@ -11,6 +11,7 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Testing/TestAST.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -432,6 +433,21 @@
   PI.getExporters(SM.getFileEntryForID(SM.getMainFileID()), FM).empty());
 }
 
+TEST_F(PragmaIncludeTest, IWYUExportForStandardHeaders) {
+  Inputs.Code = R"cpp(
+#include "export.h"
+  )cpp";
+  Inputs.ExtraFiles["export.h"] = R"cpp(
+#include  // IWYU pragma: export
+  )cpp";
+  Inputs.ExtraFiles["string"] = "";
+  Inputs.ExtraArgs = {"-isystem."};
+  TestAST Processed = build();
+  auto  = Processed.fileManager();
+  EXPECT_THAT(PI.getExporters(*tooling::stdlib::Header::named(""), FM),
+  testing::UnorderedElementsAre(FileNamed("export.h")));
+}
+
 TEST_F(PragmaIncludeTest, IWYUExportBlock) {
   Inputs.Code = R"cpp(// Line 1
#include "normal.h"
Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Testing/TestAST.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -107,6 +108,23 @@
   UnorderedElementsAre(physicalHeader("exporter.h")));
 }
 
+TEST_F(FindHeadersTest, IWYUExportForStandardHeaders) {
+  Inputs.Code = R"cpp(
+#include "exporter.h"
+  )cpp";
+  Inputs.ExtraFiles["exporter.h"] = guard(R"cpp(
+#include  // IWYU pragma: export
+  )cpp");
+  Inputs.ExtraFiles["string"] = guard("");
+  Inputs.ExtraArgs.push_back("-isystem.");
+  buildAST();
+  tooling::stdlib::Symbol StdString =
+  *tooling::stdlib::Symbol::named("std::", "string");
+  EXPECT_THAT(
+  include_cleaner::findHeaders(StdString, AST->sourceManager(), ),
+  UnorderedElementsAre(physicalHeader("exporter.h"), StdString.header()));
+}
+
 TEST_F(FindHeadersTest, SelfContained) {
   Inputs.Code = R"cpp(
 #include "header.h"
Index: clang-tools-extra/include-cleaner/lib/Record.cpp
===
--- clang-tools-extra/include-cleaner/lib/Record.cpp
+++ clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -18,6 +18,7 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 
 namespace clang::include_cleaner {
 namespace {
@@ -188,12 +189,20 @@
   SrcMgr::CharacteristicKind FileKind) override {
 FileID HashFID = SM.getFileID(HashLoc);
 int HashLine = SM.getLineNumber(HashFID, SM.getFileOffset(HashLoc));
-checkForExport(HashFID, HashLine, File ? >getFileEntry() : nullptr);
+std::optional IncludedHeader;
+if (IsAngled)
+  if (auto StandardHeader =
+  tooling::stdlib::Header::named("<" + FileName.str() + ">")) {
+IncludedHeader = *StandardHeader;
+  }
+if (!IncludedHeader && File)
+  IncludedHeader = >getFileEntry();
+checkForExport(HashFID, HashLine, std::move(IncludedHeader));
 checkForKeep(HashLine);
   }
 
   void checkForExport(FileID IncludingFile, int HashLine,
-  const FileEntry *IncludedHeader) {
+  std::optional IncludedHeader) {
 if (ExportStack.empty())
   return;
 auto  = ExportStack.back();
@@ -202,9 +211,20 @@
 // Make sure current include is covered by the export pragma.
 if ((Top.Block && HashLine > 

[PATCH] D140972: [flang] Add -fstack-arrays flag

2023-01-16 Thread Tom Eccles via Phabricator via cfe-commits
tblah updated this revision to Diff 489484.
tblah marked 6 inline comments as done.
tblah added a comment.

Update to address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140972

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/docs/FlangDriver.md
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/fast_math.f90
  flang/test/Transforms/stack-arrays.f90

Index: flang/test/Transforms/stack-arrays.f90
===
--- flang/test/Transforms/stack-arrays.f90
+++ flang/test/Transforms/stack-arrays.f90
@@ -1,5 +1,10 @@
 ! RUN: %flang_fc1 -emit-fir %s -o - | fir-opt --array-value-copy | fir-opt --stack-arrays | FileCheck %s
 
+! We have to check llvm ir here to force flang to run the whole mlir pipeline
+! this is just to check that -fstack-arrays enables the stack-arrays pass so
+! only check the first example
+! RUN: %flang_fc1 -emit-llvm -o - -fstack-arrays %s | FileCheck --check-prefix=CHECK-LLVM %s
+
 ! check simple array value copy case
 subroutine array_value_copy_simple(arr)
   integer, intent(inout) :: arr(4)
@@ -14,6 +19,15 @@
 ! CHECK: return
 ! CHECK-NEXT: }
 
+! CHECK-LLVM: array_value_copy_simple
+! CHECK-LLVM-NOT: malloc
+! CHECK-LLVM-NOT: free
+! CHECK-LLVM: alloca [4 x i32]
+! CHECK-LLVM-NOT: malloc
+! CHECK-LLVM-NOT: free
+! CHECK-LLVM: ret void
+! CHECK-LLVM-NEXT: }
+
 ! check complex array value copy case
 module stuff
   type DerivedWithAllocatable
Index: flang/test/Driver/fast_math.f90
===
--- flang/test/Driver/fast_math.f90
+++ flang/test/Driver/fast_math.f90
@@ -1,25 +1,35 @@
 ! Test for correct forwarding of fast-math flags from the compiler driver to the
 ! frontend driver
 
-! -Ofast => -ffast-math -O3
+! -Ofast => -ffast-math -O3 -fstack-arrays
 ! RUN: %flang -Ofast -fsyntax-only -### %s -o %t 2>&1 \
 ! RUN: | FileCheck --check-prefix=CHECK-OFAST %s
 ! CHECK-OFAST: -fc1
 ! CHECK-OFAST-SAME: -ffast-math
+! CHECK-OFAST-SAME: -fstack-arrays
 ! CHECK-OFAST-SAME: -O3
 
-! TODO: update once -fstack-arays is added
-! RUN: %flang -fstack-arrays -fsyntax-only %s -o %t 2>&1 \
+! RUN: %flang -fstack-arrays -fsyntax-only -### %s -o %t 2>&1 \
 ! RUN: | FileCheck --check-prefix=CHECK-STACK-ARRAYS %s
-! CHECK-STACK-ARRAYS: warning: argument unused during compilation: '-fstack-arrays'
+! CHECK-STACK-ARRAYS: -fc1
+! CHECK-STACK-ARRAYS-SAME: -fstack-arrays
 
-! -Ofast -fno-fast-math => -O3
+! -Ofast -fno-fast-math => -O3 -fstack-arrays
 ! RUN: %flang -Ofast -fno-fast-math -fsyntax-only -### %s -o %t 2>&1 \
 ! RUN: | FileCheck --check-prefix=CHECK-OFAST-NO-FAST %s
 ! CHECK-OFAST-NO-FAST: -fc1
 ! CHECK-OFAST-NO-FAST-NOT: -ffast-math
+! CHECK-OFAST-NO-FAST-SAME: -fstack-arrays
 ! CHECK-OFAST-NO-FAST-SAME: -O3
 
+! -Ofast -fno-stack-arrays -> -O3 -ffast-math
+! RUN: %flang -Ofast -fno-stack-arrays -fsyntax-only -### %s -o %t 2>&1 \
+! RUN: | FileCheck --check-prefix=CHECK-OFAST-NO-SA %s
+! CHECK-OFAST-NO-SA: -fc1
+! CHECK-OFAST-NO-SA-SAME: -ffast-math
+! CHECK-OFAST-NO-SA-NOT: -fstack-arrays
+! CHECK-OFAST-NO-SA-SAME: -O3
+
 ! -ffast-math => -ffast-math
 ! RUN: %flang -ffast-math -fsyntax-only -### %s -o %t 2>&1 \
 ! RUN: | FileCheck --check-prefix=CHECK-FFAST %s
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -45,10 +45,12 @@
 ! HELP-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
+! HELP-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-NEXT: -freciprocal-math  Allow division operations to be reassociated
+! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
@@ -130,10 +132,12 @@
 ! HELP-FC1-NEXT: -fno-debug-pass-manager Disables debug printing for the new pass manager
 ! HELP-FC1-NEXT: -fno-reformat  Dump the 

[PATCH] D140972: [flang] Add -fstack-arrays flag

2023-01-16 Thread Tom Eccles via Phabricator via cfe-commits
tblah added inline comments.



Comment at: flang/include/flang/Tools/CLOptions.inc:159
 inline void createDefaultFIROptimizerPassPipeline(
-mlir::PassManager , llvm::OptimizationLevel optLevel = defaultOptLevel) 
{
+mlir::PassManager , bool stackArrays = false, llvm::OptimizationLevel 
optLevel = defaultOptLevel) {
   // simplify the IR

awarzynski wrote:
> CLANG-FORMAT-ME :) Same for other long lines here.
It seems clang-format is not run on this file. I have fixed the lines changed 
in my patch. Should I clang-format the whole file in a separate patch?



Comment at: flang/test/Transforms/stack-arrays.f90:3
 
+! We have to check llvm ir here to force flang to run the whole mlir pipeline
+! this is just to check that -fstack-arrays enables the stack-arrays pass so

awarzynski wrote:
> Also, I don't quite follow this comment:
> 
> >  We have to check llvm ir here to force flang to run the whole mlir pipeline
> 
> Why is checking LLVM IR going to force Flang to run anything?
Just running `flang-new -fc1 -emit-fir` outputs the FIR before all of the 
transformation passes run (which is why I have to pipe the result through 
`fir-opt` to run the array value copy and stack arrays passes on the first 
line).

Outputting LLVM IR requires all of the MLIR transformation passes to be run to 
transform all of the higher level dialects into the LLVM dialect. Stack arrays 
is run as part of that same pipeline (`fir::createMLIRToLLVMPassPipeline`). I 
want to test that `-fstack-arrays` does cause the stack arrays pass to run as 
part of that pipeline, which is why I am checking the LLVM-IR.

One alternative would be to print out which passes have run and check that, but 
I felt this way fits more with the spirit of the other tests.



Comment at: flang/test/Transforms/stack-arrays.f90:6
+! only check the first example
+! RUN: %flang_fc1 -emit-llvm -o - -fstack-arrays %s | FileCheck 
--check-prefix=CHECK-LLVM %s
+

awarzynski wrote:
> 
Lots of other tests do not follow this convention. It would change the 
FileCheck comments to look like `! LLVM: array_value_copy_simple`. 

I think it is good to require `CHECK-FEATURE:` so that any mention of `FEATURE` 
in comments does not confuse FileCheck. Especially for a name like LLVM which 
is likely to be written in capitals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140972

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


[PATCH] D141788: [NFC] Use `llvm::enumerate` in llvm/unittests/Object

2023-01-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D141788#4055263 , @MaskRay wrote:

> non-reference `auto` shall work better in these cases.

Not sure why? Won't Data be copied every iteration?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141788

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


[PATCH] D141824: [clang-repl] Add a command to load dynamic libraries

2023-01-16 Thread Anubhab Ghosh via Phabricator via cfe-commits
argentite created this revision.
Herald added a project: All.
argentite added reviewers: v.g.vassilev, lhames, sgraenitz.
argentite published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This commit adds the %lib  command to load a dynamic library to be
used by the currently running interpreted code. For example `%lib SDL2`
loads libSDL2.so on Linux and SDL2.dll on Windows automatically.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141824

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/Interpreter.cpp
  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
@@ -123,6 +123,13 @@
 }
 continue;
   }
+  if (Line->rfind(R"(%lib )", 0) == 0) {
+if (auto Err = Interp->LoadDynamicLibrary(Line->data() + 5)) {
+  llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+  HasError = true;
+}
+continue;
+  }
 
   if (auto Err = Interp->ParseAndExecute(*Line)) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -29,10 +29,13 @@
 #include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "clang/Lex/PreprocessorOptions.h"
 
+#include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Host.h"
 
+#include 
+
 using namespace clang;
 
 // FIXME: Figure out how to unify with namespace init_convenience from
@@ -203,10 +206,13 @@
   return IncrParser->getCI();
 }
 
-const llvm::orc::LLJIT *Interpreter::getExecutionEngine() const {
-  if (IncrExecutor)
-return IncrExecutor->getExecutionEngine();
-  return nullptr;
+llvm::Expected Interpreter::GetExecutionEngine() {
+  if (!IncrExecutor) {
+if (auto Err = CreateExecutor())
+  return Err;
+  }
+
+  return IncrExecutor->GetExecutionEngine();
 }
 
 llvm::Expected
@@ -214,14 +220,21 @@
   return IncrParser->Parse(Code);
 }
 
+llvm::Error Interpreter::CreateExecutor() {
+  const clang::TargetInfo  =
+  getCompilerInstance()->getASTContext().getTargetInfo();
+  llvm::Error Err = llvm::Error::success();
+  auto Executor = std::make_unique(*TSCtx, Err, TI);
+  if (!Err)
+IncrExecutor = std::move(Executor);
+
+  return Err;
+}
+
 llvm::Error Interpreter::Execute(PartialTranslationUnit ) {
   assert(T.TheModule);
   if (!IncrExecutor) {
-const clang::TargetInfo  =
-getCompilerInstance()->getASTContext().getTargetInfo();
-llvm::Error Err = llvm::Error::success();
-IncrExecutor = std::make_unique(*TSCtx, Err, TI);
-
+auto Err = CreateExecutor();
 if (Err)
   return Err;
   }
@@ -283,3 +296,30 @@
   }
   return llvm::Error::success();
 }
+
+llvm::Error Interpreter::LoadDynamicLibrary(const char *name) {
+  auto EE = GetExecutionEngine();
+  if (!EE)
+return EE.takeError();
+
+  auto  = EE->getDataLayout();
+
+  std::stringstream filename;
+#if defined(LLVM_ON_UNIX)
+  filename << "lib";
+#endif
+  filename << name;
+#if defined(_WIN32)
+  filename << ".dll";
+#elif defined(LLVM_ON_UNIX)
+  filename << ".so";
+#endif
+
+  if (auto DLSG = llvm::orc::DynamicLibrarySearchGenerator::Load(
+  filename.str().c_str(), DL.getGlobalPrefix()))
+EE->getMainJITDylib().addGenerator(std::move(*DLSG));
+  else
+return DLSG.takeError();
+
+  return llvm::Error::success();
+}
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -53,7 +53,8 @@
   llvm::Error cleanUp();
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
-  llvm::orc::LLJIT *getExecutionEngine() const { return Jit.get(); }
+
+  llvm::orc::LLJIT () { return *Jit; }
 };
 
 } // end namespace clang
Index: clang/include/clang/Interpreter/Interpreter.h
===
--- clang/include/clang/Interpreter/Interpreter.h
+++ clang/include/clang/Interpreter/Interpreter.h
@@ -28,7 +28,7 @@
 namespace orc {
 class LLJIT;
 class ThreadSafeContext;
-}
+} // namespace orc
 } // namespace llvm
 
 namespace clang {
@@ -52,12 +52,15 @@
 
   Interpreter(std::unique_ptr CI, llvm::Error );
 
+  llvm::Error CreateExecutor();
+
 public:
   ~Interpreter();
   static llvm::Expected>
   create(std::unique_ptr CI);
   const CompilerInstance *getCompilerInstance() const;
-  const llvm::orc::LLJIT *getExecutionEngine() const;
+  llvm::Expected 

[PATCH] D141818: Add test for an invalid requirement in requires expr.

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141818

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


[PATCH] D141389: [DFSAN] Add support for strnlen, strncat, strsep, sscanf and _tolower

2023-01-16 Thread Tomasz Kuchta via Phabricator via cfe-commits
tkuchta added inline comments.



Comment at: compiler-rt/lib/dfsan/dfsan_custom.cpp:213
+  char *res = strsep(s, delim);
+  s_label = dfsan_read_label(base, strlen(base));
+  if (res && (res != base)) {

browneee wrote:
> The `s_label` represents the taint label for `s` (the pointer).
> 
> This line would clobber the taint label of the pointer (`s`) with a taint 
> label from `s[0][0..n]`.
> 
> I think this line should be deleted.
Agree, s_label represents the taint associated with the **s pointer. However I 
am now wondering if that is the taint wich we would like to return.
For example, if we have
if (flags().strict_data_dependencies) {
*ret_label = res ? s_label : 0;

We would taint the return value with the value of the pointer, not the data. It 
means that if we operate on a string for which the characters are tainted, but 
the pointer itself isn't, we are likely going to return label 0. My 
understanding was that we are more concerned with the taint of the data, not 
the pointer, am I missing something?




Comment at: compiler-rt/lib/dfsan/dfsan_custom.cpp:214
+  s_label = dfsan_read_label(base, strlen(base));
+  if (res && (res != base)) {
+char *token_start = res;

browneee wrote:
> I think `res && (res != base)` is never true.
> 
> Checking an implementation of strsep 
> (http://git.musl-libc.org/cgit/musl/tree/src/string/strsep.c)
> `res` can either be `NULL` or the same value as `base`.
> 
> I think this line should be `(res != *s)`. This is different because `*s` may 
> be changed by the call to `strsep` just above.
good point, my bad


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

https://reviews.llvm.org/D141389

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


[clang] 596f76a - Revert "[C2x] reject type definitions in offsetof"

2023-01-16 Thread Yingchi Long via cfe-commits

Author: Yingchi Long
Date: 2023-01-16T16:52:50+08:00
New Revision: 596f76a799c933927eec4d8ac8a83c44efff9854

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

LOG: Revert "[C2x] reject type definitions in offsetof"

This reverts commit e327b52766ed497e4779f4e652b9ad237dfda8e6.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Parse/RAIIObjectsForParser.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/C/drs/dr4xx.c
clang/test/Parser/declarators.c
clang/test/SemaCXX/offsetof.cpp

Removed: 
clang/test/C/C2x/n2350.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a75bc1df2d7c9..09133f967f01f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -670,9 +670,6 @@ C2x Feature Support
   va_start(list); // Invalid in C17 and earlier, valid in C2x and later.
   va_end(list);
 }
-
-- Reject type definitions in the ``type`` argument of ``__builtin_offsetof`` 
-  according to `WG14 N2350 
`_.
 
 C++ Language Changes in Clang
 -

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 862ac845bda45..02afb098b2395 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1650,8 +1650,6 @@ def err_type_defined_in_condition : Error<
   "%0 cannot be defined in a condition">;
 def err_type_defined_in_enum : Error<
   "%0 cannot be defined in an enumeration">;
-def err_type_defined_in_offsetof : Error<
-  "%0 cannot be defined in '%select{__builtin_offsetof|offsetof}1'">;
 
 def note_pure_virtual_function : Note<
   "unimplemented pure virtual method %0 in %1">;

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 6f9581b9ea1fc..7a33532eec14e 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -62,7 +62,6 @@ class Parser : public CodeCompletionHandler {
   friend class ColonProtectionRAIIObject;
   friend class ParsingOpenMPDirectiveRAII;
   friend class InMessageExpressionRAIIObject;
-  friend class OffsetOfStateRAIIObject;
   friend class PoisonSEHIdentifiersRAIIObject;
   friend class ObjCDeclContextSwitch;
   friend class ParenBraceBracketBalancer;
@@ -249,8 +248,6 @@ class Parser : public CodeCompletionHandler {
   /// function call.
   bool CalledSignatureHelp = false;
 
-  Sema::OffsetOfKind OffsetOfState = Sema::OffsetOfKind::OOK_Outside;
-
   /// The "depth" of the template parameters currently being parsed.
   unsigned TemplateParameterDepth;
 

diff  --git a/clang/include/clang/Parse/RAIIObjectsForParser.h 
b/clang/include/clang/Parse/RAIIObjectsForParser.h
index cb525c9d0edd6..5ae609e600734 100644
--- a/clang/include/clang/Parse/RAIIObjectsForParser.h
+++ b/clang/include/clang/Parse/RAIIObjectsForParser.h
@@ -341,19 +341,6 @@ namespace clang {
 }
   };
 
-  class OffsetOfStateRAIIObject {
-Sema::OffsetOfKind 
-Sema::OffsetOfKind OldValue;
-
-  public:
-OffsetOfStateRAIIObject(Parser , Sema::OffsetOfKind Value)
-: OffsetOfState(P.OffsetOfState), OldValue(P.OffsetOfState) {
-  OffsetOfState = Value;
-}
-
-~OffsetOfStateRAIIObject() { OffsetOfState = OldValue; }
-  };
-
   /// RAII object that makes sure paren/bracket/brace count is correct
   /// after declaration/statement parsing, even when there's a parsing error.
   class ParenBraceBracketBalancer {

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 35e319879a98d..30c5ea608f7a0 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3304,16 +3304,6 @@ class Sema final {
 TUK_Friend   // Friend declaration:  'friend struct foo;'
   };
 
-  enum OffsetOfKind {
-// Not parsing a type within __builtin_offsetof.
-OOK_Outside,
-// Parsing a type within __builtin_offsetof.
-OOK_Builtin,
-// Parsing a type within macro "offsetof", defined in __buitin_offsetof
-// To improve our diagnostic message.
-OOK_Macro,
-  };
-
   Decl *ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
  SourceLocation KWLoc, CXXScopeSpec , IdentifierInfo *Name,
  SourceLocation NameLoc, const ParsedAttributesView ,
@@ -3322,7 +3312,7 @@ class Sema final {
  bool , SourceLocation 

[PATCH] D141788: [NFC] Use `llvm::enumerate` in llvm/unittests/Object

2023-01-16 Thread Sergei Barannikov 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 rG8a0e0c226018: [NFC] Use `llvm::enumerate` in 
llvm/unittests/Object (authored by barannikov88).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141788

Files:
  clang/docs/tools/clang-formatted-files.txt
  llvm/unittests/Object/ELFObjectFileTest.cpp

Index: llvm/unittests/Object/ELFObjectFileTest.cpp
===
--- llvm/unittests/Object/ELFObjectFileTest.cpp
+++ llvm/unittests/Object/ELFObjectFileTest.cpp
@@ -7,8 +7,9 @@
 //===--===//
 
 #include "llvm/Object/ELFObjectFile.h"
-#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ObjectYAML/yaml2obj.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gtest/gtest.h"
@@ -86,38 +87,33 @@
 TEST(ELFObjectFileTest, MachineTestForNoneOrUnused) {
   std::array Formats = {"elf32-unknown", "elf32-unknown",
   "elf64-unknown", "elf64-unknown"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_NONE))
-checkFormatAndArch(D, Formats[I++], Triple::UnknownArch);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_NONE)))
+checkFormatAndArch(Data, Formats[Idx], Triple::UnknownArch);
 
   // Test an arbitrary unused EM_* value (255).
-  I = 0;
-  for (const DataForTest  : generateData(255))
-checkFormatAndArch(D, Formats[I++], Triple::UnknownArch);
+  for (auto [Idx, Data] : enumerate(generateData(255)))
+checkFormatAndArch(Data, Formats[Idx], Triple::UnknownArch);
 }
 
 TEST(ELFObjectFileTest, MachineTestForVE) {
   std::array Formats = {"elf32-unknown", "elf32-unknown",
   "elf64-ve", "elf64-ve"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_VE))
-checkFormatAndArch(D, Formats[I++], Triple::ve);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_VE)))
+checkFormatAndArch(Data, Formats[Idx], Triple::ve);
 }
 
 TEST(ELFObjectFileTest, MachineTestForX86_64) {
   std::array Formats = {"elf32-x86-64", "elf32-x86-64",
   "elf64-x86-64", "elf64-x86-64"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_X86_64))
-checkFormatAndArch(D, Formats[I++], Triple::x86_64);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_X86_64)))
+checkFormatAndArch(Data, Formats[Idx], Triple::x86_64);
 }
 
 TEST(ELFObjectFileTest, MachineTestFor386) {
   std::array Formats = {"elf32-i386", "elf32-i386", "elf64-i386",
   "elf64-i386"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_386))
-checkFormatAndArch(D, Formats[I++], Triple::x86);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_386)))
+checkFormatAndArch(Data, Formats[Idx], Triple::x86);
 }
 
 TEST(ELFObjectFileTest, MachineTestForMIPS) {
@@ -125,27 +121,22 @@
   "elf64-mips"};
   std::array Archs = {Triple::mipsel, Triple::mips,
Triple::mips64el, Triple::mips64};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_MIPS)) {
-checkFormatAndArch(D, Formats[I], Archs[I]);
-++I;
-  }
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_MIPS)))
+checkFormatAndArch(Data, Formats[Idx], Archs[Idx]);
 }
 
 TEST(ELFObjectFileTest, MachineTestForAMDGPU) {
   std::array Formats = {"elf32-amdgpu", "elf32-amdgpu",
   "elf64-amdgpu", "elf64-amdgpu"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_AMDGPU))
-checkFormatAndArch(D, Formats[I++], Triple::UnknownArch);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_AMDGPU)))
+checkFormatAndArch(Data, Formats[Idx], Triple::UnknownArch);
 }
 
 TEST(ELFObjectFileTest, MachineTestForIAMCU) {
   std::array Formats = {"elf32-iamcu", "elf32-iamcu",
   "elf64-unknown", "elf64-unknown"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_IAMCU))
-checkFormatAndArch(D, Formats[I++], Triple::x86);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_IAMCU)))
+checkFormatAndArch(Data, Formats[Idx], Triple::x86);
 }
 
 TEST(ELFObjectFileTest, MachineTestForAARCH64) {
@@ -154,11 +145,8 @@
   "elf64-bigaarch64"};
   std::array Archs = {Triple::aarch64, Triple::aarch64_be,
Triple::aarch64, Triple::aarch64_be};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_AARCH64)) {
-checkFormatAndArch(D, Formats[I], Archs[I]);
-++I;
-  }
+ 

[clang] 8a0e0c2 - [NFC] Use `llvm::enumerate` in llvm/unittests/Object

2023-01-16 Thread Sergei Barannikov via cfe-commits

Author: Sergei Barannikov
Date: 2023-01-16T15:59:31+03:00
New Revision: 8a0e0c226018a77ea148e128c97c2592e6f25416

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

LOG: [NFC] Use `llvm::enumerate` in llvm/unittests/Object

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/docs/tools/clang-formatted-files.txt
llvm/unittests/Object/ELFObjectFileTest.cpp

Removed: 




diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 708501329238b..6730aacf43cd4 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -7310,6 +7310,7 @@ llvm/unittests/MC/AMDGPU/DwarfRegMappings.cpp
 llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
 llvm/unittests/ObjCopy/ObjCopyTest.cpp
 llvm/unittests/Object/ArchiveTest.cpp
+llvm/unittests/Object/ELFObjectFileTest.cpp
 llvm/unittests/Object/ELFTest.cpp
 llvm/unittests/Object/ELFTypesTest.cpp
 llvm/unittests/Object/MinidumpTest.cpp

diff  --git a/llvm/unittests/Object/ELFObjectFileTest.cpp 
b/llvm/unittests/Object/ELFObjectFileTest.cpp
index 577cec5152e5e..af8b300ddc21f 100644
--- a/llvm/unittests/Object/ELFObjectFileTest.cpp
+++ b/llvm/unittests/Object/ELFObjectFileTest.cpp
@@ -7,8 +7,9 @@
 
//===--===//
 
 #include "llvm/Object/ELFObjectFile.h"
-#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ObjectYAML/yaml2obj.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gtest/gtest.h"
@@ -86,38 +87,33 @@ std::array generateData(uint16_t Machine) {
 TEST(ELFObjectFileTest, MachineTestForNoneOrUnused) {
   std::array Formats = {"elf32-unknown", "elf32-unknown",
   "elf64-unknown", "elf64-unknown"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_NONE))
-checkFormatAndArch(D, Formats[I++], Triple::UnknownArch);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_NONE)))
+checkFormatAndArch(Data, Formats[Idx], Triple::UnknownArch);
 
   // Test an arbitrary unused EM_* value (255).
-  I = 0;
-  for (const DataForTest  : generateData(255))
-checkFormatAndArch(D, Formats[I++], Triple::UnknownArch);
+  for (auto [Idx, Data] : enumerate(generateData(255)))
+checkFormatAndArch(Data, Formats[Idx], Triple::UnknownArch);
 }
 
 TEST(ELFObjectFileTest, MachineTestForVE) {
   std::array Formats = {"elf32-unknown", "elf32-unknown",
   "elf64-ve", "elf64-ve"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_VE))
-checkFormatAndArch(D, Formats[I++], Triple::ve);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_VE)))
+checkFormatAndArch(Data, Formats[Idx], Triple::ve);
 }
 
 TEST(ELFObjectFileTest, MachineTestForX86_64) {
   std::array Formats = {"elf32-x86-64", "elf32-x86-64",
   "elf64-x86-64", "elf64-x86-64"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_X86_64))
-checkFormatAndArch(D, Formats[I++], Triple::x86_64);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_X86_64)))
+checkFormatAndArch(Data, Formats[Idx], Triple::x86_64);
 }
 
 TEST(ELFObjectFileTest, MachineTestFor386) {
   std::array Formats = {"elf32-i386", "elf32-i386", "elf64-i386",
   "elf64-i386"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_386))
-checkFormatAndArch(D, Formats[I++], Triple::x86);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_386)))
+checkFormatAndArch(Data, Formats[Idx], Triple::x86);
 }
 
 TEST(ELFObjectFileTest, MachineTestForMIPS) {
@@ -125,27 +121,22 @@ TEST(ELFObjectFileTest, MachineTestForMIPS) {
   "elf64-mips"};
   std::array Archs = {Triple::mipsel, Triple::mips,
Triple::mips64el, Triple::mips64};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_MIPS)) {
-checkFormatAndArch(D, Formats[I], Archs[I]);
-++I;
-  }
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_MIPS)))
+checkFormatAndArch(Data, Formats[Idx], Archs[Idx]);
 }
 
 TEST(ELFObjectFileTest, MachineTestForAMDGPU) {
   std::array Formats = {"elf32-amdgpu", "elf32-amdgpu",
   "elf64-amdgpu", "elf64-amdgpu"};
-  size_t I = 0;
-  for (const DataForTest  : generateData(ELF::EM_AMDGPU))
-checkFormatAndArch(D, Formats[I++], Triple::UnknownArch);
+  for (auto [Idx, Data] : enumerate(generateData(ELF::EM_AMDGPU)))
+

[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-16 Thread Yingchi Long via Phabricator via cfe-commits
inclyc added a comment.

On Mon, Jan 16, 2023 Roman Lebedev  wrote:

> Reminder to please always mention the reason for the revert/recommit in the 
> commit message.

Thanks! This change needs to be fixed up (see comments above).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[clang] f2d301f - Revert "[codegen] Store address of indirect arguments on the stack"

2023-01-16 Thread Felipe de Azevedo Piovezan via cfe-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-01-16T13:05:22-03:00
New Revision: f2d301fe82869f881b86b51da7b4752972c66707

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

LOG: Revert "[codegen] Store address of indirect arguments on the stack"

This reverts commit 7e4447a17db4a070f01c8f8a87505a4b2a1b0e3a.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CGDecl.cpp
clang/test/CodeGen/aarch64-ls64.c
clang/test/CodeGen/atomic-arm64.c
clang/test/CodeGenCXX/amdgcn-func-arg.cpp
clang/test/CodeGenCXX/debug-info.cpp
clang/test/CodeGenCXX/derived-to-base-conv.cpp
clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
clang/test/CodeGenCoroutines/coro-params.cpp
clang/test/OpenMP/for_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_firstprivate_codegen.cpp
clang/test/OpenMP/sections_firstprivate_codegen.cpp
clang/test/OpenMP/single_firstprivate_codegen.cpp
clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
clang/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp
clang/test/OpenMP/teams_firstprivate_codegen.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 731d10ac64a3f..3bbab951e8a8c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -500,9 +500,6 @@ Non-comprehensive list of changes in this release
 - Clang can now generate a PCH when using ``-fdelayed-template-parsing`` for
   code with templates containing loop hint pragmas, OpenMP pragmas, and
   ``#pragma unused``.
-- Clang now saves the address of ABI-indirect function parameters on the stack,
-  improving the debug information available in programs compiled without
-  optimizations.
 
 
 New Compiler Flags

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index f2d558456fde4..f53a9d00ae5fd 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4822,10 +4822,9 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
 
 llvm::DILocalVariable *
 CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI,
-  unsigned ArgNo, CGBuilderTy ,
-  const bool UsePointerValue) {
+  unsigned ArgNo, CGBuilderTy ) {
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
-  return EmitDeclare(VD, AI, ArgNo, Builder, UsePointerValue);
+  return EmitDeclare(VD, AI, ArgNo, Builder);
 }
 
 namespace {

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 10660a2550b56..95484a060cd88 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -487,9 +487,10 @@ class CGDebugInfo {
 
   /// Emit call to \c llvm.dbg.declare for an argument variable
   /// declaration.
-  llvm::DILocalVariable *
-  EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, unsigned 
ArgNo,
-   CGBuilderTy , bool UsePointerValue = false);
+  llvm::DILocalVariable *EmitDeclareOfArgVariable(const VarDecl *Decl,
+  llvm::Value *AI,
+  unsigned ArgNo,
+  CGBuilderTy );
 
   /// Emit call to \c llvm.dbg.declare for the block-literal argument
   /// to a block invocation function.

diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index a70997f5b27b8..ceaddc4e694ac 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2476,8 +2476,6 @@ void CodeGenFunction::EmitParmDecl(const VarDecl , 
ParamValue Arg,
   Address AllocaPtr = Address::invalid();
   bool DoStore = false;
   bool IsScalar = hasScalarEvaluationKind(Ty);
-  bool UseIndirectDebugAddress = false;
-
   // If we already have a pointer to the argument, reuse the input pointer.
   if (Arg.isIndirect()) {
 // If we have a prettier pointer type at this point, bitcast to that.
@@ -2489,19 +2487,6 @@ void CodeGenFunction::EmitParmDecl(const VarDecl , 
ParamValue Arg,
 auto AllocaAS = CGM.getASTAllocaAddressSpace();
 auto *V = 

[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

@barannikov88  - Imam stuck with an incomplete explanation:

The issue raised by @mgorny is about stand-alone 
 builds. In this 
build configuration, clang is built separately from LLVM, which is first build 
and installed in a folder.

When clang is build as a stand-alone project, clang does not have access to the 
cmake configuration of LLVM. Therefore it knows nothing about the tablegen 
target `RISCVTargetParserTableGen`.

The's why we see the following error when building stand-alone clang on `main`:

  CMake Error at 
/Users/fpetrogalli/projects/cpu-defs/install/lib/cmake/llvm/AddLLVM.cmake:536 
(add_dependencies):
The dependency target "RISCVTargetParserTableGen" of target
"obj.clangBasic" does not exist.
  Call Stack (most recent call first):
cmake/modules/AddClang.cmake:106 (llvm_add_library)
lib/Basic/CMakeLists.txt:40 (add_clang_library)

I do not know why `LLVMTargetParser` (which is also specified in the cmake 
configuration of llvm) is instead recognised as a valid dependencies of clang 
on some LLVM library. Maybe because cmake looks in the prefix folder where LLVM 
was installed and finds the object file of the library?

FWIW, I was able to reproduce the issue reported by @mgorny via the following 
script when run on `main`:

  #!/bin/sh
  
  build_llvm=`pwd`/build-llvm
  build_clang=`pwd`/build-clang
  installprefix=`pwd`/install
  llvm=`pwd`/llvm-project
  mkdir -p $build_llvm
  mkdir -p $installprefix
  
  cmake -G Ninja -S $llvm/llvm -B $build_llvm \
-DLLVM_INSTALL_UTILS=ON \
-DCMAKE_INSTALL_PREFIX=$installprefix \
-DCMAKE_BUILD_TYPE=Release
  
  
  ninja -C $build_llvm install
  
  cmake -G Ninja -S $llvm/clang -B $build_clang \
-DLLVM_EXTERNAL_LIT=$build_llvm/utils/llvm-lit \
-DLLVM_ROOT=$installprefix

Given it was an issue that cmake itself was reporting (and not a build time 
failure), I thought that its disappearance after applying this patch was a 
signal thatI was doing the right thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D131915: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2023-01-16 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan accepted this revision.
kiranchandramohan added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for making the changes and for your patience. Please wait a couple 
of days to give other reviewers a chance to have a look before submitting.

Could you update the Summary of this patch to specify what is in this patch and 
what is left out? Also, might be useful to specify any special modelling, like 
for the map clause.

Could you specify the co-authors in the following way?
Co-authored-by: abidmalikwaterloo 
Co-authored-by: raghavendra 




Comment at: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td:790
+//===-===//
+// 2.12.2 target data Construct
+//===-===//

Is this number from the OpenMP 5.0 standard? I think 5.0 does not have the 
`present` map-type modifier. The printer includes this. I think we can either 
remove things that are not there in 5.0 or add comments when items from newer 
versions are included or alternatively change the number to the latest version 
and call out everything that is not implemented.



Comment at: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td:818-820
+The $map_operands specifies operands in map clause along with it's type 
and modifiers.
+
+The $map_operand_segments specifies the segment sizes for $map_operands.

Update these two to their current meanings. (Also replace 
`map_operand_segments` with `map_types`.

Same comment for the other two operations.



Comment at: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp:542
+// Parser, printer and verifier for Target Data
+//===--===//
+static ParseResult

Could you specify the EBNF (https://mlir.llvm.org/docs/LangRef/#notation) for 
the expected structure of the map clause?



Comment at: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp:595
+
+if (mapTypeOp.isa())
+  mapTypeBits = mapTypeOp.cast().getInt();

Nit: Should this be an assert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131915

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


[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-16 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 accepted this revision.
tianshilei1992 added a comment.
This revision is now accepted and ready to land.

Yeah, otherwise I suppose there will be some errors when compiling OpenMP 
program when there is no CUDA installed.




Comment at: clang/tools/nvptx-arch/NVPTXArch.cpp:89
 
 int main() {
+  // Attempt to load the NVPTX driver runtime.

unrelated: I always prefer:
```
int main(int argc, char *argv[]) {
  return 0;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141861

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


[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

2023-01-16 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:60
+// Checks if T1 is convertible to T2.
+static bool isMultiLevelConvertiblePointer(QualType P1, QualType P2,
+   unsigned CurrentLevel = 0,

isuckatcs wrote:
> xazax.hun wrote:
> > xazax.hun wrote:
> > > Did you take a look at `ASTContext::hasCvrSimilarType`? I wonder if it is 
> > > already doing what you want. 
> > Oh, maybe it is not, but it might also make sense to take a look at 
> > `ASTContext::typesAreCompatible`.
> > Did you take a look at ASTContext::hasCvrSimilarType? I wonder if it is 
> > already doing what you want.
> 
> This function compares the types by removing the CVR qualifiers.
> 
> > Oh, maybe it is not, but it might also make sense to take a look at 
> > ASTContext::typesAreCompatible.
> 
> This one only compares the canonical types if the language is C++.
> 
> ```lang=c++
> if (getLangOpts().CPlusPlus)
> return hasSameType(LHS, RHS);
> 
> bool hasSameType(QualType T1, QualType T2) const {
> return getCanonicalType(T1) == getCanonicalType(T2);
>   }
> 
> ```
Could you rename the arguments like `To`, `From` or `Exception`, `Catch` or 
something to make the direction of the conversion clearer?



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:95
+
+  if (P1->isArrayType() && P2->isArrayType()) {
+// At every level that array type is involved in, at least

isuckatcs wrote:
> xazax.hun wrote:
> > If none of the functions I recommended works for you, I still strongly 
> > suggest reusing utilities from ASTContext, like `UnwrapSimilarTypes` and 
> > `UnwrapSimilarArrayTypes`.
> I didn't check all of the functions inside `ASTContext`, but here we have 
> very specific rules, we need to check. One utility might help with one check 
> or two, but won't replace the need to go ove all of them. Also I think it's 
> easier to understand which section checks what, if I keep them separated.
> 
> In an ealier comment I link to [[ 
> https://en.cppreference.com/w/cpp/language/implicit_conversion#Qualification_conversions
>  | the section on cppreference ]], which discusses what these rules are. Also 
> there I found one controversial example, that's only detected by MSVC. I 
> wonder if you know why that happens.
I see. It is unfortunate that we cannot simply reuse the corresponding 
functionality from Sema. The code mostly looks good to me, apart from some nits.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:111
+// ... [or there is an array type of known bound in P1 and
+// an array type of unknown bound in P2 (since C++20)] then
+// there must be a 'const' at every single level (other than

If this rule only applies to C++20 and above, consider adding a language 
version check for LangOpts.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:130-131
+  if (!P1->isPointerType() || !P2->isPointerType())
+return convertible && P1->getUnqualifiedDesugaredType() ==
+  P2->getUnqualifiedDesugaredType();
+

Looking at the documentation of DesugaredType:
```
This takes off typedefs, typeof's etc. If the outer level of the type is 
already concrete, it returns it unmodified. This is similar to getting the 
canonical type, but it doesn't remove all typedefs. For example, it returns 
"T*" as "T*", (not as "int*"), because the pointer is concrete.
```
I wonder if we actually want to compare canonical types rather than desugared 
types.


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

https://reviews.llvm.org/D135495

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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D141581#4056612 , @barannikov88 
wrote:

> In D141581#4056503 , @fpetrogalli 
> wrote:
>
>> This is because the sources of clangBasic and clangDriver might be compiled 
>> before LLVMTargetParser is ready.
>
> ...
>
>> Therefore, if we say that clangDriver and clangBasic depend on 
>> LLVMTargetParser we make sure that the inclusion of the tablegen-generated 
>> file resolves correctly.
>
> Sorry, I don't follow. If I read correctly, you're saying that clang 
> libraries might begin to //compile// before their DEPENDS dependency is built 
> (implying that DEPENDS clause only guarantees that the dependency is ready at 
> //link// stage). If it is true, the proposed patch changes nothing -- the 
> sources might still start to compile before cmake decides to generate inc 
> file, because it is only needed at link stage.
> Am I missing something?

Ops, yeah, I think I am wrong. In fact , when `RISCVTargetParserTableGen` is in 
the `DEPENDS`, it should be built before the clangBasic start to compile. This 
means that I actually do not know why this change fixes the issue reported 


@mgorny - can you try this patch on your workflow? Maybe the issue disappeared 
in my local machine just because for some reason it changed the order of 
compilation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D137058: [Driver] [Modules] Support -fmodule-output (1/2)

2023-01-16 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan added a comment.

Hi, this new test fails on AIX 
https://lab.llvm.org/buildbot/#/builders/214/builds/5351/steps/6/logs/FAIL__Clang__module-output_cppm
Could you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137058

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


[PATCH] D141432: Add two additional float8 types to MLIR and APFloat.

2023-01-16 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 added a comment.
Herald added a reviewer: ftynse.

I think we have dueling patches that we should reconcile. I've put together 
https://reviews.llvm.org/D141863 to do the same thing. (it's just now posted 
because we were waiting to talk to y'all over at GraphCore to finalize naming, 
etc. ... but since this revision's already up I might as well go and put mine.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141432

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


[PATCH] D139926: [clangd] Add semantic tokens for angle brackets

2023-01-16 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

In D139926#4056585 , @kadircet wrote:

> Especially as this comes as two different `HighlightingKind`s and they're 
> likely to get colored differently, and having your matching brackets in 
> different colors is quite annoying.

We can easily check the actual character at the given position in the client, 
so I could just merge the two highlighting kinds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D141581#4056492 , @tschuett wrote:

> I though Clang Basic is a leaf library and must not depend on anything.

I wasn't aware of this requirement.  As of https://reviews.llvm.org/D137517 it 
depends on some auto-generated target information stored in `LLVMTargetParser` 
and `llvm/lib/Target/Target/RISCV/RISCV.td`. At the end, it is not even 
depending on the LLVMTargetParser library, it is just one header file in the 
public interface of the `TargetParser` that is needed (see explanation in 
https://reviews.llvm.org/D141581#4056503)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141586: [include-mapping] Replace the stdlib symbol maps with the newest official version from https://en.cppreference.com/w/File:html_book_20190607.zip.

2023-01-16 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo abandoned this revision.
VitaNuo added a comment.

Abandoning since we will eventually parse a newer version of the archive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141586

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


[PATCH] D141381: [codegen] Store address of indirect arguments on the stack

2023-01-16 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve added a comment.

In hindsight, this should have been obvious.
While SROA will not touch this:

  define @foo(ptr %arg) {
 call void @llvm.dbg.declare(%arg, [...], metadata !DIExpression())

It completely destroys the debug information provided by:

  define @foo(ptr %arg) {
 %ptr_storage = alloca ptr
 store ptr %arg, ptr %ptr_storage
 call void @llvm.dbg.declare(%ptr_storage, [...], metadata 
!DIExpression(DW_OP_deref))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141381

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


[PATCH] D141859: [amdgpu-arch] Dynamically load the HSA runtime if not found during the build

2023-01-16 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, tra, yaxunl, 
JonChesterfield, gregrodgers.
Herald added subscribers: kosarev, kerbowa, tpr, dstuttard, jvesely, kzhuravl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

We use the `amdgpu-arch` tool to query the installed GPUs at runtime.
One problem is that this tool is currently not build if the person
building the LLVM binary does not have the HSA runtime on their system.
This means that if someone built and distrubted an installation of LLVM
without HSA, then the user will not be able to use it even if they have
it on their system.

This patch makes us build this tool unconditionally and adds extra logic
to dynamically load HSA if it's present.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141859

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp
  clang/tools/amdgpu-arch/CMakeLists.txt

Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -6,14 +6,13 @@
 # //
 # //===--===//
 
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
-if (NOT ${hsa-runtime64_FOUND})
-  message(STATUS "Not building amdgpu-arch: hsa-runtime64 not found")
-  return()
-endif()
+set(LLVM_LINK_COMPONENTS Support)
 
 add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
 
-set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
-
-clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)
+# If we find the HSA runtime we link with it directly.
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
+if (${hsa-runtime64_FOUND})
+  set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
+  clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)
+endif()
Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===
--- clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,6 +11,12 @@
 //
 //===--===//
 
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
 #if defined(__has_include)
 #if __has_include("hsa/hsa.h")
 #define HSA_HEADER_FOUND 1
@@ -26,11 +32,62 @@
 #endif
 
 #if !HSA_HEADER_FOUND
-int main() { return 1; }
-#else
+// Forward declaration of the status enumeration used by HSA.
+typedef enum {
+  HSA_STATUS_SUCCESS = 0x0,
+} hsa_status_t;
 
-#include 
-#include 
+// Forward declaration of the device types used by HSA.
+typedef enum {
+  HSA_DEVICE_TYPE_CPU = 0,
+  HSA_DEVICE_TYPE_GPU = 1,
+} hsa_device_type_t;
+
+// Forward declaration of the agent information types we use.
+typedef enum {
+  HSA_AGENT_INFO_NAME = 0,
+  HSA_AGENT_INFO_DEVICE = 17,
+} hsa_agent_info_t;
+
+typedef struct hsa_agent_s {
+  uint64_t handle;
+} hsa_agent_t;
+
+hsa_status_t (*hsa_init)();
+hsa_status_t (*hsa_shut_down)();
+hsa_status_t (*hsa_agent_get_info)(hsa_agent_t, hsa_agent_info_t, void *);
+hsa_status_t (*hsa_iterate_agents)(hsa_status_t (*callback)(hsa_agent_t,
+void *),
+   void *);
+
+constexpr const char *DynamicHSAPath = "libhsa-runtime64.so";
+
+llvm::Error loadHSA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHSAPath, ));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s\n", DynamicHSAPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   \
+  {\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   \
+if (!SymbolPtr)\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   \
+ "Failed to 'dlsym' " #SYMBOL);\
+SYMBOL = reinterpret_cast(SymbolPtr);\
+  }
+  DYNAMIC_INIT(hsa_init);
+  DYNAMIC_INIT(hsa_shut_down);
+  DYNAMIC_INIT(hsa_agent_get_info);
+  DYNAMIC_INIT(hsa_iterate_agents);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+#else
+llvm::Error loadHSA() { return llvm::Error::success(); }
+#endif
 
 static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
   hsa_device_type_t DeviceType;
@@ -54,6 +111,12 @@
 }
 
 int main() {
+  // Attempt to load the HSA runtime.
+  

[PATCH] D141547: Fix format for `case` in .proto files

2023-01-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcaf393da1823: Fix format for `case` in .proto files 
(authored by fowles, committed by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141547

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestProto.cpp


Index: clang/unittests/Format/FormatTestProto.cpp
===
--- clang/unittests/Format/FormatTestProto.cpp
+++ clang/unittests/Format/FormatTestProto.cpp
@@ -113,6 +113,13 @@
"}");
 }
 
+TEST_F(FormatTestProto, CaseAsFieldName) {
+  verifyFormat("message SomeMessage {\n"
+   "  required string case = 1;\n"
+   "  repeated int32 fizz = 2;\n"
+   "}");
+}
+
 TEST_F(FormatTestProto, UnderstandsReturns) {
   verifyFormat("rpc Search(SearchRequest) returns (SearchResponse);");
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -590,8 +590,9 @@
   [[fallthrough]];
 }
 case tok::kw_case:
-  if (Style.isVerilog() ||
+  if (Style.isProto() || Style.isVerilog() ||
   (Style.isJavaScript() && Line->MustBeDeclaration)) {
+// Proto: there are no switch/case statements
 // Verilog: Case labels don't have this word. We handle case
 // labels including default in TokenAnnotator.
 // JavaScript: A 'case: string' style field declaration.
@@ -1620,7 +1621,11 @@
 // e.g. "default void f() {}" in a Java interface.
 break;
   case tok::kw_case:
-// In Verilog switch is called case.
+// Proto: there are no switch/case statements.
+if (Style.isProto()) {
+  nextToken();
+  return;
+}
 if (Style.isVerilog()) {
   parseBlock();
   addUnwrappedLine();
@@ -2100,6 +2105,11 @@
   parseNew();
   break;
 case tok::kw_case:
+  // Proto: there are no switch/case statements.
+  if (Style.isProto()) {
+nextToken();
+return;
+  }
   // In Verilog switch is called case.
   if (Style.isVerilog()) {
 parseBlock();


Index: clang/unittests/Format/FormatTestProto.cpp
===
--- clang/unittests/Format/FormatTestProto.cpp
+++ clang/unittests/Format/FormatTestProto.cpp
@@ -113,6 +113,13 @@
"}");
 }
 
+TEST_F(FormatTestProto, CaseAsFieldName) {
+  verifyFormat("message SomeMessage {\n"
+   "  required string case = 1;\n"
+   "  repeated int32 fizz = 2;\n"
+   "}");
+}
+
 TEST_F(FormatTestProto, UnderstandsReturns) {
   verifyFormat("rpc Search(SearchRequest) returns (SearchResponse);");
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -590,8 +590,9 @@
   [[fallthrough]];
 }
 case tok::kw_case:
-  if (Style.isVerilog() ||
+  if (Style.isProto() || Style.isVerilog() ||
   (Style.isJavaScript() && Line->MustBeDeclaration)) {
+// Proto: there are no switch/case statements
 // Verilog: Case labels don't have this word. We handle case
 // labels including default in TokenAnnotator.
 // JavaScript: A 'case: string' style field declaration.
@@ -1620,7 +1621,11 @@
 // e.g. "default void f() {}" in a Java interface.
 break;
   case tok::kw_case:
-// In Verilog switch is called case.
+// Proto: there are no switch/case statements.
+if (Style.isProto()) {
+  nextToken();
+  return;
+}
 if (Style.isVerilog()) {
   parseBlock();
   addUnwrappedLine();
@@ -2100,6 +2105,11 @@
   parseNew();
   break;
 case tok::kw_case:
+  // Proto: there are no switch/case statements.
+  if (Style.isProto()) {
+nextToken();
+return;
+  }
   // In Verilog switch is called case.
   if (Style.isVerilog()) {
 parseBlock();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7e4447a - [codegen] Store address of indirect arguments on the stack

2023-01-16 Thread Felipe de Azevedo Piovezan via cfe-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-01-16T11:14:55-03:00
New Revision: 7e4447a17db4a070f01c8f8a87505a4b2a1b0e3a

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

LOG: [codegen] Store address of indirect arguments on the stack

With codegen prior to this patch, truly indirect arguments -- i.e.
those that are not `byval` -- can have their debug information lost even
at O0. Because indirect arguments are passed by pointer, and this
pointer is likely placed in a register as per the function call ABI,
debug information is lost as soon as the register gets clobbered.

This patch solves the issue by storing the address of the parameter on
the stack, using a similar strategy employed when C++ references are
passed. In other words, this patch changes codegen from:

```
define @foo(ptr %arg) {
   call void @llvm.dbg.declare(%arg, [...], metadata !DIExpression())
```

To:

```
define @foo(ptr %arg) {
   %ptr_storage = alloca ptr
   store ptr %arg, ptr %ptr_storage
   call void @llvm.dbg.declare(%ptr_storage, [...], metadata 
!DIExpression(DW_OP_deref))
```

Some common cases where this may happen with C or C++ function calls:
  1. "Big enough" trivial structures passed by value under the ARM ABI.
  2. Structures that are non-trivial for the purposes of call (as per
  the Itanium ABI) when passed by value.

A few tests were matching the wrong alloca (matching against the new
alloca, instead of the old one), so they were updated to either match
both allocas or include a `,` right after the alloca type, to prevent
matching against a pointer type.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CGDecl.cpp
clang/test/CodeGen/aarch64-ls64.c
clang/test/CodeGen/atomic-arm64.c
clang/test/CodeGenCXX/amdgcn-func-arg.cpp
clang/test/CodeGenCXX/debug-info.cpp
clang/test/CodeGenCXX/derived-to-base-conv.cpp
clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
clang/test/CodeGenCoroutines/coro-params.cpp
clang/test/OpenMP/for_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_firstprivate_codegen.cpp
clang/test/OpenMP/sections_firstprivate_codegen.cpp
clang/test/OpenMP/single_firstprivate_codegen.cpp
clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
clang/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp
clang/test/OpenMP/teams_firstprivate_codegen.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3bbab951e8a8c..731d10ac64a3f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -500,6 +500,9 @@ Non-comprehensive list of changes in this release
 - Clang can now generate a PCH when using ``-fdelayed-template-parsing`` for
   code with templates containing loop hint pragmas, OpenMP pragmas, and
   ``#pragma unused``.
+- Clang now saves the address of ABI-indirect function parameters on the stack,
+  improving the debug information available in programs compiled without
+  optimizations.
 
 
 New Compiler Flags

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index f53a9d00ae5fd..f2d558456fde4 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4822,9 +4822,10 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
 
 llvm::DILocalVariable *
 CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI,
-  unsigned ArgNo, CGBuilderTy ) {
+  unsigned ArgNo, CGBuilderTy ,
+  const bool UsePointerValue) {
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
-  return EmitDeclare(VD, AI, ArgNo, Builder);
+  return EmitDeclare(VD, AI, ArgNo, Builder, UsePointerValue);
 }
 
 namespace {

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 95484a060cd88..10660a2550b56 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -487,10 +487,9 @@ class CGDebugInfo {
 
   /// Emit call to \c llvm.dbg.declare for an argument variable
   /// declaration.
-  llvm::DILocalVariable 

[PATCH] D141381: [codegen] Store address of indirect arguments on the stack

2023-01-16 Thread Felipe de Azevedo Piovezan 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 rG7e4447a17db4: [codegen] Store address of indirect arguments 
on the stack (authored by fdeazeve).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141381

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/CodeGen/aarch64-ls64.c
  clang/test/CodeGen/atomic-arm64.c
  clang/test/CodeGenCXX/amdgcn-func-arg.cpp
  clang/test/CodeGenCXX/debug-info.cpp
  clang/test/CodeGenCXX/derived-to-base-conv.cpp
  clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
  clang/test/CodeGenCoroutines/coro-params.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_firstprivate_codegen.cpp

Index: clang/test/OpenMP/teams_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/teams_firstprivate_codegen.cpp
+++ clang/test/OpenMP/teams_firstprivate_codegen.cpp
@@ -557,8 +557,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
 // CHECK9-NEXT:call void @_ZN1SIfEC2ERKS0_2St(ptr nonnull align 4 dereferenceable(4) [[THIS1]], ptr nonnull align 4 dereferenceable(4) [[TMP0]], ptr [[T]])
@@ -784,8 +786,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[F:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[THIS1]], i32 0, i32 0
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
@@ -932,8 +936,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
 // CHECK9-NEXT:call void @_ZN1SIiEC2ERKS0_2St(ptr nonnull align 4 dereferenceable(4) [[THIS1]], ptr nonnull align 4 dereferenceable(4) [[TMP0]], ptr [[T]])
@@ -1012,8 +1018,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[F:%.*]] = getelementptr inbounds [[STRUCT_S_0:%.*]], ptr [[THIS1]], i32 0, i32 0
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
@@ -1318,8 +1326,10 @@
 // CHECK11-NEXT:  entry:
 // CHECK11-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 4
 // CHECK11-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 4
+// CHECK11-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 4
 // CHECK11-NEXT:store ptr 

Re: [clang] 596f76a - Revert "[C2x] reject type definitions in offsetof"

2023-01-16 Thread Roman Lebedev via cfe-commits
Reminder to please always mention the reason for the revert/recommit
in the commit message.

On Mon, Jan 16, 2023 at 11:53 AM Yingchi Long via cfe-commits
 wrote:
>
>
> Author: Yingchi Long
> Date: 2023-01-16T16:52:50+08:00
> New Revision: 596f76a799c933927eec4d8ac8a83c44efff9854
>
> URL: 
> https://github.com/llvm/llvm-project/commit/596f76a799c933927eec4d8ac8a83c44efff9854
> DIFF: 
> https://github.com/llvm/llvm-project/commit/596f76a799c933927eec4d8ac8a83c44efff9854.diff
>
> LOG: Revert "[C2x] reject type definitions in offsetof"
>
> This reverts commit e327b52766ed497e4779f4e652b9ad237dfda8e6.
>
> Added:
>
>
> Modified:
> clang/docs/ReleaseNotes.rst
> clang/include/clang/Basic/DiagnosticSemaKinds.td
> clang/include/clang/Parse/Parser.h
> clang/include/clang/Parse/RAIIObjectsForParser.h
> clang/include/clang/Sema/Sema.h
> clang/lib/Parse/ParseDecl.cpp
> clang/lib/Parse/ParseDeclCXX.cpp
> clang/lib/Parse/ParseExpr.cpp
> clang/lib/Sema/SemaDecl.cpp
> clang/lib/Sema/SemaDeclCXX.cpp
> clang/lib/Sema/SemaTemplate.cpp
> clang/test/C/drs/dr4xx.c
> clang/test/Parser/declarators.c
> clang/test/SemaCXX/offsetof.cpp
>
> Removed:
> clang/test/C/C2x/n2350.c
>
>
> 
> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> index a75bc1df2d7c9..09133f967f01f 100644
> --- a/clang/docs/ReleaseNotes.rst
> +++ b/clang/docs/ReleaseNotes.rst
> @@ -670,9 +670,6 @@ C2x Feature Support
>va_start(list); // Invalid in C17 and earlier, valid in C2x and later.
>va_end(list);
>  }
> -
> -- Reject type definitions in the ``type`` argument of ``__builtin_offsetof``
> -  according to `WG14 N2350 
> `_.
>
>  C++ Language Changes in Clang
>  -
>
> diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> index 862ac845bda45..02afb098b2395 100644
> --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
> +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> @@ -1650,8 +1650,6 @@ def err_type_defined_in_condition : Error<
>"%0 cannot be defined in a condition">;
>  def err_type_defined_in_enum : Error<
>"%0 cannot be defined in an enumeration">;
> -def err_type_defined_in_offsetof : Error<
> -  "%0 cannot be defined in '%select{__builtin_offsetof|offsetof}1'">;
>
>  def note_pure_virtual_function : Note<
>"unimplemented pure virtual method %0 in %1">;
>
> diff  --git a/clang/include/clang/Parse/Parser.h 
> b/clang/include/clang/Parse/Parser.h
> index 6f9581b9ea1fc..7a33532eec14e 100644
> --- a/clang/include/clang/Parse/Parser.h
> +++ b/clang/include/clang/Parse/Parser.h
> @@ -62,7 +62,6 @@ class Parser : public CodeCompletionHandler {
>friend class ColonProtectionRAIIObject;
>friend class ParsingOpenMPDirectiveRAII;
>friend class InMessageExpressionRAIIObject;
> -  friend class OffsetOfStateRAIIObject;
>friend class PoisonSEHIdentifiersRAIIObject;
>friend class ObjCDeclContextSwitch;
>friend class ParenBraceBracketBalancer;
> @@ -249,8 +248,6 @@ class Parser : public CodeCompletionHandler {
>/// function call.
>bool CalledSignatureHelp = false;
>
> -  Sema::OffsetOfKind OffsetOfState = Sema::OffsetOfKind::OOK_Outside;
> -
>/// The "depth" of the template parameters currently being parsed.
>unsigned TemplateParameterDepth;
>
>
> diff  --git a/clang/include/clang/Parse/RAIIObjectsForParser.h 
> b/clang/include/clang/Parse/RAIIObjectsForParser.h
> index cb525c9d0edd6..5ae609e600734 100644
> --- a/clang/include/clang/Parse/RAIIObjectsForParser.h
> +++ b/clang/include/clang/Parse/RAIIObjectsForParser.h
> @@ -341,19 +341,6 @@ namespace clang {
>  }
>};
>
> -  class OffsetOfStateRAIIObject {
> -Sema::OffsetOfKind 
> -Sema::OffsetOfKind OldValue;
> -
> -  public:
> -OffsetOfStateRAIIObject(Parser , Sema::OffsetOfKind Value)
> -: OffsetOfState(P.OffsetOfState), OldValue(P.OffsetOfState) {
> -  OffsetOfState = Value;
> -}
> -
> -~OffsetOfStateRAIIObject() { OffsetOfState = OldValue; }
> -  };
> -
>/// RAII object that makes sure paren/bracket/brace count is correct
>/// after declaration/statement parsing, even when there's a parsing error.
>class ParenBraceBracketBalancer {
>
> diff  --git a/clang/include/clang/Sema/Sema.h 
> b/clang/include/clang/Sema/Sema.h
> index 35e319879a98d..30c5ea608f7a0 100644
> --- a/clang/include/clang/Sema/Sema.h
> +++ b/clang/include/clang/Sema/Sema.h
> @@ -3304,16 +3304,6 @@ class Sema final {
>  TUK_Friend   // Friend declaration:  'friend struct foo;'
>};
>
> -  enum OffsetOfKind {
> -// Not parsing a type within __builtin_offsetof.
> -OOK_Outside,
> -// Parsing a type within __builtin_offsetof.
> -OOK_Builtin,
> -// Parsing a type within macro "offsetof", 

[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-01-16 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 489552.
pmatos added a comment.

Add new Attr Subject Function Pointer for __funcref attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/DirectX.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Format/FormatToken.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/wasm-funcref.c
  clang/test/Parser/wasm-funcref.c
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388587)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388586)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x7FFFEA>();
+  correct<0x7FFFE9>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650L>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: clang/test/Parser/wasm-funcref.c
===
--- /dev/null
+++ clang/test/Parser/wasm-funcref.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple powerpc-linux-gnu -fsyntax-only -verify %s
+
+// Test that we trigger an error at parse time if using keyword funcref
+// while not using a wasm triple.
+typedef void (*__funcref funcref_t)(); // expected-error {{invalid use of __funcref keyword outside the WebAssembly triple}}
+typedef int (*__funcref fn_funcref_t)(int);// expected-error {{invalid use of __funcref keyword outside the WebAssembly triple}}
+typedef int (*fn_t)(int);
+
+static fn_funcref_t nullFuncref = 0;
Index: clang/test/CodeGen/WebAssembly/wasm-funcref.c
===
--- /dev/null
+++ clang/test/CodeGen/WebAssembly/wasm-funcref.c
@@ -0,0 +1,84 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple wasm32 -target-feature +reference-types -o - -emit-llvm %s | FileCheck %s
+
+typedef void (*__funcref funcref_t)();
+typedef int (*__funcref fn_funcref_t)(int);
+typedef int (*fn_t)(int);
+
+// Null funcref builtin call
+// CHECK-LABEL: @get_null(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call ptr addrspace(20) @llvm.wasm.ref.null.func()
+// CHECK-NEXT:ret ptr addrspace(20) [[TMP0]]
+//
+funcref_t get_null() {
+  return __builtin_wasm_ref_null_func();
+}
+
+// Call to null funcref builtin but requires cast since
+// default return value for builtin is a funcref with function type () -> ().
+// CHECK-LABEL: @get_null_ii(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call ptr addrspace(20) @llvm.wasm.ref.null.func()
+// CHECK-NEXT:ret ptr addrspace(20) [[TMP0]]
+//
+fn_funcref_t get_null_ii() {
+  return (fn_funcref_t) __builtin_wasm_ref_null_func();
+}
+
+// Identity function for funcref.
+// CHECK-LABEL: @identity(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FN_ADDR:%.*]] = alloca ptr addrspace(20), align 4
+// CHECK-NEXT:store ptr addrspace(20) [[FN:%.*]], ptr [[FN_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr addrspace(20), ptr [[FN_ADDR]], align 4
+// CHECK-NEXT:ret ptr addrspace(20) [[TMP0]]
+//
+funcref_t identity(funcref_t fn) {
+  return fn;
+}
+
+void helper(funcref_t);
+
+// Pass funcref ref as an argument to a helper function.
+// CHECK-LABEL: 

[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D141581#4056464 , @lebedev.ri 
wrote:

> Why is it not sufficient to link to `RISCVTargetParserTableGen`, but is 
> sufficient to link to `LLVMTargetParser`?

This is because  the sources of clangBasic and clangDriver might be compiled 
before LLVMTargetParser is ready. In this case, compilation would fail because 
both libraries include the header file `llvm/TargetParser/RISCVTargetParser.h`, 
which needs the `inc` file generated by `RISCVTargetParserTableGen`.

  // quoting code from llvm/TargetParser/RISCVTargetParser.h
  enum CPUKind : unsigned {
  #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
  #define TUNE_PROC(ENUM, NAME) CK_##ENUM,
  #include "llvm/TargetParser/RISCVTargetParserDef.inc"
  };



> Does `RISCVTargetParserTableGen` itself not link to `LLVMTargetParser`?

Nope, there is no "linking" between these two components. It is just that 
`LLVMTargetParser` requires `RISCVTargetParserTableGen`. Therefore, if we say 
that `clangDriver` and `clangBasic` depend on `LLVMTargetParser` we make sure 
that the inclusion of the tablegen-generated file resolves correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D139926: [clangd] Add semantic tokens for angle brackets

2023-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> Note that we use this information to *animate* the matching tokens, i.e. when 
> the cursor is on one of them, both it and its counterpart get a special 
> highlighting. That's why it's so important that the language server 
> guarantees they always come in pairs.

Oh I see the argument here (somehow missed comment, probably because i had a 
stale window lying around), this totally makes sense. but I am still feeling 
uneasy due to implementation complexity (it's embarrassing but dealing with 
`>>` is quite problematic, still, with little value :/) + the UX we'll have in 
other editors by default.
Especially as this comes as two different `HighlightingKind`s and they're 
likely to get colored differently, and having your matching brackets in 
different colors is quite annoying.

I feel like editors can still have a quite good behaviour with existing 
operator highlights, as one can build an extra layer on top to provide 
"matching bracket" support, and whenever the data is broken (e.g. non-matching 
brackets) just keep using the results from last "successful" run.




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:408
+  Position End = Begin;
+  ++End.character;
+  addToken(*LRange, HighlightingKind::AngleBracketOpen);

there can be weird cases like (same goes for -1 below):
```foo>\
>```

can you add tests to make sure we're handling these properly (or not producing 
braces for them if it complicates the logic too much, i don't think there'll be 
many cases where they pop-up).



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:930
+  $Class[[B]] $LocalVariable_def[[b]];
+  int $LocalVariable_def[[i]] = 
static_cast$AngleBracketOpen[[<]]int$AngleBracketClose[[>]](3.5);
+  void *$LocalVariable_def[[p]] = 
reinterpret_cast$AngleBracketOpen[[<]]void *$AngleBracketClose[[>]](0);

could you also add tests for `>>` and `>>>` to make sure they're handled 
correctly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


[PATCH] D141855: [include-mapping] Parse zombie_names.html into a removed symbols map.

2023-01-16 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
VitaNuo added a reviewer: hokein.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141855

Files:
  clang/tools/include-mapping/gen_std.py


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -64,6 +64,14 @@
   default='cpp',
   help='Generate c or cpp symbols',
   required=True)
+  parser.add_argument('-output',
+  default='SymbolMap.inc',
+  help='path to the output file for symbol map',
+  required=True)
+  parser.add_argument('-removedoutput',
+  default='RemovedSymbolMap.inc',
+  help='path to the output file for removed symbols map',
+  required=False)
   return parser.parse_args()
 
 
@@ -87,6 +95,9 @@
   (symbol_index_root, "regex_constants.html", "std::regex_constants::"),
   (symbol_index_root, "this_thread.html", "std::this_thread::"),
 ]
+removed_symbols = cppreference_parser.GetSymbols(
+  [(symbol_index_root, "zombie_names.html", "std::")])
+WriteSymbols(args.language, removed_symbols, args.removedoutput, page_root)
   elif args.language == 'c':
 page_root = os.path.join(args.cppreference, "en", "c")
 symbol_index_root = page_root
@@ -96,24 +107,28 @@
 exit("Path %s doesn't exist!" % symbol_index_root)
 
   symbols = cppreference_parser.GetSymbols(parse_pages)
+  WriteSymbols(args.language, symbols, args.output, page_root)
 
+def WriteSymbols(language, symbols, path, page_root):
   # We don't have version information from the unzipped offline HTML files.
   # so we use the modified time of the symbol_index.html as the version.
   index_page_path = os.path.join(page_root, "index.html")
   cppreference_modified_date = datetime.datetime.fromtimestamp(
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
-  print(CODE_PREFIX % (args.language.upper(), cppreference_modified_date))
-  for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
-  sys.stderr.write("No header found for symbol %s\n" % symbol.name)
-else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
+  with open(path, "w") as f:  
+f.write(CODE_PREFIX % (language.upper(), cppreference_modified_date))
+f.write("\n")
+for symbol in symbols:
+  if len(symbol.headers) == 1:
+# SYMBOL(unqualified_name, namespace, header)
+f.write("SYMBOL(%s, %s, %s)\n" % (symbol.name, symbol.namespace,
+  symbol.headers[0]))
+  elif len(symbol.headers) == 0:
+sys.stderr.write("No header found for symbol %s\n" % symbol.name)
+  else:
+# FIXME: support symbols with multiple headers (e.g. std::move).
+sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
+symbol.name, ', '.join(symbol.headers)))
 
 
 if __name__ == '__main__':


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -64,6 +64,14 @@
   default='cpp',
   help='Generate c or cpp symbols',
   required=True)
+  parser.add_argument('-output',
+  default='SymbolMap.inc',
+  help='path to the output file for symbol map',
+  required=True)
+  parser.add_argument('-removedoutput',
+  default='RemovedSymbolMap.inc',
+  help='path to the output file for removed symbols map',
+  required=False)
   return parser.parse_args()
 
 
@@ -87,6 +95,9 @@
   (symbol_index_root, "regex_constants.html", "std::regex_constants::"),
   (symbol_index_root, "this_thread.html", "std::this_thread::"),
 ]
+removed_symbols = cppreference_parser.GetSymbols(
+  [(symbol_index_root, "zombie_names.html", "std::")])
+WriteSymbols(args.language, removed_symbols, args.removedoutput, page_root)
   elif args.language == 'c':
 page_root = os.path.join(args.cppreference, "en", "c")
 symbol_index_root = page_root
@@ -96,24 +107,28 @@
 exit("Path %s doesn't exist!" % symbol_index_root)
 
   symbols = 

[PATCH] D136554: Implement CWG2631

2023-01-16 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm added a comment.

I've reduced a regression on:

commit ca619613801233ef2def8c3cc7d311d5ed0033cb 
 (HEAD, 
refs/bisect/bad)
Author: Corentin Jabot 
Date:   Sun Oct 23 17:32:58 2022 +0200

  template  int f(T) { return 42; }
  
  struct A {
 int x = f(A());
 A() { }
  };
  
  void foo() { A(); }



  clang++ t2.C -c
  t2.C:4:12: warning: stack nearly exhausted; compilation time may suffer, and 
crashes due to stack overflow are likely [-Wstack-exhausted]
 int x = f(A());
 ^
  Segmentation fault (core dumped)

@cor3ntin would you like me to open a new issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D141858: [clang][Interp] Fix Pointer::toAPValue() for expressions

2023-01-16 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is now relevant because we generate pointers for expressions more often, 
since `MaterializeTemporaryExpr`s work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141858

Files:
  clang/lib/AST/Interp/Pointer.cpp


Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -105,6 +105,10 @@
 if (isUnknownSizeArray()) {
   IsOnePastEnd = false;
   Offset = CharUnits::Zero();
+} else if (getFieldDesc()->asExpr()) {
+  // Pointer pointing to a an expression.
+  IsOnePastEnd = false;
+  Offset = CharUnits::Zero();
 } else {
   // TODO: compute the offset into the object.
   Offset = CharUnits::Zero();


Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -105,6 +105,10 @@
 if (isUnknownSizeArray()) {
   IsOnePastEnd = false;
   Offset = CharUnits::Zero();
+} else if (getFieldDesc()->asExpr()) {
+  // Pointer pointing to a an expression.
+  IsOnePastEnd = false;
+  Offset = CharUnits::Zero();
 } else {
   // TODO: compute the offset into the object.
   Offset = CharUnits::Zero();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Why is it not sufficient to link to `RISCVTargetParserTableGen`, but is 
sufficient to link to `LLVMTargetParser`?
Does `RISCVTargetParserTableGen` itself not link to `LLVMTargetParser`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[clang] caf393d - Fix format for `case` in .proto files

2023-01-16 Thread Krasimir Georgiev via cfe-commits

Author: Matt Kulukundis
Date: 2023-01-16T17:43:50Z
New Revision: caf393da1823d50852f51604b3793e8f4a23c140

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

LOG: Fix format for `case` in .proto files

Fix format for `case` in .proto files

Reviewed By: krasimir, echristo

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestProto.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index c97ecc7821209..effb0ecb368bb 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -590,8 +590,9 @@ bool UnwrappedLineParser::parseLevel(const FormatToken 
*OpeningBrace,
   [[fallthrough]];
 }
 case tok::kw_case:
-  if (Style.isVerilog() ||
+  if (Style.isProto() || Style.isVerilog() ||
   (Style.isJavaScript() && Line->MustBeDeclaration)) {
+// Proto: there are no switch/case statements
 // Verilog: Case labels don't have this word. We handle case
 // labels including default in TokenAnnotator.
 // JavaScript: A 'case: string' style field declaration.
@@ -1620,7 +1621,11 @@ void UnwrappedLineParser::parseStructuralElement(
 // e.g. "default void f() {}" in a Java interface.
 break;
   case tok::kw_case:
-// In Verilog switch is called case.
+// Proto: there are no switch/case statements.
+if (Style.isProto()) {
+  nextToken();
+  return;
+}
 if (Style.isVerilog()) {
   parseBlock();
   addUnwrappedLine();
@@ -2100,6 +2105,11 @@ void UnwrappedLineParser::parseStructuralElement(
   parseNew();
   break;
 case tok::kw_case:
+  // Proto: there are no switch/case statements.
+  if (Style.isProto()) {
+nextToken();
+return;
+  }
   // In Verilog switch is called case.
   if (Style.isVerilog()) {
 parseBlock();

diff  --git a/clang/unittests/Format/FormatTestProto.cpp 
b/clang/unittests/Format/FormatTestProto.cpp
index 1ff7c22a6df78..5de40b6eae597 100644
--- a/clang/unittests/Format/FormatTestProto.cpp
+++ b/clang/unittests/Format/FormatTestProto.cpp
@@ -113,6 +113,13 @@ TEST_F(FormatTestProto, EnumAsFieldName) {
"}");
 }
 
+TEST_F(FormatTestProto, CaseAsFieldName) {
+  verifyFormat("message SomeMessage {\n"
+   "  required string case = 1;\n"
+   "  repeated int32 fizz = 2;\n"
+   "}");
+}
+
 TEST_F(FormatTestProto, UnderstandsReturns) {
   verifyFormat("rpc Search(SearchRequest) returns (SearchResponse);");
 }



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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

clangBasic and clangDriver already have a dependency on TargetParser (see 
LLVM_LINK_COMPONENTS at the beginning of corresponding files). Is that not 
enough?
Will it build if you just remove the additional dependency?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

2023-01-16 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Also, could you open a bug report about the strange exception behavior on 
GitHub? Hopefully someone working on conformance can take a look.


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

https://reviews.llvm.org/D135495

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


[PATCH] D141717: [Clang] Only emit textual LLVM-IR in device only mode

2023-01-16 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

I made the phases always go to `Assemble` but it didn't make a difference. We 
still get the textual IR here without the exception I added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141717

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


[PATCH] D141381: [codegen] Store address of indirect arguments on the stack

2023-01-16 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve added a comment.

There is a real regression in 
`lldb/test/API/functionalities/param_entry_vals/basic_entry_values/` when this 
is compiled with O2 :

  __attribute__((noinline)) void func15(StructPassedViaPointerToTemporaryCopy 
S) 

It seems that, prior to this patch, `S` had debug information in O2 
 builds. I'll investigate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141381

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


[clang] 0f42221 - [AArch64] Move default extensions from clang Driver to TargetParser

2023-01-16 Thread David Green via cfe-commits

Author: David Green
Date: 2023-01-16T16:58:18Z
New Revision: 0f422215ac63da4cb610a21998a2d24c11703fbf

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

LOG: [AArch64] Move default extensions from clang Driver to TargetParser

The default extensions would be better added in the TargetParser, not by
the driver. This removes the addition of +i8mm and +bf16 features in the
driver as they are already added in 8.6/9.1 architectures. AEK_MOPS and
AEK_HBC have been added to 8.8/9.3 architectures to replace the need for
+hbc and +mops features.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-hbc.c
clang/test/Driver/aarch64-i8mm.c
clang/test/Driver/aarch64-mops.c
clang/test/Driver/aarch64-v91a.c
clang/test/Driver/aarch64-v92a.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index fcbf2e08d12df..2c559cc8b3b90 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -485,18 +485,6 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
 }
   }
 
-  // FIXME: these insertions should ideally be automated using default
-  // extensions support from the backend target parser.
-  if (V8Version >= 6 || V9Version >= 1)
-Features.insert(std::next(Features.begin() + ArchFeatPos),
-{"+i8mm", "+bf16"});
-
-  // For Armv8.8-a/Armv9.3-a or later, FEAT_HBC and FEAT_MOPS are enabled by
-  // default.
-  if (V8Version >= 8 || V9Version >= 3)
-Features.insert(std::next(Features.begin() + ArchFeatPos),
-{"+hbc", "+mops"});
-
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_mno_unaligned_access))

diff  --git a/clang/test/Driver/aarch64-hbc.c b/clang/test/Driver/aarch64-hbc.c
index b25e7c3f52809..90b11b1fd8078 100644
--- a/clang/test/Driver/aarch64-hbc.c
+++ b/clang/test/Driver/aarch64-hbc.c
@@ -1,12 +1,14 @@
 // Test that target feature hbc is implemented and available correctly
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.7-a+hbc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+hbc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+nohbc %s 
2>&1 | FileCheck %s --check-prefix=NO_HBC
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.2-a+hbc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+hbc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+nohbc %s 
2>&1 | FileCheck %s --check-prefix=NO_HBC
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.7-a+hbc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.8-a   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.8-a+hbc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.8-a+nohbc %s 2>&1 | FileCheck %s --check-prefix=NO_HBC
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.2-a+hbc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.3-a   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.3-a+hbc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.3-a+nohbc %s 2>&1 | FileCheck %s --check-prefix=NO_HBC
 
-// CHECK: "-target-feature" "+hbc"
-// NO_HBC: "-target-feature" "-hbc"
+// CHECK: "target-features"="{{.*}},+hbc
+// NO_HBC: "target-features"="{{.*}},-hbc
+
+void test() {}
\ No newline at end of file

diff  --git a/clang/test/Driver/aarch64-i8mm.c 
b/clang/test/Driver/aarch64-i8mm.c
index 4036996e5a3fc..a5e1c4863a273 100644
--- a/clang/test/Driver/aarch64-i8mm.c
+++ b/clang/test/Driver/aarch64-i8mm.c
@@ -1,7 +1,11 @@
 // The 8-bit integer matrix multiply extension is a mandatory component of the
 // Armv8.6-A extensions, but is permitted as an optional feature for any
 // implementation of Armv8.2-A to Armv8.5-A (inclusive)
-// RUN: %clang -target aarch64 -march=armv8.5a -### -c %s 2>&1 | 

[PATCH] D141518: [AArch64] Move default extensions from clang Driver to TargetParser

2023-01-16 Thread Dave Green 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 rG0f422215ac63: [AArch64] Move default extensions from clang 
Driver to TargetParser (authored by dmgreen).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D141518?vs=488255=489578#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141518

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-hbc.c
  clang/test/Driver/aarch64-i8mm.c
  clang/test/Driver/aarch64-mops.c
  clang/test/Driver/aarch64-v91a.c
  clang/test/Driver/aarch64-v92a.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.h

Index: llvm/include/llvm/TargetParser/AArch64TargetParser.h
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -312,12 +312,12 @@
 constexpr unsigned BaseNoCrypto = ARMV8_5A.DefaultExts ^ AArch64::AEK_CRYPTO; // 8.6 onwards has no AEK_CRYPTO
 inline constexpr ArchInfo ARMV8_6A  = { VersionTuple{8, 6}, AProfile, "armv8.6-a", "+v8.6a", (BaseNoCrypto | AArch64::AEK_SM4 | AArch64::AEK_SHA3 | AArch64::AEK_BF16 | AArch64::AEK_SHA2 | AArch64::AEK_AES | AArch64::AEK_I8MM)};
 inline constexpr ArchInfo ARMV8_7A  = { VersionTuple{8, 7}, AProfile, "armv8.7-a", "+v8.7a", (ARMV8_6A.DefaultExts)};
-inline constexpr ArchInfo ARMV8_8A  = { VersionTuple{8, 8}, AProfile, "armv8.8-a", "+v8.8a", (ARMV8_7A.DefaultExts)};
+inline constexpr ArchInfo ARMV8_8A  = { VersionTuple{8, 8}, AProfile, "armv8.8-a", "+v8.8a", (ARMV8_7A.DefaultExts | AArch64::AEK_MOPS | AArch64::AEK_HBC)};
 inline constexpr ArchInfo ARMV8_9A  = { VersionTuple{8, 9}, AProfile, "armv8.9-a", "+v8.9a", (ARMV8_8A.DefaultExts)};
 inline constexpr ArchInfo ARMV9A= { VersionTuple{9, 0}, AProfile, "armv9-a", "+v9a", (BaseNoCrypto | AArch64::AEK_SVE | AArch64::AEK_SVE2)};
 inline constexpr ArchInfo ARMV9_1A  = { VersionTuple{9, 1}, AProfile, "armv9.1-a", "+v9.1a", (ARMV9A.DefaultExts | AArch64::AEK_BF16 | AArch64::AEK_I8MM)};
 inline constexpr ArchInfo ARMV9_2A  = { VersionTuple{9, 2}, AProfile, "armv9.2-a", "+v9.2a", (ARMV9_1A.DefaultExts)};
-inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, AProfile, "armv9.3-a", "+v9.3a", (ARMV9_2A.DefaultExts)};
+inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, AProfile, "armv9.3-a", "+v9.3a", (ARMV9_2A.DefaultExts | AArch64::AEK_MOPS | AArch64::AEK_HBC)};
 inline constexpr ArchInfo ARMV9_4A  = { VersionTuple{9, 4}, AProfile, "armv9.4-a", "+v9.4a", (ARMV9_3A.DefaultExts)};
 // For v8-R, we do not enable crypto and align with GCC that enables a more minimal set of optional architecture extensions.
 inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, "armv8-r", "+v8r", ((BaseNoCrypto ^ AArch64::AEK_LSE) | AArch64::AEK_SSBS | AArch64::AEK_FP16 | AArch64::AEK_FP16FML | AArch64::AEK_SB), };
Index: clang/test/Driver/aarch64-v92a.c
===
--- clang/test/Driver/aarch64-v92a.c
+++ clang/test/Driver/aarch64-v92a.c
@@ -4,7 +4,7 @@
 // RUN: %clang -target aarch64 -mlittle-endian -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A %s
 // RUN: %clang -target aarch64_be -mlittle-endian -march=armv9.2a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A %s
 // RUN: %clang -target aarch64_be -mlittle-endian -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A %s
-// GENERICV92A: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v9.2a" "-target-feature" "+i8mm" "-target-feature" "+bf16" "-target-feature" "+sve" "-target-feature" "+sve2"
+// GENERICV92A: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v9.2a" "-target-feature" "+sve" "-target-feature" "+sve2"
 
 // RUN: %clang -target aarch64_be -march=armv9.2a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
 // RUN: %clang -target aarch64_be -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
@@ -12,4 +12,4 @@
 // RUN: %clang -target aarch64 -mbig-endian -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.2a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
-// GENERICV92A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v9.2a" "-target-feature" "+i8mm" "-target-feature" "+bf16" "-target-feature" "+sve" "-target-feature" "+sve2"
+// GENERICV92A-BE: "-cc1"{{.*}} "-triple" 

[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-16 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, tra, yaxunl, 
JonChesterfield.
Herald added subscribers: mattd, gchakrabarti, asavonic.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, jholewinski.
Herald added a project: clang.

Much like the changes in D141859 , this patch 
allows the `nvptx-arch`
tool to be built and provided with every distrubition of LLVM / Clang.
This will make it more reliable for our toolchains to depend on. The
changes here configure a version that dynamically loads CUDA if it was
not found at build time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141861

Files:
  clang/tools/nvptx-arch/CMakeLists.txt
  clang/tools/nvptx-arch/NVPTXArch.cpp

Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- clang/tools/nvptx-arch/NVPTXArch.cpp
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -11,6 +11,12 @@
 //
 //===--===//
 
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
 #if defined(__has_include)
 #if __has_include("cuda.h")
 #include "cuda.h"
@@ -23,11 +29,53 @@
 #endif
 
 #if !CUDA_HEADER_FOUND
-int main() { return 1; }
-#else
+typedef enum cudaError_enum {
+  CUDA_SUCCESS = 0,
+  CUDA_ERROR_NO_DEVICE = 100,
+} CUresult;
 
-#include 
-#include 
+typedef enum CUdevice_attribute_enum {
+  CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75,
+  CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76,
+} CUdevice_attribute;
+
+typedef uint32_t CUdevice;
+
+CUresult (*cuInit)(unsigned int);
+CUresult (*cuDeviceGetCount)(int *);
+CUresult (*cuGetErrorString)(CUresult, const char **);
+CUresult (*cuDeviceGet)(CUdevice *, int);
+CUresult (*cuDeviceGetAttribute)(int *, CUdevice_attribute, CUdevice);
+
+constexpr const char *DynamicCudaPath = "libcuda.so";
+
+llvm::Error loadCUDA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicCudaPath, ));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s\n", DynamicCudaPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   \
+  {\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   \
+if (!SymbolPtr)\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   \
+ "Failed to 'dlsym' " #SYMBOL);\
+SYMBOL = reinterpret_cast(SymbolPtr);\
+  }
+  DYNAMIC_INIT(cuInit);
+  DYNAMIC_INIT(cuDeviceGetCount);
+  DYNAMIC_INIT(cuGetErrorString);
+  DYNAMIC_INIT(cuDeviceGet);
+  DYNAMIC_INIT(cuDeviceGetAttribute);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+#else
+llvm::Error loadCUDA() { return llvm::Error::success(); }
+#endif
 
 static int handleError(CUresult Err) {
   const char *ErrStr = nullptr;
@@ -39,6 +87,12 @@
 }
 
 int main() {
+  // Attempt to load the NVPTX driver runtime.
+  if (llvm::Error Err = loadCUDA()) {
+logAllUnhandledErrors(std::move(Err), llvm::errs());
+return EXIT_FAILURE;
+  }
+
   if (CUresult Err = cuInit(0)) {
 if (Err == CUDA_ERROR_NO_DEVICE)
   return EXIT_SUCCESS;
@@ -68,5 +122,3 @@
   }
   return EXIT_SUCCESS;
 }
-
-#endif
Index: clang/tools/nvptx-arch/CMakeLists.txt
===
--- clang/tools/nvptx-arch/CMakeLists.txt
+++ clang/tools/nvptx-arch/CMakeLists.txt
@@ -6,6 +6,8 @@
 # //
 # //======//
 
+set(LLVM_LINK_COMPONENTS Support)
+add_clang_tool(nvptx-arch NVPTXArch.cpp)
 
 # TODO: This is deprecated. Since CMake 3.17 we can use FindCUDAToolkit instead.
 find_package(CUDA QUIET)
@@ -15,14 +17,8 @@
   find_library(cuda-library NAMES cuda HINTS "${CUDA_LIBDIR}/stubs")
 endif()
 
-if (NOT CUDA_FOUND OR NOT cuda-library)
-  message(STATUS "Not building nvptx-arch: cuda runtime not found")
-  return()
+# If we found the CUDA library directly we just dynamically link against it.
+if (CUDA_FOUND AND cuda-library)
+  target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
+  target_link_libraries(nvptx-arch PRIVATE ${cuda-library})
 endif()
-
-add_clang_tool(nvptx-arch NVPTXArch.cpp)
-
-set_target_properties(nvptx-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
-target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
-
-target_link_libraries(nvptx-arch PRIVATE ${cuda-library})
___
cfe-commits mailing list

[PATCH] D141625: [DeclContext] Sort the Decls before adding into DeclContext

2023-01-16 Thread Steven Wu via Phabricator via cfe-commits
steven_wu updated this revision to Diff 489587.
steven_wu added a comment.

Minor touch up on the test case. Also add some comments in test to explain what 
is being tested.

I don't measure any performance regression from `-fsyntax-only` on Foundation.h 
but if there are some other performance benchmark I need to be tested first, 
let me know.
Alternatively, there can be a even safer fix by moving the sorting into 
`numberAnonymousDeclsWithin` which seems to be only used in serialization. I 
can change to that to be extra safe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141625

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Modules/decl-params-determinisim.m


Index: clang/test/Modules/decl-params-determinisim.m
===
--- /dev/null
+++ clang/test/Modules/decl-params-determinisim.m
@@ -0,0 +1,70 @@
+/// Test determinisim when serializing anonymous decls. Create enough Decls in
+/// DeclContext that can overflow the small storage of SmallPtrSet to make sure
+/// the serialization does not rely on iteration order of SmallPtrSet.
+// RUN: rm -rf %t.dir
+// RUN: split-file %s %t.dir
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 
\
+// RUN:   -I%t.dir/headers %t.dir/main.m -fdisable-module-hash -Wno-visibility
+// RUN: mv %t.dir/cache/A.pcm %t1.pcm
+// RUN: rm -rf %t.dir/cache
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 
\
+// RUN:   -I%t.dir/headers %t.dir/main.m -fdisable-module-hash -Wno-visibility
+// RUN: mv %t.dir/cache/A.pcm %t2.pcm
+// RUN: diff %t1.pcm %t2.pcm
+
+//--- headers/a.h
+void f(struct A0 *a0,
+   struct A1 *a1,
+   struct A2 *a2,
+   struct A3 *a3,
+   struct A4 *a4,
+   struct A5 *a5,
+   struct A6 *a6,
+   struct A7 *a7,
+   struct A8 *a8,
+   struct A9 *a9,
+   struct A10 *a10,
+   struct A11 *a11,
+   struct A12 *a12,
+   struct A13 *a13,
+   struct A14 *a14,
+   struct A15 *a15,
+   struct A16 *a16,
+   struct A17 *a17,
+   struct A18 *a18,
+   struct A19 *a19,
+   struct A20 *a20,
+   struct A21 *a21,
+   struct A22 *a22,
+   struct A23 *a23,
+   struct A24 *a24,
+   struct A25 *a25,
+   struct A26 *a26,
+   struct A27 *a27,
+   struct A28 *a28,
+   struct A29 *a29,
+   struct A30 *a30,
+   struct A31 *a31,
+   struct A32 *a32,
+   struct A33 *a33,
+   struct A34 *a34,
+   struct A35 *a35,
+   struct A36 *a36,
+   struct A37 *a37,
+   struct A38 *a38,
+   struct A39 *a39,
+   struct A40 *a40);
+
+
+//--- headers/module.modulemap
+
+module A {
+  header "a.h"
+}
+
+//--- main.m
+
+#import 
+
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -6986,6 +6986,15 @@
 continue;
   DeclsInPrototype.push_back(ND);
 }
+// Sort DeclsInPrototype based on raw encoding of the source location.
+// Scope::decls() is iterating over a SmallPtrSet so sort the Decls before
+// moving to DeclContext. This provides a stable ordering for traversing
+// Decls in DeclContext, which is important for tasks like ASTWriter for
+// deterministic output.
+llvm::sort(DeclsInPrototype, [](Decl *D1, Decl *D2) {
+  return D1->getLocation().getRawEncoding() <
+ D2->getLocation().getRawEncoding();
+});
   }
 
   // Remember that we parsed a function type, and remember the attributes.


Index: clang/test/Modules/decl-params-determinisim.m
===
--- /dev/null
+++ clang/test/Modules/decl-params-determinisim.m
@@ -0,0 +1,70 @@
+/// Test determinisim when serializing anonymous decls. Create enough Decls in
+/// DeclContext that can overflow the small storage of SmallPtrSet to make sure
+/// the serialization does not rely on iteration order of SmallPtrSet.
+// RUN: rm -rf %t.dir
+// RUN: split-file %s %t.dir
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   -I%t.dir/headers %t.dir/main.m -fdisable-module-hash -Wno-visibility
+// RUN: mv %t.dir/cache/A.pcm %t1.pcm
+// RUN: rm -rf %t.dir/cache
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   -I%t.dir/headers %t.dir/main.m -fdisable-module-hash -Wno-visibility
+// RUN: mv %t.dir/cache/A.pcm %t2.pcm
+// RUN: diff %t1.pcm %t2.pcm
+
+//--- headers/a.h
+void f(struct A0 *a0,
+   struct A1 *a1,
+   struct A2 *a2,
+   struct A3 *a3,
+   struct 

[PATCH] D141625: [DeclContext] Sort the Decls before adding into DeclContext

2023-01-16 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Actually, sorting in `numberAnonymousDeclsWithin` doesn't work for some reasons.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141625

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


Re: [PATCH] D136554: Implement CWG2631

2023-01-16 Thread Corentin via cfe-commits
Yes please! However the warning looks correct to me in that case. A
constructs x which constructs A etc.

On Mon, Jan 16, 2023, 18:00 Chris Bowler via Phabricator <
revi...@reviews.llvm.org> wrote:

> cebowleratibm added a comment.
>
> I've reduced a regression on:
>
> commit ca619613801233ef2def8c3cc7d311d5ed0033cb <
> https://reviews.llvm.org/rGca619613801233ef2def8c3cc7d311d5ed0033cb>
> (HEAD, refs/bisect/bad)
> Author: Corentin Jabot 
> Date:   Sun Oct 23 17:32:58 2022 +0200
>
>   template  int f(T) { return 42; }
>
>   struct A {
>  int x = f(A());
>  A() { }
>   };
>
>   void foo() { A(); }
>
>
>
>   clang++ t2.C -c
>   t2.C:4:12: warning: stack nearly exhausted; compilation time may suffer,
> and crashes due to stack overflow are likely [-Wstack-exhausted]
>  int x = f(A());
>  ^
>   Segmentation fault (core dumped)
>
> @cor3ntin would you like me to open a new issue?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D136554/new/
>
> https://reviews.llvm.org/D136554
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140158: [CUDA] Allow targeting NVPTX directly without a host toolchain

2023-01-16 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 489554.
jhuber6 added a comment.

Updating. Used a different method to determine if we need to use `.cubin` or 
`.o`. It's a little ugly but I don't think there's a better way to do it.

Also I just realized that if this goes through I could probably heavily 
simplify linker wrapper code by just invoking `clang --target=nvptx64` instead 
of calling the tools manually. So that's another benefit to this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140158

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/test/Driver/cuda-cross-compiling.c

Index: clang/test/Driver/cuda-cross-compiling.c
===
--- /dev/null
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -0,0 +1,68 @@
+// Tests the driver when targeting the NVPTX architecture directly without a
+// host toolchain to perform CUDA mappings.
+
+// REQUIRES: nvptx-registered-target
+
+//
+// Test the generated phases when targeting NVPTX.
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -ccc-print-phases %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=PHASES %s
+
+//  PHASES: 0: input, "[[INPUT:.+]]", c
+// PHASES-NEXT: 1: preprocessor, {0}, cpp-output
+// PHASES-NEXT: 2: compiler, {1}, ir
+// PHASES-NEXT: 3: backend, {2}, assembler
+// PHASES-NEXT: 4: assembler, {3}, object
+// PHASES-NEXT: 5: linker, {4}, image
+
+//
+// Test the generated bindings when targeting NVPTX.
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -ccc-print-bindings %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=BINDINGS %s
+
+//  BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[PTX:.+]].s"
+// BINDINGS-NEXT: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[PTX]].s"], output: "[[CUBIN:.+]].o"
+// BINDINGS-NEXT: "nvptx64-nvidia-cuda" - "NVPTX::Linker", inputs: ["[[CUBIN]].o"], output: "a.out"
+
+//
+// Test the generated arguments to the CUDA binary utils when targeting NVPTX. 
+// Ensure that the '.o' files are converted to '.cubin' if produced internally.
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=ARGS %s
+
+//  ARGS: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_61" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
+// ARGS-NEXT: ptxas" "-m64" "-O0" "--gpu-name" "sm_61" "--output-file" "[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
+// ARGS-NEXT: nvlink" "-o" "a.out" "-arch" "sm_61" {{.*}} "[[CUBIN]].cubin"
+
+//
+// Test the generated arguments to the CUDA binary utils when targeting NVPTX. 
+// Ensure that we emit '.o' files if compiled with '-c'
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -c -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OBJECT %s
+
+//  OBJECT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_61" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
+// OBJECT-NEXT: ptxas" "-m64" "-O0" "--gpu-name" "sm_61" "--output-file" "[[OBJ:.+]].o" "[[PTX]].s" "-c"
+
+//
+// Test the generated arguments to the CUDA binary utils when targeting NVPTX. 
+// Ensure that we copy input '.o' files to '.cubin' files when linking.
+//
+// RUN: touch %t.o
+// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -### %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK %s
+
+// LINK: nvlink" "-o" "a.out" "-arch" "sm_61" {{.*}} "{{.*}}.cubin"
+
+//
+// Test the generated arguments default to a value with no architecture. 
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DEFAULT %s
+
+//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_35" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
+// DEFAULT-NEXT: ptxas" "-m64" "-O0" "--gpu-name" "sm_35" "--output-file" "[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
+// DEFAULT-NEXT: nvlink" "-o" "a.out" "-arch" "sm_35" {{.*}} "[[CUBIN]].cubin"
Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -95,9 +95,22 @@
 
 // Runs fatbinary, which combines GPU object files ("cubin" files) and/or PTX
 // assembly into a single output file.
+class LLVM_LIBRARY_VISIBILITY FatBinary : public Tool {
+ public:
+   FatBinary(const ToolChain ) : Tool("NVPTX::Linker", "fatbinary", TC) {}
+
+   bool hasIntegratedCPP() const override { return false; }
+
+   void ConstructJob(Compilation , const JobAction ,
+ const InputInfo , const InputInfoList ,
+ const llvm::opt::ArgList ,
+ const char *LinkingOutput) const override;
+};
+
+// Runs nvlink, which links GPU object files ("cubin" files) into a single file.
 class LLVM_LIBRARY_VISIBILITY 

[PATCH] D139926: [clangd] Add semantic tokens for angle brackets

2023-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Sorry for missing this one, apparently I've already started writing an answer 
but got context switching and forgot about it.

> This is needed for clients that would like to visualize matching
> opening and closing angle brackets, which can be valuable in non-trivial
> template declarations or instantiations.

I am not sure how the clients will make use of this information to visualize 
"matching" angle brackets. all the opening and closing brackets are likely to 
be visualized in the same way (respectively), no?
This will only make sure we have a distinction between `<<` and `>>` used as 
operators vs `<`/`>` and the rest of the work to highlight matching braces 
needs to be specially done by the editor.
Since we've the distinction of "operator" now as @nridge pointed out, I would 
rather want editors to use that information to skip brackets that have the 
operator highlighting.
I am not sure what concrete cases you've (it would help if you could provide 
some examples) for the incomplete code argument, because it goes both ways, 
i.e. I don't think the false positives you get in operators vs template 
argument lists won't be any different (e.g. foo x, where `foo` is not 
defined won't have right highlighting).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-01-16 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:4129
+  let Documentation = [WebAssemblyExportNameDocs];
+  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
+}

erichkeane wrote:
> pmatos wrote:
> > erichkeane wrote:
> > > Note that it seems this is likely not going to work correctly on template 
> > > type aliases!  You probably want to make sure that is acceptable to you.
> > Documentation says about Subject:
> > 
> > ```
> >   // The things to which an attribute can appertain
> >   SubjectList Subjects;
> > ```
> > 
> > Given this can be attached to function pointer types, is the subject then 
> > just Type ?
> IIRC, the list of subjects are the Decls and Stmt types that are possibly 
> allowed.  I don't thnk it would be just 'Type' there.
> 
> As you have it, it is only allowed on TypedefNameDecl.
> 
> See the SubsetSubject's at the top of this file for some examples on how you 
> could constrain a special matcher to only work on function pointer decls.
Good point @erichkeane . What do you think of FunctionPointer implementation 
here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


Re: [clang] f2d301f - Revert "[codegen] Store address of indirect arguments on the stack"

2023-01-16 Thread Roman Lebedev via cfe-commits
Reminder to please always mention the reason for the revert/recommit
in the commit message.

On Mon, Jan 16, 2023 at 7:05 PM Felipe de Azevedo Piovezan via
cfe-commits  wrote:
>
>
> Author: Felipe de Azevedo Piovezan
> Date: 2023-01-16T13:05:22-03:00
> New Revision: f2d301fe82869f881b86b51da7b4752972c66707
>
> URL: 
> https://github.com/llvm/llvm-project/commit/f2d301fe82869f881b86b51da7b4752972c66707
> DIFF: 
> https://github.com/llvm/llvm-project/commit/f2d301fe82869f881b86b51da7b4752972c66707.diff
>
> LOG: Revert "[codegen] Store address of indirect arguments on the stack"
>
> This reverts commit 7e4447a17db4a070f01c8f8a87505a4b2a1b0e3a.
>
> Added:
>
>
> Modified:
> clang/docs/ReleaseNotes.rst
> clang/lib/CodeGen/CGDebugInfo.cpp
> clang/lib/CodeGen/CGDebugInfo.h
> clang/lib/CodeGen/CGDecl.cpp
> clang/test/CodeGen/aarch64-ls64.c
> clang/test/CodeGen/atomic-arm64.c
> clang/test/CodeGenCXX/amdgcn-func-arg.cpp
> clang/test/CodeGenCXX/debug-info.cpp
> clang/test/CodeGenCXX/derived-to-base-conv.cpp
> clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
> clang/test/CodeGenCoroutines/coro-params.cpp
> clang/test/OpenMP/for_firstprivate_codegen.cpp
> clang/test/OpenMP/parallel_firstprivate_codegen.cpp
> clang/test/OpenMP/sections_firstprivate_codegen.cpp
> clang/test/OpenMP/single_firstprivate_codegen.cpp
> clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
> 
> clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
> 
> clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
> clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
> clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
> clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
> 
> clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
> clang/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp
> clang/test/OpenMP/teams_firstprivate_codegen.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> index 731d10ac64a3f..3bbab951e8a8c 100644
> --- a/clang/docs/ReleaseNotes.rst
> +++ b/clang/docs/ReleaseNotes.rst
> @@ -500,9 +500,6 @@ Non-comprehensive list of changes in this release
>  - Clang can now generate a PCH when using ``-fdelayed-template-parsing`` for
>code with templates containing loop hint pragmas, OpenMP pragmas, and
>``#pragma unused``.
> -- Clang now saves the address of ABI-indirect function parameters on the 
> stack,
> -  improving the debug information available in programs compiled without
> -  optimizations.
>
>
>  New Compiler Flags
>
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index f2d558456fde4..f53a9d00ae5fd 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -4822,10 +4822,9 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
>
>  llvm::DILocalVariable *
>  CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI,
> -  unsigned ArgNo, CGBuilderTy ,
> -  const bool UsePointerValue) {
> +  unsigned ArgNo, CGBuilderTy ) {
>assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
> -  return EmitDeclare(VD, AI, ArgNo, Builder, UsePointerValue);
> +  return EmitDeclare(VD, AI, ArgNo, Builder);
>  }
>
>  namespace {
>
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.h 
> b/clang/lib/CodeGen/CGDebugInfo.h
> index 10660a2550b56..95484a060cd88 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.h
> +++ b/clang/lib/CodeGen/CGDebugInfo.h
> @@ -487,9 +487,10 @@ class CGDebugInfo {
>
>/// Emit call to \c llvm.dbg.declare for an argument variable
>/// declaration.
> -  llvm::DILocalVariable *
> -  EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, unsigned 
> ArgNo,
> -   CGBuilderTy , bool UsePointerValue = 
> false);
> +  llvm::DILocalVariable *EmitDeclareOfArgVariable(const VarDecl *Decl,
> +  llvm::Value *AI,
> +  unsigned ArgNo,
> +  CGBuilderTy );
>
>/// Emit call to \c llvm.dbg.declare for the block-literal argument
>/// to a block invocation function.
>
> diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
> index a70997f5b27b8..ceaddc4e694ac 100644
> --- a/clang/lib/CodeGen/CGDecl.cpp
> +++ b/clang/lib/CodeGen/CGDecl.cpp
> @@ -2476,8 +2476,6 @@ void CodeGenFunction::EmitParmDecl(const VarDecl , 
> ParamValue Arg,
>Address AllocaPtr = Address::invalid();
>bool DoStore = false;
>bool IsScalar = hasScalarEvaluationKind(Ty);
> -  

[PATCH] D141422: [clang][sema][Matrix] Move code from try-cast to `TypeLocVisitor`. NFC intended.

2023-01-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141422

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


[PATCH] D141381: [codegen] Store address of indirect arguments on the stack

2023-01-16 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve added a comment.

Windows failures happening in Flang's MLIR stage, likely unrelated to this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141381

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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

@jrtc27, @thakis, @craig.topper - gentle ping,  it would be great if I could 
unlock @mgorny with this patch for the issue they are seeing at 
https://reviews.llvm.org/rGac1ffd3caca12c254e0b8c847aa8ce8e51b6cfbf

Francesco


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

I though Clang Basic is a leaf library and must not depend on anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141547: Fix format for `case` in .proto files

2023-01-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141547

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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D141581#4056503 , @fpetrogalli 
wrote:

> This is because the sources of clangBasic and clangDriver might be compiled 
> before LLVMTargetParser is ready.

...

> Therefore, if we say that clangDriver and clangBasic depend on 
> LLVMTargetParser we make sure that the inclusion of the tablegen-generated 
> file resolves correctly.

Sorry, I don't follow. If I read correctly, you're saying that clang libraries 
might begin to //compile// before their DEPENDS dependency is built (implying 
that DEPENDS clause only guarantees that the dependency is ready at //link// 
stage). If it is true, the proposed patch changes nothing -- the sources might 
still start to compile before cmake decides to generate inc file, because it is 
only needed at link stage.
Am I missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141838: [clang-tidy] fix a false positive of `cppcoreguidelines-avoid-non-const-global-variables`

2023-01-16 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I'm not convinced this is the correct fix.
The guildline 

 states that tools should flag all variables declared at global or namespace 
scope.
Therefore we shouldn't be flagging any class static members, no matter if they 
are public, private or protected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141838

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


[PATCH] D141858: [clang][Interp] Fix Pointer::toAPValue() for expressions

2023-01-16 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 489581.

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

https://reviews.llvm.org/D141858

Files:
  clang/lib/AST/Interp/Pointer.cpp


Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -105,6 +105,10 @@
 if (isUnknownSizeArray()) {
   IsOnePastEnd = false;
   Offset = CharUnits::Zero();
+} else if (Desc->asExpr()) {
+  // Pointer pointing to a an expression.
+  IsOnePastEnd = false;
+  Offset = CharUnits::Zero();
 } else {
   // TODO: compute the offset into the object.
   Offset = CharUnits::Zero();


Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -105,6 +105,10 @@
 if (isUnknownSizeArray()) {
   IsOnePastEnd = false;
   Offset = CharUnits::Zero();
+} else if (Desc->asExpr()) {
+  // Pointer pointing to a an expression.
+  IsOnePastEnd = false;
+  Offset = CharUnits::Zero();
 } else {
   // TODO: compute the offset into the object.
   Offset = CharUnits::Zero();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141859: [amdgpu-arch] Dynamically load the HSA runtime if not found during the build

2023-01-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Yes, ok. Not thrilled about the copy from openmp but we can fix that as 
soon as we agree on a subdir to put code shared between llvm/clang/openmp and 
that has been tricky to achieve consensus on. Feature is good, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141859

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


[PATCH] D141862: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

2023-01-16 Thread Xing Xue via Phabricator via cfe-commits
xingxue created this revision.
xingxue added reviewers: daltenty, cebowleratibm, kkwli0.
xingxue added a project: LLVM.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
xingxue requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

This patch adds OpenMP runtime to the linker command line if `-fopenmp` is 
specifed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141862

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,25 @@
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+// Add OpenMP runtime if -fopenmp is specified.
+if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+ options::OPT_fno_openmp, false)) {
+  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
+CmdArgs.push_back("-lomp");
+break;
+  case Driver::OMPRT_IOMP5:
+CmdArgs.push_back("-liomp5");
+break;
+  case Driver::OMPRT_GOMP:
+CmdArgs.push_back("-lgomp");
+break;
+  case Driver::OMPRT_Unknown:
+// Already diagnosed.
+break;
+  }
+}
+
 // Support POSIX threads if "-pthreads" or "-pthread" is present.
 if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
   CmdArgs.push_back("-lpthreads");


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,25 @@
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+// Add OpenMP runtime if -fopenmp is specified.
+if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+ options::OPT_fno_openmp, false)) {
+  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
+CmdArgs.push_back("-lomp");
+break;
+  case Driver::OMPRT_IOMP5:
+CmdArgs.push_back("-liomp5");
+break;
+  case Driver::OMPRT_GOMP:
+CmdArgs.push_back("-lgomp");
+break;
+  case Driver::OMPRT_Unknown:
+// Already diagnosed.
+break;
+  }
+}
+
 // Support POSIX threads if "-pthreads" or "-pthread" is present.
 if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
   CmdArgs.push_back("-lpthreads");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D141581#4056671 , @fpetrogalli 
wrote:

> @barannikov88  - I am stuck with an incomplete explanation:

Ah, I see. The key point is that standalone build that depends on //installed// 
LLVM.
RISCVTargetParser is a custom target and it is not being installed, while 
LLVMTargetParser is a "real" target and gets installed. This is probably why 
changing the dependency fixes the issue.
The change looks good to me then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141572: [C++] [Coroutines] Deprecates the '-fcoroutines-ts' flag

2023-01-16 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik accepted this revision.
philnik added a comment.
This revision is now accepted and ready to land.

LGTM from the libc++ side of things % nit. I think @aaron.ballman should take 
another look at the Clang changes.




Comment at: libcxx/utils/generate_header_tests.py:22
 
+"coroutine": "(defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 
201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)",
+

A `TODO LLVM17: simplify this to __cplusplus >= 202002L` would be nice. 


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

https://reviews.llvm.org/D141572

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


[PATCH] D141717: [Clang] Only emit textual LLVM-IR in device only mode

2023-01-16 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D141717#4056971 , @yaxunl wrote:

> The intention of -emit-llvm -S is usually to get LLVM assembly for all 
> targets for inspection or modification. HIP emits a bundled LLVM assembly in 
> textual format in this case. Users can modify it directly, or extract 
> assembly for each device and bundle them together again. The modified file 
> can then be passed on to the next compilation stage.

Yeah, this is part of where I'm questioning how we want to treat the 
compilation pipeline when we perform offloading. When I set up the new driver 
support I decided to eschew the idea of perfectly bundled phases and instead 
decided that if users did not want the full pipeline they should use 
`--offload-device-only` and built it for themselves. In that vein I'd prefer it 
to be where we always generate a full (To Assembler) phase and avoid textual 
formats since it's supposed to be embedded as a binary blob.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141717

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


[PATCH] D141814: [llvm][ADT] Replace uses of `makeMutableArrayRef` with deduction guides

2023-01-16 Thread Joe Loser 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 rGa288d7f93770: [llvm][ADT] Replace uses of 
`makeMutableArrayRef` with deduction guides (authored by jloser).

Changed prior to commit:
  https://reviews.llvm.org/D141814?vs=489419=489635#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141814

Files:
  bolt/lib/Profile/DataAggregator.cpp
  clang-tools-extra/clangd/FuzzyMatch.cpp
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
  clang/include/clang/AST/DeclOpenMP.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Lex/MacroInfo.h
  clang/lib/AST/StmtOpenMP.cpp
  lld/COFF/Chunks.cpp
  lld/COFF/DebugTypes.cpp
  lld/COFF/Writer.cpp
  lld/ELF/InputFiles.h
  lld/ELF/SyntheticSections.cpp
  lldb/source/Host/common/NativeProcessProtocol.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/Metadata.h
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/Support/Parallel.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/ExecutionEngine/ExecutionEngine.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
  llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/unittests/Support/Path.cpp
  mlir/lib/Bytecode/Writer/IRNumbering.cpp
  mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
  mlir/test/mlir-tblgen/constraint-unique.td
  mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Index: mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
===
--- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2746,7 +2746,7 @@
   ///
   /// {0}: The region's index.
   const char *const getSingleRegion =
-  "::llvm::makeMutableArrayRef((*this)->getRegion({0}))";
+  "::llvm::MutableArrayRef((*this)->getRegion({0}))";
 
   // If we have no regions, there is nothing more to do.
   const auto canSkip = [](const NamedRegion ) {
@@ -2781,7 +2781,7 @@
   /// Get a single successor.
   ///
   /// {0}: The successor's name.
-  const char *const getSingleSuccessor = "::llvm::makeMutableArrayRef({0}())";
+  const char *const getSingleSuccessor = "::llvm::MutableArrayRef({0}())";
 
   // If we have no successors, there is nothing more to do.
   const auto canSkip = [](const NamedSuccessor ) {
Index: mlir/test/mlir-tblgen/constraint-unique.td
===
--- mlir/test/mlir-tblgen/constraint-unique.td
+++ mlir/test/mlir-tblgen/constraint-unique.td
@@ -127,10 +127,10 @@
 // CHECK: for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
 // CHECK-NEXT:  if (::mlir::failed([[$A_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto  : ::llvm::makeMutableArrayRef((*this)->getRegion(0)))
+// CHECK: for (auto  : ::llvm::MutableArrayRef((*this)->getRegion(0)))
 // CHECK-NEXT:  if (::mlir::failed([[$A_REGION_CONSTRAINT]](*this, region, "d", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto *successor : ::llvm::makeMutableArrayRef(c()))
+// CHECK: for (auto *successor : ::llvm::MutableArrayRef(c()))
 // CHECK-NEXT:  if (::mlir::failed([[$A_SUCCESSOR_CONSTRAINT]](*this, successor, "c", index++)))
 // CHECK-NEXT:return ::mlir::failure();
 
@@ -148,9 +148,9 @@
 // CHECK: for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
 // CHECK-NEXT:  if (::mlir::failed([[$O_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto  : ::llvm::makeMutableArrayRef((*this)->getRegion(0)))
+// CHECK: for (auto  : ::llvm::MutableArrayRef((*this)->getRegion(0)))
 // CHECK-NEXT:  if (::mlir::failed([[$O_REGION_CONSTRAINT]](*this, region, "d", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto *successor : ::llvm::makeMutableArrayRef(c()))
+// CHECK: for (auto *successor : ::llvm::MutableArrayRef(c()))
 // CHECK-NEXT:  if (::mlir::failed([[$O_SUCCESSOR_CONSTRAINT]](*this, successor, "c", index++)))
 // CHECK-NEXT:return ::mlir::failure();
Index: mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
===
--- mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
+++ mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
@@ -80,8 +80,7 @@
 LLVM_DEBUG(llvm::dbgs() << "  found coalesceable band from " << start
   

  1   2   >