[clang] Support C++20 Modules in clang-repl (PR #79261)

2024-01-24 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> Hi @ChuanqiXu9, the test you added is failing on the PS4 bot because for the 
> PS4 target, it requires an external linker which is not present/available. 
> Can the test be rewritten to not require linking?
> 
> https://lab.llvm.org/buildbot/#/builders/139/builds/57928
> 
> ```
> clang: error: unable to execute command: Executable "orbis-ld" doesn't exist!
> clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)
> ```

Oh, maybe I need to add more requires to the test.

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


[clang] c125965 - [NFC] Add more requirement to clang/test/Interpreter/cxx20-modules.cppm

2024-01-24 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2024-01-24T16:10:49+08:00
New Revision: c1259650e742e7b3053f6520729b4c1f44c27814

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

LOG: [NFC] Add more requirement to clang/test/Interpreter/cxx20-modules.cppm

The previous test can't work on other platforms like PS4.

Address the comments in
https://github.com/llvm/llvm-project/pull/79261#issuecomment-1907589030

Added: 


Modified: 
clang/test/Interpreter/cxx20-modules.cppm

Removed: 




diff  --git a/clang/test/Interpreter/cxx20-modules.cppm 
b/clang/test/Interpreter/cxx20-modules.cppm
index bc2b722f6b5197e..2c6eba525519175 100644
--- a/clang/test/Interpreter/cxx20-modules.cppm
+++ b/clang/test/Interpreter/cxx20-modules.cppm
@@ -1,3 +1,4 @@
+// REQUIRES: host-supports-jit, x86_64-linux
 // UNSUPPORTED: system-aix
 //
 // RUN: rm -rf %t



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


[clang] [llvm] [mlir] [AMDGPU] Add GFX12 WMMA and SWMMAC instructions (PR #77795)

2024-01-24 Thread Piotr Sobczak via cfe-commits


@@ -2601,67 +2601,73 @@ def int_amdgcn_ds_bvh_stack_rtn :
 [ImmArg>, IntrWillReturn, IntrNoCallback, IntrNoFree]
   >;
 
+def int_amdgcn_s_wait_event_export_ready :
+  ClangBuiltin<"__builtin_amdgcn_s_wait_event_export_ready">,
+  Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects, IntrWillReturn]
+>;
+
 // WMMA (Wave Matrix Multiply-Accumulate) intrinsics
 //
 // These operations perform a matrix multiplication and accumulation of
 // the form: D = A * B + C .
 
 class AMDGPUWmmaIntrinsic :
   Intrinsic<
-[CD],   // %D
+[CD], // %D
 [
   AB,   // %A
-  AB,   // %B
+  LLVMMatchType<1>, // %B
   LLVMMatchType<0>, // %C
 ],
 [IntrNoMem, IntrConvergent, IntrWillReturn, IntrNoCallback, IntrNoFree]
 >;
 
 class AMDGPUWmmaIntrinsicOPSEL :
   Intrinsic<
-[CD],   // %D
+[CD], // %D
 [
   AB,   // %A
-  AB,   // %B
+  LLVMMatchType<1>, // %B
   LLVMMatchType<0>, // %C
-  llvm_i1_ty,   // %high
+  llvm_i1_ty,   // %high (op_sel) for GFX11, 0 for GFX12
 ],
 [IntrNoMem, IntrConvergent, ImmArg>, IntrWillReturn, 
IntrNoCallback, IntrNoFree]
 >;
 
 class AMDGPUWmmaIntrinsicIU :
   Intrinsic<
-[CD],   // %D
+[CD], // %D
 [
   llvm_i1_ty,   // %A_sign
   AB,   // %A
   llvm_i1_ty,   // %B_sign
-  AB,   // %B
+  LLVMMatchType<1>, // %B
   LLVMMatchType<0>, // %C
   llvm_i1_ty,   // %clamp
 ],
 [IntrNoMem, IntrConvergent, ImmArg>, ImmArg>, 
ImmArg>, IntrWillReturn, IntrNoCallback, IntrNoFree]
 >;
 
-def int_amdgcn_wmma_f32_16x16x16_f16   : AMDGPUWmmaIntrinsic;
-def int_amdgcn_wmma_f32_16x16x16_bf16  : AMDGPUWmmaIntrinsic;
-// The regular, untied f16/bf16 wmma intrinsics only write to one half
-// of the registers (set via the op_sel bit).
-// The content of the other 16-bit of the registers is undefined.
-def int_amdgcn_wmma_f16_16x16x16_f16   : 
AMDGPUWmmaIntrinsicOPSEL;
-def int_amdgcn_wmma_bf16_16x16x16_bf16 : 
AMDGPUWmmaIntrinsicOPSEL;
-// The tied versions of the f16/bf16 wmma intrinsics tie the destination matrix
-// registers to the input accumulator registers.
-// Essentially, the content of the other 16-bit is preserved from the input.
-def int_amdgcn_wmma_f16_16x16x16_f16_tied   : 
AMDGPUWmmaIntrinsicOPSEL;
-def int_amdgcn_wmma_bf16_16x16x16_bf16_tied : 
AMDGPUWmmaIntrinsicOPSEL;
-def int_amdgcn_wmma_i32_16x16x16_iu8   : AMDGPUWmmaIntrinsicIU;
-def int_amdgcn_wmma_i32_16x16x16_iu4   : AMDGPUWmmaIntrinsicIU;
+// WMMA GFX11Only
 
-def int_amdgcn_s_wait_event_export_ready :
-  ClangBuiltin<"__builtin_amdgcn_s_wait_event_export_ready">,
-  Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects, IntrWillReturn]
->;
+// The OPSEL intrinsics read from and write to one half of the registers, 
selected by the op_sel bit.
+// The tied versions of the f16/bf16 wmma intrinsics tie the destination 
matrix registers to the input accumulator registers.
+// The content of the other 16-bit half is preserved from the input.
+def int_amdgcn_wmma_f16_16x16x16_f16_tied   : 
AMDGPUWmmaIntrinsicOPSEL;
+def int_amdgcn_wmma_bf16_16x16x16_bf16_tied : 
AMDGPUWmmaIntrinsicOPSEL;
+
+// WMMA GFX11Plus
+
+def int_amdgcn_wmma_f32_16x16x16_f16   : AMDGPUWmmaIntrinsic;
+def int_amdgcn_wmma_f32_16x16x16_bf16  : AMDGPUWmmaIntrinsic;
+def int_amdgcn_wmma_i32_16x16x16_iu8   : AMDGPUWmmaIntrinsicIU;
+def int_amdgcn_wmma_i32_16x16x16_iu4   : AMDGPUWmmaIntrinsicIU;
+
+// GFX11: The OPSEL intrinsics read from and write to one half of the 
registers, selected by the op_sel bit.
+//The content of the other 16-bit half is undefined.
+// GFX12: The op_sel bit must be 0.
+def int_amdgcn_wmma_f16_16x16x16_f16   : 
AMDGPUWmmaIntrinsicOPSEL;
+def int_amdgcn_wmma_bf16_16x16x16_bf16 : AMDGPUWmmaIntrinsicOPSEL;

piotrAMD wrote:

I suggest we take a step back, and push the previous version of the patch where 
the bf16 intrinsics used i16 for consistency with gfx11. 

Then, in a follow-up commit we will add new bf16 intrinsics with the proper 
bfloat type (I realize the naming could be contentious, but we could discuss it 
in the follow-up review).

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


[clang] bae1ada - [docs] [C++20] [Modules] Document how to import modules in clang-repl

2024-01-24 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2024-01-24T16:14:14+08:00
New Revision: bae1adae1c7cdf3b0bd618fc9cd5af251dc901ed

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

LOG: [docs] [C++20] [Modules] Document how to import modules in clang-repl

We support to import C++20 named modules now in in clang-repl in
https://github.com/llvm/llvm-project/commit/dd3e6c87f3f4affd17d05a4d25fa77d224a98d94.

Then we should document how can we do that.

Added: 


Modified: 
clang/docs/StandardCPlusPlusModules.rst

Removed: 




diff  --git a/clang/docs/StandardCPlusPlusModules.rst 
b/clang/docs/StandardCPlusPlusModules.rst
index 81043ff25be02ea..4e853990a7338a1 100644
--- a/clang/docs/StandardCPlusPlusModules.rst
+++ b/clang/docs/StandardCPlusPlusModules.rst
@@ -1213,6 +1213,45 @@ instead a real binary. There are 4 potential solutions 
to the problem:
   $ clang-scan-deps -format=p1689 -- /clang++ 
-std=c++20 -resource-dir  mod.cppm -c -o mod.o
 
 
+Import modules with clang-repl
+==
+
+We're able to import C++20 named modules with clang-repl.
+
+Let's start with a simple example:
+
+.. code-block:: c++
+
+  // M.cppm
+  export module M;
+  export const char* Hello() {
+  return "Hello Interpreter for Modules!";
+  }
+
+We still need to compile the named module in ahead.
+
+.. code-block:: console
+
+  $ clang++ -std=c++20 M.cppm --precompile -o M.pcm
+  $ clang++ M.pcm -c -o M.o
+  $ clang++ -shared M.o -o libM.so
+
+Note that we need to compile the module unit into a dynamic library so that 
the clang-repl
+can load the object files of the module units.
+
+Then we are able to import module ``M`` in clang-repl.
+
+.. code-block:: console
+
+  $ clang-repl -Xcc=-std=c++20 -Xcc=-fprebuilt-module-path=.
+  # We need to load the dynamic library first before importing the modules.
+  clang-repl> %lib libM.so
+  clang-repl> import M;
+  clang-repl> extern "C" int printf(const char *, ...);
+  clang-repl> printf("%s\n", Hello());
+  Hello Interpreter for Modules!
+  clang-repl> %quit
+
 Possible Questions
 ==
 



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


[clang] 5404a37 - [Driver] Use StringRef::consume_front (NFC)

2024-01-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2024-01-24T00:27:33-08:00
New Revision: 5404a3792ed58b94b938bbf5cfe6eeb23c664efc

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

LOG: [Driver] Use StringRef::consume_front (NFC)

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 7109faa1072de5f..190a73bfd40b68e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6482,18 +6482,15 @@ bool Driver::GetReleaseVersion(StringRef Str, unsigned 
&Major, unsigned &Minor,
 return false;
   if (Str.empty())
 return true;
-  if (Str[0] != '.')
+  if (!Str.consume_front("."))
 return false;
 
-  Str = Str.drop_front(1);
-
   if (Str.consumeInteger(10, Minor))
 return false;
   if (Str.empty())
 return true;
-  if (Str[0] != '.')
+  if (!Str.consume_front("."))
 return false;
-  Str = Str.drop_front(1);
 
   if (Str.consumeInteger(10, Micro))
 return false;
@@ -6521,9 +6518,8 @@ bool Driver::GetReleaseVersion(StringRef Str,
 Digits[CurDigit] = Digit;
 if (Str.empty())
   return true;
-if (Str[0] != '.')
+if (!Str.consume_front("."))
   return false;
-Str = Str.drop_front(1);
 CurDigit++;
   }
 

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index fadaf3e60c6616a..48534bc1669e44d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -317,9 +317,7 @@ void tools::handleTargetFeaturesGroup(const Driver &D,
   continue;
 }
 
-bool IsNegative = Name.starts_with("no-");
-if (IsNegative)
-  Name = Name.substr(3);
+bool IsNegative = Name.consume_front("no-");
 
 Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
   }

diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index d1eed931be5f1ee..8a5f8f148993192 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -801,7 +801,6 @@ StringRef HexagonToolChain::GetTargetCPUVersion(const 
ArgList &Args) {
 CpuArg = A;
 
   StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU();
-  if (CPU.starts_with("hexagon"))
-return CPU.substr(sizeof("hexagon") - 1);
+  CPU.consume_front("hexagon");
   return CPU;
 }



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


[clang] [llvm] [mlir] [AArch64] Replace LLVM IR function attributes for PSTATE.ZA. (PR #79166)

2024-01-24 Thread Cullen Rhodes via cfe-commits

https://github.com/c-rhodes edited 
https://github.com/llvm/llvm-project/pull/79166
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [AArch64] Replace LLVM IR function attributes for PSTATE.ZA. (PR #79166)

2024-01-24 Thread Cullen Rhodes via cfe-commits


@@ -1098,11 +1098,15 @@ LogicalResult 
ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
 llvmFunc->addFnAttr("aarch64_pstate_sm_compatible");
 
   if (func.getArmNewZa())
-llvmFunc->addFnAttr("aarch64_pstate_za_new");
-  else if (func.getArmSharedZa())
-llvmFunc->addFnAttr("aarch64_pstate_za_shared");
+llvmFunc->addFnAttr("aarch64_new_za");
+  else if (func.getArmInZa())
+llvmFunc->addFnAttr("aarch64_in_za");
+  else if (func.getArmOutZa())
+llvmFunc->addFnAttr("aarch64_out_za");
+  else if (func.getArmInoutZa())
+llvmFunc->addFnAttr("aarch64_inout_za");
   if (func.getArmPreservesZa())
-llvmFunc->addFnAttr("aarch64_pstate_za_preserved");
+llvmFunc->addFnAttr("aarch64_preserves_za");

c-rhodes wrote:

this should be `else if`, I missed this from 
https://llvm.org/docs/AArch64SME.html#restrictions-on-attributes
> It is not allowed for a function to be decorated with both 
> aarch64_pstate_za_new and aarch64_pstate_za_preserved.

when I originally reviewed this. I see you've fixed it for import, please could 
you fix it here as well?

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


[mlir] [clang] [llvm] [AArch64] Replace LLVM IR function attributes for PSTATE.ZA. (PR #79166)

2024-01-24 Thread Cullen Rhodes via cfe-commits

https://github.com/c-rhodes commented:

MLIR changes LGTM cheers, just left one comment for something I missed when the 
preserved attr was added recently.

Also, in the commit message the LLVM IR attributes are prefixed with `arm`, 
should be `aarch64`.

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


[llvm] [mlir] [clang] [AArch64] Replace LLVM IR function attributes for PSTATE.ZA. (PR #79166)

2024-01-24 Thread Cullen Rhodes via cfe-commits


@@ -22,26 +22,32 @@ Below we describe the LLVM IR attributes and their relation 
to the C/C++
 level ACLE attributes:
 
 ``aarch64_pstate_sm_enabled``
-is used for functions with ``__attribute__((arm_streaming))``
+is used for functions with ``__arm_streaming``
 
 ``aarch64_pstate_sm_compatible``
-is used for functions with ``__attribute__((arm_streaming_compatible))``
+is used for functions with ``__arm_streaming_compatible``
 
 ``aarch64_pstate_sm_body``
-  is used for functions with ``__attribute__((arm_locally_streaming))`` and is
+  is used for functions with ``__arm_locally_streaming`` and is
   only valid on function definitions (not declarations)
 
-``aarch64_pstate_za_new``
-  is used for functions with ``__attribute__((arm_new_za))``
+``aarch64_pstate_new_za``

c-rhodes wrote:

```suggestion
``aarch64_new_za``
```

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


[pstl] [lldb] [llvm] [openmp] [clang-tools-extra] [libcxx] [lld] [mlir] [clang] [ELF] Don't resolve relocations referencing SHN_ABS to tombstone in non-SHF_ALLOC sections (PR #79238)

2024-01-24 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/79238
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [clang] [llvm] [mlir] [pstl] [libcxx] [openmp] [lldb] [clang-tools-extra] [ELF] Don't resolve relocations referencing SHN_ABS to tombstone in non-SHF_ALLOC sections (PR #79238)

2024-01-24 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/79238

>From 97b500a7061041b5478b6b1b1094e76140e3d9c3 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Tue, 23 Jan 2024 17:53:31 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 lld/ELF/InputSection.cpp  | 13 ++---
 lld/test/ELF/dead-reloc-in-nonalloc.s |  2 +-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index c728dd6c6306aa..0e0b9783bd88a0 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -961,12 +961,11 @@ void InputSection::relocateNonAlloc(uint8_t *buf, 
ArrayRef rels) {
   // vector. The computed value is st_value plus a non-negative offset.
   // Negative values are invalid, so -1 can be used as the tombstone value.
   //
-  // If the referenced symbol is discarded (made Undefined), or the
-  // section defining the referenced symbol is garbage collected,
-  // sym.getOutputSection() is nullptr. `ds->folded` catches the ICF folded
-  // case. However, resolving a relocation in .debug_line to -1 would stop
-  // debugger users from setting breakpoints on the folded-in function, so
-  // exclude .debug_line.
+  // If the referenced symbol is relative to a discarded section (due to
+  // --gc-sections, COMDAT, etc), it has been converted to a Undefined.
+  // `ds->folded` catches the ICF folded case. However, resolving a
+  // relocation in .debug_line to -1 would stop debugger users from setting
+  // breakpoints on the folded-in function, so exclude .debug_line.
   //
   // For pre-DWARF-v5 .debug_loc and .debug_ranges, -1 is a reserved value
   // (base address selection entry), use 1 (which is used by GNU ld for
@@ -974,7 +973,7 @@ void InputSection::relocateNonAlloc(uint8_t *buf, 
ArrayRef rels) {
   //
   // TODO To reduce disruption, we use 0 instead of -1 as the tombstone
   // value. Enable -1 in a future release.
-  if (!sym.getOutputSection() || (ds && ds->folded && !isDebugLine)) {
+  if (!ds || (ds->folded && !isDebugLine)) {
 // If -z dead-reloc-in-nonalloc= is specified, respect it.
 uint64_t value = SignExtend64(*tombstone);
 // For a 32-bit local TU reference in .debug_names, X86_64::relocate
diff --git a/lld/test/ELF/dead-reloc-in-nonalloc.s 
b/lld/test/ELF/dead-reloc-in-nonalloc.s
index 145604eb883a9a..b675fc50fc2ea2 100644
--- a/lld/test/ELF/dead-reloc-in-nonalloc.s
+++ b/lld/test/ELF/dead-reloc-in-nonalloc.s
@@ -17,7 +17,7 @@
 # AA:  Contents of section .debug_info:
 # AA-NEXT:   [[ADDR]]   
 # AA:  Contents of section .not_debug:
-# AA-NEXT:       .
+# AA-NEXT:    2a00   .
 
 ## Specifying zero can get a behavior similar to GNU ld.
 # RUN: ld.lld --icf=all -z dead-reloc-in-nonalloc=.debug_info=0 %t.o %tabs.o 
-o %tzero

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


[compiler-rt] [lld] [clang] [llvm] [libc] [libcxx] [lldb] [flang] [clang-tools-extra] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)

2024-01-24 Thread Mariya Podchishchaeva via cfe-commits

Fznamznon wrote:

> CheckConstexprFunctionDefinition will return false for a destructor if 
> defaultedDestructorIsConstexpr returns false (unless we want to emit a 
> diagnostic)`

I see. So defaulted special members now *actually* constexpr. I've made that 
change. I confused everything with functions and only disabled diagnostic for 
these. Now it should work correctly.

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


[flang] [libc] [lldb] [compiler-rt] [llvm] [clang-tools-extra] [libcxx] [lld] [clang] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)

2024-01-24 Thread Mariya Podchishchaeva via cfe-commits


@@ -356,14 +356,7 @@ C++23 implementation status
 
   Relaxing some constexpr restrictions
   https://wg21.link/P2448R2";>P2448R2
-  
-Clang 17 (Partial)
- We do not support outside of defaulted special memeber functions the 
change that constexpr functions no
-  longer have to be constexpr compatible but rather support a less 
restricted requirements for constexpr
-  functions. Which include allowing non-literal types as return values 
and parameters, allow calling of
-  non-constexpr functions and constructors.
-
-  
+  Clang 18

Fznamznon wrote:

I suppose, I should put clang 19 here, right?

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


[flang] [libc] [lldb] [compiler-rt] [llvm] [clang-tools-extra] [libcxx] [lld] [clang] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)

2024-01-24 Thread Mariya Podchishchaeva via cfe-commits


@@ -9108,7 +9123,8 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   //   declaration, it is implicitly considered to be constexpr.
   // FIXME: Only applying this to the first declaration seems problematic, as
   // simple reorderings can affect the meaning of the program.
-  if (First && !FD->isConstexpr() && Info.Constexpr)
+  if ((First && !FD->isConstexpr() && Info.Constexpr) ||
+  getLangOpts().CPlusPlus23)

Fznamznon wrote:

This change perhaps needs a test.

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


[clang] [clang][Interp] Handle casts between complex types (PR #79269)

2024-01-24 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/79269

Just handle this like two primtive casts.

>From ecc963e4fbcfe1cd1c1f40c642c1c0fbf916a8c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Wed, 24 Jan 2024 10:04:50 +0100
Subject: [PATCH] [clang][Interp] Handle casts between complex types

Just handle this like two primtive casts.
---
 clang/lib/AST/Interp/ByteCodeExprGen.cpp | 57 
 clang/lib/AST/Interp/Pointer.h   | 10 -
 clang/test/AST/Interp/complex.cpp| 19 +++-
 3 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index cfcef067b92bdc..fd9e6ee47614bc 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -314,6 +314,63 @@ bool ByteCodeExprGen::VisitCastExpr(const 
CastExpr *CE) {
 return this->emitInitElem(T, 1, SubExpr);
   }
 
+  case CK_IntegralComplexCast:
+  case CK_FloatingComplexCast:
+  case CK_IntegralComplexToFloatingComplex:
+  case CK_FloatingComplexToIntegralComplex: {
+assert(CE->getType()->isAnyComplexType());
+assert(SubExpr->getType()->isAnyComplexType());
+if (DiscardResult)
+  return this->discard(SubExpr);
+
+if (!Initializing) {
+  std::optional LocalIndex =
+  allocateLocal(CE, /*IsExtended=*/true);
+  if (!LocalIndex)
+return false;
+  if (!this->emitGetPtrLocal(*LocalIndex, CE))
+return false;
+}
+
+// Location for the SubExpr.
+// Since SubExpr is of complex type, visiting it results in a pointer
+// anyway, so we just create a temporary pointer variable.
+std::optional SubExprOffset = allocateLocalPrimitive(
+SubExpr, PT_Ptr, /*IsConst=*/true, /*IsExtended=*/false);
+if (!SubExprOffset)
+  return false;
+
+if (!this->visit(SubExpr))
+  return false;
+if (!this->emitSetLocal(PT_Ptr, *SubExprOffset, CE))
+  return false;
+
+PrimType SourceElemT = *classifyComplexElementType(SubExpr->getType());
+QualType DestElemType =
+CE->getType()->getAs()->getElementType();
+PrimType DestElemT = classifyPrim(DestElemType);
+// Cast both elements individually.
+for (unsigned I = 0; I != 2; ++I) {
+  if (!this->emitGetLocal(PT_Ptr, *SubExprOffset, CE))
+return false;
+  if (!this->emitConstUint8(I, CE))
+return false;
+  if (!this->emitArrayElemPtrPopUint8(CE))
+return false;
+  if (!this->emitLoadPop(SourceElemT, CE))
+return false;
+
+  // Do the cast.
+  if (!this->emitPrimCast(SourceElemT, DestElemT, DestElemType, CE))
+return false;
+
+  // Save the value.
+  if (!this->emitInitElem(DestElemT, I, CE))
+return false;
+}
+return true;
+  }
+
   case CK_ToVoid:
 return discard(SubExpr);
 
diff --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h
index 8ccaff41ded8da..15be54d4110b71 100644
--- a/clang/lib/AST/Interp/Pointer.h
+++ b/clang/lib/AST/Interp/Pointer.h
@@ -234,8 +234,14 @@ class Pointer {
 
   /// Returns the type of the innermost field.
   QualType getType() const {
-if (inPrimitiveArray() && Offset != Base)
-  return 
getFieldDesc()->getType()->getAsArrayTypeUnsafe()->getElementType();
+if (inPrimitiveArray() && Offset != Base) {
+  // Unfortunately, complex types are not array types in clang, but they 
are
+  // for us.
+  if (const auto *AT = getFieldDesc()->getType()->getAsArrayTypeUnsafe())
+return AT->getElementType();
+  if (const auto *CT = getFieldDesc()->getType()->castAs())
+return CT->getElementType();
+}
 return getFieldDesc()->getType();
   }
 
diff --git a/clang/test/AST/Interp/complex.cpp 
b/clang/test/AST/Interp/complex.cpp
index 99c0dd141d0b77..e9c0ffa5f4a56a 100644
--- a/clang/test/AST/Interp/complex.cpp
+++ b/clang/test/AST/Interp/complex.cpp
@@ -42,16 +42,31 @@ static_assert(__real(12u) == 12u, "");
 static_assert(__imag(4.0) == 0.0, "");
 static_assert(__imag(13) == 0, "");
 
-constexpr int ignoredCast() {
+
+constexpr _Complex long L1 = D;
+static_assert(__real(L1) == 1.0, "");
+static_assert(__imag(L1) == 3.0, "");
+
+constexpr _Complex short I4 = L1;
+static_assert(__real(I4) == 1, "");
+static_assert(__imag(I4) == 3, "");
+
+constexpr _Complex float D3 = D;
+static_assert(__real(D3) == 1.0, "");
+static_assert(__imag(D3) == 3.0, "");
+
+
+constexpr int ignored() {
   I2;
   (int)I2;
   (float)I2;
   D1;
   (int)D1;
   (double)D1;
+  (_Complex float)I2;
   return 0;
 }
-static_assert(ignoredCast() == 0, "");
+static_assert(ignored() == 0, "");
 static_assert((int)I1 == 1, "");
 static_assert((float)D == 1.0f, "");
 

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


[clang] [clang][Interp] Handle casts between complex types (PR #79269)

2024-01-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Just handle this like two primtive casts.

---
Full diff: https://github.com/llvm/llvm-project/pull/79269.diff


3 Files Affected:

- (modified) clang/lib/AST/Interp/ByteCodeExprGen.cpp (+57) 
- (modified) clang/lib/AST/Interp/Pointer.h (+8-2) 
- (modified) clang/test/AST/Interp/complex.cpp (+17-2) 


``diff
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index cfcef067b92bdc..fd9e6ee47614bc 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -314,6 +314,63 @@ bool ByteCodeExprGen::VisitCastExpr(const 
CastExpr *CE) {
 return this->emitInitElem(T, 1, SubExpr);
   }
 
+  case CK_IntegralComplexCast:
+  case CK_FloatingComplexCast:
+  case CK_IntegralComplexToFloatingComplex:
+  case CK_FloatingComplexToIntegralComplex: {
+assert(CE->getType()->isAnyComplexType());
+assert(SubExpr->getType()->isAnyComplexType());
+if (DiscardResult)
+  return this->discard(SubExpr);
+
+if (!Initializing) {
+  std::optional LocalIndex =
+  allocateLocal(CE, /*IsExtended=*/true);
+  if (!LocalIndex)
+return false;
+  if (!this->emitGetPtrLocal(*LocalIndex, CE))
+return false;
+}
+
+// Location for the SubExpr.
+// Since SubExpr is of complex type, visiting it results in a pointer
+// anyway, so we just create a temporary pointer variable.
+std::optional SubExprOffset = allocateLocalPrimitive(
+SubExpr, PT_Ptr, /*IsConst=*/true, /*IsExtended=*/false);
+if (!SubExprOffset)
+  return false;
+
+if (!this->visit(SubExpr))
+  return false;
+if (!this->emitSetLocal(PT_Ptr, *SubExprOffset, CE))
+  return false;
+
+PrimType SourceElemT = *classifyComplexElementType(SubExpr->getType());
+QualType DestElemType =
+CE->getType()->getAs()->getElementType();
+PrimType DestElemT = classifyPrim(DestElemType);
+// Cast both elements individually.
+for (unsigned I = 0; I != 2; ++I) {
+  if (!this->emitGetLocal(PT_Ptr, *SubExprOffset, CE))
+return false;
+  if (!this->emitConstUint8(I, CE))
+return false;
+  if (!this->emitArrayElemPtrPopUint8(CE))
+return false;
+  if (!this->emitLoadPop(SourceElemT, CE))
+return false;
+
+  // Do the cast.
+  if (!this->emitPrimCast(SourceElemT, DestElemT, DestElemType, CE))
+return false;
+
+  // Save the value.
+  if (!this->emitInitElem(DestElemT, I, CE))
+return false;
+}
+return true;
+  }
+
   case CK_ToVoid:
 return discard(SubExpr);
 
diff --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h
index 8ccaff41ded8da..15be54d4110b71 100644
--- a/clang/lib/AST/Interp/Pointer.h
+++ b/clang/lib/AST/Interp/Pointer.h
@@ -234,8 +234,14 @@ class Pointer {
 
   /// Returns the type of the innermost field.
   QualType getType() const {
-if (inPrimitiveArray() && Offset != Base)
-  return 
getFieldDesc()->getType()->getAsArrayTypeUnsafe()->getElementType();
+if (inPrimitiveArray() && Offset != Base) {
+  // Unfortunately, complex types are not array types in clang, but they 
are
+  // for us.
+  if (const auto *AT = getFieldDesc()->getType()->getAsArrayTypeUnsafe())
+return AT->getElementType();
+  if (const auto *CT = getFieldDesc()->getType()->castAs())
+return CT->getElementType();
+}
 return getFieldDesc()->getType();
   }
 
diff --git a/clang/test/AST/Interp/complex.cpp 
b/clang/test/AST/Interp/complex.cpp
index 99c0dd141d0b77..e9c0ffa5f4a56a 100644
--- a/clang/test/AST/Interp/complex.cpp
+++ b/clang/test/AST/Interp/complex.cpp
@@ -42,16 +42,31 @@ static_assert(__real(12u) == 12u, "");
 static_assert(__imag(4.0) == 0.0, "");
 static_assert(__imag(13) == 0, "");
 
-constexpr int ignoredCast() {
+
+constexpr _Complex long L1 = D;
+static_assert(__real(L1) == 1.0, "");
+static_assert(__imag(L1) == 3.0, "");
+
+constexpr _Complex short I4 = L1;
+static_assert(__real(I4) == 1, "");
+static_assert(__imag(I4) == 3, "");
+
+constexpr _Complex float D3 = D;
+static_assert(__real(D3) == 1.0, "");
+static_assert(__imag(D3) == 3.0, "");
+
+
+constexpr int ignored() {
   I2;
   (int)I2;
   (float)I2;
   D1;
   (int)D1;
   (double)D1;
+  (_Complex float)I2;
   return 0;
 }
-static_assert(ignoredCast() == 0, "");
+static_assert(ignored() == 0, "");
 static_assert((int)I1 == 1, "");
 static_assert((float)D == 1.0f, "");
 

``




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


[clang] [llvm] [clang][MBD] set up module build daemon infrastructure (PR #67562)

2024-01-24 Thread via cfe-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
230c13d59d0843c3b738920b85c341cc78a61fa9...a7729911df5e852ecc8718ddb2882d9b7d0928da
 clang/utils/kill_process.py clang/test/lit.cfg.py
``





View the diff from darker here.


``diff
--- utils/kill_process.py   2024-01-24 09:10:36.00 +
+++ utils/kill_process.py   2024-01-24 09:23:19.885954 +
@@ -5,29 +5,30 @@
 import os
 import psutil
 import signal
 import sys
 
+
 def main():
 if len(sys.argv) == 1:
 sys.stderr.write("Error: no search pattern provided")
 sys.exit(1)
 
 search_pattern = sys.argv[1]
 
-for process in psutil.process_iter(['pid', 'name', 'cmdline']):
-if('clang' in process.info['name']):
+for process in psutil.process_iter(["pid", "name", "cmdline"]):
+if "clang" in process.info["name"]:
+PID = []
+if search_pattern in " ".join(process.info["cmdline"]):
+PID.append(process.info["pid"])
 
-PID = []
-if(search_pattern in ' '.join(process.info['cmdline'])):
-PID.append(process.info['pid'])
+if len(PID) == 0:
+return
 
-if(len(PID) == 0):
-return
-
-if(len(PID) > 1):
+if len(PID) > 1:
 sys.stderr.write("Error: more then one process matches search 
pattern")
 
 os.kill(PID[0], signal.SIGTERM)
 
+
 if __name__ == "__main__":
 main()

``




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


[clang-tools-extra] [llvm] [clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-24 Thread via cfe-commits

mikaelholmen wrote:

Hello,

It seems like with this change it warns like
```
w.c:1:10: warning: use of infinity via a macro is undefined behavior due to the 
currently enabled floating-point options [-Wnan-infinity-disabled]
1 | # ifndef INFINITY
  |  ^
1 warning generated.
```
with
```
clang w.c -c -ffast-math
```
on input like
```
# ifndef INFINITY

# endif
```
Is this expected and wanted?


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


[compiler-rt] [clang] [llvm] [libc] [libcxx] [flang] [clang-tools-extra] Reland: [libc++][format] P2637R3: Member visit (std::basic_format_arg) #76449 (PR #79032)

2024-01-24 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/79032

>From e03452fda84a5284420bba1913299b68caabb6cd Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Mon, 22 Jan 2024 20:35:00 +0200
Subject: [PATCH 1/2] Revert "Revert "[libc++][format] P2637R3: Member `visit`
 (`std::basic_format_arg`) (#76449)""

This reverts commit 02f95b77515fe18ed1076b94cbb850ea0cf3c77e.
---
 libcxx/docs/ReleaseNotes/18.rst   |   1 +
 libcxx/docs/Status/Cxx2cPapers.csv|   2 +-
 libcxx/docs/Status/FormatIssues.csv   |   2 +-
 libcxx/include/__config   |   6 +
 libcxx/include/__format/format_arg.h  | 109 +-
 libcxx/include/__format/format_context.h  |  33 +-
 libcxx/include/format |   2 +-
 .../format.arg/visit.pass.cpp | 333 
 .../format.arg/visit.return_type.pass.cpp | 369 ++
 .../visit_format_arg.deprecated.verify.cpp|  38 ++
 .../format.arg/visit_format_arg.pass.cpp  |   6 +-
 .../format.arguments/format.args/get.pass.cpp |  48 ++-
 libcxx/test/support/test_basic_format_arg.h   |  20 +-
 libcxx/test/support/test_macros.h |   5 +
 .../generate_feature_test_macro_components.py |   1 +
 15 files changed, 927 insertions(+), 48 deletions(-)
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.deprecated.verify.cpp

diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fd882bafe19a517..237a63022d55ff5 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -79,6 +79,7 @@ Implemented Papers
 - P1759R6 - Native handles and file streams
 - P2868R3 - Remove Deprecated ``std::allocator`` Typedef From C++26
 - P2517R1 - Add a conditional ``noexcept`` specification to ``std::apply``
+- P2637R3 - Member ``visit``
 - P2447R6 - ``span`` over initializer list
 
 
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index f80b1f6b663f045..c45aa3c510072e4 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -17,7 +17,7 @@
 "`P0792R14 `__","LWG","``function_ref``: a 
type-erased callable reference","Varna June 2023","","",""
 "`P2874R2 `__","LWG","Mandating Annex D Require No 
More","Varna June 2023","","",""
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
-"`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","|Partial|","18.0",""
+"`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","|Complete|","18.0",""
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
 "`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
diff --git a/libcxx/docs/Status/FormatIssues.csv 
b/libcxx/docs/Status/FormatIssues.csv
index 513988d08036ca6..6e58e752191ea5d 100644
--- a/libcxx/docs/Status/FormatIssues.csv
+++ b/libcxx/docs/Status/FormatIssues.csv
@@ -16,7 +16,7 @@ Number,Name,Standard,Assignee,Status,First released version
 "`P2693R1 `__","Formatting ``thread::id`` and 
``stacktrace``","C++23","Mark de Wever","|In Progress|"
 "`P2510R3 `__","Formatting pointers","C++26","Mark 
de Wever","|Complete|",17.0
 "`P2757R3 `__","Type-checking format 
args","C++26","","",
-"`P2637R3 `__","Member ``visit``","C++26","","",
+"`P2637R3 `__","Member ``visit``","C++26","Hristo 
Hristov","|Complete|",18.0
 "`P2905R2 `__","Runtime format strings","C++26 
DR","Mark de Wever","|Complete|",18.0
 "`P2918R2 `__","Runtime format strings 
II","C++26","Mark de Wever","|Complete|",18.0
 "`P2909R4 `__","Fix formatting of code units as 
integers (Dude, where’s my ``char``?)","C++26 DR","Mark de 
Wever","|Complete|",18.0
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 9a64cdb489119d9..00489d971c296c2 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -995,6 +995,12 @@ typedef __char32_t char32_t;
 #define _LIBCPP_DEPRECATED_IN_CXX23
 #  endif
 
+#  if _LIBCPP_STD_VER >= 26
+#define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
+#  else
+#define _LIBCPP_DEPRECATED_IN_CXX26
+#  endif
+
 #  if !defined(_LIBCPP_

[llvm] [pstl] [clang] [mlir] [libcxx] [clang-tools-extra] [lld] [openmp] [lldb] [ELF] Don't resolve relocations referencing SHN_ABS to tombstone in non-SHF_ALLOC sections (PR #79238)

2024-01-24 Thread Bevin Hansson via cfe-commits

https://github.com/bevin-hansson commented:

This looks good to me, but someone else should probably chime in as well to 
approve.

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


[llvm] [clang] [flang] [compiler-rt] [libcxx] [clang-tools-extra] [libc] Reland: [libc++][format] P2637R3: Member visit (std::basic_format_arg) #76449 (PR #79032)

2024-01-24 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

> @H-G-Hristov Would it be possible to update your branch? I sent it to our 
> Windows builders but Clang is segfaulting while building runtimes.

Thank you for taking a look. I updated the branch. Please note that pre-release 
Clang 18 used to have a bug related to "deducing this", which is used by this 
feature. It has been rectified since then: 
https://github.com/llvm/llvm-project/pull/75913
The other patch related to this paper seems to have passed the CI: 
https://github.com/llvm/llvm-project/pull/76449

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


[llvm] [clang] [clang-tools-extra] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-24 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> Is this expected and wanted?

Good catch! I would not expect that diagnostic; we should silence the 
diagnostic if it's used in a `#ifdef`, `#elifdef`, or `defined` because the 
value isn't necessary. Perhaps we should also silence something like 
`sizeof(INFINITY)` because it's unevaluated?

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


[lldb] [flang] [clang-tools-extra] [libcxx] [clang] [lld] [llvm] [compiler-rt] [libc] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-24 Thread Mariusz Sikora via cfe-commits
Mirko =?utf-8?q?Brkušanin?= ,
Mirko =?utf-8?q?Brkušanin?= ,Mirko Brkusanin
 ,Mariusz Sikora 
Message-ID:
In-Reply-To: 



@@ -8770,6 +8781,22 @@ void AMDGPUAsmParser::cvtVOP3DPP(MCInst &Inst, const 
OperandVector &Operands,
   }
 }
 
+int VdstInIdx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::vdst_in);
+if (VdstInIdx == static_cast(Inst.getNumOperands())) {
+  Inst.addOperand(Inst.getOperand(0));
+}
+
+bool IsVOP3CvtSrDpp = Opc == AMDGPU::V_CVT_SR_BF8_F32_e64_dpp8_gfx12 ||
+  Opc == AMDGPU::V_CVT_SR_FP8_F32_e64_dpp8_gfx12 ||
+  Opc == AMDGPU::V_CVT_SR_BF8_F32_e64_dpp_gfx12 ||
+  Opc == AMDGPU::V_CVT_SR_FP8_F32_e64_dpp_gfx12;

mariusz-sikora-at-amd wrote:

Thanks, I will prepare different PRs to cover this and what Joe pointed out.

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


[clang] [AMDGPU][GFX12] Add tests for unsupported builtins (PR #78729)

2024-01-24 Thread Mariusz Sikora via cfe-commits

mariusz-sikora-at-amd wrote:

ping

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


[libcxx] [mlir] [openmp] [pstl] [clang-tools-extra] [llvm] [lld] [lldb] [clang] [ELF] Don't resolve relocations referencing SHN_ABS to tombstone in non-SHF_ALLOC sections (PR #79238)

2024-01-24 Thread Peter Smith via cfe-commits

https://github.com/smithp35 approved this pull request.

Code changes LGTM too. I can't think of a case when a C/C++ compiler would 
directly generate a reference to an SHN_ABS symbol as I don't think there is a 
way of expressing such a symbol in C/C++ and debug generation concentrates on 
describing entities in the same module. I've asked a colleague that knows more 
about debug generation than I do. If I get an answer I'll post another comment.

There is a typo in the description (SHN_ANS) -> (SHN_ABS)

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


[mlir] [llvm] [clang] [AMDGPU] Add GFX12 WMMA and SWMMAC instructions (PR #77795)

2024-01-24 Thread Mirko Brkušanin via cfe-commits

mbrkusanin wrote:

Rebased and reverted bfloat

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


[clang] [llvm] [clang-tools-extra] [clang] Refactor Builtins.def to be a tablegen file (PR #68324)

2024-01-24 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 closed 
https://github.com/llvm/llvm-project/pull/68324
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [AMDGPU] Emit a waitcnt instruction after each memory instruction (PR #79236)

2024-01-24 Thread Jay Foad via cfe-commits


@@ -2561,6 +2567,70 @@ bool SIMemoryLegalizer::expandAtomicCmpxchgOrRmw(const 
SIMemOpInfo &MOI,
   return Changed;
 }
 
+bool SIMemoryLegalizer::GFX9InsertWaitcntForPreciseMem(MachineFunction &MF) {
+  const GCNSubtarget &ST = MF.getSubtarget();
+  const SIInstrInfo *TII = ST.getInstrInfo();
+  IsaVersion IV = getIsaVersion(ST.getCPU());
+
+  bool Changed = false;
+
+  for (auto &MBB : MF) {
+for (auto MI = MBB.begin(); MI != MBB.end();) {
+  MachineInstr &Inst = *MI;
+  ++MI;
+  if (Inst.mayLoadOrStore() == false)
+continue;
+
+  // Todo: if next insn is an s_waitcnt
+  AMDGPU::Waitcnt Wait;
+
+  if (!(Inst.getDesc().TSFlags & SIInstrFlags::maybeAtomic)) {
+if (TII->isSMRD(Inst)) {  // scalar

jayfoad wrote:

This logic would need updating again for GFX12. It seems like it's duplicating 
a lot of knowledge which is already implemented in SIInsertWaitcnts.

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


[clang] [clang][Diagnostics] Highlight code snippets (PR #66514)

2024-01-24 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/66514

>From 69aa9b23a7d5afb58b89a703e7755924561dd54f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Fri, 15 Sep 2023 15:51:39 +0200
Subject: [PATCH] [clang][Diagnostics] Highlight code snippets

Add some primitive syntax highlighting to our code snippet output.
---
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/include/clang/Frontend/TextDiagnostic.h |  18 +-
 clang/include/clang/Lex/Preprocessor.h|  10 +
 clang/lib/Frontend/TextDiagnostic.cpp | 211 +-
 clang/lib/Frontend/TextDiagnosticPrinter.cpp  |   2 +-
 clang/lib/Lex/Preprocessor.cpp|  24 ++
 clang/test/Frontend/diagnostic-pipe.c |  16 ++
 7 files changed, 269 insertions(+), 14 deletions(-)
 create mode 100644 clang/test/Frontend/diagnostic-pipe.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index db3d74e124e7d1d..6f5fe2049e242fc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -97,6 +97,8 @@ Attribute Changes in Clang
 
 Improvements to Clang's diagnostics
 ---
+- Clang now applies syntax highlighting to the code snippets it
+  prints.
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/include/clang/Frontend/TextDiagnostic.h 
b/clang/include/clang/Frontend/TextDiagnostic.h
index 7eb0ab0cdc9bca8..a2fe8ae995423b9 100644
--- a/clang/include/clang/Frontend/TextDiagnostic.h
+++ b/clang/include/clang/Frontend/TextDiagnostic.h
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTIC_H
 
 #include "clang/Frontend/DiagnosticRenderer.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 
@@ -33,14 +34,22 @@ namespace clang {
 /// printing coming out of libclang.
 class TextDiagnostic : public DiagnosticRenderer {
   raw_ostream &OS;
+  const Preprocessor *PP;
 
 public:
-  TextDiagnostic(raw_ostream &OS,
- const LangOptions &LangOpts,
- DiagnosticOptions *DiagOpts);
+  TextDiagnostic(raw_ostream &OS, const LangOptions &LangOpts,
+ DiagnosticOptions *DiagOpts, const Preprocessor *PP = 
nullptr);
 
   ~TextDiagnostic() override;
 
+  struct StyleRange {
+unsigned Start;
+unsigned End;
+enum llvm::raw_ostream::Colors Color;
+StyleRange(unsigned S, unsigned E, enum llvm::raw_ostream::Colors C)
+: Start(S), End(E), Color(C){};
+  };
+
   /// Print the diagonstic level to a raw_ostream.
   ///
   /// This is a static helper that handles colorizing the level and formatting
@@ -104,7 +113,8 @@ class TextDiagnostic : public DiagnosticRenderer {
ArrayRef Hints);
 
   void emitSnippet(StringRef SourceLine, unsigned MaxLineNoDisplayWidth,
-   unsigned LineNo);
+   unsigned LineNo, unsigned DisplayLineNo,
+   ArrayRef Styles);
 
   void emitParseableFixits(ArrayRef Hints, const SourceManager &SM);
 };
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 2d9c53cdf5bde8e..9d0d53129a12dd9 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -284,6 +284,13 @@ class Preprocessor {
   /// The kind of translation unit we are processing.
   const TranslationUnitKind TUKind;
 
+  /// Returns a pointer into the given file's buffer that's guaranteed
+  /// to be between tokens. The returned pointer is always before \p Start.
+  /// The maximum distance betweenthe returned pointer and \p Start is
+  /// limited by a constant value, but also an implementation detail.
+  /// If no such check point exists, \c nullptr is returned.
+  const char *getCheckPoint(FileID FID, const char *Start) const;
+
 private:
   /// The code-completion handler.
   CodeCompletionHandler *CodeComplete = nullptr;
@@ -311,6 +318,9 @@ class Preprocessor {
   /// The import path for named module that we're currently processing.
   SmallVector, 2> 
NamedModuleImportPath;
 
+  llvm::DenseMap> CheckPoints;
+  unsigned CheckPointCounter = 0;
+
   /// Whether the import is an `@import` or a standard c++ modules import.
   bool IsAtImport = false;
 
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp 
b/clang/lib/Frontend/TextDiagnostic.cpp
index 779dead5d058d1a..291d71f6db61f17 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -12,6 +12,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/ConvertUTF.h"
@@ -41,6 +42,14 @@ static const enum raw_ostream::Colors fatalColor = 
raw_ostream::RED;
 static const enum raw_ostream::Colors savedColor =
   raw_ostream::SAVEDCOLOR;
 
+// Magenta is taken for 'warning'. Red is already 'error' and '

[clang] [clang][analyzer] Improve modeling of 'execv' and 'execvp' in StdLibraryFunctionsChecker (PR #78930)

2024-01-24 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/78930

>From 74a43113ee4152eb0cb6aaeb4fbc917bcf0abcf8 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Mon, 22 Jan 2024 12:42:43 +0800
Subject: [PATCH 1/2] [clang[analyzer] Improve modeling of 'execv' and 'execvp'
 in StdLibraryFunctionsChecker

These functions always return -1 and set 'errno'.
---
 .../StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index fcd907a9bb0da0..61bf3c8528be2b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -3002,7 +3002,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 "execv",
 Signature(ArgTypes{ConstCharPtrTy, CharPtrConstPtr}, RetType{IntTy}),
 Summary(NoEvalCall)
-.Case(ReturnsMinusOne, ErrnoIrrelevant)
+.Case(ReturnsMinusOne, ErrnoNEZeroIrrelevant)
 .ArgConstraint(NotNull(ArgNo(0;
 
 // int execvp(const char *file, char *const argv[]);
@@ -3010,7 +3010,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 "execvp",
 Signature(ArgTypes{ConstCharPtrTy, CharPtrConstPtr}, RetType{IntTy}),
 Summary(NoEvalCall)
-.Case(ReturnsMinusOne, ErrnoIrrelevant)
+.Case(ReturnsMinusOne, ErrnoNEZeroIrrelevant)
 .ArgConstraint(NotNull(ArgNo(0;
 
 // int getopt(int argc, char * const argv[], const char *optstring);

>From e18e2c0318f4582b071e043183cdc874e034cbc2 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Wed, 24 Jan 2024 18:32:54 +0800
Subject: [PATCH 2/2] [clang[analyzer] Improve modeling of 'execv' and 'execvp'
 in StdLibraryFunctionsChecker

These functions always return -1 and set 'errno'.
---
 clang/test/Analysis/errno-stdlibraryfunctions.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/clang/test/Analysis/errno-stdlibraryfunctions.c 
b/clang/test/Analysis/errno-stdlibraryfunctions.c
index 9e3d07e7aa88a0..7876bafc2eb210 100644
--- a/clang/test/Analysis/errno-stdlibraryfunctions.c
+++ b/clang/test/Analysis/errno-stdlibraryfunctions.c
@@ -89,3 +89,17 @@ void errno_getcwd(char *Buf, size_t Sz) {
 if (errno) {}  // expected-warning{{An undefined value 
may be read from 'errno'}}
   }
 }
+
+void errno_execv(char *Path, char * Argv[]) {
+  int Ret = execv(Path, Argv);
+  clang_analyzer_eval(Ret == -1);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+  if (errno) {}// no warning
+}
+
+void errno_execvp(char *File, char * Argv[]) {
+  int Ret = execvp(File, Argv);
+  clang_analyzer_eval(Ret == -1);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+  if (errno) {}// no warning
+}

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


[clang-tools-extra] [flang] [compiler-rt] [lld] [llvm] [libcxx] [clang] [lldb] [libc] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)

2024-01-24 Thread via cfe-commits


@@ -356,14 +356,7 @@ C++23 implementation status
 
   Relaxing some constexpr restrictions
   https://wg21.link/P2448R2";>P2448R2
-  
-Clang 17 (Partial)
- We do not support outside of defaulted special memeber functions the 
change that constexpr functions no
-  longer have to be constexpr compatible but rather support a less 
restricted requirements for constexpr
-  functions. Which include allowing non-literal types as return values 
and parameters, allow calling of
-  non-constexpr functions and constructors.
-
-  
+  Clang 18

cor3ntin wrote:

@AaronBallman WDYT?

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


[clang-tools-extra] [flang] [compiler-rt] [lld] [llvm] [libcxx] [clang] [lldb] [libc] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)

2024-01-24 Thread via cfe-commits


@@ -9108,7 +9123,8 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   //   declaration, it is implicitly considered to be constexpr.
   // FIXME: Only applying this to the first declaration seems problematic, as
   // simple reorderings can affect the meaning of the program.
-  if (First && !FD->isConstexpr() && Info.Constexpr)
+  if ((First && !FD->isConstexpr() && Info.Constexpr) ||
+  getLangOpts().CPlusPlus23)

cor3ntin wrote:

isn't `Info.Constexpr` always true in c++ mode?
I'm trying to think of a meaningful test.

Haybe calling a comparison function of a class with a non-literal member from a 
consteval function?




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


[clang] [libclang/python] Expose Rewriter to the python binding (PR #77269)

2024-01-24 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

@linux4life798 Can you review the last update?

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


[clang] [clang][Interp] Cleaning up `FIXME`s added during `ArrayInitLoopExpr` implementation. (PR #70053)

2024-01-24 Thread Timm Baeder via cfe-commits


@@ -389,10 +391,28 @@ template  class LocalScope : public 
VariableScope {
   if (!Local.Desc->isPrimitive() && !Local.Desc->isPrimitiveArray()) {
 this->Ctx->emitGetPtrLocal(Local.Offset, SourceInfo{});
 this->Ctx->emitRecordDestruction(Local.Desc);
+removeIfStoredOpaqueValue(Local);
   }
 }
   }
 
+  void removeStoredOpaqueValues() {
+if (!Idx)
+  return;
+
+for (Scope::Local &Local : this->Ctx->Descriptors[*Idx]) {
+  removeIfStoredOpaqueValue(Local);
+}
+  }
+
+  void removeIfStoredOpaqueValue(const Scope::Local &Local) {
+if (auto *OVE =
+llvm::dyn_cast_or_null(Local.Desc->asExpr());

tbaederr wrote:

```suggestion
llvm::dyn_cast_if_present(Local.Desc->asExpr());
```

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


[clang] [clang][Interp] Cleaning up `FIXME`s added during `ArrayInitLoopExpr` implementation. (PR #70053)

2024-01-24 Thread Timm Baeder via cfe-commits


@@ -389,10 +391,28 @@ template  class LocalScope : public 
VariableScope {
   if (!Local.Desc->isPrimitive() && !Local.Desc->isPrimitiveArray()) {
 this->Ctx->emitGetPtrLocal(Local.Offset, SourceInfo{});
 this->Ctx->emitRecordDestruction(Local.Desc);
+removeIfStoredOpaqueValue(Local);
   }
 }
   }
 
+  void removeStoredOpaqueValues() {
+if (!Idx)
+  return;
+
+for (Scope::Local &Local : this->Ctx->Descriptors[*Idx]) {

tbaederr wrote:

```suggestion
for (const Scope::Local &Local : this->Ctx->Descriptors[*Idx]) {
```

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


[clang] [clang][Interp] Cleaning up `FIXME`s added during `ArrayInitLoopExpr` implementation. (PR #70053)

2024-01-24 Thread Timm Baeder via cfe-commits


@@ -368,6 +369,7 @@ template  class LocalScope : public 
VariableScope {
   return;
 this->emitDestructors();
 this->Ctx->emitDestroy(*Idx, SourceInfo{});
+removeStoredOpaqueValues();

tbaederr wrote:

Inline this function here.

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


[clang] [clang][Interp] Cleaning up `FIXME`s added during `ArrayInitLoopExpr` implementation. (PR #70053)

2024-01-24 Thread Timm Baeder via cfe-commits


@@ -389,10 +391,28 @@ template  class LocalScope : public 
VariableScope {
   if (!Local.Desc->isPrimitive() && !Local.Desc->isPrimitiveArray()) {
 this->Ctx->emitGetPtrLocal(Local.Offset, SourceInfo{});
 this->Ctx->emitRecordDestruction(Local.Desc);
+removeIfStoredOpaqueValue(Local);
   }
 }
   }
 
+  void removeStoredOpaqueValues() {
+if (!Idx)
+  return;
+
+for (Scope::Local &Local : this->Ctx->Descriptors[*Idx]) {
+  removeIfStoredOpaqueValue(Local);
+}
+  }
+
+  void removeIfStoredOpaqueValue(const Scope::Local &Local) {
+if (auto *OVE =
+llvm::dyn_cast_or_null(Local.Desc->asExpr());
+OVE && this->Ctx->OpaqueExprs.contains(OVE)) {
+  this->Ctx->OpaqueExprs.erase(OVE);

tbaederr wrote:

This needs to be a `find()` + `erase()` combination so we don't do the lookup 
twice.

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


[clang] fb9a82b - [clang-repl] Refine fix for linker error: PLT offset too large

2024-01-24 Thread Stefan Gränitz via cfe-commits

Author: Stefan Gränitz
Date: 2024-01-24T11:45:04+01:00
New Revision: fb9a82b0235713782c1cf9d1eba20ce8d95766f7

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

LOG: [clang-repl] Refine fix for linker error: PLT offset too large

This is a follow-up improvement after the discussion in #78959

Added: 


Modified: 
clang/tools/clang-repl/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/clang-repl/CMakeLists.txt 
b/clang/tools/clang-repl/CMakeLists.txt
index 031dcaba5e4468..d3dec1984b78d2 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -23,12 +23,13 @@ if(CLANG_PLUGIN_SUPPORT)
   export_executable_symbols_for_plugins(clang-repl)
 endif()
 
-string(TOUPPER "${CMAKE_SYSTEM_PROCESSOR}" system_processor)
-if(system_processor MATCHES "ARM")
-  set(FLAG_LONG_PLT "-Wl,--long-plt")
-  llvm_check_linker_flag(CXX ${FLAG_LONG_PLT} LINKER_HAS_FLAG_LONG_PLT)
-  # Linkers without this flag are assumed to have long PLTs by default
-  if(LINKER_HAS_FLAG_LONG_PLT)
-target_link_options(clang-repl PRIVATE ${FLAG_LONG_PLT})
-  endif()
+# The clang-repl binary can get huge with static linking in debug mode.
+# Some 32-bit targets use PLT slots with limited branch range by default and we
+# start to exceed this limit, e.g. when linking for arm-linux-gnueabihf with
+# gold. This flag tells the linker to build a PLT for the full address range.
+# Linkers without this flag are assumed to support proper PLTs by default.
+set(flag_long_plt "-Wl,--long-plt")
+llvm_check_linker_flag(CXX ${flag_long_plt} HAVE_LINKER_FLAG_LONG_PLT)
+if(HAVE_LINKER_FLAG_LONG_PLT)
+  target_link_options(clang-repl PRIVATE ${flag_long_plt})
 endif()



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


[clang] [clang][analyzer] Support `fgets` in the SteamChecker (PR #73638)

2024-01-24 Thread Balazs Benics via cfe-commits


@@ -778,42 +781,61 @@ void StreamChecker::evalFgetc(const FnDescription *Desc, 
const CallEvent &Call,
   assertStreamStateOpened(OldSS);
 

steakhal wrote:

This patch caused a downstream test failure.
Here is the fix:

```suggestion
  // We don't model the buffer, thus they should escape.
  State = Call.invalidateRegions(C.blockCount(), State);
```

Test where it currently breaks:
```c++
void test_double_switch_ok() {
  char buffer[10] = {10};
  FILE *F1 = tmpfile();
  if (!F1)
return;

  char* s = fgets(buffer, sizeof(buffer), F1); // ok
  if (s) {
clang_analyzer_dump_char(buffer[0]); // expected-warning {{conj_$}} Should 
not preserve the previous value, thus should not be 10.
  }
  // Hmm, what do we know of the buffer on failure? IDK.

  fclose(F1);
}
```

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


[llvm] [clang] [mlir] [AMDGPU] Add GFX12 WMMA and SWMMAC instructions (PR #77795)

2024-01-24 Thread Piotr Sobczak via cfe-commits

https://github.com/piotrAMD approved this pull request.


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


[llvm] [clang-tools-extra] [clang] [Clang] Fix : More Detailed "No expected directives found" (PR #78338)

2024-01-24 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr edited 
https://github.com/llvm/llvm-project/pull/78338
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang-tools-extra] [Clang] Fix : More Detailed "No expected directives found" (PR #78338)

2024-01-24 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr requested changes to this pull request.


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


[clang] [llvm] [clang-tools-extra] [Clang] Fix : More Detailed "No expected directives found" (PR #78338)

2024-01-24 Thread Timm Baeder via cfe-commits


@@ -1098,7 +1098,13 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
 // Produce an error if no expected-* directives could be found in the
 // source file(s) processed.
 if (Status == HasNoDirectives) {
-  Diags.Report(diag::err_verify_no_directives).setForceEmit();
+  std::string directives;

tbaederr wrote:

```suggestion
  std::string Directive;
```

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


[clang] [clang-tools-extra] [llvm] [Clang] Fix : More Detailed "No expected directives found" (PR #78338)

2024-01-24 Thread Timm Baeder via cfe-commits


@@ -1098,7 +1098,13 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
 // Produce an error if no expected-* directives could be found in the
 // source file(s) processed.
 if (Status == HasNoDirectives) {
-  Diags.Report(diag::err_verify_no_directives).setForceEmit();
+  std::string directives;
+  if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) {
+directives = "expected";

tbaederr wrote:

I don't think this can be empty. Have you checked that this can actually happen?

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


[clang] [clang-tools-extra] [llvm] [Clang] Fix : More Detailed "No expected directives found" (PR #78338)

2024-01-24 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Adding Aaron since we're probably getting close.

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


[clang] [clang][analyzer] Support `fgets` in the SteamChecker (PR #73638)

2024-01-24 Thread Balazs Benics via cfe-commits

https://github.com/steakhal edited 
https://github.com/llvm/llvm-project/pull/73638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Mark the fallthrough coreturn statement implicit. (PR #77465)

2024-01-24 Thread Haojian Wu via cfe-commits

https://github.com/hokein updated 
https://github.com/llvm/llvm-project/pull/77465

>From 781201c5c0a526821f51ce6aa0e2c972a9f5f51f Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Tue, 9 Jan 2024 14:02:01 +0100
Subject: [PATCH 1/2] [AST] Mark the fallthrough coreturn statement implicit.

---
 clang/lib/Sema/SemaCoroutine.cpp  | 2 +-
 clang/test/AST/ast-dump-coroutine.cpp | 6 ++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index 4e600fd29ee7395..a171ab579cba838 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1748,7 +1748,7 @@ bool CoroutineStmtBuilder::makeOnFallthrough() {
   return false;
   } else if (HasRVoid) {
 Fallthrough = S.BuildCoreturnStmt(FD.getLocation(), nullptr,
-  /*IsImplicit*/false);
+  /*IsImplicit*/true);
 Fallthrough = S.ActOnFinishFullStmt(Fallthrough.get());
 if (Fallthrough.isInvalid())
   return false;
diff --git a/clang/test/AST/ast-dump-coroutine.cpp 
b/clang/test/AST/ast-dump-coroutine.cpp
index 5e7736300f9fee8..8741c7b35b155aa 100644
--- a/clang/test/AST/ast-dump-coroutine.cpp
+++ b/clang/test/AST/ast-dump-coroutine.cpp
@@ -52,8 +52,7 @@ Task test()  {
 // CHECK-NEXT:   |-CXXMemberCallExpr  {{.*}} 'std::suspend_always'
 // CHECK-NEXT:   |   | `-MemberExpr {{.*}} .initial_suspend
 //   ...
-// FIXME: the CoreturnStmt should be marked as implicit
-// CHECK: CoreturnStmt {{.*}} {{$}}
+// CHECK: CoreturnStmt {{.*}}  implicit
 
 Task test2()  {
 // Writen souce code, verify no implicit bit for the co_return expr.
@@ -65,5 +64,4 @@ Task test2()  {
 // CHECK:|-DeclStmt {{.*}}
 // CHECK-NEXT:   | `-VarDecl {{.*}} implicit used __promise
 //   ...
-// FIXME: the CoreturnStmt should be marked as implicit
-// CHECK: CoreturnStmt {{.*}} {{$}}
+// CHECK: CoreturnStmt {{.*}}  implicit

>From 7ac002e371e2b3c089c5f7f771da9064481f551b Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Wed, 24 Jan 2024 11:51:53 +0100
Subject: [PATCH 2/2] Address a comment.

---
 clang/lib/Sema/SemaCoroutine.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index a171ab579cba838..a969b9383563b22 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1748,7 +1748,7 @@ bool CoroutineStmtBuilder::makeOnFallthrough() {
   return false;
   } else if (HasRVoid) {
 Fallthrough = S.BuildCoreturnStmt(FD.getLocation(), nullptr,
-  /*IsImplicit*/true);
+  /*IsImplicit=*/true);
 Fallthrough = S.ActOnFinishFullStmt(Fallthrough.get());
 if (Fallthrough.isInvalid())
   return false;

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


[clang] [AMDGPU][GFX12] Add tests for unsupported builtins (PR #78729)

2024-01-24 Thread Jay Foad via cfe-commits

https://github.com/jayfoad edited 
https://github.com/llvm/llvm-project/pull/78729
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AMDGPU][GFX12] Add tests for unsupported builtins (PR #78729)

2024-01-24 Thread Jay Foad via cfe-commits

https://github.com/jayfoad approved this pull request.

LGTM.

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


[clang] [AMDGPU][GFX12] Add tests for unsupported builtins (PR #78729)

2024-01-24 Thread Jay Foad via cfe-commits


@@ -4,10 +4,114 @@
 
 typedef unsigned int uint;
 
-kernel void test_builtins_amdgcn_gws_insts(uint a, uint b) {
+#pragma OPENCL EXTENSION cl_khr_fp64:enable
+
+typedef float  v2f   __attribute__((ext_vector_type(2)));
+typedef float  v4f   __attribute__((ext_vector_type(4)));
+typedef float  v16f  __attribute__((ext_vector_type(16)));
+typedef float  v32f  __attribute__((ext_vector_type(32)));
+typedef half   v4h   __attribute__((ext_vector_type(4)));
+typedef half   v8h   __attribute__((ext_vector_type(8)));
+typedef half   v16h  __attribute__((ext_vector_type(16)));
+typedef half   v32h  __attribute__((ext_vector_type(32)));
+typedef intv2i   __attribute__((ext_vector_type(2)));
+typedef intv4i   __attribute__((ext_vector_type(4)));
+typedef intv16i  __attribute__((ext_vector_type(16)));
+typedef intv32i  __attribute__((ext_vector_type(32)));
+typedef short  v2s   __attribute__((ext_vector_type(2)));
+typedef short  v4s   __attribute__((ext_vector_type(4)));
+typedef short  v8s   __attribute__((ext_vector_type(8)));
+typedef short  v16s  __attribute__((ext_vector_type(16)));
+typedef short  v32s  __attribute__((ext_vector_type(32)));
+typedef double v4d   __attribute__((ext_vector_type(4)));
+
+void builtin_test_unsupported(global v32f*out_v32f,
+  global v16f*out_v16f,
+  global v4f* out_v4f,
+  global v32i*out_v32i,
+  global v16i*out_v16i,
+  global v4i* out_v4i,
+  global v4d* out_v4d,
+  global double*  out_double,
+  double a_double , double b_double , double 
c_double,

jayfoad wrote:

Nit: you don't really need separate out/a/b/c versions of all these types. You 
could just test expressions like:
```
x_v32f = __builtin_amdgcn_mfma_f32_32x32x1f32(x_float, x_float, x_v32f, 0, 0, 
0);
```

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


[clang] [AMDGPU][GFX12] Add tests for unsupported builtins (PR #78729)

2024-01-24 Thread Mariusz Sikora via cfe-commits


@@ -4,10 +4,114 @@
 
 typedef unsigned int uint;
 
-kernel void test_builtins_amdgcn_gws_insts(uint a, uint b) {
+#pragma OPENCL EXTENSION cl_khr_fp64:enable
+
+typedef float  v2f   __attribute__((ext_vector_type(2)));
+typedef float  v4f   __attribute__((ext_vector_type(4)));
+typedef float  v16f  __attribute__((ext_vector_type(16)));
+typedef float  v32f  __attribute__((ext_vector_type(32)));
+typedef half   v4h   __attribute__((ext_vector_type(4)));
+typedef half   v8h   __attribute__((ext_vector_type(8)));
+typedef half   v16h  __attribute__((ext_vector_type(16)));
+typedef half   v32h  __attribute__((ext_vector_type(32)));
+typedef intv2i   __attribute__((ext_vector_type(2)));
+typedef intv4i   __attribute__((ext_vector_type(4)));
+typedef intv16i  __attribute__((ext_vector_type(16)));
+typedef intv32i  __attribute__((ext_vector_type(32)));
+typedef short  v2s   __attribute__((ext_vector_type(2)));
+typedef short  v4s   __attribute__((ext_vector_type(4)));
+typedef short  v8s   __attribute__((ext_vector_type(8)));
+typedef short  v16s  __attribute__((ext_vector_type(16)));
+typedef short  v32s  __attribute__((ext_vector_type(32)));
+typedef double v4d   __attribute__((ext_vector_type(4)));
+
+void builtin_test_unsupported(global v32f*out_v32f,
+  global v16f*out_v16f,
+  global v4f* out_v4f,
+  global v32i*out_v32i,
+  global v16i*out_v16i,
+  global v4i* out_v4i,
+  global v4d* out_v4d,
+  global double*  out_double,
+  double a_double , double b_double , double 
c_double,

mariusz-sikora-at-amd wrote:

Thanks, I will update these.

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


[clang] 9dddb3d - [AST] Mark the fallthrough coreturn statement implicit. (#77465)

2024-01-24 Thread via cfe-commits

Author: Haojian Wu
Date: 2024-01-24T12:11:00+01:00
New Revision: 9dddb3d5f3bf323b7b7f8281bb848731f69fddfa

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

LOG: [AST] Mark the fallthrough coreturn statement implicit. (#77465)

This is a followup of #77311.

Added: 


Modified: 
clang/lib/Sema/SemaCoroutine.cpp
clang/test/AST/ast-dump-coroutine.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 4e600fd29ee7395..a969b9383563b22 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1748,7 +1748,7 @@ bool CoroutineStmtBuilder::makeOnFallthrough() {
   return false;
   } else if (HasRVoid) {
 Fallthrough = S.BuildCoreturnStmt(FD.getLocation(), nullptr,
-  /*IsImplicit*/false);
+  /*IsImplicit=*/true);
 Fallthrough = S.ActOnFinishFullStmt(Fallthrough.get());
 if (Fallthrough.isInvalid())
   return false;

diff  --git a/clang/test/AST/ast-dump-coroutine.cpp 
b/clang/test/AST/ast-dump-coroutine.cpp
index 5e7736300f9fee8..8741c7b35b155aa 100644
--- a/clang/test/AST/ast-dump-coroutine.cpp
+++ b/clang/test/AST/ast-dump-coroutine.cpp
@@ -52,8 +52,7 @@ Task test()  {
 // CHECK-NEXT:   |-CXXMemberCallExpr  {{.*}} 'std::suspend_always'
 // CHECK-NEXT:   |   | `-MemberExpr {{.*}} .initial_suspend
 //   ...
-// FIXME: the CoreturnStmt should be marked as implicit
-// CHECK: CoreturnStmt {{.*}} {{$}}
+// CHECK: CoreturnStmt {{.*}}  implicit
 
 Task test2()  {
 // Writen souce code, verify no implicit bit for the co_return expr.
@@ -65,5 +64,4 @@ Task test2()  {
 // CHECK:|-DeclStmt {{.*}}
 // CHECK-NEXT:   | `-VarDecl {{.*}} implicit used __promise
 //   ...
-// FIXME: the CoreturnStmt should be marked as implicit
-// CHECK: CoreturnStmt {{.*}} {{$}}
+// CHECK: CoreturnStmt {{.*}}  implicit



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


[clang] [AST] Mark the fallthrough coreturn statement implicit. (PR #77465)

2024-01-24 Thread Haojian Wu via cfe-commits

https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/77465
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang-tools-extra] [clang] [Docs] Fix CMakeLists.txt in doc (PR #79273)

2024-01-24 Thread via cfe-commits

https://github.com/LukeLIN-web updated 
https://github.com/llvm/llvm-project/pull/79273

>From 5bec4cb8a832ace256c69993f12ceae9fddedf85 Mon Sep 17 00:00:00 2001
From: Luke <1263810...@qq.com>
Date: Wed, 24 Jan 2024 14:07:31 +0300
Subject: [PATCH] fix CMakeLists.txt in doc

---
 llvm/docs/WritingAnLLVMNewPMPass.rst | 4 
 1 file changed, 4 insertions(+)

diff --git a/llvm/docs/WritingAnLLVMNewPMPass.rst 
b/llvm/docs/WritingAnLLVMNewPMPass.rst
index 799863c7864ecc..fb95c24691a6f1 100644
--- a/llvm/docs/WritingAnLLVMNewPMPass.rst
+++ b/llvm/docs/WritingAnLLVMNewPMPass.rst
@@ -129,6 +129,10 @@ manager will ensure that the pass will be run on every 
function in a module.
 The ``PreservedAnalyses`` return value says that all analyses (e.g. dominator
 tree) are still valid after this pass since we didn't modify any functions.
 
+We need to put  ``HelloWorld.cpp`` to ``add_llvm_component_library`` in the
+``llvm/lib/Transforms/Utils/CMakeLists.txt`` file. This will ensure that the
+pass is built and linked into ``opt``.
+
 That's it for the pass itself. Now in order to "register" the pass, we need
 to add it to a couple places. Add the following to
 ``llvm/lib/Passes/PassRegistry.def`` in the ``FUNCTION_PASS`` section

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


[llvm] [clang-tools-extra] [clang] [Docs] Fix running-a-pass-with-opt in doc (PR #79273)

2024-01-24 Thread via cfe-commits

https://github.com/LukeLIN-web edited 
https://github.com/llvm/llvm-project/pull/79273
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libc] [compiler-rt] [libcxx] [lldb] [pstl] [flang] [clang-tools-extra] [mlir] [openmp] [lld] [llvm] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-24 Thread Mariusz Sikora via cfe-commits
Mirko =?utf-8?q?Brkušanin?= ,
Mirko =?utf-8?q?Brkušanin?= ,Mirko Brkusanin
 ,Mariusz Sikora 
Message-ID:
In-Reply-To: 


https://github.com/mariusz-sikora-at-amd closed 
https://github.com/llvm/llvm-project/pull/78414
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AArch64][SME] Implement inline-asm clobbers for za/zt0 (PR #79276)

2024-01-24 Thread Matthew Devereau via cfe-commits

https://github.com/MDevereau created 
https://github.com/llvm/llvm-project/pull/79276

This enables specifing "za" or "zt0" to the clobber list for inline asm. This 
complies with the acle SME addition to the asm extension here:
https://github.com/ARM-software/acle/pull/276

>From e98987ebb48839ea652d63dfaa62ed841b426e46 Mon Sep 17 00:00:00 2001
From: Matt Devereau 
Date: Thu, 18 Jan 2024 15:41:25 +
Subject: [PATCH] [AArch64][SME] Implement inline-asm clobbers for za/zt0

This enables specifing "za" or "zt0" to the clobber list
for inline asm. This complies with the acle SME addition to the
asm extension here:
https://github.com/ARM-software/acle/pull/276
---
 clang/lib/Basic/Targets/AArch64.cpp |  5 -
 clang/test/CodeGen/aarch64-inline-asm.c |  8 
 llvm/lib/Target/AArch64/AArch64ISelLowering.cpp |  8 
 llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp |  4 
 llvm/test/CodeGen/AArch64/aarch64-za-clobber.ll | 16 
 5 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/CodeGen/AArch64/aarch64-za-clobber.ll

diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index d47181bfca4fc86..781118c9358987b 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1200,7 +1200,10 @@ const char *const AArch64TargetInfo::GCCRegNames[] = {
 
 // SVE predicate-as-counter registers
 "pn0",  "pn1",  "pn2",  "pn3",  "pn4",  "pn5",  "pn6",  "pn7",  "pn8",
-"pn9",  "pn10", "pn11", "pn12", "pn13", "pn14", "pn15"
+"pn9",  "pn10", "pn11", "pn12", "pn13", "pn14", "pn15",
+
+// SME registers
+"za", "zt0",
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {
diff --git a/clang/test/CodeGen/aarch64-inline-asm.c 
b/clang/test/CodeGen/aarch64-inline-asm.c
index 75e9a8c46b87692..8ddee560b11da4f 100644
--- a/clang/test/CodeGen/aarch64-inline-asm.c
+++ b/clang/test/CodeGen/aarch64-inline-asm.c
@@ -95,3 +95,11 @@ void test_reduced_gpr_constraints(int var32, long var64) {
 // CHECK: [[ARG2:%.+]] = load i64, ptr
 // CHECK: call void asm sideeffect "add x0, x0, $0", "@3Ucj,~{x0}"(i64 
[[ARG2]])
 }
+
+void test_sme_constraints(){
+  asm("movt zt0[3, mul vl], z0" : : : "za");
+// CHECK: call void asm sideeffect "movt zt0[3, mul vl], z0", "~{za}"()
+
+  asm("movt zt0[3, mul vl], z0" : : : "zt0");
+// CHECK: call void asm sideeffect "movt zt0[3, mul vl], z0", "~{zt0}"()
+}
\ No newline at end of file
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 332fb37655288ce..6a210846cf4dffe 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -10702,6 +10702,14 @@ AArch64TargetLowering::getRegForInlineAsmConstraint(
   parseConstraintCode(Constraint) != AArch64CC::Invalid)
 return std::make_pair(unsigned(AArch64::NZCV), &AArch64::CCRRegClass);
 
+  if (StringRef("{za}").equals_insensitive(Constraint)){
+return std::make_pair(unsigned(AArch64::ZA), &AArch64::MPRRegClass);
+  }
+
+  if (StringRef("{zt0}").equals_insensitive(Constraint)){
+return std::make_pair(unsigned(AArch64::ZT0), &AArch64::ZTRRegClass);
+  }
+
   // Use the default implementation in TargetLowering to convert the register
   // constraint into a member of a register class.
   std::pair Res;
diff --git a/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
index ea9882160d6fb29..7d6b86ab8a3e957 100644
--- a/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
@@ -507,6 +507,10 @@ bool AArch64RegisterInfo::isAsmClobberable(const 
MachineFunction &MF,
 MCRegisterInfo::regsOverlap(PhysReg, AArch64::X16))
 return true;
 
+  // ZA/ZT0 registers are reserved but may be permitted in the clobber list.
+  if (PhysReg.id() == AArch64::ZA || PhysReg.id() == AArch64::ZT0)
+return true;
+
   return !isReservedReg(MF, PhysReg);
 }
 
diff --git a/llvm/test/CodeGen/AArch64/aarch64-za-clobber.ll 
b/llvm/test/CodeGen/AArch64/aarch64-za-clobber.ll
new file mode 100644
index 000..a8cba7dc9a91e9a
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/aarch64-za-clobber.ll
@@ -0,0 +1,16 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64-none-linux-gnu -stop-after=aarch64-isel < %s -o - 
| FileCheck %s
+
+define void @alpha( %x) local_unnamed_addr {
+entry:
+; CHECK: INLINEASM &"movt zt0[3, mul vl], z0", 1 /* sideeffect attdialect */, 
12 /* clobber */, implicit-def early-clobber $za
+  tail call void asm sideeffect "movt zt0[3, mul vl], z0", "~{za}"()
+  ret void
+}
+
+define void @beta( %x) local_unnamed_addr {
+entry:
+; CHECK: INLINEASM &"movt zt0[3, mul vl], z0", 1 /* sideeffect attdialect */, 
12 /* clobber */, implicit-def early-clobber $zt0
+  tail call void asm sideeffect "movt zt0[3, mul vl], z0", 

[clang] [clang][Interp] Cleaning up `FIXME`s added during `ArrayInitLoopExpr` implementation. (PR #70053)

2024-01-24 Thread via cfe-commits


@@ -368,6 +369,7 @@ template  class LocalScope : public 
VariableScope {
   return;
 this->emitDestructors();
 this->Ctx->emitDestroy(*Idx, SourceInfo{});
+removeStoredOpaqueValues();

isuckatcs wrote:

This function has 2 callsites, you want the other callsite inlined too, or you 
want me to remove that?

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


[clang] [libc++] Add builtin to clear padding bytes (prework for P0528R3) (PR #75371)

2024-01-24 Thread via cfe-commits

https://github.com/huixie90 ready_for_review 
https://github.com/llvm/llvm-project/pull/75371
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AArch64][SME] Implement inline-asm clobbers for za/zt0 (PR #79276)

2024-01-24 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff cfddb59be2124f7ec615f48a2d0395c6fdb1bb56 
e98987ebb48839ea652d63dfaa62ed841b426e46 -- clang/lib/Basic/Targets/AArch64.cpp 
clang/test/CodeGen/aarch64-inline-asm.c 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 781118c935..e15242e79e 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1165,45 +1165,248 @@ TargetInfo::BuiltinVaListKind 
AArch64TargetInfo::getBuiltinVaListKind() const {
 
 const char *const AArch64TargetInfo::GCCRegNames[] = {
 // 32-bit Integer registers
-"w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10", "w11",
-"w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19", "w20", "w21", 
"w22",
-"w23", "w24", "w25", "w26", "w27", "w28", "w29", "w30", "wsp",
+"w0",
+"w1",
+"w2",
+"w3",
+"w4",
+"w5",
+"w6",
+"w7",
+"w8",
+"w9",
+"w10",
+"w11",
+"w12",
+"w13",
+"w14",
+"w15",
+"w16",
+"w17",
+"w18",
+"w19",
+"w20",
+"w21",
+"w22",
+"w23",
+"w24",
+"w25",
+"w26",
+"w27",
+"w28",
+"w29",
+"w30",
+"wsp",
 
 // 64-bit Integer registers
-"x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11",
-"x12", "x13", "x14", "x15", "x16", "x17", "x18", "x19", "x20", "x21", 
"x22",
-"x23", "x24", "x25", "x26", "x27", "x28", "fp", "lr", "sp",
+"x0",
+"x1",
+"x2",
+"x3",
+"x4",
+"x5",
+"x6",
+"x7",
+"x8",
+"x9",
+"x10",
+"x11",
+"x12",
+"x13",
+"x14",
+"x15",
+"x16",
+"x17",
+"x18",
+"x19",
+"x20",
+"x21",
+"x22",
+"x23",
+"x24",
+"x25",
+"x26",
+"x27",
+"x28",
+"fp",
+"lr",
+"sp",
 
 // 32-bit floating point regsisters
-"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11",
-"s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", 
"s22",
-"s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
+"s0",
+"s1",
+"s2",
+"s3",
+"s4",
+"s5",
+"s6",
+"s7",
+"s8",
+"s9",
+"s10",
+"s11",
+"s12",
+"s13",
+"s14",
+"s15",
+"s16",
+"s17",
+"s18",
+"s19",
+"s20",
+"s21",
+"s22",
+"s23",
+"s24",
+"s25",
+"s26",
+"s27",
+"s28",
+"s29",
+"s30",
+"s31",
 
 // 64-bit floating point regsisters
-"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11",
-"d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", 
"d22",
-"d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
+"d0",
+"d1",
+"d2",
+"d3",
+"d4",
+"d5",
+"d6",
+"d7",
+"d8",
+"d9",
+"d10",
+"d11",
+"d12",
+"d13",
+"d14",
+"d15",
+"d16",
+"d17",
+"d18",
+"d19",
+"d20",
+"d21",
+"d22",
+"d23",
+"d24",
+"d25",
+"d26",
+"d27",
+"d28",
+"d29",
+"d30",
+"d31",
 
 // Neon vector registers
-"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
-"v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", 
"v22",
-"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+"v0",
+"v1",
+"v2",
+"v3",
+"v4",
+"v5",
+"v6",
+"v7",
+"v8",
+"v9",
+"v10",
+"v11",
+"v12",
+"v13",
+"v14",
+"v15",
+"v16",
+"v17",
+"v18",
+"v19",
+"v20",
+"v21",
+"v22",
+"v23",
+"v24",
+"v25",
+"v26",
+"v27",
+"v28",
+"v29",
+"v30",
+"v31",
 
 // SVE vector registers
-"z0",  "z1",  "z2",  "z3",  "z4",  "z5",  "z6",  "z7",  "z8",  "z9",  
"z10",
-"z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", 
"z21",
-"z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31",
+"z0",
+"z1",
+"z2",
+"z3",
+"z4",
+"z5",
+"z6",
+"z7",
+"z8",
+"z9",
+"z10",
+"z11",
+"z12",
+"z13",
+"z14",
+"z15",
+"z16",
+"z17",
+"z18",
+"z19",
+"z20",
+"z21",
+"z22",
+"z23",
+"z24",
+"z25",
+"z26",
+"z27",
+"z28",
+"z29",
+"z30",
+"z31",
 
 // SVE predicate registers
-"p0",  "p1",  "p2",  "p3",  "p4",  "p5",  "p6",  "p7",  "p8",  "p9",  
"p10",
-"p11", "p12", "p13", "p14", "p15",
+"p0",
+"p1",
+"p2",
+"p3",
+"p4",
+"p5",
+"p6",
+ 

[clang] [LTO] Fix Veclib flags correctly pass to LTO flags (PR #78749)

2024-01-24 Thread David Sherwood via cfe-commits

https://github.com/david-arm approved this pull request.

LGTM as well!

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


[libc] [lld] [flang] [clang] [libcxx] [compiler-rt] [llvm] [clang-tools-extra] [lldb] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)

2024-01-24 Thread Mariya Podchishchaeva via cfe-commits


@@ -9108,7 +9123,8 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   //   declaration, it is implicitly considered to be constexpr.
   // FIXME: Only applying this to the first declaration seems problematic, as
   // simple reorderings can affect the meaning of the program.
-  if (First && !FD->isConstexpr() && Info.Constexpr)
+  if ((First && !FD->isConstexpr() && Info.Constexpr) ||
+  getLangOpts().CPlusPlus23)

Fznamznon wrote:

> isn't Info.Constexpr always true in c++ mode?

Hmm, then we probably don't need this change at all?

> Haybe calling a comparison function of a class with a non-literal member from 
> a consteval function?

Should the call to such function be allowed? I suppose not due to-literal 
member. The problem is, there result is same with our without this change. I 
meant to apply this:

> CheckExplicitlyDefaultedComparison should alwways set the constexpr flag in 
> c++23 mode per 
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2448r2.html#pnum_39

Did I misunderstand?

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


[clang] [clang][Interp] Cleaning up `FIXME`s added during `ArrayInitLoopExpr` implementation. (PR #70053)

2024-01-24 Thread Timm Baeder via cfe-commits


@@ -368,6 +369,7 @@ template  class LocalScope : public 
VariableScope {
   return;
 this->emitDestructors();
 this->Ctx->emitDestroy(*Idx, SourceInfo{});
+removeStoredOpaqueValues();

tbaederr wrote:

Ah, didn't see that. Well, it's fine to leave it then.

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


[clang] dee02ee - [clang][Interp][NFC] Complex elements can only be primitives

2024-01-24 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-01-24T12:56:16+01:00
New Revision: dee02ee9f8ffc74fea6c54f4c00df16e7ca4c8a1

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

LOG: [clang][Interp][NFC] Complex elements can only be primitives

So, return a PrimType directly from classifyComplexElementType().

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index cfcef067b92bdc3..24a33c32df14042 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -601,8 +601,8 @@ bool ByteCodeExprGen::VisitComplexBinOp(const 
BinaryOperator *E) {
 
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
-  PrimType LHSElemT = *this->classifyComplexElementType(LHS->getType());
-  PrimType RHSElemT = *this->classifyComplexElementType(RHS->getType());
+  PrimType LHSElemT = this->classifyComplexElementType(LHS->getType());
+  PrimType RHSElemT = this->classifyComplexElementType(RHS->getType());
 
   unsigned LHSOffset = this->allocateLocalPrimitive(LHS, PT_Ptr, true, false);
   unsigned RHSOffset = this->allocateLocalPrimitive(RHS, PT_Ptr, true, false);
@@ -2992,7 +2992,7 @@ bool ByteCodeExprGen::emitComplexReal(const Expr 
*SubExpr) {
   // Since our _Complex implementation does not map to a primitive type,
   // we sometimes have to do the lvalue-to-rvalue conversion here manually.
   if (!SubExpr->isLValue())
-return this->emitLoadPop(*classifyComplexElementType(SubExpr->getType()),
+return this->emitLoadPop(classifyComplexElementType(SubExpr->getType()),
  SubExpr);
   return true;
 }

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index df4cb736299cb62..63ea8292b587675 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -282,12 +282,12 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
   }
 
   bool emitPrimCast(PrimType FromT, PrimType ToT, QualType ToQT, const Expr 
*E);
-  std::optional classifyComplexElementType(QualType T) const {
+  PrimType classifyComplexElementType(QualType T) const {
 assert(T->isAnyComplexType());
 
 QualType ElemType = T->getAs()->getElementType();
 
-return this->classify(ElemType);
+return *this->classify(ElemType);
   }
 
   bool emitComplexReal(const Expr *SubExpr);



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


[clang] [mlir] [llvm] [AMDGPU] Add GFX12 WMMA and SWMMAC instructions (PR #77795)

2024-01-24 Thread Mirko Brkušanin via cfe-commits

mbrkusanin wrote:

Rebased and updated after https://github.com/llvm/llvm-project/pull/76143

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


[llvm] [clang] [clang-tools-extra] [Clang] Fix : More Detailed "No expected directives found" (PR #78338)

2024-01-24 Thread Shourya Goel via cfe-commits


@@ -1098,7 +1098,13 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
 // Produce an error if no expected-* directives could be found in the
 // source file(s) processed.
 if (Status == HasNoDirectives) {
-  Diags.Report(diag::err_verify_no_directives).setForceEmit();
+  std::string directives;
+  if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) {
+directives = "expected";

Sh0g0-1758 wrote:

yes, when there are no diagnostics passed in the verify, ie. when we pass 
```-verify=``` only. In this case ```expected-no-directives``` should be the 
error output when no directives are present. and when we pass ```-verify=foo``` 
then ```foo-no-diagnostics``` should be the error when no foo directives are 
present. If I don't include this check, then with only ```-verify=``` it 
results in a segmentation fault. 

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


[llvm] [clang] [clang-tools-extra] [Clang] Fix : More Detailed "No expected directives found" (PR #78338)

2024-01-24 Thread Shourya Goel via cfe-commits

https://github.com/Sh0g0-1758 updated 
https://github.com/llvm/llvm-project/pull/78338

>From b98f02d4c155b5be9bd4f5b2e4bf73720a81f39a Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 
Date: Wed, 17 Jan 2024 01:24:17 +0530
Subject: [PATCH 01/10] Fix : more detailed no expected directive message

---
 clang-tools-extra/clangd/test/indexer.test   | 2 +-
 clang/include/clang/Basic/Diagnostic.h   | 4 +++-
 clang/include/clang/Basic/DiagnosticFrontendKinds.td | 2 +-
 clang/lib/AST/ASTContext.cpp | 2 +-
 clang/lib/Frontend/VerifyDiagnosticConsumer.cpp  | 4 +++-
 clang/test/ARCMT/verify.m| 2 +-
 clang/test/Frontend/verify.c | 2 +-
 clang/test/Frontend/verify2.c| 2 +-
 clang/test/Frontend/verify3.c| 4 ++--
 9 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/clang-tools-extra/clangd/test/indexer.test 
b/clang-tools-extra/clangd/test/indexer.test
index 2f01f6c557a7de..213d33f8e2d6a5 100644
--- a/clang-tools-extra/clangd/test/indexer.test
+++ b/clang-tools-extra/clangd/test/indexer.test
@@ -5,5 +5,5 @@
 # `.ii` file and `-verify` triggers extra diagnostics generation. Clangd should
 # strip those.
 # RUN: clangd-indexer %t.cpp -- -Xclang -verify --save-temps -- 2>&1 | 
FileCheck %s
-# CHECK-NOT: error: no expected directives found: consider use of 
'expected-no-diagnostics'
+# CHECK-NOT: error: no expected directives found: consider use of 
{{.*}}-no-diagnostics
 # RUN: not ls %t.ii
diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 0c7836c2ea569c..a185c75e418b58 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -9,7 +9,9 @@
 /// \file
 /// Defines the Diagnostic-related interfaces.
 //
-//===--===//
+//===--===//]
+
+// look into this file as well
 
 #ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H
 #define LLVM_CLANG_BASIC_DIAGNOSTIC_H
diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 568000106a84dc..42d2767af6b708 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -179,7 +179,7 @@ def err_verify_invalid_no_diags : Error<
 "%select{expected|'expected-no-diagnostics'}0 directive cannot follow "
 "%select{'expected-no-diagnostics' directive|other expected directives}0">;
 def err_verify_no_directives : Error<
-"no expected directives found: consider use of 'expected-no-diagnostics'">;
+"no expected directives found: consider use of '%0'-no-diagnostics">;
 def err_verify_nonconst_addrspace : Error<
   "qualifier 'const' is needed for variables in address space '%0'">;
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b60dcfaabfd1a4..0997ac9fa7df04 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1404,7 +1404,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo 
&Target,
 getTranslationUnitDecl()->addDecl(MSGuidTagDecl);
   }
 }
-
+// maybe change here also. 
 DiagnosticsEngine &ASTContext::getDiagnostics() const {
   return SourceMgr.getDiagnostics();
 }
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp 
b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index 8a3d2286cd168c..9a26905a76d46b 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -1098,7 +1098,9 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
 // Produce an error if no expected-* directives could be found in the
 // source file(s) processed.
 if (Status == HasNoDirectives) {
-  Diags.Report(diag::err_verify_no_directives).setForceEmit();
+  // change here
+  std::string directives = 
*Diags.getDiagnosticOptions().VerifyPrefixes.begin();
+  Diags.Report(diag::err_verify_no_directives).setForceEmit() << 
directives;
   ++NumErrors;
   Status = HasNoDirectivesReported;
 }
diff --git a/clang/test/ARCMT/verify.m b/clang/test/ARCMT/verify.m
index 7d245fe80575e5..13fd599f530fbe 100644
--- a/clang/test/ARCMT/verify.m
+++ b/clang/test/ARCMT/verify.m
@@ -11,7 +11,7 @@
 #error
 // expected-error@-1 {{}}
 
-//  CHECK: error: no expected directives found: consider use of 
'expected-no-diagnostics'
+//  CHECK: error: no expected directives found: consider use of 
{{.*}}-no-diagnostics
 // CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected:
 // CHECK-NEXT:   (frontend): error reading '{{.*}}verify.m.tmp.invalid'
 // CHECK-NEXT: 2 errors generated.
diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c
index 221b715c19e416..657a9d3f2bf6bb 100644
--- a/clang/test/Frontend/verify.c
+++ b/clang/test/F

[llvm] [clang] [clang-tools-extra] [Clang] Fix : More Detailed "No expected directives found" (PR #78338)

2024-01-24 Thread Shourya Goel via cfe-commits


@@ -1098,7 +1098,13 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
 // Produce an error if no expected-* directives could be found in the
 // source file(s) processed.
 if (Status == HasNoDirectives) {
-  Diags.Report(diag::err_verify_no_directives).setForceEmit();
+  std::string directives;

Sh0g0-1758 wrote:

done. 

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


[llvm] [clang] [mlir] [AMDGPU] Add GFX12 WMMA and SWMMAC instructions (PR #77795)

2024-01-24 Thread Mirko Brkušanin via cfe-commits

https://github.com/mbrkusanin closed 
https://github.com/llvm/llvm-project/pull/77795
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [clang] [SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (PR #77768)

2024-01-24 Thread via cfe-commits

alexfh wrote:

We've started seeing `call to constructor of 'SomeType' is ambiguous` errors 
after this patch on some code. In the case I closely inspected the code looks 
like https://gcc.godbolt.org/z/3MbWf69cx:

```
#include 
struct A {
A() {}
};

struct B {
explicit B(A);
explicit B(std::vector);
};

struct C {
B b;
C() : b({A()}) {}
};
```

Is the new error expected? (I would totally agree with it, just making sure. 
And the behavior is now different to that of GCC trunk.)

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


[clang] [clang][dataflow] Strengthen pointer comparison. (PR #75170)

2024-01-24 Thread via cfe-commits

martinboehme wrote:

Finally getting back to this.

The reason this was causing tests to fail is really pretty obvious in 
hindsight: Different `StorageLocation`s may alias, so if the `StorageLocation`s 
for two `PointerValue`s are different, we can't assume that the pointers must 
compare unequal.

Here's an example:

```cxx
void f(int *p1, int *p2) {
  if (p1 == p2) {
do_something();
  }
}
```

The framework initializes `p1` and `p2` with different storage locations, so 
the current state of this PR causes the comparison `p1 == p2` to be evaluated 
to a false literal, which in turn causes the `do_something()` block to be 
considered dead code. But this is nonsense: `p1` and `p2` may alias, so it's 
definitely possible that `do_something()` will be executed.

In summary, if the storage locations for two pointers are the same, we can 
return a true literal for the comparison, but if the storage locations are 
different, we need to return an atom.

I'll change the PR accordingly and will let you know once it's ready for 
another look.

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -681,12 +718,26 @@ renameOutsideFile(const NamedDecl &RenameDecl, 
llvm::StringRef MainFilePath,
ExpBuffer.getError().message());
   continue;
 }
+std::string RenameIdentifier = RenameDecl.getNameAsString();
+std::optional Selector = std::nullopt;
+llvm::SmallVector NewNames;
+if (const auto *MD = dyn_cast(&RenameDecl)) {
+  if (MD->getSelector().getNumArgs() > 1) {
+RenameIdentifier = MD->getSelector().getNameForSlot(0).str();
+Selector = MD->getSelector();
+NewName.split(NewNames, ":");

kadircet wrote:

you can perform the split unconditionally ,rather than pushing to `NewNames` 
below.

also is it possible to have "empty" selector segments? (e.g. is a NewName like 
`foo::bar` valid for a selector with 3 segments? if not we should probably 
raise an error when validating)

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -543,6 +550,45 @@ std::optional checkName(const NamedDecl 
&RenameDecl,
   return Result;
 }
 
+clangd::Range tokenRangeForLoc(ParsedAST &AST, SourceLocation TokLoc,
+   const SourceManager &SM,
+   const LangOptions &LangOpts) {
+  const auto *Token = AST.getTokens().spelledTokenAt(TokLoc);
+  assert(Token && "got inclusion at wrong offset");
+  clangd::Range Result;
+  Result.start = sourceLocToPosition(SM, Token->location());
+  Result.end = sourceLocToPosition(SM, Token->endLocation());
+  return Result;
+}
+
+// AST-based ObjC method rename, it renames all occurrences in the main file
+// even for selectors which may have multiple tokens.
+llvm::Expected
+renameObjCMethodWithinFile(ParsedAST &AST, const ObjCMethodDecl *MD,
+   llvm::StringRef NewName,
+   std::vector Locs) {
+  const SourceManager &SM = AST.getSourceManager();
+  auto Code = SM.getBufferData(SM.getMainFileID());
+  auto RenameIdentifier = MD->getSelector().getNameForSlot(0).str();
+  llvm::SmallVector NewNames;
+  NewName.split(NewNames, ":");
+  if (NewNames.empty())
+NewNames.push_back(NewName);
+
+  std::vector Ranges;
+  const auto &LangOpts = MD->getASTContext().getLangOpts();
+  for (const auto &Loc : Locs)
+Ranges.push_back(tokenRangeForLoc(AST, Loc, SM, LangOpts));
+  auto FilePath = AST.tuPath();
+  auto RenameRanges = collectRenameIdentifierRanges(

kadircet wrote:

hmm we don't re-use the `Ranges`/`Locs` here at all. let's strip it all (or use 
it to guide lexing, instead of searching for selector identifier, just check if 
selectors at these locations are what we need ?)

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -817,7 +939,8 @@ llvm::Expected rename(const RenameInputs 
&RInputs) {
 return StartOffset.takeError();
   if (!EndOffset)
 return EndOffset.takeError();
-  if (llvm::none_of(
+  if (RenamingCurToken &&

kadircet wrote:

as mentioned above, let's just check with 
`shouldRenameTriggeringLocation(RenameDecl)`

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -778,12 +868,44 @@ llvm::Expected rename(const RenameInputs 
&RInputs) {
 return makeError(ReasonToReject::NoSymbolFound);
   if (DeclsUnderCursor.size() > 1)
 return makeError(ReasonToReject::AmbiguousSymbol);
+  std::string Placeholder;
+  // We expect the token under the cursor to be changed unless the user is
+  // renaming an Objective-C selector with multiple pieces and only renames
+  // some of the selector piece(s).
+  bool RenamingCurToken = true;
   const auto &RenameDecl = **DeclsUnderCursor.begin();
-  const auto *ID = RenameDecl.getIdentifier();
-  if (!ID)
-return makeError(ReasonToReject::UnsupportedSymbol);
-  if (ID->getName() == RInputs.NewName)
-return makeError(ReasonToReject::SameName);
+  if (const auto *MD = dyn_cast(&RenameDecl)) {
+const auto Sel = MD->getSelector();
+if (Sel.getAsString() == RInputs.NewName)
+  return makeError(ReasonToReject::SameName);
+if (Sel.getNumArgs() != RInputs.NewName.count(':') &&
+RInputs.NewName != "__clangd_rename_placeholder")
+  return makeError(
+  InvalidName{InvalidName::BadIdentifier, RInputs.NewName.str()});
+if (Sel.getNumArgs() > 1)
+  Placeholder = Sel.getAsString();
+
+// See if the token under the cursor should actually be renamed.
+if (RInputs.NewName != "__clangd_rename_placeholder") {
+  llvm::StringRef NewName = RInputs.NewName;
+  llvm::SmallVector NewNames;
+  NewName.split(NewNames, ":");
+
+  unsigned NumSelectorLocs = MD->getNumSelectorLocs();
+  for (unsigned I = 0; I < NumSelectorLocs; ++I) {
+if (MD->getSelectorLoc(I) == IdentifierToken->location()) {
+  RenamingCurToken = Sel.getNameForSlot(I) != NewNames[I];

kadircet wrote:

i don't think it's worth all this trouble to leave things in a semi-working 
state. we might rely on `CurrentIdentifier` or `IdentifierRange` in other 
places, and until we change this logic to actually amend the identifer, it's 
easier to assume that it'll always be invalid for objc.

let's leave a TODO to figure out the relevant selector range using 
`ObjCMessageExpr` under the cursor and change the safety check to not happen 
for ObjCMethodDecls for now?

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -1017,9 +1159,10 @@ size_t renameRangeAdjustmentCost(ArrayRef 
Indexed, ArrayRef Lexed,
   int LastDLine = 0, LastDColumn = 0;
   int Cost = 0;
   for (size_t I = 0; I < Indexed.size(); ++I) {
-int DLine = Indexed[I].start.line - Lexed[MappedIndex[I]].start.line;
-int DColumn =
-Indexed[I].start.character - Lexed[MappedIndex[I]].start.character;
+int DLine =
+Indexed[I].start.line - Lexed[MappedIndex[I]].range().start.line;
+int DColumn = Indexed[I].start.character -
+  Lexed[MappedIndex[I]].range().start.character;

kadircet wrote:

looks like just formatting change, can you revert?

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -746,6 +812,30 @@ void findNearMiss(
 
 } // namespace
 
+SymbolRange::SymbolRange(Range R) : Ranges({R}) {}
+
+SymbolRange::SymbolRange(std::vector Ranges)
+: Ranges(std::move(Ranges)) {}
+
+Range SymbolRange::range() const { return Ranges.front(); }
+
+bool operator==(const SymbolRange &LHS, const SymbolRange &RHS) {
+  return LHS.Ranges == RHS.Ranges;
+}
+bool operator!=(const SymbolRange &LHS, const SymbolRange &RHS) {
+  return !(LHS == RHS);
+}
+bool operator<(const SymbolRange &LHS, const SymbolRange &RHS) {
+  return LHS.range() < RHS.range();
+}
+
+std::vector symbolRanges(const std::vector Ranges) {

kadircet wrote:

can we take in `llvm::ArrayRef Ranges`, also move it to renametests, i 
don't think it's used elswhere

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -1029,5 +1172,151 @@ size_t renameRangeAdjustmentCost(ArrayRef 
Indexed, ArrayRef Lexed,
   return Cost;
 }
 
+static bool isMatchingSelectorName(const syntax::Token &Cur,
+   const syntax::Token &Next,
+   const SourceManager &SM,
+   llvm::StringRef SelectorName) {
+  if (SelectorName.empty())
+return Cur.kind() == tok::colon;
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ Cur.text(SM) == SelectorName &&
+ // We require the selector name and : to be contiguous.
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();
+}
+
+static bool isSelectorLike(const syntax::Token &Cur,
+   const syntax::Token &Next) {
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ // We require the selector name and : to be contiguous.
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();
+}
+
+static void
+lex(llvm::StringRef Code, const LangOptions &LangOpts,
+llvm::function_ref
+Action) {
+  // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
+  std::string NullTerminatedCode = Code.str();
+  SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode);
+  auto &SM = FileSM.get();
+  for (const auto &Tok : syntax::tokenize(SM.getMainFileID(), SM, LangOpts))
+Action(Tok, SM);
+}
+
+std::vector collectRenameIdentifierRanges(
+llvm::StringRef Identifier, llvm::StringRef Content,
+const LangOptions &LangOpts, std::optional Selector) {
+  std::vector Ranges;
+  if (!Selector) {
+lex(Content, LangOpts,
+[&](const syntax::Token &Tok, const SourceManager &SM) {
+  if (Tok.kind() != tok::identifier || Tok.text(SM) != Identifier)
+return;
+  Ranges.emplace_back(
+  halfOpenToRange(SM, Tok.range(SM).toCharRange(SM)));
+});
+return Ranges;
+  }
+  // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
+  std::string NullTerminatedCode = Content.str();
+  SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode);
+  auto &SM = FileSM.get();
+
+  auto Tokens = syntax::tokenize(SM.getMainFileID(), SM, LangOpts);
+  unsigned Last = Tokens.size() - 1;
+
+  // One parser state for top level and each `[]` pair, can be nested.
+  // Technically we should have a state or recursion for each ()/{} as well,
+  // but since we're expecting well formed code it shouldn't matter in 
practice.
+  struct ParserState {
+unsigned ParenCount = 0;
+unsigned BraceCount = 0;
+std::vector Pieces;
+  };
+
+  // We have to track square brackets, parens and braces as we want to skip the
+  // tokens inside them. This ensures that we don't use identical selector
+  // pieces in inner message sends, blocks, lambdas and @selector expressions.
+  std::vector States = {ParserState()};
+  unsigned NumPieces = Selector->getNumArgs();
+
+  for (unsigned Index = 0; Index < Last; ++Index) {

kadircet wrote:

i think it'd be better if you moved declaration of `Tokens` to here, to make it 
obvious what this `Index`, `Last` is associated with.

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -1029,5 +1172,151 @@ size_t renameRangeAdjustmentCost(ArrayRef 
Indexed, ArrayRef Lexed,
   return Cost;
 }
 
+static bool isMatchingSelectorName(const syntax::Token &Cur,
+   const syntax::Token &Next,
+   const SourceManager &SM,
+   llvm::StringRef SelectorName) {
+  if (SelectorName.empty())
+return Cur.kind() == tok::colon;
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ Cur.text(SM) == SelectorName &&
+ // We require the selector name and : to be contiguous.
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();
+}
+
+static bool isSelectorLike(const syntax::Token &Cur,
+   const syntax::Token &Next) {
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ // We require the selector name and : to be contiguous.
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();
+}
+
+static void
+lex(llvm::StringRef Code, const LangOptions &LangOpts,
+llvm::function_ref
+Action) {
+  // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
+  std::string NullTerminatedCode = Code.str();
+  SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode);
+  auto &SM = FileSM.get();
+  for (const auto &Tok : syntax::tokenize(SM.getMainFileID(), SM, LangOpts))
+Action(Tok, SM);
+}
+
+std::vector collectRenameIdentifierRanges(
+llvm::StringRef Identifier, llvm::StringRef Content,
+const LangOptions &LangOpts, std::optional Selector) {
+  std::vector Ranges;
+  if (!Selector) {
+lex(Content, LangOpts,
+[&](const syntax::Token &Tok, const SourceManager &SM) {
+  if (Tok.kind() != tok::identifier || Tok.text(SM) != Identifier)
+return;
+  Ranges.emplace_back(
+  halfOpenToRange(SM, Tok.range(SM).toCharRange(SM)));
+});
+return Ranges;
+  }
+  // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
+  std::string NullTerminatedCode = Content.str();
+  SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode);
+  auto &SM = FileSM.get();
+
+  auto Tokens = syntax::tokenize(SM.getMainFileID(), SM, LangOpts);
+  unsigned Last = Tokens.size() - 1;
+
+  // One parser state for top level and each `[]` pair, can be nested.
+  // Technically we should have a state or recursion for each ()/{} as well,
+  // but since we're expecting well formed code it shouldn't matter in 
practice.
+  struct ParserState {
+unsigned ParenCount = 0;
+unsigned BraceCount = 0;
+std::vector Pieces;
+  };
+
+  // We have to track square brackets, parens and braces as we want to skip the
+  // tokens inside them. This ensures that we don't use identical selector
+  // pieces in inner message sends, blocks, lambdas and @selector expressions.
+  std::vector States = {ParserState()};
+  unsigned NumPieces = Selector->getNumArgs();
+
+  for (unsigned Index = 0; Index < Last; ++Index) {
+auto &State = States.back();
+auto &Pieces = State.Pieces;
+const auto &Tok = Tokens[Index];
+const auto Kind = Tok.kind();
+auto PieceCount = Pieces.size();
+
+if (State.ParenCount == 0) {
+  // Check for matches until we find all selector pieces.
+  if (PieceCount < NumPieces &&
+  isMatchingSelectorName(Tok, Tokens[Index + 1], SM,

kadircet wrote:

`Index + 1` might be OOB

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -1029,5 +1172,151 @@ size_t renameRangeAdjustmentCost(ArrayRef 
Indexed, ArrayRef Lexed,
   return Cost;
 }
 
+static bool isMatchingSelectorName(const syntax::Token &Cur,
+   const syntax::Token &Next,
+   const SourceManager &SM,
+   llvm::StringRef SelectorName) {
+  if (SelectorName.empty())
+return Cur.kind() == tok::colon;
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ Cur.text(SM) == SelectorName &&
+ // We require the selector name and : to be contiguous.
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();
+}
+
+static bool isSelectorLike(const syntax::Token &Cur,
+   const syntax::Token &Next) {
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ // We require the selector name and : to be contiguous.
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();
+}
+
+static void
+lex(llvm::StringRef Code, const LangOptions &LangOpts,
+llvm::function_ref
+Action) {
+  // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
+  std::string NullTerminatedCode = Code.str();
+  SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode);
+  auto &SM = FileSM.get();
+  for (const auto &Tok : syntax::tokenize(SM.getMainFileID(), SM, LangOpts))
+Action(Tok, SM);
+}
+
+std::vector collectRenameIdentifierRanges(
+llvm::StringRef Identifier, llvm::StringRef Content,
+const LangOptions &LangOpts, std::optional Selector) {
+  std::vector Ranges;
+  if (!Selector) {
+lex(Content, LangOpts,
+[&](const syntax::Token &Tok, const SourceManager &SM) {
+  if (Tok.kind() != tok::identifier || Tok.text(SM) != Identifier)
+return;
+  Ranges.emplace_back(
+  halfOpenToRange(SM, Tok.range(SM).toCharRange(SM)));
+});
+return Ranges;
+  }
+  // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
+  std::string NullTerminatedCode = Content.str();
+  SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode);
+  auto &SM = FileSM.get();
+
+  auto Tokens = syntax::tokenize(SM.getMainFileID(), SM, LangOpts);
+  unsigned Last = Tokens.size() - 1;
+
+  // One parser state for top level and each `[]` pair, can be nested.
+  // Technically we should have a state or recursion for each ()/{} as well,
+  // but since we're expecting well formed code it shouldn't matter in 
practice.
+  struct ParserState {
+unsigned ParenCount = 0;
+unsigned BraceCount = 0;
+std::vector Pieces;

kadircet wrote:

what are these?

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -778,12 +868,44 @@ llvm::Expected rename(const RenameInputs 
&RInputs) {
 return makeError(ReasonToReject::NoSymbolFound);
   if (DeclsUnderCursor.size() > 1)
 return makeError(ReasonToReject::AmbiguousSymbol);
+  std::string Placeholder;
+  // We expect the token under the cursor to be changed unless the user is
+  // renaming an Objective-C selector with multiple pieces and only renames
+  // some of the selector piece(s).
+  bool RenamingCurToken = true;
   const auto &RenameDecl = **DeclsUnderCursor.begin();
-  const auto *ID = RenameDecl.getIdentifier();
-  if (!ID)
-return makeError(ReasonToReject::UnsupportedSymbol);
-  if (ID->getName() == RInputs.NewName)
-return makeError(ReasonToReject::SameName);
+  if (const auto *MD = dyn_cast(&RenameDecl)) {
+const auto Sel = MD->getSelector();
+if (Sel.getAsString() == RInputs.NewName)
+  return makeError(ReasonToReject::SameName);
+if (Sel.getNumArgs() != RInputs.NewName.count(':') &&
+RInputs.NewName != "__clangd_rename_placeholder")
+  return makeError(
+  InvalidName{InvalidName::BadIdentifier, RInputs.NewName.str()});
+if (Sel.getNumArgs() > 1)
+  Placeholder = Sel.getAsString();
+
+// See if the token under the cursor should actually be renamed.
+if (RInputs.NewName != "__clangd_rename_placeholder") {
+  llvm::StringRef NewName = RInputs.NewName;
+  llvm::SmallVector NewNames;
+  NewName.split(NewNames, ":");
+
+  unsigned NumSelectorLocs = MD->getNumSelectorLocs();
+  for (unsigned I = 0; I < NumSelectorLocs; ++I) {
+if (MD->getSelectorLoc(I) == IdentifierToken->location()) {
+  RenamingCurToken = Sel.getNameForSlot(I) != NewNames[I];
+  break;
+}
+  }
+}
+  } else {
+const auto *ID = RenameDecl.getIdentifier();
+if (!ID)
+  return makeError(ReasonToReject::UnsupportedSymbol);

kadircet wrote:

let's move this check into `renameable`

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -778,12 +868,44 @@ llvm::Expected rename(const RenameInputs 
&RInputs) {
 return makeError(ReasonToReject::NoSymbolFound);
   if (DeclsUnderCursor.size() > 1)
 return makeError(ReasonToReject::AmbiguousSymbol);
+  std::string Placeholder;
+  // We expect the token under the cursor to be changed unless the user is
+  // renaming an Objective-C selector with multiple pieces and only renames
+  // some of the selector piece(s).
+  bool RenamingCurToken = true;
   const auto &RenameDecl = **DeclsUnderCursor.begin();
-  const auto *ID = RenameDecl.getIdentifier();
-  if (!ID)
-return makeError(ReasonToReject::UnsupportedSymbol);
-  if (ID->getName() == RInputs.NewName)
-return makeError(ReasonToReject::SameName);
+  if (const auto *MD = dyn_cast(&RenameDecl)) {
+const auto Sel = MD->getSelector();
+if (Sel.getAsString() == RInputs.NewName)
+  return makeError(ReasonToReject::SameName);
+if (Sel.getNumArgs() != RInputs.NewName.count(':') &&
+RInputs.NewName != "__clangd_rename_placeholder")
+  return makeError(
+  InvalidName{InvalidName::BadIdentifier, RInputs.NewName.str()});
+if (Sel.getNumArgs() > 1)
+  Placeholder = Sel.getAsString();

kadircet wrote:

why not do this unconditionally (including C++), preferably with something 
like: `std::string PlaceHolder = getName(RenameDecl);`

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -1029,5 +1172,151 @@ size_t renameRangeAdjustmentCost(ArrayRef 
Indexed, ArrayRef Lexed,
   return Cost;
 }
 
+static bool isMatchingSelectorName(const syntax::Token &Cur,
+   const syntax::Token &Next,
+   const SourceManager &SM,
+   llvm::StringRef SelectorName) {
+  if (SelectorName.empty())
+return Cur.kind() == tok::colon;
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ Cur.text(SM) == SelectorName &&
+ // We require the selector name and : to be contiguous.
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();
+}
+
+static bool isSelectorLike(const syntax::Token &Cur,
+   const syntax::Token &Next) {
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ // We require the selector name and : to be contiguous.
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();
+}
+
+static void
+lex(llvm::StringRef Code, const LangOptions &LangOpts,
+llvm::function_ref
+Action) {
+  // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
+  std::string NullTerminatedCode = Code.str();
+  SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode);
+  auto &SM = FileSM.get();
+  for (const auto &Tok : syntax::tokenize(SM.getMainFileID(), SM, LangOpts))
+Action(Tok, SM);
+}
+
+std::vector collectRenameIdentifierRanges(
+llvm::StringRef Identifier, llvm::StringRef Content,
+const LangOptions &LangOpts, std::optional Selector) {
+  std::vector Ranges;
+  if (!Selector) {
+lex(Content, LangOpts,
+[&](const syntax::Token &Tok, const SourceManager &SM) {
+  if (Tok.kind() != tok::identifier || Tok.text(SM) != Identifier)
+return;
+  Ranges.emplace_back(
+  halfOpenToRange(SM, Tok.range(SM).toCharRange(SM)));
+});
+return Ranges;
+  }
+  // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
+  std::string NullTerminatedCode = Content.str();
+  SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode);
+  auto &SM = FileSM.get();
+
+  auto Tokens = syntax::tokenize(SM.getMainFileID(), SM, LangOpts);
+  unsigned Last = Tokens.size() - 1;
+
+  // One parser state for top level and each `[]` pair, can be nested.
+  // Technically we should have a state or recursion for each ()/{} as well,
+  // but since we're expecting well formed code it shouldn't matter in 
practice.
+  struct ParserState {
+unsigned ParenCount = 0;
+unsigned BraceCount = 0;
+std::vector Pieces;
+  };
+
+  // We have to track square brackets, parens and braces as we want to skip the
+  // tokens inside them. This ensures that we don't use identical selector
+  // pieces in inner message sends, blocks, lambdas and @selector expressions.
+  std::vector States = {ParserState()};
+  unsigned NumPieces = Selector->getNumArgs();
+
+  for (unsigned Index = 0; Index < Last; ++Index) {
+auto &State = States.back();
+auto &Pieces = State.Pieces;
+const auto &Tok = Tokens[Index];
+const auto Kind = Tok.kind();
+auto PieceCount = Pieces.size();
+
+if (State.ParenCount == 0) {
+  // Check for matches until we find all selector pieces.
+  if (PieceCount < NumPieces &&
+  isMatchingSelectorName(Tok, Tokens[Index + 1], SM,
+ Selector->getNameForSlot(PieceCount))) {
+if (!Selector->getNameForSlot(PieceCount).empty()) {

kadircet wrote:

what does it mean for this selector slot to be empty?

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -38,6 +38,11 @@
 
 namespace clang {
 namespace clangd {
+
+std::vector collectRenameIdentifierRanges(

kadircet wrote:

let's move this into anonymous namespace, and add some comments explaining what 
it does?

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -1029,5 +1172,151 @@ size_t renameRangeAdjustmentCost(ArrayRef 
Indexed, ArrayRef Lexed,
   return Cost;
 }
 
+static bool isMatchingSelectorName(const syntax::Token &Cur,

kadircet wrote:

can you move all of these into anon namespace instead?

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -543,6 +550,45 @@ std::optional checkName(const NamedDecl 
&RenameDecl,
   return Result;
 }
 
+clangd::Range tokenRangeForLoc(ParsedAST &AST, SourceLocation TokLoc,
+   const SourceManager &SM,
+   const LangOptions &LangOpts) {
+  const auto *Token = AST.getTokens().spelledTokenAt(TokLoc);
+  assert(Token && "got inclusion at wrong offset");
+  clangd::Range Result;
+  Result.start = sourceLocToPosition(SM, Token->location());
+  Result.end = sourceLocToPosition(SM, Token->endLocation());
+  return Result;
+}
+
+// AST-based ObjC method rename, it renames all occurrences in the main file
+// even for selectors which may have multiple tokens.

kadircet wrote:

can we also define what `Locs` are, with a better name (like 
`SelectorOccurences`)?

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-01-24 Thread kadir çetinkaya via cfe-commits


@@ -1029,5 +1172,151 @@ size_t renameRangeAdjustmentCost(ArrayRef 
Indexed, ArrayRef Lexed,
   return Cost;
 }
 
+static bool isMatchingSelectorName(const syntax::Token &Cur,
+   const syntax::Token &Next,
+   const SourceManager &SM,
+   llvm::StringRef SelectorName) {
+  if (SelectorName.empty())
+return Cur.kind() == tok::colon;
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ Cur.text(SM) == SelectorName &&
+ // We require the selector name and : to be contiguous.
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();
+}
+
+static bool isSelectorLike(const syntax::Token &Cur,
+   const syntax::Token &Next) {
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ // We require the selector name and : to be contiguous.
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();
+}
+
+static void
+lex(llvm::StringRef Code, const LangOptions &LangOpts,
+llvm::function_ref
+Action) {
+  // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
+  std::string NullTerminatedCode = Code.str();
+  SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode);
+  auto &SM = FileSM.get();
+  for (const auto &Tok : syntax::tokenize(SM.getMainFileID(), SM, LangOpts))
+Action(Tok, SM);
+}
+
+std::vector collectRenameIdentifierRanges(
+llvm::StringRef Identifier, llvm::StringRef Content,
+const LangOptions &LangOpts, std::optional Selector) {
+  std::vector Ranges;
+  if (!Selector) {
+lex(Content, LangOpts,
+[&](const syntax::Token &Tok, const SourceManager &SM) {
+  if (Tok.kind() != tok::identifier || Tok.text(SM) != Identifier)
+return;
+  Ranges.emplace_back(
+  halfOpenToRange(SM, Tok.range(SM).toCharRange(SM)));
+});
+return Ranges;
+  }
+  // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
+  std::string NullTerminatedCode = Content.str();
+  SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode);
+  auto &SM = FileSM.get();
+
+  auto Tokens = syntax::tokenize(SM.getMainFileID(), SM, LangOpts);
+  unsigned Last = Tokens.size() - 1;
+
+  // One parser state for top level and each `[]` pair, can be nested.
+  // Technically we should have a state or recursion for each ()/{} as well,
+  // but since we're expecting well formed code it shouldn't matter in 
practice.
+  struct ParserState {
+unsigned ParenCount = 0;
+unsigned BraceCount = 0;
+std::vector Pieces;
+  };
+
+  // We have to track square brackets, parens and braces as we want to skip the
+  // tokens inside them. This ensures that we don't use identical selector
+  // pieces in inner message sends, blocks, lambdas and @selector expressions.
+  std::vector States = {ParserState()};
+  unsigned NumPieces = Selector->getNumArgs();
+
+  for (unsigned Index = 0; Index < Last; ++Index) {
+auto &State = States.back();
+auto &Pieces = State.Pieces;
+const auto &Tok = Tokens[Index];
+const auto Kind = Tok.kind();
+auto PieceCount = Pieces.size();
+
+if (State.ParenCount == 0) {
+  // Check for matches until we find all selector pieces.
+  if (PieceCount < NumPieces &&
+  isMatchingSelectorName(Tok, Tokens[Index + 1], SM,
+ Selector->getNameForSlot(PieceCount))) {
+if (!Selector->getNameForSlot(PieceCount).empty()) {
+  // Skip the ':' after the name. This ensures that it won't match a
+  // follow-up selector piece with an empty name.
+  ++Index;
+}
+Pieces.push_back(halfOpenToRange(SM, Tok.range(SM).toCharRange(SM)));
+continue;
+  }
+  // If we've found all pieces, we still need to try to consume more pieces
+  // as it's possible the selector being renamed is a prefix of this method
+  // name.

kadircet wrote:

shouldn't we just fail in that case?

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


[mlir] [llvm] [clang] [AArch64] Replace LLVM IR function attributes for PSTATE.ZA. (PR #79166)

2024-01-24 Thread Benjamin Maxwell via cfe-commits


@@ -1098,11 +1098,15 @@ LogicalResult 
ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
 llvmFunc->addFnAttr("aarch64_pstate_sm_compatible");
 
   if (func.getArmNewZa())
-llvmFunc->addFnAttr("aarch64_pstate_za_new");
-  else if (func.getArmSharedZa())
-llvmFunc->addFnAttr("aarch64_pstate_za_shared");
+llvmFunc->addFnAttr("aarch64_new_za");
+  else if (func.getArmInZa())
+llvmFunc->addFnAttr("aarch64_in_za");
+  else if (func.getArmOutZa())
+llvmFunc->addFnAttr("aarch64_out_za");
+  else if (func.getArmInoutZa())
+llvmFunc->addFnAttr("aarch64_inout_za");
   if (func.getArmPreservesZa())
-llvmFunc->addFnAttr("aarch64_pstate_za_preserved");
+llvmFunc->addFnAttr("aarch64_preserves_za");

MacDue wrote:

(it used to be that `aarch64_pstate_za_preserved` was used with 
`aarch64_pstate_za_shared`, which is why the import was originally like this)

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


[llvm] [clang-tools-extra] [clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-24 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

> > Is this expected and wanted?
> 
> Good catch! I would not expect that diagnostic; we should silence the 
> diagnostic if it's used in a `#ifdef`, `#elifdef`, or `defined` because the 
> value isn't necessary. Perhaps we should also silence something like 
> `sizeof(INFINITY)` because it's unevaluated?

Thanks @mikaelholmen and @AaronBallman. I will take a look and create a PR to 
fix the issue.

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


[clang] [FatLTO] output of -ffat-lto-objects -S should be assembly. (PR #79041)

2024-01-24 Thread Wael Yehia via cfe-commits


@@ -12,14 +12,27 @@
 // CHECK-CC-S-NOT: -emit-llvm
 // CHECK-CC-S-NOT: -ffat-lto-objects
 
-/// When LTO is enabled, we expect LLVM IR output and -ffat-lto-objects to be 
passed to cc1.
+/// When fat LTO is enabled with -S, we expect asm output and 
-ffat-lto-objects to be passed to cc1.
 // RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### 
%s -S 2>&1 | FileCheck %s -check-prefix=CHECK-CC-S-LTO
-// RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### 
%s -S -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-CC-S-LTO
 // CHECK-CC-S-LTO: -cc1
 // CHECK-CC-S-LTO-SAME: -funified-lto
-// CHECK-CC-S-LTO-SAME: -emit-llvm
+// CHECK-CC-S-NOT: -emit-llvm
 // CHECK-CC-S-LTO-SAME: -ffat-lto-objects
 
+/// When fat LTO is enabled with -S and -emit-llvm, we expect IR output and 
-ffat-lto-objects to be passed to cc1.
+// RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### 
%s -S -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-CC-S-EL-LTO
+// CHECK-CC-S-EL-LTO: -cc1
+// CHECK-CC-S-EL-LTO-SAME: -funified-lto
+// CHECK-CC-S-EL-LTO-SAME: -emit-llvm
+// CHECK-CC-S-EL-LTO-SAME: -ffat-lto-objects
+
+/// When fat LTO is enabled wihtout -S we expect native object output and 
-ffat-lto-object to be passed to cc1.
+// RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### 
%s -c 2>&1 | FileCheck %s -check-prefix=CHECK-CC-C-LTO
+// CHECK-CC-C-LTO: -cc1
+// CHECK-CC-C-LTO: -funified-lto

w2yehia wrote:

should these be CHECK-CC-C-LTO-SAME ?

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


[clang] [llvm] [clang][MBD] set up module build daemon infrastructure (PR #67562)

2024-01-24 Thread Alexandre Ganea via cfe-commits

aganea wrote:

Can you please send separate PRs for the Support changes?

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


[libcxx] [clang] [SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (PR #77768)

2024-01-24 Thread via cfe-commits

alexfh wrote:

Actually, on the second look it doesn't seem to be too ambiguous to me. I 
*think* `std::vector` should be a strictly better match in this case.

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


[clang] c3e7707 - [clang][AST][NFC] Turn a isa<> + cast<> into dynamic_cast<>

2024-01-24 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-01-24T15:17:33+01:00
New Revision: c3e77070489979788788ef479f8932ac460b675b

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

LOG: [clang][AST][NFC] Turn a isa<> + cast<> into dynamic_cast<>

Added: 


Modified: 
clang/lib/AST/ExprCXX.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index e61c11dffd8841f..a775beadff9da53 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -511,14 +511,14 @@ DependentScopeDeclRefExpr::CreateEmpty(const ASTContext 
&Context,
 }
 
 SourceLocation CXXConstructExpr::getBeginLoc() const {
-  if (isa(this))
-return cast(this)->getBeginLoc();
+  if (const auto *TOE = dyn_cast(this))
+return TOE->getBeginLoc();
   return getLocation();
 }
 
 SourceLocation CXXConstructExpr::getEndLoc() const {
-  if (isa(this))
-return cast(this)->getEndLoc();
+  if (const auto *TOE = dyn_cast(this))
+return TOE->getEndLoc();
 
   if (ParenOrBraceRange.isValid())
 return ParenOrBraceRange.getEnd();



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


[libcxx] [lld] [clang] [lldb] [clang-tools-extra] [flang] [libc] [compiler-rt] [llvm] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)

2024-01-24 Thread via cfe-commits


@@ -9108,7 +9123,8 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   //   declaration, it is implicitly considered to be constexpr.
   // FIXME: Only applying this to the first declaration seems problematic, as
   // simple reorderings can affect the meaning of the program.
-  if (First && !FD->isConstexpr() && Info.Constexpr)
+  if ((First && !FD->isConstexpr() && Info.Constexpr) ||
+  getLangOpts().CPlusPlus23)

cor3ntin wrote:

> isn't Info.Constexpr always true in c++ mode?

**C++23**, sorry 

> Should the call to such function be allowed? I suppose not due to-literal 
> member. The problem is, there result is same with or without this change. I 
> meant to apply this

Hum right, i was thinking we could have a `if(false)` in the comparison 
function, but that's for defaulted function so it doesn't work.

The error message should be different though, right? something like "the call 
to operator== is not a constant expression" ?




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


[clang] [Clang][Sema] fix outline member function template with default align crash (PR #78400)

2024-01-24 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.

LGTM, let me know if you need someone to merge this for you.

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


[clang] [llvm] [flang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2024-01-24 Thread Nikita Popov via cfe-commits

https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/68882
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lldb] [clang] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-24 Thread via cfe-commits

bgra8 wrote:

@bolshakov-a this is causing a regression in the way partial template 
specializations work.

For the following reproducer the partial template specialization is not used by 
the compiler when it is expected it should be used:

```
const char kt[] = "dummy";

template 
class SomeTempl {
 public:
  explicit SomeTempl(T t) {
  }
  // The generic impl always returns 66.
  int exit_code() const { return 66; }
 private:
};

template 
class SomeTempl {
 public:
  explicit SomeTempl(int s) : exit_code_(s) {
  }
  int exit_code() const { return exit_code_; }
 private:
  int exit_code_;
};

int main() {
  SomeTempl dummy(0);
  // This should return 0.
  return dummy.exit_code();
}
```

Compile with: `clang -o /tmp/repro -x c++ /tmp/repro.cc `

It will return 0 (expected value when the specialization is used) before this 
patch and 66 (the generic impl is used) at this patch.

Could you please look into it? Reverting would be nice if a fix is necessary.

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


[libcxxabi] [openmp] [clang] [flang] [libcxx] [libc] [compiler-rt] [mlir] [llvm] [clang-tools-extra] [AArch64] Combine store (trunc X to <3 x i8>) to sequence of ST1.b. (PR #78637)

2024-01-24 Thread Florian Hahn via cfe-commits

https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/78637

>From efd07e93aed51049ad3783c701284617ae446330 Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Wed, 17 Jan 2024 11:11:59 +
Subject: [PATCH 1/5] [AArch64] Combine store (trunc X to <3 x i8>) to sequence
 of ST1.b.

Improve codegen for (trunc X to <3 x i8>) by converting it to a sequence
of 3 ST1.b, but first converting the truncate operand to either v8i8 or
v16i8, extracting the lanes for the truncate results and storing them.

At the moment, there are almost no cases in which such vector operations
will be generated automatically. The motivating case is non-power-of-2
SLP vectorization: https://github.com/llvm/llvm-project/pull/77790
---
 .../Target/AArch64/AArch64ISelLowering.cpp| 50 +++
 .../AArch64/vec3-loads-ext-trunc-stores.ll| 33 +---
 2 files changed, 62 insertions(+), 21 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 8a6f1dc7487bae8..4be78f61fe7b651 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -21318,6 +21318,53 @@ bool isHalvingTruncateOfLegalScalableType(EVT SrcVT, 
EVT DstVT) {
  (SrcVT == MVT::nxv2i64 && DstVT == MVT::nxv2i32);
 }
 
+// Combine store (trunc X to <3 x i8>) to sequence of ST1.b.
+static SDValue combineI8TruncStore(StoreSDNode *ST, SelectionDAG &DAG,
+   const AArch64Subtarget *Subtarget) {
+  SDValue Value = ST->getValue();
+  EVT ValueVT = Value.getValueType();
+
+  if (ST->isVolatile() || !Subtarget->isLittleEndian() ||
+  ST->getOriginalAlign() >= 4 || Value.getOpcode() != ISD::TRUNCATE ||
+  ValueVT != EVT::getVectorVT(*DAG.getContext(), MVT::i8, 3))
+return SDValue();
+
+  SDLoc DL(ST);
+  auto WideVT = EVT::getVectorVT(
+  *DAG.getContext(),
+  Value->getOperand(0).getValueType().getVectorElementType(), 4);
+  SDValue UndefVector = DAG.getUNDEF(WideVT);
+  SDValue WideTrunc = DAG.getNode(
+  ISD::INSERT_SUBVECTOR, DL, WideVT,
+  {UndefVector, Value->getOperand(0), DAG.getVectorIdxConstant(0, DL)});
+  SDValue Cast = DAG.getNode(
+  ISD::BITCAST, DL, WideVT.getSizeInBits() == 64 ? MVT::v8i8 : MVT::v16i8,
+  WideTrunc);
+
+  SDValue Chain = ST->getChain();
+  SDValue E2 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i8, Cast,
+   DAG.getConstant(8, DL, MVT::i64));
+
+  SDValue Ptr2 =
+  DAG.getMemBasePlusOffset(ST->getBasePtr(), TypeSize::getFixed(2), DL);
+  Chain = DAG.getStore(Chain, DL, E2, Ptr2, ST->getPointerInfo(),
+   ST->getOriginalAlign());
+
+  SDValue E1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i8, Cast,
+   DAG.getConstant(4, DL, MVT::i64));
+
+  SDValue Ptr1 =
+  DAG.getMemBasePlusOffset(ST->getBasePtr(), TypeSize::getFixed(1), DL);
+  Chain = DAG.getStore(Chain, DL, E1, Ptr1, ST->getPointerInfo(),
+   ST->getOriginalAlign());
+  SDValue E0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i8, Cast,
+   DAG.getConstant(0, DL, MVT::i64));
+  Chain = DAG.getStore(Chain, DL, E0, ST->getBasePtr(), ST->getPointerInfo(),
+   ST->getOriginalAlign());
+
+  return Chain;
+}
+
 static SDValue performSTORECombine(SDNode *N,
TargetLowering::DAGCombinerInfo &DCI,
SelectionDAG &DAG,
@@ -21333,6 +21380,9 @@ static SDValue performSTORECombine(SDNode *N,
 return EltVT == MVT::f32 || EltVT == MVT::f64;
   };
 
+  if (SDValue Res = combineI8TruncStore(ST, DAG, Subtarget))
+return Res;
+
   // If this is an FP_ROUND followed by a store, fold this into a truncating
   // store. We can do this even if this is already a truncstore.
   // We purposefully don't care about legality of the nodes here as we know
diff --git a/llvm/test/CodeGen/AArch64/vec3-loads-ext-trunc-stores.ll 
b/llvm/test/CodeGen/AArch64/vec3-loads-ext-trunc-stores.ll
index 9eeb194409df6fa..60639ea91fbaa18 100644
--- a/llvm/test/CodeGen/AArch64/vec3-loads-ext-trunc-stores.ll
+++ b/llvm/test/CodeGen/AArch64/vec3-loads-ext-trunc-stores.ll
@@ -154,17 +154,12 @@ define <3 x i32> @load_v3i32(ptr %src) {
 define void @store_trunc_from_64bits(ptr %src, ptr %dst) {
 ; CHECK-LABEL: store_trunc_from_64bits:
 ; CHECK:   ; %bb.0: ; %entry
-; CHECK-NEXT:sub sp, sp, #16
-; CHECK-NEXT:.cfi_def_cfa_offset 16
-; CHECK-NEXT:ldr s0, [x0]
-; CHECK-NEXT:ldrh w8, [x0, #4]
-; CHECK-NEXT:mov.h v0[2], w8
-; CHECK-NEXT:xtn.8b v0, v0
-; CHECK-NEXT:str s0, [sp, #12]
-; CHECK-NEXT:ldrh w9, [sp, #12]
-; CHECK-NEXT:strb w8, [x1, #2]
-; CHECK-NEXT:strh w9, [x1]
-; CHECK-NEXT:add sp, sp, #16
+; CHECK-NEXT:add x8, x0, #4
+; CHECK-NEXT:ld1r.4h { v0 }, [x8]
+; CHECK-NEXT:ldr w8, [x0]
+; CHECK-NEXT:strb w8, [x1]
+; CHECK

[clang] [clang][analyzer] Support `fgets` in the SteamChecker (PR #73638)

2024-01-24 Thread Balázs Kéri via cfe-commits


@@ -778,42 +781,61 @@ void StreamChecker::evalFgetc(const FnDescription *Desc, 
const CallEvent &Call,
   assertStreamStateOpened(OldSS);
 

balazske wrote:

Will this invalidate only the buffer, not `F1`?

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


[clang] [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve the (PR #79296)

2024-01-24 Thread Haojian Wu via cfe-commits

https://github.com/hokein created 
https://github.com/llvm/llvm-project/pull/79296

source location in AliasTemplateDeductionGuideTransform.

I don't have a reproducible testcase, but this should be a safe and 
non-functional change. We have checked the `hasDefaultArg` before calling 
getDefaultArg(), but `hasDefaultArg` allows unparsed/uninstantiated default arg 
which is prohibited in getDefaultArg().

Since we're only interested in the source location, we switch to use 
getDefaultArgRange() API.

Context: I hit the "!hasUninstantiatedDefaultArg()" assertion inside the 
getDefaultArg when reusing the "transformFunctionTypeParam" for type alias CTAD 
implementation 
(https://github.com/llvm/llvm-project/pull/77890/commits/f0919914f828daf705f89317081946359f00971a).

>From 034810c714dcbebc26b6d6d50c4396c318849327 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Wed, 24 Jan 2024 14:55:03 +0100
Subject: [PATCH] [clang] Use getDefaultArgRange instead of getDefaultArg to
 retrieve the source location in AliasTemplateDeductionGuideTransform.

I don't have a reproducible testcase, but this should be a safe and 
non-functional change.
We have checked the `hasDefaultArg` before calling getDefaultArg(), but 
`hasDefaultArg`
allows unparsed/uninstantiated default arg which is prohibited in 
getDefaultArg().

Since we're only interested in the source location, we switch to use 
getDefaultArgRange() API.

Context: I hit the "!hasUninstantiatedDefaultArg()" assertion inside the
getDefaultArg when reusing the "transformFunctionTypeParam" for
implementing type alias CTAD.
---
 clang/lib/Sema/SemaTemplate.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 9bfa71dc8bcf1db..a5d2afdf4a0bab8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2588,7 +2588,7 @@ struct ConvertConstructorToDeductionGuideTransform {
   // placeholder to indicate there is a default argument.
   QualType ParamTy = NewDI->getType();
   NewDefArg = new (SemaRef.Context)
-  OpaqueValueExpr(OldParam->getDefaultArg()->getBeginLoc(),
+  OpaqueValueExpr(OldParam->getDefaultArgRange().getBegin(),
   ParamTy.getNonLValueExprType(SemaRef.Context),
   ParamTy->isLValueReferenceType()   ? VK_LValue
   : ParamTy->isRValueReferenceType() ? VK_XValue

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


  1   2   3   4   5   6   >