[clang] [Clang][RISCV] Add assumptions to vsetvli/vsetvlimax (PR #79975)

2024-02-01 Thread Kito Cheng via cfe-commits

kito-cheng wrote:

I guess we need add that at RVVEmitter::createbuilt...@riscvvemitter.cpp?

[1] 
https://github.com/llvm/llvm-project/blob/main/clang/utils/TableGen/RISCVVEmitter.cpp#L418
[2] 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Builtins.h#L122-L124
[3] 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/BuiltinsARM.def#L32

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


[clang] [Clang][RISCV] Add assumptions to vsetvli/vsetvlimax (PR #79975)

2024-02-01 Thread Kito Cheng via cfe-commits

kito-cheng wrote:

Also I guess most of RVV intrinsic could add `const` too, that could help some 
generic optimization work better like CSE.

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


[clang] [clang-tools-extra] [compiler-rt] [llvm] [flang] [TTI]Fallback to SingleSrcPermute shuffle kind, if no direct estimation for (PR #79837)

2024-02-01 Thread David Green via cfe-commits

davemgreen wrote:

I think this is probably OK for Arm & AArch64. In the long run we should 
ideally be adding better extract subvector costs, but this patch moves the cost 
in that direction.

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


[clang] [lld] [llvm] [flang] [AMDGPU] Introduce Code Object V6 (PR #76954)

2024-02-01 Thread Pierre van Houtryve via cfe-commits

https://github.com/Pierre-vh updated 
https://github.com/llvm/llvm-project/pull/76954

>From 7ad88453f5e89fd4643afa486e52a123138433f4 Mon Sep 17 00:00:00 2001
From: pvanhout 
Date: Thu, 4 Jan 2024 14:12:00 +0100
Subject: [PATCH 1/2] [AMDGPU] Introduce Code Object V6

Introduce Code Object V6 in Clang, LLD, Flang and LLVM.
This is the same as V5 except a new "generic version" flag can be present in 
EFLAGS. This is related to new generic targets that'll be added in a follow-up 
patch. It's also likely V6 will have new changes (possibly new metadata 
entries) added later.

Docs change are not included, I'm planning to do them in a follow-up patch all 
at once (when generic targets land too).
---
 clang/include/clang/Driver/Options.td |   4 +-
 clang/lib/CodeGen/CGBuiltin.cpp   |   6 +-
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   2 +-
 .../amdgpu-code-object-version-linking.cu |  37 +++
 .../CodeGenCUDA/amdgpu-code-object-version.cu |   4 +
 .../test/CodeGenCUDA/amdgpu-workgroup-size.cu |   4 +
 .../amdgcn/bitcode/oclc_abi_version_600.bc|   0
 clang/test/Driver/hip-code-object-version.hip |  12 +
 clang/test/Driver/hip-device-libs.hip |  18 +-
 flang/lib/Frontend/CompilerInvocation.cpp |   2 +
 flang/test/Lower/AMD/code-object-version.f90  |   3 +-
 lld/ELF/Arch/AMDGPU.cpp   |  21 ++
 lld/test/ELF/amdgpu-tid.s |  16 ++
 llvm/include/llvm/BinaryFormat/ELF.h  |   9 +-
 llvm/include/llvm/Support/AMDGPUMetadata.h|   7 +
 llvm/include/llvm/Support/ScopedPrinter.h |   4 +-
 llvm/include/llvm/Target/TargetOptions.h  |   1 +
 llvm/lib/ObjectYAML/ELFYAML.cpp   |   9 +
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp   |   3 +
 .../AMDGPU/AMDGPUHSAMetadataStreamer.cpp  |  10 +
 .../Target/AMDGPU/AMDGPUHSAMetadataStreamer.h |  11 +-
 .../MCTargetDesc/AMDGPUTargetStreamer.cpp |  26 ++
 .../MCTargetDesc/AMDGPUTargetStreamer.h   |   1 +
 .../Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp|   6 +
 llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h |   2 +-
 ...licit-kernarg-backend-usage-global-isel.ll |   2 +
 .../AMDGPU/call-graph-register-usage.ll   |   1 +
 .../AMDGPU/codegen-internal-only-func.ll  |   3 +
 llvm/test/CodeGen/AMDGPU/elf-header-osabi.ll  |   4 +
 .../enable-scratch-only-dynamic-stack.ll  |   1 +
 .../AMDGPU/implicit-kernarg-backend-usage.ll  |   2 +
 .../AMDGPU/implicitarg-offset-attributes.ll   |  46 
 .../AMDGPU/llvm.amdgcn.implicitarg.ptr.ll |   1 +
 llvm/test/CodeGen/AMDGPU/non-entry-alloca.ll  |   1 +
 llvm/test/CodeGen/AMDGPU/recursion.ll |   1 +
 .../AMDGPU/resource-usage-dead-function.ll|   1 +
 .../AMDGPU/tid-mul-func-xnack-all-any.ll  |   6 +
 .../tid-mul-func-xnack-all-not-supported.ll   |   6 +
 .../AMDGPU/tid-mul-func-xnack-all-off.ll  |   6 +
 .../AMDGPU/tid-mul-func-xnack-all-on.ll   |   6 +
 .../AMDGPU/tid-mul-func-xnack-any-off-1.ll|   6 +
 .../AMDGPU/tid-mul-func-xnack-any-off-2.ll|   6 +
 .../AMDGPU/tid-mul-func-xnack-any-on-1.ll |   6 +
 .../AMDGPU/tid-mul-func-xnack-any-on-2.ll |   6 +
 .../tid-one-func-xnack-not-supported.ll   |   6 +
 .../CodeGen/AMDGPU/tid-one-func-xnack-off.ll  |   6 +
 .../CodeGen/AMDGPU/tid-one-func-xnack-on.ll   |   6 +
 .../MC/AMDGPU/hsa-v5-uses-dynamic-stack.s |   5 +
 .../elf-headers.test} |   0
 .../ELF/AMDGPU/generic_versions.s |  16 ++
 .../ELF/AMDGPU/generic_versions.test  |  26 ++
 llvm/tools/llvm-readobj/ELFDumper.cpp | 224 --
 52 files changed, 483 insertions(+), 135 deletions(-)
 create mode 100644 
clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_abi_version_600.bc
 rename llvm/test/tools/llvm-readobj/ELF/{amdgpu-elf-headers.test => 
AMDGPU/elf-headers.test} (100%)
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/AMDGPU/generic_versions.s
 create mode 100644 
llvm/test/tools/llvm-readobj/ELF/AMDGPU/generic_versions.test

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a4b35e370999e..d7152cc355ce7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4797,9 +4797,9 @@ defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
   HelpText<"Specify code object ABI version. Defaults to 5. (AMDGPU only)">,
   Visibility<[ClangOption, FlangOption, CC1Option, FC1Option]>,
-  Values<"none,4,5">,
+  Values<"none,4,5,6">,
   NormalizedValuesScope<"llvm::CodeObjectVersionKind">,
-  NormalizedValues<["COV_None", "COV_4", "COV_5"]>,
+  NormalizedValues<["COV_None", "COV_4", "COV_5", "COV_6"]>,
   MarshallingInfoEnum, "COV_5">;
 
 defm cumode : SimpleMFlag<"cumode",
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index f3ab5ad7b08ec..a55be6880c5ef 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/C

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

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

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

>From e98987ebb48839ea652d63dfaa62ed841b426e46 Mon Sep 17 00:00:00 2001
From: Matt Devereau 
Date: Thu, 18 Jan 2024 15:41:25 +
Subject: [PATCH 1/3] [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 d47181bfca4fc..781118c935898 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 75e9a8c46b876..8ddee560b11da 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 332fb37655288..6a210846cf4df 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 ea9882160d6fb..7d6b86ab8a3e9 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 0..a8cba7dc9a91e
--- /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", "~{zt0}"()
+  ret void
+}

>From 6391def8b7cfd88b12544766c94b75cb2a5bd385 Mon Sep 17 00:00:00 2001
From: Matt Devereau 
Date: Mon, 29 Jan 2024 09:59:47 +
Subject: [PATCH 2/3] run clang-format

---
 cla

[clang] ae931b4 - [Clang][test] Limit library search when linking shared lib (#80253)

2024-02-01 Thread via cfe-commits

Author: Wei Wang
Date: 2024-02-01T00:29:59-08:00
New Revision: ae931b470319ade31fcc0797b6051eb8b96f9a8a

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

LOG: [Clang][test] Limit library search when linking shared lib (#80253)

Don't search for unnecessary libs when linking the shared lib. This
allows the test to run in chroot environment.

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 239968d8c7445..4e56e2fc1528a 100644
--- a/clang/test/Interpreter/cxx20-modules.cppm
+++ b/clang/test/Interpreter/cxx20-modules.cppm
@@ -8,7 +8,7 @@
 // RUN: %clang -std=c++20 %t/mod.cppm --precompile \
 // RUN: -o %t/mod.pcm --target=x86_64-linux-gnu
 // RUN: %clang -fPIC %t/mod.pcm -c -o %t/mod.o --target=x86_64-linux-gnu
-// RUN: %clang -fPIC -shared %t/mod.o -o %t/libmod.so --target=x86_64-linux-gnu
+// RUN: %clang -nostdlib -fPIC -shared %t/mod.o -o %t/libmod.so 
--target=x86_64-linux-gnu
 //
 // RUN: cat %t/import.cpp | env LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH \
 // RUN: clang-repl -Xcc=-std=c++20 -Xcc=-fmodule-file=M=%t/mod.pcm \



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


[clang] [Clang][test] Limit library search when linking shared lib (PR #80253)

2024-02-01 Thread Wei Wang via cfe-commits

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


[clang] [clang-tools-extra] [llvm] [llvm-exegesis] Replace --num-repetitions with --min-instructions (PR #77153)

2024-02-01 Thread Aiden Grossman via cfe-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/77153

>From 1a86a03fdc9d6eee08830ff2f113c39e6096d564 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Fri, 5 Jan 2024 14:40:26 -0800
Subject: [PATCH 1/3] [llvm-exegesis] Replace --num-repetitions with
 --min-instructions

This patch replaces --num-repetitions with --min-instructions to make it
more clear that the value refers to the minimum number of instructions
in the final assembled snippet rather than the number of repetitions  of
the snippet. This patch also refactors some llvm-exegesis internal
variable names to reflect the name change.

Fixes #76890.
---
 llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp |  8 +++-
 llvm/tools/llvm-exegesis/lib/BenchmarkResult.h   |  2 +-
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | 16 
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h   |  2 +-
 llvm/tools/llvm-exegesis/llvm-exegesis.cpp   | 13 +++--
 .../llvm-exegesis/Mips/BenchmarkResultTest.cpp   |  6 +++---
 .../llvm-exegesis/X86/BenchmarkResultTest.cpp|  6 +++---
 7 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp 
b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
index 02c4da11e032d..d13409fe4738a 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -293,7 +293,6 @@ struct MappingContextTraits {
 Io.mapRequired("key", Obj.Key, Context);
 Io.mapRequired("cpu_name", Obj.CpuName);
 Io.mapRequired("llvm_triple", Obj.LLVMTriple);
-Io.mapRequired("num_repetitions", Obj.NumRepetitions);
 Io.mapRequired("measurements", Obj.Measurements);
 Io.mapRequired("error", Obj.Error);
 Io.mapOptional("info", Obj.Info);
@@ -301,6 +300,13 @@ struct MappingContextTraits {
 MappingNormalization> BinaryString(
 Io, Obj.AssembledSnippet);
 Io.mapOptional("assembled_snippet", BinaryString->Binary);
+// Optionally map num_repetitions and min_instructions to the same
+// value to preserve backwards compatibility.
+// TODO(boomanaiden154): Move min_instructions to mapRequired and
+// remove num_repetitions once num_repetitions is ready to be removed
+// completely.
+Io.mapOptional("num_repetitions", Obj.MinInstructions);
+Io.mapOptional("min_instructions", Obj.MinInstructions);
   }
 };
 
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h 
b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index 0d08febae20cb..ffba634151586 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
@@ -100,7 +100,7 @@ struct Benchmark {
   const MCInst &keyInstruction() const { return Key.Instructions[0]; }
   // The number of instructions inside the repeated snippet. For example, if a
   // snippet of 3 instructions is repeated 4 times, this is 12.
-  unsigned NumRepetitions = 0;
+  unsigned MinInstructions = 0;
   enum RepetitionModeE { Duplicate, Loop, AggregateMin };
   // Note that measurements are per instruction.
   std::vector Measurements;
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp 
b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index dee7af5fd520a..6c5f9e557812d 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -498,7 +498,7 @@ Expected> BenchmarkRunner::assembleSnippet(
 
 Expected
 BenchmarkRunner::getRunnableConfiguration(
-const BenchmarkCode &BC, unsigned NumRepetitions, unsigned LoopBodySize,
+const BenchmarkCode &BC, unsigned MinInstructions, unsigned LoopBodySize,
 const SnippetRepetitor &Repetitor) const {
   RunnableConfiguration RC;
 
@@ -508,7 +508,7 @@ BenchmarkRunner::getRunnableConfiguration(
   std::string(State.getTargetMachine().getTargetCPU());
   BenchmarkResult.LLVMTriple =
   State.getTargetMachine().getTargetTriple().normalize();
-  BenchmarkResult.NumRepetitions = NumRepetitions;
+  BenchmarkResult.MinInstructions = MinInstructions;
   BenchmarkResult.Info = BC.Info;
 
   const std::vector &Instructions = BC.Key.Instructions;
@@ -534,12 +534,12 @@ BenchmarkRunner::getRunnableConfiguration(
   return std::move(Err);
   }
 
-  // Assemble NumRepetitions instructions repetitions of the snippet for
-  // measurements.
+  // Assemble enough repetitions of the snippet so we have at least
+  // MinInstructios instructions.
   if (BenchmarkPhaseSelector >
   BenchmarkPhaseSelectorE::PrepareAndAssembleSnippet) {
 auto Snippet =
-assembleSnippet(BC, Repetitor, BenchmarkResult.NumRepetitions,
+assembleSnippet(BC, Repetitor, BenchmarkResult.MinInstructions,
 LoopBodySize, GenerateMemoryInstructions);
 if (Error E = Snippet.takeError())
   return std::move(E);
@@ -610,14 +610,14 @@ std::pair 
BenchmarkRunner::runConfiguration(
   if (Error E = NewMeasurements.takeError()) {
   

[clang] [clang-tools-extra] [llvm] [llvm-exegesis] Replace --num-repetitions with --min-instructions (PR #77153)

2024-02-01 Thread Aiden Grossman via cfe-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/77153

>From 1a86a03fdc9d6eee08830ff2f113c39e6096d564 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Fri, 5 Jan 2024 14:40:26 -0800
Subject: [PATCH 1/4] [llvm-exegesis] Replace --num-repetitions with
 --min-instructions

This patch replaces --num-repetitions with --min-instructions to make it
more clear that the value refers to the minimum number of instructions
in the final assembled snippet rather than the number of repetitions  of
the snippet. This patch also refactors some llvm-exegesis internal
variable names to reflect the name change.

Fixes #76890.
---
 llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp |  8 +++-
 llvm/tools/llvm-exegesis/lib/BenchmarkResult.h   |  2 +-
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | 16 
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h   |  2 +-
 llvm/tools/llvm-exegesis/llvm-exegesis.cpp   | 13 +++--
 .../llvm-exegesis/Mips/BenchmarkResultTest.cpp   |  6 +++---
 .../llvm-exegesis/X86/BenchmarkResultTest.cpp|  6 +++---
 7 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp 
b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
index 02c4da11e032d..d13409fe4738a 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -293,7 +293,6 @@ struct MappingContextTraits {
 Io.mapRequired("key", Obj.Key, Context);
 Io.mapRequired("cpu_name", Obj.CpuName);
 Io.mapRequired("llvm_triple", Obj.LLVMTriple);
-Io.mapRequired("num_repetitions", Obj.NumRepetitions);
 Io.mapRequired("measurements", Obj.Measurements);
 Io.mapRequired("error", Obj.Error);
 Io.mapOptional("info", Obj.Info);
@@ -301,6 +300,13 @@ struct MappingContextTraits {
 MappingNormalization> BinaryString(
 Io, Obj.AssembledSnippet);
 Io.mapOptional("assembled_snippet", BinaryString->Binary);
+// Optionally map num_repetitions and min_instructions to the same
+// value to preserve backwards compatibility.
+// TODO(boomanaiden154): Move min_instructions to mapRequired and
+// remove num_repetitions once num_repetitions is ready to be removed
+// completely.
+Io.mapOptional("num_repetitions", Obj.MinInstructions);
+Io.mapOptional("min_instructions", Obj.MinInstructions);
   }
 };
 
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h 
b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index 0d08febae20cb..ffba634151586 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
@@ -100,7 +100,7 @@ struct Benchmark {
   const MCInst &keyInstruction() const { return Key.Instructions[0]; }
   // The number of instructions inside the repeated snippet. For example, if a
   // snippet of 3 instructions is repeated 4 times, this is 12.
-  unsigned NumRepetitions = 0;
+  unsigned MinInstructions = 0;
   enum RepetitionModeE { Duplicate, Loop, AggregateMin };
   // Note that measurements are per instruction.
   std::vector Measurements;
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp 
b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index dee7af5fd520a..6c5f9e557812d 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -498,7 +498,7 @@ Expected> BenchmarkRunner::assembleSnippet(
 
 Expected
 BenchmarkRunner::getRunnableConfiguration(
-const BenchmarkCode &BC, unsigned NumRepetitions, unsigned LoopBodySize,
+const BenchmarkCode &BC, unsigned MinInstructions, unsigned LoopBodySize,
 const SnippetRepetitor &Repetitor) const {
   RunnableConfiguration RC;
 
@@ -508,7 +508,7 @@ BenchmarkRunner::getRunnableConfiguration(
   std::string(State.getTargetMachine().getTargetCPU());
   BenchmarkResult.LLVMTriple =
   State.getTargetMachine().getTargetTriple().normalize();
-  BenchmarkResult.NumRepetitions = NumRepetitions;
+  BenchmarkResult.MinInstructions = MinInstructions;
   BenchmarkResult.Info = BC.Info;
 
   const std::vector &Instructions = BC.Key.Instructions;
@@ -534,12 +534,12 @@ BenchmarkRunner::getRunnableConfiguration(
   return std::move(Err);
   }
 
-  // Assemble NumRepetitions instructions repetitions of the snippet for
-  // measurements.
+  // Assemble enough repetitions of the snippet so we have at least
+  // MinInstructios instructions.
   if (BenchmarkPhaseSelector >
   BenchmarkPhaseSelectorE::PrepareAndAssembleSnippet) {
 auto Snippet =
-assembleSnippet(BC, Repetitor, BenchmarkResult.NumRepetitions,
+assembleSnippet(BC, Repetitor, BenchmarkResult.MinInstructions,
 LoopBodySize, GenerateMemoryInstructions);
 if (Error E = Snippet.takeError())
   return std::move(E);
@@ -610,14 +610,14 @@ std::pair 
BenchmarkRunner::runConfiguration(
   if (Error E = NewMeasurements.takeError()) {
   

[clang] [clang-tools-extra] [llvm] [llvm-exegesis] Replace --num-repetitions with --min-instructions (PR #77153)

2024-02-01 Thread Aiden Grossman via cfe-commits

boomanaiden154 wrote:

@legrosbuffle This is ready for review when you have a chance. Thanks!

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


[clang] [clang-tools-extra] [llvm] [llvm-exegesis] Replace --num-repetitions with --min-instructions (PR #77153)

2024-02-01 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 90e68086d8fdbfb32dfc7e7e3498f44365274ce8 
6a81778059d72a4e4d236d0d6777a621a5bc965b -- 
llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp 
llvm/tools/llvm-exegesis/lib/BenchmarkResult.h 
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp 
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h 
llvm/tools/llvm-exegesis/lib/ResultAggregator.cpp 
llvm/tools/llvm-exegesis/llvm-exegesis.cpp 
llvm/unittests/tools/llvm-exegesis/Mips/BenchmarkResultTest.cpp 
llvm/unittests/tools/llvm-exegesis/ResultAggregatorTest.cpp 
llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/tools/llvm-exegesis/lib/ResultAggregator.cpp 
b/llvm/tools/llvm-exegesis/lib/ResultAggregator.cpp
index 7e873bc9d4..f3470344a8 100644
--- a/llvm/tools/llvm-exegesis/lib/ResultAggregator.cpp
+++ b/llvm/tools/llvm-exegesis/lib/ResultAggregator.cpp
@@ -47,7 +47,8 @@ void MiddleHalfResultAggregator::AggregateMeasurement(
 const Benchmark &Result) const {
   Measurement.RawValue = NewMeasurement.RawValue - Measurement.RawValue;
   Measurement.PerInstructionValue = Measurement.RawValue;
-  Measurement.PerInstructionValue /= Result.MinInstructions;;
+  Measurement.PerInstructionValue /= Result.MinInstructions;
+  ;
   Measurement.PerSnippetValue = Measurement.RawValue;
   Measurement.PerSnippetValue /=
   std::ceil(Result.MinInstructions /

``




https://github.com/llvm/llvm-project/pull/77153
___
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-02-01 Thread Sander de Smalen via cfe-commits


@@ -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)) {

sdesmalen-arm wrote:

```suggestion
  if (Constraint == "za") {
```
?

https://github.com/llvm/llvm-project/pull/79276
___
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-02-01 Thread Sander de Smalen via cfe-commits


@@ -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)

sdesmalen-arm wrote:

```suggestion
  if (PhysReg == AArch64::ZA || PhysReg == AArch64::ZT0)
```

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


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

2024-02-01 Thread Sander de Smalen via cfe-commits


@@ -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)) {

sdesmalen-arm wrote:

```suggestion
  if (Constraint == "zt0") {
```
?

https://github.com/llvm/llvm-project/pull/79276
___
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-02-01 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm edited 
https://github.com/llvm/llvm-project/pull/79276
___
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-02-01 Thread Sander de Smalen via cfe-commits

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


[clang] [clang-tools-extra] [llvm] [llvm-exegesis] Replace --num-repetitions with --min-instructions (PR #77153)

2024-02-01 Thread Aiden Grossman via cfe-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/77153

>From 1a86a03fdc9d6eee08830ff2f113c39e6096d564 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Fri, 5 Jan 2024 14:40:26 -0800
Subject: [PATCH 1/5] [llvm-exegesis] Replace --num-repetitions with
 --min-instructions

This patch replaces --num-repetitions with --min-instructions to make it
more clear that the value refers to the minimum number of instructions
in the final assembled snippet rather than the number of repetitions  of
the snippet. This patch also refactors some llvm-exegesis internal
variable names to reflect the name change.

Fixes #76890.
---
 llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp |  8 +++-
 llvm/tools/llvm-exegesis/lib/BenchmarkResult.h   |  2 +-
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | 16 
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h   |  2 +-
 llvm/tools/llvm-exegesis/llvm-exegesis.cpp   | 13 +++--
 .../llvm-exegesis/Mips/BenchmarkResultTest.cpp   |  6 +++---
 .../llvm-exegesis/X86/BenchmarkResultTest.cpp|  6 +++---
 7 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp 
b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
index 02c4da11e032d..d13409fe4738a 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -293,7 +293,6 @@ struct MappingContextTraits {
 Io.mapRequired("key", Obj.Key, Context);
 Io.mapRequired("cpu_name", Obj.CpuName);
 Io.mapRequired("llvm_triple", Obj.LLVMTriple);
-Io.mapRequired("num_repetitions", Obj.NumRepetitions);
 Io.mapRequired("measurements", Obj.Measurements);
 Io.mapRequired("error", Obj.Error);
 Io.mapOptional("info", Obj.Info);
@@ -301,6 +300,13 @@ struct MappingContextTraits {
 MappingNormalization> BinaryString(
 Io, Obj.AssembledSnippet);
 Io.mapOptional("assembled_snippet", BinaryString->Binary);
+// Optionally map num_repetitions and min_instructions to the same
+// value to preserve backwards compatibility.
+// TODO(boomanaiden154): Move min_instructions to mapRequired and
+// remove num_repetitions once num_repetitions is ready to be removed
+// completely.
+Io.mapOptional("num_repetitions", Obj.MinInstructions);
+Io.mapOptional("min_instructions", Obj.MinInstructions);
   }
 };
 
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h 
b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index 0d08febae20cb..ffba634151586 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
@@ -100,7 +100,7 @@ struct Benchmark {
   const MCInst &keyInstruction() const { return Key.Instructions[0]; }
   // The number of instructions inside the repeated snippet. For example, if a
   // snippet of 3 instructions is repeated 4 times, this is 12.
-  unsigned NumRepetitions = 0;
+  unsigned MinInstructions = 0;
   enum RepetitionModeE { Duplicate, Loop, AggregateMin };
   // Note that measurements are per instruction.
   std::vector Measurements;
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp 
b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index dee7af5fd520a..6c5f9e557812d 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -498,7 +498,7 @@ Expected> BenchmarkRunner::assembleSnippet(
 
 Expected
 BenchmarkRunner::getRunnableConfiguration(
-const BenchmarkCode &BC, unsigned NumRepetitions, unsigned LoopBodySize,
+const BenchmarkCode &BC, unsigned MinInstructions, unsigned LoopBodySize,
 const SnippetRepetitor &Repetitor) const {
   RunnableConfiguration RC;
 
@@ -508,7 +508,7 @@ BenchmarkRunner::getRunnableConfiguration(
   std::string(State.getTargetMachine().getTargetCPU());
   BenchmarkResult.LLVMTriple =
   State.getTargetMachine().getTargetTriple().normalize();
-  BenchmarkResult.NumRepetitions = NumRepetitions;
+  BenchmarkResult.MinInstructions = MinInstructions;
   BenchmarkResult.Info = BC.Info;
 
   const std::vector &Instructions = BC.Key.Instructions;
@@ -534,12 +534,12 @@ BenchmarkRunner::getRunnableConfiguration(
   return std::move(Err);
   }
 
-  // Assemble NumRepetitions instructions repetitions of the snippet for
-  // measurements.
+  // Assemble enough repetitions of the snippet so we have at least
+  // MinInstructios instructions.
   if (BenchmarkPhaseSelector >
   BenchmarkPhaseSelectorE::PrepareAndAssembleSnippet) {
 auto Snippet =
-assembleSnippet(BC, Repetitor, BenchmarkResult.NumRepetitions,
+assembleSnippet(BC, Repetitor, BenchmarkResult.MinInstructions,
 LoopBodySize, GenerateMemoryInstructions);
 if (Error E = Snippet.takeError())
   return std::move(E);
@@ -610,14 +610,14 @@ std::pair 
BenchmarkRunner::runConfiguration(
   if (Error E = NewMeasurements.takeError()) {
   

[clang] [Clang][RISCV] Add assumptions to vsetvli/vsetvlimax (PR #79975)

2024-02-01 Thread Wang Pengcheng via cfe-commits

wangpc-pp wrote:

> Also I guess most of RVV intrinsic could add `const` too, that could help 
> some generic optimization work better like CSE.

This PR doesn't add the `const` attribute, I don't know if adding `const` may 
help to optimize.

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


[clang] [coroutine] Suppress unreachable-code warning on coroutine statements. (PR #77454)

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

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

>From 43810d2b18e1e31c5f15dc58c847c83b3c34d982 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Tue, 9 Jan 2024 12:29:45 +0100
Subject: [PATCH 1/2] [coroutine] Suppress unreachable-code warning on
 coroutine statements.

---
 clang/lib/Analysis/ReachableCode.cpp  | 42 +++-
 .../SemaCXX/coroutine-unreachable-warning.cpp | 50 +++
 2 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCXX/coroutine-unreachable-warning.cpp

diff --git a/clang/lib/Analysis/ReachableCode.cpp 
b/clang/lib/Analysis/ReachableCode.cpp
index 1bf0d9aec8620..d839d2f999609 100644
--- a/clang/lib/Analysis/ReachableCode.cpp
+++ b/clang/lib/Analysis/ReachableCode.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ParentMap.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
@@ -60,6 +61,45 @@ static bool isTrivialDoWhile(const CFGBlock *B, const Stmt 
*S) {
   return false;
 }
 
+// Check if the block starts with a coroutine statement and see if the given
+// unreachable 'S' is the substmt of the coroutine statement.
+//
+// We suppress the unreachable warning for cases where an unreachable code is
+// a substmt of the coroutine statement, becase removing it will change the
+// function semantic if this is the only coroutine statement of the coroutine.
+static bool isInCoroutineStmt(const CFGBlock *Block, const Stmt* S) {
+  // The coroutine statement, co_return, co_await, or co_yield.
+  const Stmt* CoroStmt = nullptr;
+  // Find the first coroutine statement in the block.
+  for (CFGBlock::const_iterator I = Block->begin(), E = Block->end(); I != E;
+   ++I)
+if (std::optional CS = I->getAs()) {
+  const Stmt *S = CS->getStmt();
+  if (llvm::isa(S) || llvm::isa(S)) {
+CoroStmt = S ;
+break;
+  }
+}
+  if (!CoroStmt)
+return false;
+
+  struct Checker : RecursiveASTVisitor {
+const Stmt *StmtToCheck;
+bool CoroutineSubStmt = false;
+Checker(const Stmt *S) : StmtToCheck(S) {}
+bool VisitStmt(const Stmt *S) {
+  if (S == StmtToCheck)
+CoroutineSubStmt = true;
+  return true;
+}
+// The 'S' stmt captured in the CFG can be implicit.
+bool shouldVisitImplicitCode() const { return true; }
+  };
+  Checker checker(S);
+  checker.TraverseStmt(const_cast(CoroStmt));
+  return checker.CoroutineSubStmt;
+}
+
 static bool isBuiltinUnreachable(const Stmt *S) {
   if (const auto *DRE = dyn_cast(S))
 if (const auto *FDecl = dyn_cast(DRE->getDecl()))
@@ -623,7 +663,7 @@ void DeadCodeScan::reportDeadCode(const CFGBlock *B,
   if (isa(S)) {
 UK = reachable_code::UK_Break;
   } else if (isTrivialDoWhile(B, S) || isBuiltinUnreachable(S) ||
- isBuiltinAssumeFalse(B, S, C)) {
+ isBuiltinAssumeFalse(B, S, C) || isInCoroutineStmt(B, S)) {
 return;
   }
   else if (isDeadReturn(B, S)) {
diff --git a/clang/test/SemaCXX/coroutine-unreachable-warning.cpp 
b/clang/test/SemaCXX/coroutine-unreachable-warning.cpp
new file mode 100644
index 0..6ac5c34262b7e
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-unreachable-warning.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -std=c++20 -fsyntax-only 
-verify -Wunreachable-code
+
+#include "Inputs/std-coroutine.h"
+
+extern void abort (void) __attribute__ ((__noreturn__));
+
+struct task {
+  struct promise_type {
+std::suspend_always initial_suspend();
+std::suspend_always final_suspend() noexcept;
+void return_void();
+std::suspend_always yield_value(int) { return {}; }
+  task get_return_object();
+void unhandled_exception();
+  };
+};
+
+task test1() {
+  abort();
+  co_yield 1;
+}
+
+task test2() {
+  abort();
+  1; // expected-warning {{code will never be executed}}
+  co_yield 1;
+}
+
+task test3() {
+  abort();
+  co_return;
+}
+
+task test4() {
+  abort();
+  1; // expected-warning {{code will never be executed}}
+  co_return;
+}
+
+
+task test5() {
+  abort();
+  co_await std::suspend_never{};
+}
+
+task test6() {
+  abort();
+  1; // expected-warning {{code will never be executed}}
+  co_await std::suspend_never{};
+}

>From ee6fa40a7864480a059225ef56ae6cf2187d5f18 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Wed, 31 Jan 2024 16:08:32 +0100
Subject: [PATCH 2/2] Never treat coroutine statements as valid dead
 statements.

---
 clang/lib/Analysis/ReachableCode.cpp  | 91 ++-
 .../SemaCXX/coroutine-unreachable-warning.cpp | 17 +++-
 2 files changed, 63 insertions(+), 45 deletions(-)

diff --git a/clang/lib/Analysis/ReachableCode.cpp 
b/clang/lib/Analysis/ReachableCode.cpp
index d839d2f999609..1e92e6458a538 100644
--- a/clang/lib/Analysis/ReachableCode.cpp
+++ b/clang/lib/Analysis/ReachableCode.cp

[clang] [AMDGPU] Allow w64 ballot to be used on w32 targets (PR #80183)

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

jayfoad wrote:

After this change is there any value in having two different builtins? You 
could just have one that always return 64 bits.

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


[clang] [AMDGPU] Allow w64 ballot to be used on w32 targets (PR #80183)

2024-02-01 Thread Matt Arsenault via cfe-commits


@@ -151,7 +151,7 @@ BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", 
"nc")
 
//===--===//
 
 TARGET_BUILTIN(__builtin_amdgcn_ballot_w32, "ZUib", "nc", "wavefrontsize32")
-TARGET_BUILTIN(__builtin_amdgcn_ballot_w64, "WUib", "nc", "wavefrontsize64")
+BUILTIN(__builtin_amdgcn_ballot_w64, "WUib", "nc")

arsenm wrote:

The target attribute is just a giant footgun for AMDGPU. This one only works in 
the library with special handholding by the compiler 

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


[clang] [AMDGPU] Allow w64 ballot to be used on w32 targets (PR #80183)

2024-02-01 Thread Matt Arsenault via cfe-commits


@@ -4,13 +4,10 @@
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx1010 -target-feature 
-wavefrontsize64 -verify -S -o - %s
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx1010 -verify -S -o - %s
 
+// expected-no-diagnostics
+
 typedef unsigned long ulong;
 
 void test_ballot_wave64(global ulong* out, int a, int b) {
-  *out = __builtin_amdgcn_ballot_w64(a == b);  // expected-error 
{{'__builtin_amdgcn_ballot_w64' needs target feature wavefrontsize64}}
-}
-
-__attribute__((target("wavefrontsize64")))
-void test_ballot_wave64_target_attr(global ulong* out, int a, int b) {

arsenm wrote:

Should keep the target_attr test 

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


[clang-tools-extra] [clang] [llvm] [llvm-exegesis] Replace --num-repetitions with --min-instructions (PR #77153)

2024-02-01 Thread Clement Courbet via cfe-commits

legrosbuffle wrote:

> I'm assuming at some point we'll want to deprecate this old option?

It's a single line of code so it probably can stay there for backwards 
compatibility :)

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


[clang-tools-extra] [clang] [llvm] [llvm-exegesis] Replace --num-repetitions with --min-instructions (PR #77153)

2024-02-01 Thread Clement Courbet via cfe-commits

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


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


[clang] [Clang][AArch64] Add ACLE macros for FEAT_PAuth_LR (PR #80163)

2024-02-01 Thread Jonathan Thackray via cfe-commits

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

Good stuff, approved.

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


[clang] [clang-tools-extra] [llvm] [llvm-exegesis] Replace --num-repetitions with --min-instructions (PR #77153)

2024-02-01 Thread Aiden Grossman via cfe-commits

boomanaiden154 wrote:

> It's a single line of code so it probably can stay there for backwards 
> compatibility :)

Sounds good.

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


[clang] [polly] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread Owen Pan via cfe-commits


@@ -914,16 +914,31 @@ struct FormatStyle {
   /// Different ways to break after the function definition or
   /// declaration return type.
   enum ReturnTypeBreakingStyle : int8_t {
-/// Break after return type automatically.
-/// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
+/// This is **deprecated**. See ``Automatic`` below.
+RTBS_None,
+/// Break after return type based on ``PenaltyReturnTypeOnItsOwnLine``.
 /// \code
 ///   class A {
 /// int f() { return 0; };
 ///   };
 ///   int f();
 ///   int f() { return 1; }
+///   int
+///   LongName::AnotherLongName();
 /// \endcode
-RTBS_None,
+RTBS_Automatic,
+/// Same as ``Automatic`` above, expect that there is no break after short

owenca wrote:

```suggestion
/// Same as ``Automatic`` above, except that there is no break after short
```

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


[clang] [polly] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread Owen Pan via cfe-commits


@@ -9920,13 +9962,17 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
   verifyFormat("class C {\n"
"  int f() { return 1; }\n"
"  int g();\n"
+   "  long\n"
+   "  f::br();\n"

owenca wrote:

Delete because it's not top-level?

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


[polly] [clang] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread Owen Pan via cfe-commits

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


[clang] [polly] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread Owen Pan via cfe-commits


@@ -9906,12 +9944,16 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
   verifyFormat("class B {\n"
"  int f() { return 1; }\n"
"  int g();\n"
+   "  long\n"
+   "  f::br();\n"
"};\n"
"int\n"
"f() {\n"
"  return 1;\n"
"}\n"
-   "int g();",
+   "int g();\n"
+   "int\n"
+   "f::bar();",

owenca wrote:

Ditto.

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


[polly] [clang] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread Owen Pan via cfe-commits


@@ -9938,12 +9984,16 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
"return 1;\n"
"  }\n"
"  int g();\n"
+   "  long\n"
+   "  f::br();\n"

owenca wrote:

Delete it because it's not a definition?

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


[polly] [clang] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread Owen Pan via cfe-commits


@@ -9906,12 +9944,16 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
   verifyFormat("class B {\n"
"  int f() { return 1; }\n"
"  int g();\n"
+   "  long\n"
+   "  f::br();\n"

owenca wrote:

Delete it because it's not a definition?

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


[clang] [polly] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread Owen Pan via cfe-commits

https://github.com/owenca commented:

Looks good otherwise.

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


[polly] [clang] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread Owen Pan via cfe-commits


@@ -9938,12 +9984,16 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
"return 1;\n"
"  }\n"
"  int g();\n"
+   "  long\n"
+   "  f::br();\n"
"};\n"
"int\n"
"f() {\n"
"  return 1;\n"
"}\n"
-   "int g();",
+   "int g();\n"
+   "int\n"
+   "f::bar();",

owenca wrote:

Ditto.

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


[lld] [libc] [clang-tools-extra] [lldb] [libcxxabi] [clang] [flang] [llvm] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. (PR #79512)

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

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

>From 299a055e271264f918321bf7360ee37c6ede8b26 Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Tue, 23 Jan 2024 13:39:38 +
Subject: [PATCH] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic
 inc agree.

We are replacing with a wider increment. If both OrigInc and IsomorphicInc
are NUW/NSW, then we can preserve them on the wider increment; the narrower
IsomorphicInc would wrap before the wider OrigInc, so the replacement won't
make IsomorphicInc's uses more poisonous.
---
 .../Utils/ScalarEvolutionExpander.cpp | 28 +--
 .../Transforms/IndVarSimplify/iv-poison.ll| 12 
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp 
b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index cf8cea937a6bf..902c4db883769 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1607,11 +1607,35 @@ void SCEVExpander::replaceCongruentIVInc(
   const SCEV *TruncExpr =
   SE.getTruncateOrNoop(SE.getSCEV(OrigInc), IsomorphicInc->getType());
   if (OrigInc == IsomorphicInc || TruncExpr != SE.getSCEV(IsomorphicInc) ||
-  !SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc) ||
-  !hoistIVInc(OrigInc, IsomorphicInc,
+  !SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc))
+return;
+
+  bool BothHaveNUW = false;
+  bool BothHaveNSW = false;
+  auto *OBOIncV = dyn_cast(OrigInc);
+  auto *OBOIsomorphic = dyn_cast(IsomorphicInc);
+  assert(OrigInc->getType()->getScalarSizeInBits() >=
+ IsomorphicInc->getType()->getScalarSizeInBits()) && "Should only 
replace an increment with a wider one.");
+  if (OBOIncV && OBOIsomorphic) {
+BothHaveNUW =
+OBOIncV->hasNoUnsignedWrap() && OBOIsomorphic->hasNoUnsignedWrap();
+BothHaveNSW =
+OBOIncV->hasNoSignedWrap() && OBOIsomorphic->hasNoSignedWrap();
+  }
+
+  if (!hoistIVInc(OrigInc, IsomorphicInc,
   /*RecomputePoisonFlags*/ true))
 return;
 
+  // We are replacing with a wider increment. If both OrigInc and IsomorphicInc
+  // are NUW/NSW, then we can preserve them on the wider increment; the 
narrower
+  // IsomorphicInc would wrap before the wider OrigInc, so the replacement 
won't
+  // make IsomorphicInc's uses more poisonous.
+  if (BothHaveNUW || BothHaveNSW) {
+OrigInc->setHasNoUnsignedWrap(OBOIncV->hasNoUnsignedWrap() || BothHaveNUW);
+OrigInc->setHasNoSignedWrap(OBOIncV->hasNoSignedWrap() || BothHaveNSW);
+  }
+
   SCEV_DEBUG_WITH_TYPE(DebugType,
dbgs() << "INDVARS: Eliminated congruent iv.inc: "
   << *IsomorphicInc << '\n');
diff --git a/llvm/test/Transforms/IndVarSimplify/iv-poison.ll 
b/llvm/test/Transforms/IndVarSimplify/iv-poison.ll
index 38299e0a6b353..383599f614357 100644
--- a/llvm/test/Transforms/IndVarSimplify/iv-poison.ll
+++ b/llvm/test/Transforms/IndVarSimplify/iv-poison.ll
@@ -64,7 +64,7 @@ define i2 @iv_hoist_both_adds_nsw(i2 %arg) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i2 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], 
[[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i2 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i2 [[IV_0]], 1
 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i2 1, [[ARG:%.*]]
 ; CHECK-NEXT:br i1 [[DOTNOT_NOT]], label [[EXIT:%.*]], label [[LOOP]]
 ; CHECK:   exit:
@@ -92,7 +92,7 @@ define i4 @iv_hoist_both_adds_nsw_extra_use(i4 %arg) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i4 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], 
[[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i4 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i4 [[IV_0]], 1
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i4 1, [[ARG:%.*]]
@@ -124,7 +124,7 @@ define i4 
@iv_hoist_both_adds_nsw_extra_use_incs_reordered(i4 %arg) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i4 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], 
[[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i4 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i4 [[IV_0]], 1
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i4 1, [[ARG:%.*]]
@@ -244,7 +244,7 @@ define i2 @iv_hoist_both_adds_nuw(i2 %arg, i2 %start) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i2 [ [[START:%.*]], [[BB:%.*]] ], [ 
[[IV_0_NEXT:%.*]], [[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add i2 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i2 [[IV_0]], 1
 ; CHECK-NEXT:[[DOTN

[clang] [Clang] Convert __builtin_dynamic_object_size into a calculation (PR #80256)

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

nikic wrote:

(Dropping myself as reviewer as I'm not really familiar with clang.)

Looks like this is missing test coverage?

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


[lld] [libc] [clang-tools-extra] [lldb] [libcxxabi] [clang] [flang] [llvm] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. (PR #79512)

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

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

>From 299a055e271264f918321bf7360ee37c6ede8b26 Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Tue, 23 Jan 2024 13:39:38 +
Subject: [PATCH 1/2] [SCEVExp] Keep NUW/NSW if both original inc and
 isomporphic inc agree.

We are replacing with a wider increment. If both OrigInc and IsomorphicInc
are NUW/NSW, then we can preserve them on the wider increment; the narrower
IsomorphicInc would wrap before the wider OrigInc, so the replacement won't
make IsomorphicInc's uses more poisonous.
---
 .../Utils/ScalarEvolutionExpander.cpp | 28 +--
 .../Transforms/IndVarSimplify/iv-poison.ll| 12 
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp 
b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index cf8cea937a6bf..902c4db883769 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1607,11 +1607,35 @@ void SCEVExpander::replaceCongruentIVInc(
   const SCEV *TruncExpr =
   SE.getTruncateOrNoop(SE.getSCEV(OrigInc), IsomorphicInc->getType());
   if (OrigInc == IsomorphicInc || TruncExpr != SE.getSCEV(IsomorphicInc) ||
-  !SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc) ||
-  !hoistIVInc(OrigInc, IsomorphicInc,
+  !SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc))
+return;
+
+  bool BothHaveNUW = false;
+  bool BothHaveNSW = false;
+  auto *OBOIncV = dyn_cast(OrigInc);
+  auto *OBOIsomorphic = dyn_cast(IsomorphicInc);
+  assert(OrigInc->getType()->getScalarSizeInBits() >=
+ IsomorphicInc->getType()->getScalarSizeInBits()) && "Should only 
replace an increment with a wider one.");
+  if (OBOIncV && OBOIsomorphic) {
+BothHaveNUW =
+OBOIncV->hasNoUnsignedWrap() && OBOIsomorphic->hasNoUnsignedWrap();
+BothHaveNSW =
+OBOIncV->hasNoSignedWrap() && OBOIsomorphic->hasNoSignedWrap();
+  }
+
+  if (!hoistIVInc(OrigInc, IsomorphicInc,
   /*RecomputePoisonFlags*/ true))
 return;
 
+  // We are replacing with a wider increment. If both OrigInc and IsomorphicInc
+  // are NUW/NSW, then we can preserve them on the wider increment; the 
narrower
+  // IsomorphicInc would wrap before the wider OrigInc, so the replacement 
won't
+  // make IsomorphicInc's uses more poisonous.
+  if (BothHaveNUW || BothHaveNSW) {
+OrigInc->setHasNoUnsignedWrap(OBOIncV->hasNoUnsignedWrap() || BothHaveNUW);
+OrigInc->setHasNoSignedWrap(OBOIncV->hasNoSignedWrap() || BothHaveNSW);
+  }
+
   SCEV_DEBUG_WITH_TYPE(DebugType,
dbgs() << "INDVARS: Eliminated congruent iv.inc: "
   << *IsomorphicInc << '\n');
diff --git a/llvm/test/Transforms/IndVarSimplify/iv-poison.ll 
b/llvm/test/Transforms/IndVarSimplify/iv-poison.ll
index 38299e0a6b353..383599f614357 100644
--- a/llvm/test/Transforms/IndVarSimplify/iv-poison.ll
+++ b/llvm/test/Transforms/IndVarSimplify/iv-poison.ll
@@ -64,7 +64,7 @@ define i2 @iv_hoist_both_adds_nsw(i2 %arg) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i2 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], 
[[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i2 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i2 [[IV_0]], 1
 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i2 1, [[ARG:%.*]]
 ; CHECK-NEXT:br i1 [[DOTNOT_NOT]], label [[EXIT:%.*]], label [[LOOP]]
 ; CHECK:   exit:
@@ -92,7 +92,7 @@ define i4 @iv_hoist_both_adds_nsw_extra_use(i4 %arg) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i4 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], 
[[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i4 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i4 [[IV_0]], 1
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i4 1, [[ARG:%.*]]
@@ -124,7 +124,7 @@ define i4 
@iv_hoist_both_adds_nsw_extra_use_incs_reordered(i4 %arg) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i4 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], 
[[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i4 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i4 [[IV_0]], 1
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i4 1, [[ARG:%.*]]
@@ -244,7 +244,7 @@ define i2 @iv_hoist_both_adds_nuw(i2 %arg, i2 %start) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i2 [ [[START:%.*]], [[BB:%.*]] ], [ 
[[IV_0_NEXT:%.*]], [[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add i2 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i2 [[IV_0]], 1
 ; CHECK-NEXT:[[

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

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

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

>From e98987ebb48839ea652d63dfaa62ed841b426e46 Mon Sep 17 00:00:00 2001
From: Matt Devereau 
Date: Thu, 18 Jan 2024 15:41:25 +
Subject: [PATCH 1/4] [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 d47181bfca4fc..781118c935898 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 75e9a8c46b876..8ddee560b11da 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 332fb37655288..6a210846cf4df 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 ea9882160d6fb..7d6b86ab8a3e9 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 0..a8cba7dc9a91e
--- /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", "~{zt0}"()
+  ret void
+}

>From 6391def8b7cfd88b12544766c94b75cb2a5bd385 Mon Sep 17 00:00:00 2001
From: Matt Devereau 
Date: Mon, 29 Jan 2024 09:59:47 +
Subject: [PATCH 2/4] run clang-format

---
 cla

[llvm] [clang] [clang-tools-extra] [AMDGPU] Add code model (#70760) test for amdgpu target. (PR #71019)

2024-02-01 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/71019

>From 2477ae87e7bb82b4551e42b8255dfe93dadff453 Mon Sep 17 00:00:00 2001
From: Pravin Jagtap 
Date: Thu, 2 Nov 2023 01:05:35 -0400
Subject: [PATCH 1/6] [AMDGPU] Add code model (#70760) test for amdgpu target.

---
 llvm/test/CodeGen/AMDGPU/codemodel.ll | 9 +
 1 file changed, 9 insertions(+)
 create mode 100644 llvm/test/CodeGen/AMDGPU/codemodel.ll

diff --git a/llvm/test/CodeGen/AMDGPU/codemodel.ll 
b/llvm/test/CodeGen/AMDGPU/codemodel.ll
new file mode 100644
index 0..8b60257b2076a
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/codemodel.ll
@@ -0,0 +1,9 @@
+; RUN: not llc -verify-machineinstrs -o - -mtriple=amdgcn-unknown-amdhsa 
-mcpu=gfx900 -code-model=tiny < %s 2>&1 | FileCheck %s --check-prefix=TINY
+; RUN: not llc -verify-machineinstrs -o - -mtriple=amdgcn-unknown-amdhsa 
-mcpu=gfx900 -code-model=kernel < %s 2>&1 | FileCheck %s --check-prefix=KERNEL
+
+; TINY:Target does not support the tiny CodeModel
+; KERNEL:Target does not support the kernel CodeModel
+
+define void @foo() {
+  ret void
+}

>From 4b3cf8a9f312caffd4492747026bc001086ef197 Mon Sep 17 00:00:00 2001
From: Pravin Jagtap 
Date: Thu, 2 Nov 2023 05:51:50 -0400
Subject: [PATCH 2/6] Added clang driver test for code model.

---
 clang/test/Driver/mcmodel.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/clang/test/Driver/mcmodel.c b/clang/test/Driver/mcmodel.c
index d8a41b0f5abd9..3b3ff08ba9ad2 100644
--- a/clang/test/Driver/mcmodel.c
+++ b/clang/test/Driver/mcmodel.c
@@ -15,6 +15,11 @@
 // RUN: not %clang -### -c --target=aarch64 -mcmodel=medium %s 2>&1 | 
FileCheck --check-prefix=ERR-MEDIUM %s
 // RUN: not %clang -### -c --target=aarch64 -mcmodel=kernel %s 2>&1 | 
FileCheck --check-prefix=ERR-KERNEL %s
 // RUN: not %clang --target=aarch64_32-linux -### -S -mcmodel=small %s 2>&1 | 
FileCheck --check-prefix=ERR-AARCH64_32 %s
+// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -c -mcmodel=tiny %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-TINY %s
+// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -c -mcmodel=small %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-SMALL %s
+// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -S -mcmodel=kernel %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-KERNEL %s
+// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -c -mcmodel=medium %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-MEDIUM %s
+// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -S -mcmodel=large %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-LARGE %s
 
 // TINY: "-mcmodel=tiny"
 // SMALL: "-mcmodel=small"
@@ -31,3 +36,8 @@
 
 // AARCH64-PIC-LARGE: error: invalid argument '-mcmodel=large' only allowed 
with '-fno-pic'
 // ERR-AARCH64_32: error: unsupported argument 'small' to option '-mcmodel=' 
for target 'aarch64_32-unknown-linux'
+// AMDGPU-MCMODEL-TINY: "-mcmodel=tiny"
+// AMDGPU-MCMODEL-SMALL: "-mcmodel=small"
+// AMDGPU-MCMODEL-KERNEL: "-mcmodel=kernel"
+// AMDGPU-MCMODEL-MEDIUM: "-mcmodel=medium"
+// AMDGPU-MCMODEL-LARGE: "-mcmodel=large"

>From 7def0ff2a9051deb2179be91dde532b8d06caf9f Mon Sep 17 00:00:00 2001
From: Pravin Jagtap 
Date: Thu, 2 Nov 2023 06:46:22 -0400
Subject: [PATCH 3/6] Updated the mcodel test to target hip

---
 clang/test/Driver/mcmodel.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/clang/test/Driver/mcmodel.c b/clang/test/Driver/mcmodel.c
index 3b3ff08ba9ad2..6d302657489f7 100644
--- a/clang/test/Driver/mcmodel.c
+++ b/clang/test/Driver/mcmodel.c
@@ -15,11 +15,11 @@
 // RUN: not %clang -### -c --target=aarch64 -mcmodel=medium %s 2>&1 | 
FileCheck --check-prefix=ERR-MEDIUM %s
 // RUN: not %clang -### -c --target=aarch64 -mcmodel=kernel %s 2>&1 | 
FileCheck --check-prefix=ERR-KERNEL %s
 // RUN: not %clang --target=aarch64_32-linux -### -S -mcmodel=small %s 2>&1 | 
FileCheck --check-prefix=ERR-AARCH64_32 %s
-// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -c -mcmodel=tiny %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-TINY %s
-// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -c -mcmodel=small %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-SMALL %s
-// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -S -mcmodel=kernel %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-KERNEL %s
-// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -c -mcmodel=medium %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-MEDIUM %s
-// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -S -mcmodel=large %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-LARGE %s
+// RUN: %clang --offload-arch=gfx906 -nogpulib -### -c -x hip -mcmodel=tiny %s 
2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-TINY %s
+// RUN: %clang --offload-arch=gfx906 -nogpulib -### -c -x hip -mcmodel=small 
%s 2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-SMALL %s
+// RUN: %clang --offload-arch=gfx906 -nogpulib -### -S -x hip -mcmodel=ker

[llvm] [clang] [clang-tools-extra] [AMDGPU] Add code model (#70760) test for amdgpu target. (PR #71019)

2024-02-01 Thread Matt Arsenault via cfe-commits

arsenm wrote:

> LGTM. Please update PR title before merging

So this was only supposed to add the test, or implement this too?

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


[llvm] [clang] [clang-tools-extra] [llvm-exegesis] Replace --num-repetitions with --min-instructions (PR #77153)

2024-02-01 Thread Aiden Grossman via cfe-commits

https://github.com/boomanaiden154 closed 
https://github.com/llvm/llvm-project/pull/77153
___
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-02-01 Thread Matthew Devereau via cfe-commits


@@ -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)) {

MDevereau wrote:

Done

https://github.com/llvm/llvm-project/pull/79276
___
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-02-01 Thread Matthew Devereau via cfe-commits


@@ -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)

MDevereau wrote:

Done

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


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

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


@@ -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)) {

MDevereau wrote:

Done

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


[clang] [llvm] [clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-02-01 Thread Bhuminjay Soni via cfe-commits

11happy wrote:

@PiotrZSL , I have tried to implement the solution you suggested, took me some 
time though , but I can say it got me better understanding of how things work. 

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


[clang] Multilib support for libraries with exceptions (PR #75031)

2024-02-01 Thread Dominik Wójt via cfe-commits


@@ -264,6 +273,14 @@ ToolChain::getMultilibFlags(const llvm::opt::ArgList 
&Args) const {
 break;
   }
 
+  // Include fno-exceptions and fno-rtti
+  // to improve multilib selection
+  if (getRTTIMode() == ToolChain::RTTIMode::RM_Disabled)
+Result.push_back("-fno-rtti");
+
+  if (getExceptionsMode() == ToolChain::ExceptionsMode::EM_Disabled)
+Result.push_back("-fno-exceptions");

domin144 wrote:

And a positive one here, too?

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


[clang] Multilib support for libraries with exceptions (PR #75031)

2024-02-01 Thread Dominik Wójt via cfe-commits


@@ -264,6 +273,14 @@ ToolChain::getMultilibFlags(const llvm::opt::ArgList 
&Args) const {
 break;
   }
 
+  // Include fno-exceptions and fno-rtti
+  // to improve multilib selection
+  if (getRTTIMode() == ToolChain::RTTIMode::RM_Disabled)
+Result.push_back("-fno-rtti");

domin144 wrote:

Could we have a positive flag, too?
I know it is not useful for now, as we are not able to say, that some feature 
of a standard library is available - only that it is allowed. However, if in 
the future such mechanism was added, than I think it would be more natural to 
say:
"If user specifies '-frtti', then the library candidate also needs '-frtti'"
than to say:
"If user specifies '-fno-rtti', than the library is allowed to have 
'-fno-rtti'".

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


[llvm] [clang] [compiler-rt] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

2024-02-01 Thread Simon Pilgrim via cfe-commits


@@ -139,20 +139,77 @@ enum ProcessorFeatures {
   FEATURE_AVX512BITALG,
   FEATURE_AVX512BF16,
   FEATURE_AVX512VP2INTERSECT,
+  FEATURE_3DNOW,
+  FEATURE_ADX = 40,
+  FEATURE_CLDEMOTE = 42,

RKSimon wrote:

Maybe leave in a commented out entry to make that clear?

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


[clang] 1bbb797 - [Clang][AArch64] Add ACLE macros for FEAT_PAuth_LR (#80163)

2024-02-01 Thread via cfe-commits

Author: Lucas Duarte Prates
Date: 2024-02-01T10:24:38Z
New Revision: 1bbb797e9c7f37aa814b9bbaba2961f730a26891

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

LOG: [Clang][AArch64] Add ACLE macros for FEAT_PAuth_LR (#80163)

This updates clang's target defines to include the ACLE changes covering
the FEAT_PAuth_LR architecture extension.
The changes include:
* The new `__ARM_FEATURE_PAUTH_LR` feature macro, which is set to 1 when
  FEAT_PAuth_LR is available in the target.
* A new bit field for the existing `__ARM_FEATURE_PAC_DEFAULT` macro,
  indicating the use of PC as a diversifier for Pointer Authentication
  (from -mbranch-protection=pac-ret+pc).

The approved changes to the ACLE spec can be found here:
https://github.com/ARM-software/acle/pull/292

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/test/Preprocessor/aarch64-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index c89e16677e974..46f14b47261ae 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -466,6 +466,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasPAuth)
 Builder.defineMacro("__ARM_FEATURE_PAUTH", "1");
 
+  if (HasPAuthLR)
+Builder.defineMacro("__ARM_FEATURE_PAUTH_LR", "1");
+
   if (HasUnaligned)
 Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1");
 
@@ -517,6 +520,7 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 // 0: Protection using the A key
 // 1: Protection using the B key
 // 2: Protection including leaf functions
+// 3: Protection using PC as a diversifier
 unsigned Value = 0;
 
 if (Opts.isSignReturnAddressWithAKey())
@@ -527,6 +531,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 if (Opts.isSignReturnAddressScopeAll())
   Value |= (1 << 2);
 
+if (Opts.BranchProtectionPAuthLR)
+  Value |= (1 << 3);
+
 Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", std::to_string(Value));
   }
 
@@ -966,6 +973,10 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasGCS = true;
 if (Feature == "+rcpc3")
   HasRCPC3 = true;
+if (Feature == "+pauth-lr") {
+  HasPAuthLR = true;
+  HasPAuth = true;
+}
   }
 
   // Check features that are manually disabled by command line options.

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 9f5e88a6ddd99..7761812295ffa 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -84,6 +84,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasGCS = false;
   bool HasRCPC3 = false;
   bool HasSMEFA64 = false;
+  bool HasPAuthLR = false;
 
   const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;
 

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 15879da04fcf0..062b802909f16 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -602,6 +602,37 @@
 // CHECK-GCS-DEFAULT: __ARM_FEATURE_GCS_DEFAULT 1
 // CHECK-NOGCS-DEFAULT-NOT: __ARM_FEATURE_GCS_DEFAULT 1
 
+// == Check Armv9.5-A Pointer Authentication 
Enhancements(PAuth_LR).
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -x c -E -dM %s -o - 
| FileCheck -check-prefix=CHECK-PAUTH-LR-OFF %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv9.5-a -x c -E -dM %s -o 
- | FileCheck -check-prefix=CHECK-PAUTH-LR-OFF %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+pauth 
-mbranch-protection=none -x c -E -dM %s -o - | FileCheck 
-check-prefix=CHECK-PAUTH-LR-OFF %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+pauth-lr 
-mbranch-protection=none -x c -E -dM %s -o - | FileCheck 
-check-prefix=CHECK-PAUTH-LR %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+pauth-lr 
-mbranch-protection=bti -x c -E -dM %s -o - | FileCheck 
-check-prefix=CHECK-PAUTH-LR %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a 
-mbranch-protection=standard -x c -E -dM %s -o - | FileCheck 
-check-prefix=CHECK-PAUTH-LR-OFF %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a 
-mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck 
-check-prefix=CHECK-PAUTH-LR-OFF %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
-check-prefix=CHECK-PAUTH-LR-OFF %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a 
-mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
-check-p

[clang] [Clang][AArch64] Add ACLE macros for FEAT_PAuth_LR (PR #80163)

2024-02-01 Thread Lucas Duarte Prates via cfe-commits

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


[clang-tools-extra] [clang-tidy] Remove enforcement of rule C.48 from cppcoreguidelines-p… (PR #80193)

2024-02-01 Thread Carlos Galvez via cfe-commits

carlosgalvezp wrote:

Thanks for the review! I agree, check names are not the best. It's a bit of a 
hassle to change them though :/ 

I will fix the comment about the release notes tonight :+1: 

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


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

2024-02-01 Thread Sander de Smalen via cfe-commits

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

LGTM!

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


[compiler-rt] [clang] [flang] [llvm] [clang-tools-extra] [TTI]Fallback to SingleSrcPermute shuffle kind, if no direct estimation for (PR #79837)

2024-02-01 Thread Simon Pilgrim via cfe-commits


@@ -2,15 +2,15 @@
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+sse2 | FileCheck %s 
-check-prefixes=SSE,SSE2
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+ssse3 | FileCheck %s 
-check-prefixes=SSE,SSSE3
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+sse4.2 | FileCheck %s 
-check-prefixes=SSE,SSE42
-; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+avx | FileCheck %s 
-check-prefixes=AVX
-; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+avx2 | FileCheck %s 
-check-prefixes=AVX
-; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+avx512f | FileCheck %s 
--check-prefixes=AVX512
-; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+avx512f,+avx512bw | FileCheck 
%s --check-prefixes=AVX512
-; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+avx512f,+avx512bw,+avx512vbmi | 
FileCheck %s --check-prefixes=AVX512
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+avx | FileCheck %s 
-check-prefixes=AVX,AVX1
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+avx2 | FileCheck %s 
-check-prefixes=AVX,AVX2
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+avx512f | FileCheck %s 
--check-prefixes=AVX512,AVX512F
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+avx512f,+avx512bw | FileCheck 
%s --check-prefixes=AVX512,AVX512BW
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mattr=+avx512f,+avx512bw,+avx512vbmi | 
FileCheck %s --check-prefixes=AVX512,AVX512VBMI
 ;
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mcpu=slm | FileCheck %s 
--check-prefixes=SSE,SLM
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mcpu=goldmont | FileCheck %s 
--check-prefixes=SSE,GLM
-; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mcpu=btver2 | FileCheck %s 
--check-prefixes=AVX
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print" 
2>&1 -disable-output -cost-kind=latency -mcpu=btver2 | FileCheck %s 
--check-prefixes=AVX,BTVER2

RKSimon wrote:

Use AVX1 instead of BTVER2?

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


[clang] Diagnose misuse of the cleanup attribute (PR #80040)

2024-02-01 Thread Bhuminjay Soni via cfe-commits

https://github.com/11happy updated 
https://github.com/llvm/llvm-project/pull/80040

>From 93adb872d0e18ff3a1356ab47527d81b61c920cd Mon Sep 17 00:00:00 2001
From: 11happy 
Date: Tue, 30 Jan 2024 23:19:04 +0530
Subject: [PATCH 1/4] Diagnose misuse of the cleanup attribute

Signed-off-by: 11happy 
---
 .../include/clang/Basic/DiagnosticSemaKinds.td  |  4 
 clang/include/clang/Sema/Sema.h |  2 ++
 clang/lib/Sema/SemaDeclAttr.cpp |  7 +++
 clang/lib/Sema/SemaExpr.cpp | 17 +
 4 files changed, 30 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 24d32cb87c89e..99ef803b1e0ec 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8265,6 +8265,10 @@ def warn_condition_is_assignment : Warning<"using the 
result of an "
 def warn_free_nonheap_object
   : Warning<"attempt to call %0 on non-heap %select{object %2|object: block 
expression|object: lambda-to-function-pointer conversion}1">,
 InGroup;
+def warn_free_called_on_unallocated_object : Warning<
+  "'%0' called on unallocated object '%1'">,
+  InGroup;
+  
 
 // Completely identical except off by default.
 def warn_condition_is_idiomatic_assignment : Warning<"using the result "
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b5946e3f3178f..535c479aeb7c5 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12932,6 +12932,8 @@ class Sema final {
 
   bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
 
+  bool IsPointerToPointer(QualType LHSType, QualType RHSType);
+
   bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
 
   ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 069571fcf7864..e149f745cc2f9 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3782,6 +3782,13 @@ static void handleCleanupAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
   }
 
   D->addAttr(::new (S.Context) CleanupAttr(S.Context, AL, FD));
+
+  if (S.IsPointerToPointer(ParamTy, Ty)) {
+VarDecl *VD = cast(D);
+S.Diag(Loc, diag::warn_free_called_on_unallocated_object)
+<< NI.getName() << VD;
+return;
+  }
 }
 
 static void handleEnumExtensibilityAttr(Sema &S, Decl *D,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2f1ddfb215116..255e0be3cc842 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10098,6 +10098,23 @@ static bool isVector(QualType QT, QualType 
ElementType) {
   return false;
 }
 
+bool Sema::IsPointerToPointer(QualType LHSType, QualType RHSType) {
+  if (const PointerType *LHSPointer = dyn_cast(LHSType)) {
+// Check if LHS is a single pointer, not a pointer to a pointer.
+if (!isa(LHSPointer->getPointeeType())) {
+  if (isa(RHSType)) {
+if (const PointerType *RHSPtr = dyn_cast(RHSType)) {
+  // If RHSType is a pointer to a pointer type, return True
+  if (isa(RHSPtr->getPointeeType())) {
+return true;
+  }
+}
+  }
+}
+  }
+  return false;
+}
+
 /// CheckAssignmentConstraints (C99 6.5.16) - This routine currently
 /// has code to accommodate several GCC extensions when type checking
 /// pointers. Here are some objectionable examples that GCC considers warnings:

>From 730f4d7f088645f4b49649c73328ca25e681339a Mon Sep 17 00:00:00 2001
From: 11happy 
Date: Wed, 31 Jan 2024 05:45:00 +0530
Subject: [PATCH 2/4] remove whitespace

Signed-off-by: 11happy 
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 99ef803b1e0ec..ae9ad757788e8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8268,7 +8268,6 @@ def warn_free_nonheap_object
 def warn_free_called_on_unallocated_object : Warning<
   "'%0' called on unallocated object '%1'">,
   InGroup;
-  
 
 // Completely identical except off by default.
 def warn_condition_is_idiomatic_assignment : Warning<"using the result "

>From 1a3cc18276be89969d5a262ff12499d20fd925ee Mon Sep 17 00:00:00 2001
From: 11happy 
Date: Wed, 31 Jan 2024 20:58:19 +0530
Subject: [PATCH 3/4] change diagnostic

Signed-off-by: 11happy 
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++--
 clang/lib/Sema/SemaDeclAttr.cpp  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ae9ad757788e8..e8165394701c9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/i

[clang] [polly] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread via cfe-commits


@@ -9906,12 +9944,16 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
   verifyFormat("class B {\n"
"  int f() { return 1; }\n"
"  int g();\n"
+   "  long\n"
+   "  f::br();\n"

rmarker wrote:

Yeah, not sure if this example is completely relevant in the tests for these 
subsequent options.
Though to me, it seems that each of the options has a test with the same block 
of code. Since there are other lines which aren't definitions in the same test.
Wondering if it is worth keeping it so that the symmetry in this area is 
preserved?
Though, I don't have strong feelings either way if you think it isn't needed.

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


[clang] [polly] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread via cfe-commits

https://github.com/rmarker updated 
https://github.com/llvm/llvm-project/pull/78011

>From a1312a0a463bb946f336977b5b01ef7afbede678 Mon Sep 17 00:00:00 2001
From: rmarker 
Date: Thu, 11 Jan 2024 15:01:18 +1030
Subject: [PATCH 01/16] [clang-format] Add ShortReturnTypeColumn option.

---
 clang/docs/ClangFormatStyleOptions.rst | 13 +++
 clang/docs/ReleaseNotes.rst|  1 +
 clang/include/clang/Format/Format.h| 12 ++
 clang/lib/Format/ContinuationIndenter.cpp  |  3 +-
 clang/lib/Format/Format.cpp|  2 +
 clang/unittests/Format/ConfigParseTest.cpp |  1 +
 clang/unittests/Format/FormatTest.cpp  | 44 ++
 7 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4dc0de3a90f26..7836cc8f1c9bb 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4999,6 +4999,19 @@ the configuration (without a prefix: ``Auto``).
int bar;   int bar;
  } // namespace b   } // namespace b
 
+.. _ShortReturnTypeColumn:
+
+**ShortReturnTypeColumn** (``Unsigned``) :versionbadge:`clang-format 19` 
:ref:`¶ `
+  When ``AlwaysBreakAfterReturnType`` is ``None``, line breaks are prevented
+  after short return types. This configures the column limit for a type
+  to be regarded as short.
+
+
+  .. note::
+
+   This isn't the length of the type itself, but the column where it
+   finishes. I.e. it includes indentation, etc.
+
 .. _SkipMacroDefinitionBody:
 
 **SkipMacroDefinitionBody** (``Boolean``) :versionbadge:`clang-format 18` 
:ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5330cd9caad80..669b420fe21ec 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -184,6 +184,7 @@ AST Matchers
 
 clang-format
 
+- Add ``ShortReturnTypeColumn`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index bc9eecd42f9eb..7fd574c98a394 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3932,6 +3932,17 @@ struct FormatStyle {
   /// \version 13
   unsigned ShortNamespaceLines;
 
+  /// When ``AlwaysBreakAfterReturnType`` is ``None``, line breaks are 
prevented
+  /// after short return types. This configures the column limit for a type
+  /// to be regarded as short.
+  ///
+  /// \note
+  ///  This isn't the length of the type itself, but the column where it
+  ///  finishes. I.e. it includes indentation, etc.
+  /// \endnote
+  /// \version 19
+  unsigned ShortReturnTypeColumn;
+
   /// Do not format macro definition body.
   /// \version 18
   bool SkipMacroDefinitionBody;
@@ -4899,6 +4910,7 @@ struct FormatStyle {
RequiresExpressionIndentation == R.RequiresExpressionIndentation &&
SeparateDefinitionBlocks == R.SeparateDefinitionBlocks &&
ShortNamespaceLines == R.ShortNamespaceLines &&
+   ShortReturnTypeColumn == R.ShortReturnTypeColumn &&
SkipMacroDefinitionBody == R.SkipMacroDefinitionBody &&
SortIncludes == R.SortIncludes &&
SortJavaStaticImport == R.SortJavaStaticImport &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index a3eb9138b2183..3f9c0cc815745 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -328,7 +328,8 @@ bool ContinuationIndenter::canBreak(const LineState &State) 
{
 
   // Don't break after very short return types (e.g. "void") as that is often
   // unexpected.
-  if (Current.is(TT_FunctionDeclarationName) && State.Column < 6) {
+  if (Current.is(TT_FunctionDeclarationName) &&
+  State.Column <= Style.ShortReturnTypeColumn) {
 if (Style.AlwaysBreakAfterReturnType == FormatStyle::RTBS_None)
   return false;
   }
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index ff326dc784783..35478fac7b496 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1085,6 +1085,7 @@ template <> struct MappingTraits {
Style.RequiresExpressionIndentation);
 IO.mapOptional("SeparateDefinitionBlocks", Style.SeparateDefinitionBlocks);
 IO.mapOptional("ShortNamespaceLines", Style.ShortNamespaceLines);
+IO.mapOptional("ShortReturnTypeColumn", Style.ShortReturnTypeColumn);
 IO.mapOptional("SkipMacroDefinitionBody", Style.SkipMacroDefinitionBody);
 IO.mapOptional("SortIncludes", Style.SortIncludes);
 IO.mapOptional("SortJavaStaticImport", Style.SortJavaStaticImport);
@@ -1557,6 +1558,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.RequiresExpressionIndentation = FormatStyle::REI_OuterScope;
   LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave;
   LLVMStyle.ShortNamespaceLines = 1;
+  LLVMSt

[clang] [polly] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-01 Thread via cfe-commits


@@ -914,16 +914,31 @@ struct FormatStyle {
   /// Different ways to break after the function definition or
   /// declaration return type.
   enum ReturnTypeBreakingStyle : int8_t {
-/// Break after return type automatically.
-/// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
+/// This is **deprecated**. See ``Automatic`` below.
+RTBS_None,
+/// Break after return type based on ``PenaltyReturnTypeOnItsOwnLine``.
 /// \code
 ///   class A {
 /// int f() { return 0; };
 ///   };
 ///   int f();
 ///   int f() { return 1; }
+///   int
+///   LongName::AnotherLongName();
 /// \endcode
-RTBS_None,
+RTBS_Automatic,
+/// Same as ``Automatic`` above, expect that there is no break after short

rmarker wrote:

Oof, spellcheck has failed me ;)

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


[clang] [AMDGPU] Check wavefrontsize for GFX11 WMMA builtins (PR #79980)

2024-02-01 Thread Matt Arsenault via cfe-commits

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


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


[clang] b5c0b67 - [AMDGPU] Check wavefrontsize for GFX11 WMMA builtins (#79980)

2024-02-01 Thread via cfe-commits

Author: Jay Foad
Date: 2024-02-01T10:49:42Z
New Revision: b5c0b67bc270936c8fa254dc42d920e867adef54

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

LOG: [AMDGPU] Check wavefrontsize for GFX11 WMMA builtins (#79980)

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w32-gfx10-err.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w64-gfx10-err.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w64.cl

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 74dfd1d214e84..e9dd8dcd0b60e 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -292,23 +292,23 @@ 
TARGET_BUILTIN(__builtin_amdgcn_s_wait_event_export_ready, "v", "n", "gfx11-inst
 // Postfix w32 indicates the builtin requires wavefront size of 32.
 // Postfix w64 indicates the builtin requires wavefront size of 64.
 
//===--===//
-TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_f16_w32, "V8fV16hV16hV8f", 
"nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32, "V8fV16sV16sV8f", 
"nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x16_f16_w32, 
"V16hV16hV16hV16hIb", "nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w32, 
"V16sV16sV16sV16sIb", "nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x16_f16_tied_w32, 
"V16hV16hV16hV16hIb", "nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_bf16_16x16x16_bf16_tied_w32, 
"V16sV16sV16sV16sIb", "nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu8_w32, 
"V8iIbV4iIbV4iV8iIb", "nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu4_w32, 
"V8iIbV2iIbV2iV8iIb", "nc", "gfx11-insts")
-
-TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_f16_w64, "V4fV16hV16hV4f", 
"nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_bf16_w64, "V4fV16sV16sV4f", 
"nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x16_f16_w64, "V8hV16hV16hV8hIb", 
"nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64, 
"V8sV16sV16sV8sIb", "nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x16_f16_tied_w64, 
"V8hV16hV16hV8hIb", "nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_bf16_16x16x16_bf16_tied_w64, 
"V8sV16sV16sV8sIb", "nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu8_w64, 
"V4iIbV4iIbV4iV4iIb", "nc", "gfx11-insts")
-TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu4_w64, 
"V4iIbV2iIbV2iV4iIb", "nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_f16_w32, "V8fV16hV16hV8f", 
"nc", "gfx11-insts,wavefrontsize32")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32, "V8fV16sV16sV8f", 
"nc", "gfx11-insts,wavefrontsize32")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x16_f16_w32, 
"V16hV16hV16hV16hIb", "nc", "gfx11-insts,wavefrontsize32")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w32, 
"V16sV16sV16sV16sIb", "nc", "gfx11-insts,wavefrontsize32")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x16_f16_tied_w32, 
"V16hV16hV16hV16hIb", "nc", "gfx11-insts,wavefrontsize32")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_bf16_16x16x16_bf16_tied_w32, 
"V16sV16sV16sV16sIb", "nc", "gfx11-insts,wavefrontsize32")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu8_w32, 
"V8iIbV4iIbV4iV8iIb", "nc", "gfx11-insts,wavefrontsize32")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu4_w32, 
"V8iIbV2iIbV2iV8iIb", "nc", "gfx11-insts,wavefrontsize32")
+
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_f16_w64, "V4fV16hV16hV4f", 
"nc", "gfx11-insts,wavefrontsize64")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_bf16_w64, "V4fV16sV16sV4f", 
"nc", "gfx11-insts,wavefrontsize64")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x16_f16_w64, "V8hV16hV16hV8hIb", 
"nc", "gfx11-insts,wavefrontsize64")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64, 
"V8sV16sV16sV8sIb", "nc", "gfx11-insts,wavefrontsize64")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x16_f16_tied_w64, 
"V8hV16hV16hV8hIb", "nc", "gfx11-insts,wavefrontsize64")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_bf16_16x16x16_bf16_tied_w64, 
"V8sV16sV16sV8sIb", "nc", "gfx11-insts,wavefrontsize64")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu8_w64, 
"V4iIbV4iIbV4iV4iIb", "nc", "gfx11-insts,wavefrontsize64")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu4_w64, 
"V4iIbV2iIbV2iV4iIb", "nc", "gfx11-insts,wavefrontsize64")
 
 TARGET_BUILTIN(__builtin_amdgcn_s_sendmsg_rtn, "UiUIi", "n", "gfx11-insts")
 TARGET_BUILTIN(__buil

[clang] [AMDGPU] Check wavefrontsize for GFX11 WMMA builtins (PR #79980)

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

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


[clang] [llvm] [compiler-rt] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

2024-02-01 Thread Freddy Ye via cfe-commits

https://github.com/FreddyLeaf updated 
https://github.com/llvm/llvm-project/pull/79086

>From b5c8579c5c8e7ea1e8436348bbf60ecee9c3c799 Mon Sep 17 00:00:00 2001
From: Freddy Ye 
Date: Fri, 19 Jan 2024 09:22:27 +0800
Subject: [PATCH 1/5] [X86] Support more ISAs to enable __builtin_cpu_supports

This patch will also expand supports for attribute/target, while
the priority of newly supported ISAs will be set to zero.
---
 clang/test/CodeGen/target-builtin-noerror.c   |  59 +
 compiler-rt/lib/builtins/cpu_model/x86.c  | 209 +-
 .../llvm/TargetParser/X86TargetParser.def | 135 ++-
 3 files changed, 324 insertions(+), 79 deletions(-)

diff --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 06bb40a2b71ea..16097fa08cb9c 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -84,6 +84,65 @@ void verifyfeaturestrings(void) {
   (void)__builtin_cpu_supports("avx512vp2intersect");
   (void)__builtin_cpu_supports("f16c");
   (void)__builtin_cpu_supports("avx512fp16");
+  (void)__builtin_cpu_supports("3dnow");
+  (void)__builtin_cpu_supports("adx");
+  (void)__builtin_cpu_supports("cldemote");
+  (void)__builtin_cpu_supports("clflushopt");
+  (void)__builtin_cpu_supports("clwb");
+  (void)__builtin_cpu_supports("clzero");
+  (void)__builtin_cpu_supports("cx16");
+  (void)__builtin_cpu_supports("cx8");
+  (void)__builtin_cpu_supports("enqcmd");
+  (void)__builtin_cpu_supports("fsgsbase");
+  (void)__builtin_cpu_supports("lwp");
+  (void)__builtin_cpu_supports("lzcnt");
+  (void)__builtin_cpu_supports("movbe");
+  (void)__builtin_cpu_supports("movdir64b");
+  (void)__builtin_cpu_supports("movdiri");
+  (void)__builtin_cpu_supports("mwaitx");
+  (void)__builtin_cpu_supports("pconfig");
+  (void)__builtin_cpu_supports("pku");
+  (void)__builtin_cpu_supports("prefetchwt1");
+  (void)__builtin_cpu_supports("prfchw");
+  (void)__builtin_cpu_supports("ptwrite");
+  (void)__builtin_cpu_supports("rdpid");
+  (void)__builtin_cpu_supports("rdrnd");
+  (void)__builtin_cpu_supports("rdseed");
+  (void)__builtin_cpu_supports("rtm");
+  (void)__builtin_cpu_supports("serialize");
+  (void)__builtin_cpu_supports("sgx");
+  (void)__builtin_cpu_supports("sha");
+  (void)__builtin_cpu_supports("shstk");
+  (void)__builtin_cpu_supports("tbm");
+  (void)__builtin_cpu_supports("tsxldtrk");
+  (void)__builtin_cpu_supports("vaes");
+  (void)__builtin_cpu_supports("waitpkg");
+  (void)__builtin_cpu_supports("wbnoinvd");
+  (void)__builtin_cpu_supports("xsave");
+  (void)__builtin_cpu_supports("xsavec");
+  (void)__builtin_cpu_supports("xsaveopt");
+  (void)__builtin_cpu_supports("xsaves");
+  (void)__builtin_cpu_supports("amx-tile");
+  (void)__builtin_cpu_supports("amx-int8");
+  (void)__builtin_cpu_supports("amx-bf16");
+  (void)__builtin_cpu_supports("uintr");
+  (void)__builtin_cpu_supports("hreset");
+  (void)__builtin_cpu_supports("kl");
+  (void)__builtin_cpu_supports("widekl");
+  (void)__builtin_cpu_supports("avxvnni");
+  (void)__builtin_cpu_supports("avxifma");
+  (void)__builtin_cpu_supports("avxvnniint8");
+  (void)__builtin_cpu_supports("avxneconvert");
+  (void)__builtin_cpu_supports("cmpccxadd");
+  (void)__builtin_cpu_supports("amx-fp16");
+  (void)__builtin_cpu_supports("prefetchi");
+  (void)__builtin_cpu_supports("raoint");
+  (void)__builtin_cpu_supports("amx-complex");
+  (void)__builtin_cpu_supports("avxvnniint16");
+  (void)__builtin_cpu_supports("sm3");
+  (void)__builtin_cpu_supports("sha512");
+  (void)__builtin_cpu_supports("sm4");
+  (void)__builtin_cpu_supports("usermsr");
 }
 
 void verifycpustrings(void) {
diff --git a/compiler-rt/lib/builtins/cpu_model/x86.c 
b/compiler-rt/lib/builtins/cpu_model/x86.c
index 0750e29f989a8..c499754890343 100644
--- a/compiler-rt/lib/builtins/cpu_model/x86.c
+++ b/compiler-rt/lib/builtins/cpu_model/x86.c
@@ -139,20 +139,77 @@ enum ProcessorFeatures {
   FEATURE_AVX512BITALG,
   FEATURE_AVX512BF16,
   FEATURE_AVX512VP2INTERSECT,
+  FEATURE_3DNOW,
+  FEATURE_ADX = 40,
+  FEATURE_CLDEMOTE = 42,
+  FEATURE_CLFLUSHOPT,
+  FEATURE_CLWB,
+  FEATURE_CLZERO,
+  FEATURE_CMPXCHG16B,
+  FEATURE_CMPXCHG8B,
+  FEATURE_ENQCMD,
+  FEATURE_F16C,
+  FEATURE_FSGSBASE,
 
-  FEATURE_CMPXCHG16B = 46,
-  FEATURE_F16C = 49,
   FEATURE_LAHF_LM = 54,
   FEATURE_LM,
-  FEATURE_WP,
+  FEATURE_LWP,
   FEATURE_LZCNT,
   FEATURE_MOVBE,
-
-  FEATURE_AVX512FP16 = 94,
+  FEATURE_MOVDIR64B,
+  FEATURE_MOVDIRI,
+  FEATURE_MWAITX,
+
+  FEATURE_PCONFIG = 63,
+  FEATURE_PKU,
+  FEATURE_PREFETCHWT1,
+  FEATURE_PRFCHW,
+  FEATURE_PTWRITE,
+  FEATURE_RDPID,
+  FEATURE_RDRND,
+  FEATURE_RDSEED,
+  FEATURE_RTM,
+  FEATURE_SERIALIZE,
+  FEATURE_SGX,
+  FEATURE_SHA,
+  FEATURE_SHSTK,
+  FEATURE_TBM,
+  FEATURE_TSXLDTRK,
+  FEATURE_VAES,
+  FEATURE_WAITPKG,
+  FEATURE_WBNOINVD,
+  FEATURE_XSAVE,
+  FEATURE_XSAVEC,
+  FEATURE_XSAVEOPT,
+  FEATURE_XSAVES,
+  FEATURE_AMX_TILE,
+  FEATURE_AMX

[clang] [llvm] [compiler-rt] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

2024-02-01 Thread Freddy Ye via cfe-commits


@@ -139,20 +139,77 @@ enum ProcessorFeatures {
   FEATURE_AVX512BITALG,
   FEATURE_AVX512BF16,
   FEATURE_AVX512VP2INTERSECT,
+  FEATURE_3DNOW,
+  FEATURE_ADX = 40,
+  FEATURE_CLDEMOTE = 42,

FreddyLeaf wrote:

agree, done in 10c2a7c

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


[flang] [clang] [libcxxabi] [clang-tools-extra] [llvm] [lld] [libc] [lldb] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. (PR #79512)

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

https://github.com/fhahn closed https://github.com/llvm/llvm-project/pull/79512
___
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-02-01 Thread Matthew Devereau via cfe-commits

https://github.com/MDevereau ready_for_review 
https://github.com/llvm/llvm-project/pull/79276
___
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-02-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Matthew Devereau (MDevereau)


Changes

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

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


5 Files Affected:

- (modified) clang/lib/Basic/Targets/AArch64.cpp (+8-1) 
- (modified) clang/test/CodeGen/aarch64-inline-asm.c (+8) 
- (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+8) 
- (modified) llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp (+4) 
- (added) llvm/test/CodeGen/AArch64/aarch64-za-clobber.ll (+16) 


``diff
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index d47181bfca4fc..dbf0fdad15dc8 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1164,6 +1164,8 @@ TargetInfo::BuiltinVaListKind 
AArch64TargetInfo::getBuiltinVaListKind() const {
 }
 
 const char *const AArch64TargetInfo::GCCRegNames[] = {
+// clang-format off
+
 // 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",
@@ -1200,7 +1202,12 @@ 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",
+
+// clang-format on
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {
diff --git a/clang/test/CodeGen/aarch64-inline-asm.c 
b/clang/test/CodeGen/aarch64-inline-asm.c
index 75e9a8c46b876..8ddee560b11da 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 332fb37655288..bd757343e1007 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 (Constraint == "{za}") {
+return std::make_pair(unsigned(AArch64::ZA), &AArch64::MPRRegClass);
+  }
+
+  if (Constraint == "{zt0}") {
+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 ea9882160d6fb..cbb21cd60335e 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 == AArch64::ZA || PhysReg == 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 0..a8cba7dc9a91e
--- /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", "~{zt0}"()
+  ret void
+}

``




https://github.com/llv

[clang-tools-extra] [clang] [clangd] Collect comments from function definitions into the index (PR #67802)

2024-02-01 Thread Christian Kandeler via cfe-commits

ckandeler wrote:

ping

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


[clang] Multilib support for libraries with exceptions (PR #75031)

2024-02-01 Thread Dominik Wójt via cfe-commits

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


[clang-tools-extra] [clangd] Do not offer extraction to variable for decl init expression (PR #69477)

2024-02-01 Thread Christian Kandeler via cfe-commits

ckandeler wrote:

ping

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


[clang-tools-extra] [clangd] Allow "move function body out-of-line" in non-header files (PR #69704)

2024-02-01 Thread Christian Kandeler via cfe-commits

ckandeler wrote:

ping

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


[compiler-rt] [flang] [libcxxabi] [lldb] [clang-tools-extra] [openmp] [lld] [libcxx] [mlir] [llvm] [libc] [clang] [libc++][memory] P2652R2: Disallow Specialization of `allocator_traits` (PR #79978)

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

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

Thanks! LGTM.

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


[libc] [libcxx] [lld] [llvm] [clang] [flang] [libcxxabi] [openmp] [compiler-rt] [mlir] [lldb] [clang-tools-extra] [libc++][memory] P2652R2: Disallow Specialization of `allocator_traits` (PR #79978)

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

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


[clang] Thread safety analysis: provide printSCFG definition. (PR #80277)

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

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

I called this function when investigating the issue 
(https://github.com/llvm/llvm-project/issues/78131), and I was surprised to see 
the definition is commented out.

I think it makes sense to provide the definition even though the implementation 
is not stable.

>From bb1a8f86e0b9ce3748af03625757d20900e053fc Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Thu, 1 Feb 2024 12:41:29 +0100
Subject: [PATCH] Thread safety analysis: provide printSCFG definition.

I'm calling this function when investigating the issue 
(https://github.com/llvm/llvm-project/issues/78131), and I'm
surprised to see the definition is commented out.

I think it makes sense to provide the definition even though the
implementation is not stable.
---
 clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h | 1 +
 clang/lib/Analysis/ThreadSafetyCommon.cpp  | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h 
b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
index 13e37ac2b56b6..4edd3374dd61b 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
@@ -528,6 +528,7 @@ class SExprBuilder {
 };
 
 // Dump an SCFG to llvm::errs().
+// The implementation is not stable, and used for debugging only.
 void printSCFG(CFGWalker &Walker);
 
 } // namespace threadSafety
diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp 
b/clang/lib/Analysis/ThreadSafetyCommon.cpp
index 2fe0f85897c3b..fc5b7d3b6f197 100644
--- a/clang/lib/Analysis/ThreadSafetyCommon.cpp
+++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp
@@ -995,7 +995,6 @@ void SExprBuilder::exitCFG(const CFGBlock *Last) {
   IncompleteArgs.clear();
 }
 
-/*
 namespace {
 
 class TILPrinter :
@@ -1016,4 +1015,3 @@ void printSCFG(CFGWalker &Walker) {
 
 } // namespace threadSafety
 } // namespace clang
-*/

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


[clang] Thread safety analysis: provide printSCFG definition. (PR #80277)

2024-02-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-analysis

Author: Haojian Wu (hokein)


Changes

I called this function when investigating the issue 
(https://github.com/llvm/llvm-project/issues/78131), and I was surprised to see 
the definition is commented out.

I think it makes sense to provide the definition even though the implementation 
is not stable.

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


2 Files Affected:

- (modified) clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h (+1) 
- (modified) clang/lib/Analysis/ThreadSafetyCommon.cpp (-2) 


``diff
diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h 
b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
index 13e37ac2b56b6..4edd3374dd61b 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
@@ -528,6 +528,7 @@ class SExprBuilder {
 };
 
 // Dump an SCFG to llvm::errs().
+// The implementation is not stable, and used for debugging only.
 void printSCFG(CFGWalker &Walker);
 
 } // namespace threadSafety
diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp 
b/clang/lib/Analysis/ThreadSafetyCommon.cpp
index 2fe0f85897c3b..fc5b7d3b6f197 100644
--- a/clang/lib/Analysis/ThreadSafetyCommon.cpp
+++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp
@@ -995,7 +995,6 @@ void SExprBuilder::exitCFG(const CFGBlock *Last) {
   IncompleteArgs.clear();
 }
 
-/*
 namespace {
 
 class TILPrinter :
@@ -1016,4 +1015,3 @@ void printSCFG(CFGWalker &Walker) {
 
 } // namespace threadSafety
 } // namespace clang
-*/

``




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


[clang] [Clang][TableGen] Add Features to TargetBuiltin (PR #80279)

2024-02-01 Thread Wang Pengcheng via cfe-commits

https://github.com/wangpc-pp created 
https://github.com/llvm/llvm-project/pull/80279

RISCV target will use this parameter, so we need a way to specify
it.


>From b0728e172ab9d6c139fc665b739d51af20a27bd2 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Thu, 1 Feb 2024 19:47:46 +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
---
 clang/include/clang/Basic/BuiltinsBase.td | 4 +++-
 clang/utils/TableGen/ClangBuiltinsEmitter.cpp | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsBase.td 
b/clang/include/clang/Basic/BuiltinsBase.td
index b65b41be03265..bfccff5600ddb 100644
--- a/clang/include/clang/Basic/BuiltinsBase.td
+++ b/clang/include/clang/Basic/BuiltinsBase.td
@@ -87,7 +87,9 @@ class CustomEntry {
 }
 
 class AtomicBuiltin : Builtin;
-class TargetBuiltin : Builtin;
+class TargetBuiltin : Builtin {
+  string Features = "";
+}
 
 class LibBuiltin : Builtin {
   string Header = header;
diff --git a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp 
b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
index dc10fa14c5959..48f55b8af97e4 100644
--- a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
+++ b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
@@ -219,7 +219,7 @@ void EmitBuiltinDef(llvm::raw_ostream &OS, StringRef 
Substitution,
 break;
   }
   case BuiltinType::TargetBuiltin:
-OS << ", \"\"";
+OS << ", \"" << Builtin->getValueAsString("Features") << "\"";
 break;
   case BuiltinType::AtomicBuiltin:
   case BuiltinType::Builtin:

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


[clang] [Clang][TableGen] Add Features to TargetBuiltin (PR #80279)

2024-02-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Wang Pengcheng (wangpc-pp)


Changes

RISCV target will use this parameter, so we need a way to specify
it.


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


2 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsBase.td (+3-1) 
- (modified) clang/utils/TableGen/ClangBuiltinsEmitter.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsBase.td 
b/clang/include/clang/Basic/BuiltinsBase.td
index b65b41be03265..bfccff5600ddb 100644
--- a/clang/include/clang/Basic/BuiltinsBase.td
+++ b/clang/include/clang/Basic/BuiltinsBase.td
@@ -87,7 +87,9 @@ class CustomEntry {
 }
 
 class AtomicBuiltin : Builtin;
-class TargetBuiltin : Builtin;
+class TargetBuiltin : Builtin {
+  string Features = "";
+}
 
 class LibBuiltin : Builtin {
   string Header = header;
diff --git a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp 
b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
index dc10fa14c5959..48f55b8af97e4 100644
--- a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
+++ b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
@@ -219,7 +219,7 @@ void EmitBuiltinDef(llvm::raw_ostream &OS, StringRef 
Substitution,
 break;
   }
   case BuiltinType::TargetBuiltin:
-OS << ", \"\"";
+OS << ", \"" << Builtin->getValueAsString("Features") << "\"";
 break;
   case BuiltinType::AtomicBuiltin:
   case BuiltinType::Builtin:

``




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


[clang] [clang-tools-extra] [llvm] [RISCV][NFC] Simplify calls.ll and autogenerate checks for tail-calls.ll (PR #79248)

2024-02-01 Thread Wang Pengcheng via cfe-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/79248

>From 63ca83d205a361464ec59e9c134fafa795b17cef Mon Sep 17 00:00:00 2001
From: wangpc 
Date: Wed, 24 Jan 2024 11:22:03 +0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 llvm/test/CodeGen/RISCV/calls.ll  | 357 +-
 llvm/test/CodeGen/RISCV/tail-calls.ll | 242 +
 2 files changed, 310 insertions(+), 289 deletions(-)

diff --git a/llvm/test/CodeGen/RISCV/calls.ll b/llvm/test/CodeGen/RISCV/calls.ll
index 365f255dd8244..58b10cf53971f 100644
--- a/llvm/test/CodeGen/RISCV/calls.ll
+++ b/llvm/test/CodeGen/RISCV/calls.ll
@@ -1,29 +1,20 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
-; RUN:   | FileCheck -check-prefix=RV32I %s
+; RUN:   | FileCheck -check-prefixes=CHECK,RV32I %s
 ; RUN: llc -relocation-model=pic -mtriple=riscv32 -verify-machineinstrs < %s \
-; RUN:   | FileCheck -check-prefix=RV32I-PIC %s
+; RUN:   | FileCheck -check-prefixes=CHECK,RV32I-PIC %s
 
 declare i32 @external_function(i32)
 
 define i32 @test_call_external(i32 %a) nounwind {
-; RV32I-LABEL: test_call_external:
-; RV32I:   # %bb.0:
-; RV32I-NEXT:addi sp, sp, -16
-; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-NEXT:call external_function
-; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
-; RV32I-NEXT:addi sp, sp, 16
-; RV32I-NEXT:ret
-;
-; RV32I-PIC-LABEL: test_call_external:
-; RV32I-PIC:   # %bb.0:
-; RV32I-PIC-NEXT:addi sp, sp, -16
-; RV32I-PIC-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-PIC-NEXT:call external_function
-; RV32I-PIC-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
-; RV32I-PIC-NEXT:addi sp, sp, 16
-; RV32I-PIC-NEXT:ret
+; CHECK-LABEL: test_call_external:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:addi sp, sp, -16
+; CHECK-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-NEXT:call external_function
+; CHECK-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-NEXT:addi sp, sp, 16
+; CHECK-NEXT:ret
   %1 = call i32 @external_function(i32 %a)
   ret i32 %1
 }
@@ -31,85 +22,51 @@ define i32 @test_call_external(i32 %a) nounwind {
 declare dso_local i32 @dso_local_function(i32)
 
 define i32 @test_call_dso_local(i32 %a) nounwind {
-; RV32I-LABEL: test_call_dso_local:
-; RV32I:   # %bb.0:
-; RV32I-NEXT:addi sp, sp, -16
-; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-NEXT:call dso_local_function
-; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
-; RV32I-NEXT:addi sp, sp, 16
-; RV32I-NEXT:ret
-;
-; RV32I-PIC-LABEL: test_call_dso_local:
-; RV32I-PIC:   # %bb.0:
-; RV32I-PIC-NEXT:addi sp, sp, -16
-; RV32I-PIC-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-PIC-NEXT:call dso_local_function
-; RV32I-PIC-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
-; RV32I-PIC-NEXT:addi sp, sp, 16
-; RV32I-PIC-NEXT:ret
+; CHECK-LABEL: test_call_dso_local:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:addi sp, sp, -16
+; CHECK-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-NEXT:call dso_local_function
+; CHECK-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-NEXT:addi sp, sp, 16
+; CHECK-NEXT:ret
   %1 = call i32 @dso_local_function(i32 %a)
   ret i32 %1
 }
 
 define i32 @defined_function(i32 %a) nounwind {
-; RV32I-LABEL: defined_function:
-; RV32I:   # %bb.0:
-; RV32I-NEXT:addi a0, a0, 1
-; RV32I-NEXT:ret
-;
-; RV32I-PIC-LABEL: defined_function:
-; RV32I-PIC:   # %bb.0:
-; RV32I-PIC-NEXT:addi a0, a0, 1
-; RV32I-PIC-NEXT:ret
+; CHECK-LABEL: defined_function:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:addi a0, a0, 1
+; CHECK-NEXT:ret
   %1 = add i32 %a, 1
   ret i32 %1
 }
 
 define i32 @test_call_defined(i32 %a) nounwind {
-; RV32I-LABEL: test_call_defined:
-; RV32I:   # %bb.0:
-; RV32I-NEXT:addi sp, sp, -16
-; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-NEXT:call defined_function
-; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
-; RV32I-NEXT:addi sp, sp, 16
-; RV32I-NEXT:ret
-;
-; RV32I-PIC-LABEL: test_call_defined:
-; RV32I-PIC:   # %bb.0:
-; RV32I-PIC-NEXT:addi sp, sp, -16
-; RV32I-PIC-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-PIC-NEXT:call defined_function
-; RV32I-PIC-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
-; RV32I-PIC-NEXT:addi sp, sp, 16
-; RV32I-PIC-NEXT:ret
+; CHECK-LABEL: test_call_defined:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:addi sp, sp, -16
+; CHECK-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
+; CHECK-NEXT:call defined_function
+; CHECK-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
+; CHECK-NEXT:addi sp, sp, 16
+; CHECK-NEXT:ret
   %1 = call i32 @d

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

2024-02-01 Thread via cfe-commits

bgra8 wrote:

@tbaederr early heads-up: this patch introduces a `clang` crash.

I don't have yet a reproducer, but here's the stack:

```
 #0 0x558360594cb8 llvm::sys::RunSignalHandlers() (bin/clang+0x8794cb8)
 #1 0x558360f6 CrashRecoverySignalHandler(int) (bin/clang+0x87555f6)
 #2 0x7f119d4f11c0 __restore_rt (/usr/grte/v5/lib64/libpthread.so.0+0x151c0)
 #3 0x55835db72d29 clang::Lexer::SkipWhitespace(clang::Token&, char const*, 
bool&) (bin/clang+0x5d72d29)
 #4 0x55835db77176 clang::Lexer::LexTokenInternal(clang::Token&, bool) 
(bin/clang+0x5d77176)
 #5 0x55835c3a6563 
clang::TextDiagnostic::emitSnippetAndCaret(clang::FullSourceLoc, 
clang::DiagnosticsEngine::Level, 
llvm::SmallVectorImpl&, 
llvm::ArrayRef) (bin/clang+0x45a6563)
 #6 0x55835c391ac8 
clang::DiagnosticRenderer::emitDiagnostic(clang::FullSourceLoc, 
clang::DiagnosticsEngine::Level, llvm::StringRef, 
llvm::ArrayRef, llvm::ArrayRef, 
llvm::PointerUnion) 
(bin/clang+0x4591ac8)
 #7 0x55835c393442 
clang::DiagnosticRenderer::emitSingleMacroExpansion(clang::FullSourceLoc, 
clang::DiagnosticsEngine::Level, llvm::ArrayRef) 
(bin/clang+0x4593442)
 #8 0x55835c392279 
clang::DiagnosticRenderer::emitMacroExpansions(clang::FullSourceLoc, 
clang::DiagnosticsEngine::Level, llvm::ArrayRef, 
llvm::ArrayRef) (bin/clang+0x4592279)
 #9 0x55835c391b13 
clang::DiagnosticRenderer::emitDiagnostic(clang::FullSourceLoc, 
clang::DiagnosticsEngine::Level, llvm::StringRef, 
llvm::ArrayRef, llvm::ArrayRef, 
llvm::PointerUnion) 
(bin/clang+0x4591b13)
#10 0x55835c3a2993 
clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, 
clang::Diagnostic const&) (bin/clang+0x45a2993)
#11 0x55835dc1dc50 
clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const 
(bin/clang+0x5e1dc50)
#12 0x55835dc17e98 clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) 
(bin/clang+0x5e17e98)
#13 0x55835dbd523a (anonymous 
namespace)::PragmaMessageHandler::HandlePragma(clang::Preprocessor&, 
clang::PragmaIntroducer, clang::Token&) (bin/clang+0x5dd523a)
#14 0x55835dbcf953 
clang::Preprocessor::HandlePragmaDirective(clang::PragmaIntroducer) 
(bin/clang+0x5dcf953)
#15 0x55835dbd00e5 clang::Preprocessor::Handle_Pragma(clang::Token&) 
(bin/clang+0x5dd00e5)
#16 0x55835dbc19cd 
clang::Preprocessor::HandleMacroExpandedIdentifier(clang::Token&, 
clang::MacroDefinition const&) (bin/clang+0x5dc19cd)
#17 0x55835dbe38e4 clang::Preprocessor::HandleIdentifier(clang::Token&) 
(bin/clang+0x5de38e4)
#18 0x55835dbe3d8d clang::Preprocessor::Lex(clang::Token&) 
(bin/clang+0x5de3d8d)
#19 0x55835c5aa29d clang::Parser::ConsumeAnyToken(bool) 
(bin/clang+0x47aa29d)
#20 0x55835c6297f4 
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, 
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, 
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, 
clang::ImplicitTypenameContext) (bin/clang+0x48297f4)
#21 0x55835c5b090f 
clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) 
(bin/clang+0x47b090f)
#22 0x55835c5b064e 
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) 
(bin/clang+0x47b064e)
#23 0x55835c5af7ba 
clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec*) (bin/clang+0x47af7ba)
#24 0x55835c5ad877 
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, 
clang::Sema::ModuleImportState&) (bin/clang+0x47ad877)
#25 0x55835c5a885e clang::ParseAST(clang::Sema&, bool, bool) 
(bin/clang+0x47a885e)
#26 0x55835c2ec5fa clang::FrontendAction::Execute() (bin/clang+0x44ec5fa)
#27 0x55835c25d974 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
(bin/clang+0x445d974)
#28 0x55835b3b1585 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (bin/clang+0x35b1585)
#29 0x55835b3a5334 cc1_main(llvm::ArrayRef, char const*, 
void*) (bin/clang+0x35a5334)
#30 0x55835b3a2e64 ExecuteCC1Tool(llvm::SmallVectorImpl&, 
llvm::ToolContext const&) (bin/clang+0x35a2e64)
#31 0x55835c3f3c9e void llvm::function_ref::callback_fn>,
 std::__u::basic_string, 
std::__u::allocator>*, bool*) const::$_0>(long) (bin/clang+0x45f3c9e)
#32 0x5583605553cf 
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) 
(bin/clang+0x87553cf)
#33 0x55835c3f343b 
clang::driver::CC1Command::Execute(llvm::ArrayRef>,
 std::__u::basic_string, 
std::__u::allocator>*, bool*) const (bin/clang+0x45f343b)
#34 0x55835c3b2343 
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, 
clang::driver::Command const*&, bool) const (bin/clang+0x45b2343)
#35 0x55835c3b288f 
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, 
llvm::SmallVectorImpl>&, 
bool) const (bin/clang+0x45b2

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

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

tbaederr wrote:

Looks a lot like the stack trace mentioned in 
https://github.com/llvm/llvm-project/issues/80127

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


[clang] [Clang][Sema] Diagnose friend declarations with enum elaborated-type-specifier in all language modes (PR #80171)

2024-02-01 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/80171

>From 16931f5be26b689f6142ffa272e07be50b1d35d6 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Wed, 31 Jan 2024 11:09:11 -0500
Subject: [PATCH] [Clang][Sema] Diagnose friend declarations with enum
 elaborated-type-specifier in all language modes

---
 clang/docs/ReleaseNotes.rst   |   2 +
 .../clang/Basic/DiagnosticSemaKinds.td|   6 +-
 clang/include/clang/Parse/Parser.h|   8 +-
 clang/include/clang/Sema/DeclSpec.h   |  20 +--
 clang/include/clang/Sema/Sema.h   |   3 -
 clang/lib/Parse/ParseDecl.cpp |   2 +-
 clang/lib/Parse/ParseTentative.cpp|   2 +-
 clang/lib/Sema/DeclSpec.cpp   |  10 +-
 clang/lib/Sema/SemaDecl.cpp   |  16 ++
 clang/lib/Sema/SemaDeclCXX.cpp| 137 +-
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |   7 +-
 .../dcl.spec/dcl.type/dcl.type.elab/p3.cpp|   6 +-
 .../dcl.spec/dcl.type/dcl.type.elab/p4.cpp|  33 +
 clang/test/CXX/drs/dr16xx.cpp |   1 +
 .../temp.class/temp.mem.enum/p1.cpp   |   5 +-
 clang/test/FixIt/fixit-c++11.cpp  |   1 +
 clang/test/Parser/cxx-decl.cpp|   3 -
 clang/test/Parser/cxx0x-decl.cpp  |   2 +-
 clang/test/SemaCXX/cxx98-compat.cpp   |   2 +-
 clang/test/SemaCXX/enum-scoped.cpp|   5 +
 20 files changed, 124 insertions(+), 147 deletions(-)
 create mode 100644 
clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p4.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ec9e3ef07057f..c0b547869ea72 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -144,6 +144,8 @@ Improvements to Clang's diagnostics
 - Clang now applies syntax highlighting to the code snippets it
   prints.
 
+- Clang now diagnoses friend declarations with an ``enum`` 
elaborated-type-specifier outside of C++98.
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7638a7e84c3c0..ca0c4509a9eb5 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1637,10 +1637,8 @@ def err_inline_namespace_std : Error<
 def err_unexpected_friend : Error<
   "friends can only be classes or functions">;
 def ext_enum_friend : ExtWarn<
-  "befriending enumeration type %0 is a C++11 extension">, InGroup;
-def warn_cxx98_compat_enum_friend : Warning<
-  "befriending enumeration type %0 is incompatible with C++98">,
-  InGroup, DefaultIgnore;
+  "elaborated enumeration type cannot be a friend">,
+  InGroup>;
 def ext_nonclass_type_friend : ExtWarn<
   "non-class friend type %0 is a C++11 extension">, InGroup;
 def warn_cxx98_compat_nonclass_type_friend : Warning<
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 4a066acf511a1..16411e1947ffc 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2551,10 +2551,10 @@ class Parser : public CodeCompletionHandler {
   /// Starting with a scope specifier, identifier, or
   /// template-id that refers to the current class, determine whether
   /// this is a constructor declarator.
-  bool isConstructorDeclarator(
-  bool Unqualified, bool DeductionGuide = false,
-  DeclSpec::FriendSpecified IsFriend = DeclSpec::FriendSpecified::No,
-  const ParsedTemplateInfo *TemplateInfo = nullptr);
+  bool
+  isConstructorDeclarator(bool Unqualified, bool DeductionGuide = false,
+  bool IsFriend = false,
+  const ParsedTemplateInfo *TemplateInfo = nullptr);
 
   /// Specifies the context in which type-id/expression
   /// disambiguation will occur.
diff --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 77638def60063..c7266b66c014d 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -346,11 +346,6 @@ class DeclSpec {
 // FIXME: Attributes should be included here.
   };
 
-  enum FriendSpecified : bool {
-No,
-Yes,
-  };
-
 private:
   // storage-class-specifier
   /*SCS*/unsigned StorageClassSpec : 3;
@@ -380,7 +375,8 @@ class DeclSpec {
   unsigned FS_noreturn_specified : 1;
 
   // friend-specifier
-  unsigned Friend_specified : 1;
+  unsigned FriendSpecified : 1;
+  unsigned FriendSpecifiedFirst : 1;
 
   // constexpr-specifier
   unsigned ConstexprSpecifier : 2;
@@ -470,9 +466,9 @@ class DeclSpec {
 TypeSpecPipe(false), TypeSpecSat(false), ConstrainedAuto(false),
 TypeQualifiers(TQ_unspecified), FS_inline_specified(false),
 FS_forceinline_specified(false), FS_virtual_specified(false),
-FS_noreturn_specified(false), Friend_specified(false

[clang] [clang] Update documentation for `#pragma diagnostic` (PR #78095)

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

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


[clang] [clang] Update documentation for `#pragma diagnostic` (PR #78095)

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

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

LGTM aside from a nit, thank you for improving the documentation here!

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


[clang] [clang] Update documentation for `#pragma diagnostic` (PR #78095)

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


@@ -1157,23 +1158,34 @@ existed.
   #if foo
   #endif foo // warning: extra tokens at end of #endif directive
 
-  #pragma clang diagnostic push
-  #pragma clang diagnostic ignored "-Wextra-tokens"
+  #pragma GCC diagnostic push
+  #pragma GCC diagnostic ignored "-Wextra-tokens"
 
   #if foo
   #endif foo // no warning
 
-  #pragma clang diagnostic pop
+  #pragma GCC diagnostic pop
 
 The push and pop pragmas will save and restore the full diagnostic state
-of the compiler, regardless of how it was set. That means that it is
-possible to use push and pop around GCC compatible diagnostics and Clang
-will push and pop them appropriately, while GCC will ignore the pushes
-and pops as unknown pragmas. It should be noted that while Clang
+of the compiler, regardless of how it was set. It should be noted that while 
Clang
 supports the GCC pragma, Clang and GCC do not support the exact same set
 of warnings, so even when using GCC compatible #pragmas there is no
 guarantee that they will have identical behaviour on both compilers.
 
+Clang also doesn't yet support GCC behavior for ``#pragma diagnostic pop``
+that doesn't have a corresponding ``#pragma diagnostic push``. In this case
+GCC pretends that there is a ``#pragma diagnostic push`` at the very beginning
+of the source file, so "unpaired" ``#pragma diagnostic pop`` matches that
+implicit push. This makes a difference for ``#pragma GCC diagnostic ignored``
+which are not guarded by push and pop. Refer to
+`GCC documentation 
`_
+for details.
+
+Like GCC, Clang accepts ``ignored``, ``warning``, ``error``, and ``fatal``
+severity levels. They can be used to change severity of a particular diagnostic
+for a region of source file. Notable difference from GCC is that diagnostic
+not enabled via CLI arguments can't be enabled this way yet.

AaronBallman wrote:

```suggestion
for a region of source file. A notable difference from GCC is that diagnostic
not enabled via command line arguments can't be enabled this way yet.
```

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


[clang] [Clang][NFC] Remove TemplateArgumentList::OnStack (PR #79760)

2024-02-01 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/79760

>From 87b8ab6b6d7f70ae27c766f4038683f9237cc65a Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Sun, 28 Jan 2024 11:03:52 -0500
Subject: [PATCH] [Clang][NFC] Remove TemplateArgumentList::OnStack

---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/AST/DeclTemplate.h| 26 +--
 clang/include/clang/Sema/Sema.h   |  8 +--
 clang/lib/AST/DeclTemplate.cpp|  3 +-
 clang/lib/Sema/SemaConcept.cpp| 20 +++---
 clang/lib/Sema/SemaExprCXX.cpp|  4 +-
 clang/lib/Sema/SemaTemplate.cpp   | 20 +++---
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 70 ---
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 11 +--
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  | 27 +++
 10 files changed, 79 insertions(+), 112 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ec9e3ef07057f..8ff3386bc59d5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -51,6 +51,8 @@ AST Dumping Potentially Breaking Changes
 
 Clang Frontend Potentially Breaking Changes
 ---
+- Removed support for constructing on-stack ``TemplateArgumentList``s.
+  Interfaces should instead use ``ArrayRef`` to pass 
template arguments.
 
 Target OS macros extension
 ^^
diff --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 832ad2de6b08a..baf71145d99dc 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -241,9 +241,6 @@ class FixedSizeTemplateParameterListStorage
 /// A template argument list.
 class TemplateArgumentList final
 : private llvm::TrailingObjects {
-  /// The template argument list.
-  const TemplateArgument *Arguments;
-
   /// The number of template arguments in this template
   /// argument list.
   unsigned NumArguments;
@@ -258,30 +255,11 @@ class TemplateArgumentList final
   TemplateArgumentList(const TemplateArgumentList &) = delete;
   TemplateArgumentList &operator=(const TemplateArgumentList &) = delete;
 
-  /// Type used to indicate that the template argument list itself is a
-  /// stack object. It does not own its template arguments.
-  enum OnStackType { OnStack };
-
   /// Create a new template argument list that copies the given set of
   /// template arguments.
   static TemplateArgumentList *CreateCopy(ASTContext &Context,
   ArrayRef Args);
 
-  /// Construct a new, temporary template argument list on the stack.
-  ///
-  /// The template argument list does not own the template arguments
-  /// provided.
-  explicit TemplateArgumentList(OnStackType, ArrayRef Args)
-  : Arguments(Args.data()), NumArguments(Args.size()) {}
-
-  /// Produces a shallow copy of the given template argument list.
-  ///
-  /// This operation assumes that the input argument list outlives it.
-  /// This takes the list as a pointer to avoid looking like a copy
-  /// constructor, since this really isn't safe to use that way.
-  explicit TemplateArgumentList(const TemplateArgumentList *Other)
-  : Arguments(Other->data()), NumArguments(Other->size()) {}
-
   /// Retrieve the template argument at a given index.
   const TemplateArgument &get(unsigned Idx) const {
 assert(Idx < NumArguments && "Invalid template argument index");
@@ -301,7 +279,9 @@ class TemplateArgumentList final
   unsigned size() const { return NumArguments; }
 
   /// Retrieve a pointer to the template argument list.
-  const TemplateArgument *data() const { return Arguments; }
+  const TemplateArgument *data() const {
+return getTrailingObjects();
+  }
 };
 
 void *allocateDefaultArgStorageChain(const ASTContext &C);
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b780cee86c3c3..780a2f2d8ce27 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9329,12 +9329,12 @@ class Sema final {
 
   TemplateDeductionResult
   DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
-  const TemplateArgumentList &TemplateArgs,
+  ArrayRef TemplateArgs,
   sema::TemplateDeductionInfo &Info);
 
   TemplateDeductionResult
   DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial,
-  const TemplateArgumentList &TemplateArgs,
+  ArrayRef TemplateArgs,
   sema::TemplateDeductionInfo &Info);
 
   TemplateDeductionResult SubstituteExplicitTemplateArguments(
@@ -9507,7 +9507,7 @@ class Sema final {
 
   MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
   const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
-  const TemplateArgumentList *In

[clang] [llvm] [clang-tools-extra] [RISCV][NFC] Simplify calls.ll and autogenerate checks for tail-calls.ll (PR #79248)

2024-02-01 Thread Wang Pengcheng via cfe-commits

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


[clang] [Clang][NFC] Remove TemplateArgumentList::OnStack (PR #79760)

2024-02-01 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

@erichkeane I added the following release note:
> Removed support for constructing on-stack `TemplateArgumentList`s. Interfaces 
> should instead use `ArrayRef` to pass template arguments.

I'm not entirely sure how to benchmark these changes. Perhaps I could determine 
the difference in AST memory usage compiling something like Boost or LLVM?

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


[clang] [llvm] [CloneFunction][DebugInfo] Avoid cloning DILocalVariables of inlined functions (PR #75385)

2024-02-01 Thread Vladislav Dzhidzhoev via cfe-commits

dzhidzhoev wrote:

> ...ah, actually is it malformed because there's a DICompositeType in the 
> retainedNodes list for a DISubprogram? I remember that the verifier 
> considered that illegal before your patch landed, but not after.

Having this commit applied, DICompositeTypes with the scope of DISubprogram 
must appear in the corresponding subprogram's retainedNodes list, so that's not 
the issue.
However, in the reproducer, DICompositeType node no !54 ("type4") has a scope 
value !55 ("plimsoles") but appears in the retainedNodes list of subprogram !49 
("crumpets").
!54 must have either scope of !49 or belong to the subprogram !55's 
retainedNodes list.
This discrepancy was likely to happen in CloneFunctionInto if LTO was used. 
However, I'm not sure about that.

https://github.com/llvm/llvm-project/pull/75385
___
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 #80288)

2024-02-01 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky created 
https://github.com/llvm/llvm-project/pull/80288

Try to fix [issue](https://github.com/llvm/llvm-project/issues/68490 ) and some 
extented problem. Root cause of current issue is that error handling in 
instantiation of function parameter with default initialization on sizeof or 
align expression. When instance an out-of-line template member function, depth 
of `TemplateTypeParmDecl` in default initialization doesn't change while depth 
of other template parameter does and this will lead to some template parameter 
uninstanced. Also, sometime it will leader to wrong instantiation when it uses 
the template parameter of the template class.
Fix it by add template args of context. This will make 
MultiLevelTemplateArgumentList::getNumLevels matching the depth of template 
parameter. Testcase with some static_assert demonstrates the template parameter 
has been instanced correctly.
But, the default initialization of lambda expression compiles failed when only 
checking if the member function is out-of-line. We should check the 
`PrimaryFunctionTemplateDecl` of the funtion if it's out-of-line.

>From b9360998d234cccda4f632067cc9aa62f5593021 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Thu, 1 Feb 2024 20:54:46 +0800
Subject: [PATCH] [Clang][Sema] fix outline member function template with
 default align crash

---
 clang/docs/ReleaseNotes.rst   |   4 +
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  14 +-
 clang/test/SemaTemplate/default-parm-init.cpp | 190 ++
 3 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/SemaTemplate/default-parm-init.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ec9e3ef07057f..263d64d610950 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -182,6 +182,10 @@ Bug Fixes to C++ Support
   and (`#79745 `_)
 - Fix incorrect code generation caused by the object argument of ``static 
operator()`` and ``static operator[]`` calls not being evaluated.
   Fixes (`#67976 `_)
+- Fix a crash when specializing an out-of-line member function with a default
+  parameter where we did an incorrect specialization of the initialization of
+  the default parameter.
+  Fixes (`#68490 `_)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index e12186d7d82f8..c107702aeba1c 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3049,6 +3049,7 @@ bool Sema::SubstDefaultArgument(
 //   default argument expression appears.
 ContextRAII SavedContext(*this, FD);
 std::unique_ptr LIS;
+MultiLevelTemplateArgumentList NewTemplateArgs = TemplateArgs;
 
 if (ForCallExpr) {
   // When instantiating a default argument due to use in a call expression,
@@ -3061,11 +3062,20 @@ bool Sema::SubstDefaultArgument(
   /*ForDefinition*/ false);
   if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
 return true;
+  const FunctionTemplateDecl *PrimaryTemplate = FD->getPrimaryTemplate();
+  if (PrimaryTemplate && PrimaryTemplate->isOutOfLine()) {
+TemplateArgumentList *CurrentTemplateArgumentList =
+TemplateArgumentList::CreateCopy(getASTContext(),
+ TemplateArgs.getInnermost());
+NewTemplateArgs = getTemplateInstantiationArgs(
+FD, FD->getDeclContext(), /*Final=*/false,
+CurrentTemplateArgumentList, /*RelativeToPrimary=*/true);
+  }
 }
 
 runWithSufficientStackSpace(Loc, [&] {
-  Result = SubstInitializer(PatternExpr, TemplateArgs,
-/*DirectInit*/false);
+  Result = SubstInitializer(PatternExpr, NewTemplateArgs,
+/*DirectInit*/ false);
 });
   }
   if (Result.isInvalid())
diff --git a/clang/test/SemaTemplate/default-parm-init.cpp 
b/clang/test/SemaTemplate/default-parm-init.cpp
new file mode 100644
index 0..6ad69c39d93dc
--- /dev/null
+++ b/clang/test/SemaTemplate/default-parm-init.cpp
@@ -0,0 +1,190 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+namespace std {
+
+template class function;
+
+template class invoker_base {
+public: 
+  virtual ~invoker_base() { } 
+  virtual R invoke(Args...) = 0; 
+  virtual invoker_base* clone() = 0;
+};
+
+template 
+class functor_invoker : public invoker_base {
+public: 
+  explicit functor_invoker(const F& f) : f(f) { } 
+  R invoke(Args... args) { return f(args...); } 
+  functor_invoker* clone() { return new functor_invoker(f); }
+
+private:
+  F f;
+};
+
+template

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

2024-02-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Qizhi Hu (jcsxky)


Changes

Try to fix [issue](https://github.com/llvm/llvm-project/issues/68490 ) and some 
extented problem. Root cause of current issue is that error handling in 
instantiation of function parameter with default initialization on sizeof or 
align expression. When instance an out-of-line template member function, depth 
of `TemplateTypeParmDecl` in default initialization doesn't change while depth 
of other template parameter does and this will lead to some template parameter 
uninstanced. Also, sometime it will leader to wrong instantiation when it uses 
the template parameter of the template class.
Fix it by add template args of context. This will make 
MultiLevelTemplateArgumentList::getNumLevels matching the depth of template 
parameter. Testcase with some static_assert demonstrates the template parameter 
has been instanced correctly.
But, the default initialization of lambda expression compiles failed when only 
checking if the member function is out-of-line. We should check the 
`PrimaryFunctionTemplateDecl` of the funtion if it's out-of-line.

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+4) 
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+12-2) 
- (added) clang/test/SemaTemplate/default-parm-init.cpp (+190) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ec9e3ef07057f..263d64d610950 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -182,6 +182,10 @@ Bug Fixes to C++ Support
   and (`#79745 `_)
 - Fix incorrect code generation caused by the object argument of ``static 
operator()`` and ``static operator[]`` calls not being evaluated.
   Fixes (`#67976 `_)
+- Fix a crash when specializing an out-of-line member function with a default
+  parameter where we did an incorrect specialization of the initialization of
+  the default parameter.
+  Fixes (`#68490 `_)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index e12186d7d82f8..c107702aeba1c 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3049,6 +3049,7 @@ bool Sema::SubstDefaultArgument(
 //   default argument expression appears.
 ContextRAII SavedContext(*this, FD);
 std::unique_ptr LIS;
+MultiLevelTemplateArgumentList NewTemplateArgs = TemplateArgs;
 
 if (ForCallExpr) {
   // When instantiating a default argument due to use in a call expression,
@@ -3061,11 +3062,20 @@ bool Sema::SubstDefaultArgument(
   /*ForDefinition*/ false);
   if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
 return true;
+  const FunctionTemplateDecl *PrimaryTemplate = FD->getPrimaryTemplate();
+  if (PrimaryTemplate && PrimaryTemplate->isOutOfLine()) {
+TemplateArgumentList *CurrentTemplateArgumentList =
+TemplateArgumentList::CreateCopy(getASTContext(),
+ TemplateArgs.getInnermost());
+NewTemplateArgs = getTemplateInstantiationArgs(
+FD, FD->getDeclContext(), /*Final=*/false,
+CurrentTemplateArgumentList, /*RelativeToPrimary=*/true);
+  }
 }
 
 runWithSufficientStackSpace(Loc, [&] {
-  Result = SubstInitializer(PatternExpr, TemplateArgs,
-/*DirectInit*/false);
+  Result = SubstInitializer(PatternExpr, NewTemplateArgs,
+/*DirectInit*/ false);
 });
   }
   if (Result.isInvalid())
diff --git a/clang/test/SemaTemplate/default-parm-init.cpp 
b/clang/test/SemaTemplate/default-parm-init.cpp
new file mode 100644
index 0..6ad69c39d93dc
--- /dev/null
+++ b/clang/test/SemaTemplate/default-parm-init.cpp
@@ -0,0 +1,190 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+namespace std {
+
+template class function;
+
+template class invoker_base {
+public: 
+  virtual ~invoker_base() { } 
+  virtual R invoke(Args...) = 0; 
+  virtual invoker_base* clone() = 0;
+};
+
+template 
+class functor_invoker : public invoker_base {
+public: 
+  explicit functor_invoker(const F& f) : f(f) { } 
+  R invoke(Args... args) { return f(args...); } 
+  functor_invoker* clone() { return new functor_invoker(f); }
+
+private:
+  F f;
+};
+
+template
+class function {
+public: 
+  typedef R result_type;
+  function() : invoker (0) { }
+  function(const function& other) : invoker(0) { 
+if (other.invoker)
+  invoker = other.invoker->clone();
+  }
+
+  template function(const F& f) :

[clang] [AMDGPU] Allow w64 ballot to be used on w32 targets (PR #80183)

2024-02-01 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> After this change is there any value in having two different builtins? You 
> could just have one that always return 64 bits.

I personally think it would be better to just have the one, but I figured that 
decision was made earlier and it would break backwards compatibility.

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


[clang] Fix INF/NAN warning. (PR #80290)

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

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/80290

None

>From 529879c78ae4c1bf4d04110b543f37c1d1af20f7 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Thu, 1 Feb 2024 05:26:00 -0800
Subject: [PATCH] Fix INF/NAN warning.

---
 .../clang/Basic/DiagnosticCommonKinds.td  |   4 +-
 clang/include/clang/Lex/Preprocessor.h|  21 ++-
 clang/lib/Lex/PPDirectives.cpp|   2 +-
 clang/lib/Lex/Preprocessor.cpp|   6 +-
 clang/lib/Sema/SemaChecking.cpp   |  10 +-
 .../Sema/warn-infinity-nan-disabled-lnx.cpp   | 172 +++---
 .../Sema/warn-infinity-nan-disabled-win.cpp   | 171 ++---
 7 files changed, 241 insertions(+), 145 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index b1bada65cb6b2..ccae70a0fdbac 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -72,7 +72,9 @@ def warn_pragma_debug_unexpected_argument : Warning<
 
 def warn_fp_nan_inf_when_disabled : Warning<
   "use of %select{infinity|NaN}0%select{| via a macro}1 is undefined behavior "
-  "due to the currently enabled floating-point options">,
+  "due to the currently enabled floating-point options%select{|; mix of safe "
+  "and unsafe math options are used. Check the order of you command line "
+  "arguments}2">,
   InGroup>;
 }
 
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 9d0d53129a12d..dac5a46f73749 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2838,7 +2838,8 @@ class Preprocessor {
 return AnnotationInfos.find(II)->second;
   }
 
-  void emitMacroExpansionWarnings(const Token &Identifier) const {
+  void emitMacroExpansionWarnings(const Token &Identifier,
+  bool IsIfnDef = false) const {
 IdentifierInfo *Info = Identifier.getIdentifierInfo();
 if (Info->isDeprecatedMacro())
   emitMacroDeprecationWarning(Identifier);
@@ -2847,12 +2848,15 @@ class Preprocessor {
 !SourceMgr.isInMainFile(Identifier.getLocation()))
   emitRestrictExpansionWarning(Identifier);
 
-if (Info->getName() == "INFINITY")
-  if (getLangOpts().NoHonorInfs)
-emitRestrictInfNaNWarning(Identifier, 0);
-if (Info->getName() == "NAN")
-  if (getLangOpts().NoHonorNaNs)
-emitRestrictInfNaNWarning(Identifier, 1);
+if (!IsIfnDef) {
+  bool UnsafeMath = getLangOpts().UnsafeFPMath;
+  if (Info->getName() == "INFINITY")
+if (getLangOpts().NoHonorInfs)
+  emitRestrictInfNaNWarning(Identifier, 0, UnsafeMath);
+  if (Info->getName() == "NAN")
+if (getLangOpts().NoHonorNaNs)
+  emitRestrictInfNaNWarning(Identifier, 1, UnsafeMath);
+}
   }
 
   static void processPathForFileMacro(SmallVectorImpl &Path,
@@ -2869,7 +2873,8 @@ class Preprocessor {
   void emitRestrictExpansionWarning(const Token &Identifier) const;
   void emitFinalMacroWarning(const Token &Identifier, bool IsUndef) const;
   void emitRestrictInfNaNWarning(const Token &Identifier,
- unsigned DiagSelection) const;
+ unsigned DiagSelection,
+ bool UnsafeMath) const;
 
   /// This boolean state keeps track if the current scanned token (by this PP)
   /// is in an "-Wunsafe-buffer-usage" opt-out region. Assuming PP scans a
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 9f82a6d073e3b..17a59677e2de4 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3288,7 +3288,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result,
 return;
   }
 
-  emitMacroExpansionWarnings(MacroNameTok);
+  emitMacroExpansionWarnings(MacroNameTok, true);
 
   // Check to see if this is the last token on the #if[n]def line.
   CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef");
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 031ed1e16bb8f..635d052070146 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -1466,8 +1466,10 @@ void Preprocessor::emitRestrictExpansionWarning(const 
Token &Identifier) const {
 }
 
 void Preprocessor::emitRestrictInfNaNWarning(const Token &Identifier,
- unsigned DiagSelection) const {
-  Diag(Identifier, diag::warn_fp_nan_inf_when_disabled) << DiagSelection << 1;
+ unsigned DiagSelection,
+ bool UnsafeMath) const {
+  Diag(Identifier, diag::warn_fp_nan_inf_when_disabled)
+  << DiagSelection << 1 << UnsafeMath;
 }
 
 void Preprocessor::emitFinalMacroWarning(const Token &Identifier,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cp

[clang] Fix INF/NAN warning. (PR #80290)

2024-02-01 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 e538486e90539096e7851d0deba4ea9ed94fced2 
529879c78ae4c1bf4d04110b543f37c1d1af20f7 -- 
clang/include/clang/Lex/Preprocessor.h clang/lib/Lex/PPDirectives.cpp 
clang/lib/Lex/Preprocessor.cpp clang/lib/Sema/SemaChecking.cpp 
clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp 
clang/test/Sema/warn-infinity-nan-disabled-win.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index dac5a46f73..de5597cc7f 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2873,8 +2873,7 @@ private:
   void emitRestrictExpansionWarning(const Token &Identifier) const;
   void emitFinalMacroWarning(const Token &Identifier, bool IsUndef) const;
   void emitRestrictInfNaNWarning(const Token &Identifier,
- unsigned DiagSelection,
- bool UnsafeMath) const;
+ unsigned DiagSelection, bool UnsafeMath) 
const;
 
   /// This boolean state keeps track if the current scanned token (by this PP)
   /// is in an "-Wunsafe-buffer-usage" opt-out region. Assuming PP scans a

``




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


[clang] [coverage] fix crash in code coverage and `if constexpr` with `ExprWithCleanups` (PR #80292)

2024-02-01 Thread Hana Dusíková via cfe-commits

https://github.com/hanickadot created 
https://github.com/llvm/llvm-project/pull/80292

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

From 84c3e120e04394d024851f30044de591cf1599e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hana=20Dusi=CC=81kova=CC=81?= 
Date: Thu, 1 Feb 2024 14:34:16 +0100
Subject: [PATCH] [coverage] fix crash in code coverage and `if constexpr` with
 `ExprWithCleanups`

---
 clang/lib/CodeGen/CoverageMappingGen.cpp | 16 +++--
 clang/test/CoverageMapping/if.cpp| 29 
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 8b5e6c4ad8272..6640fe6f41fd1 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1808,12 +1808,24 @@ struct CounterCoverageMappingBuilder
 }
   }
 
+private:
+  static bool evaluateConstantCondition(const Expr *Condition) {
+if (const auto *Expr = dyn_cast(Condition))
+  return Expr->getResultAsAPSInt().getExtValue();
+
+if (const auto *Expr = dyn_cast(Condition))
+  return evaluateConstantCondition(Expr->getSubExpr()); // recursion
+
+assert(false && "Unexpected node in 'if constexpr' condition");
+return false;
+  }
+
+public:
   void coverIfConstexpr(const IfStmt *S) {
 assert(S->isConstexpr());
 
 // evaluate constant condition...
-const auto *E = cast(S->getCond());
-const bool isTrue = E->getResultAsAPSInt().getExtValue();
+const bool isTrue = evaluateConstantCondition(S->getCond());
 
 extendRegion(S);
 
diff --git a/clang/test/CoverageMapping/if.cpp 
b/clang/test/CoverageMapping/if.cpp
index 3045ffe43948c..4de1467aa7ee3 100644
--- a/clang/test/CoverageMapping/if.cpp
+++ b/clang/test/CoverageMapping/if.cpp
@@ -234,6 +234,35 @@ constexpr int check_macro_consteval_if_skipped(int i) {   
// CHECK-NEXT: [[@LINE
   return i;
 }
 
+struct false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+template  struct dependable_false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+// GH-80285
+void should_not_crash() {
+if constexpr (false_value{}) { };
+}
+
+template  void should_not_crash_dependable() {
+if constexpr (dependable_false_value{}) { };
+}
+
+void should_not_crash_with_template_instance() {
+  should_not_crash_dependable();
+}
+
+void should_not_crash_with_requires_expr() {
+   if constexpr (requires {42;}) { };
+}
+
 int instantiate_consteval(int i) {
   i *= check_consteval_with_else_discarded_then(i);
   i *= check_notconsteval_with_else_discarded_else(i);

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


[clang] [coverage] fix crash in code coverage and `if constexpr` with `ExprWithCleanups` (PR #80292)

2024-02-01 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Hana Dusíková (hanickadot)


Changes

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

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+14-2) 
- (modified) clang/test/CoverageMapping/if.cpp (+29) 


``diff
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 8b5e6c4ad8272..6640fe6f41fd1 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1808,12 +1808,24 @@ struct CounterCoverageMappingBuilder
 }
   }
 
+private:
+  static bool evaluateConstantCondition(const Expr *Condition) {
+if (const auto *Expr = dyn_cast(Condition))
+  return Expr->getResultAsAPSInt().getExtValue();
+
+if (const auto *Expr = dyn_cast(Condition))
+  return evaluateConstantCondition(Expr->getSubExpr()); // recursion
+
+assert(false && "Unexpected node in 'if constexpr' condition");
+return false;
+  }
+
+public:
   void coverIfConstexpr(const IfStmt *S) {
 assert(S->isConstexpr());
 
 // evaluate constant condition...
-const auto *E = cast(S->getCond());
-const bool isTrue = E->getResultAsAPSInt().getExtValue();
+const bool isTrue = evaluateConstantCondition(S->getCond());
 
 extendRegion(S);
 
diff --git a/clang/test/CoverageMapping/if.cpp 
b/clang/test/CoverageMapping/if.cpp
index 3045ffe43948c..4de1467aa7ee3 100644
--- a/clang/test/CoverageMapping/if.cpp
+++ b/clang/test/CoverageMapping/if.cpp
@@ -234,6 +234,35 @@ constexpr int check_macro_consteval_if_skipped(int i) {   
// CHECK-NEXT: [[@LINE
   return i;
 }
 
+struct false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+template  struct dependable_false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+// GH-80285
+void should_not_crash() {
+if constexpr (false_value{}) { };
+}
+
+template  void should_not_crash_dependable() {
+if constexpr (dependable_false_value{}) { };
+}
+
+void should_not_crash_with_template_instance() {
+  should_not_crash_dependable();
+}
+
+void should_not_crash_with_requires_expr() {
+   if constexpr (requires {42;}) { };
+}
+
 int instantiate_consteval(int i) {
   i *= check_consteval_with_else_discarded_then(i);
   i *= check_notconsteval_with_else_discarded_else(i);

``




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


[clang] d313614 - [AArch64] Replace LLVM IR function attributes for PSTATE.ZA. (#79166)

2024-02-01 Thread via cfe-commits

Author: Sander de Smalen
Date: 2024-02-01T13:37:37Z
New Revision: d313614b60ff1194f48e5f0b1bb8d63d2b7eb52d

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

LOG: [AArch64] Replace LLVM IR function attributes for PSTATE.ZA. (#79166)

Since https://github.com/ARM-software/acle/pull/276 the ACLE
defines attributes to better describe the use of a given SME state.

Previously the attributes merely described the possibility of it being
'shared' or 'preserved', whereas the new attributes have more semantics
and also describe how the data flows through the program.

For ZT0 we already had to add new LLVM IR attributes:
* aarch64_new_zt0
* aarch64_in_zt0
* aarch64_out_zt0
* aarch64_inout_zt0
* aarch64_preserves_zt0

We have now done the same for ZA, such that we add:
* aarch64_new_za   (previously `aarch64_pstate_za_new`)
* aarch64_in_za (more specific variation of `aarch64_pstate_za_shared`)
* aarch64_out_za (more specific variation of `aarch64_pstate_za_shared`)
* aarch64_inout_za (more specific variation of
`aarch64_pstate_za_shared`)
* aarch64_preserves_za (previously `aarch64_pstate_za_shared,
aarch64_pstate_za_preserved`)

This explicitly removes 'pstate' from the name, because with SME2 and
the new ACLE attributes there is a difference between "sharing ZA"
(sharing
the ZA matrix register with the caller) and "sharing PSTATE.ZA" (sharing
either the ZA or ZT0 register, both part of PSTATE.ZA with the caller).

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp
clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_zero.c
clang/test/Modules/aarch64-sme-keywords.cppm
llvm/docs/AArch64SME.rst
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
llvm/lib/Target/AArch64/SMEABIPass.cpp
llvm/lib/Target/AArch64/Utils/AArch64SMEAttributes.cpp
llvm/lib/Target/AArch64/Utils/AArch64SMEAttributes.h
llvm/test/CodeGen/AArch64/sme-disable-gisel-fisel.ll
llvm/test/CodeGen/AArch64/sme-lazy-save-call-remarks.ll
llvm/test/CodeGen/AArch64/sme-lazy-save-call.ll
llvm/test/CodeGen/AArch64/sme-new-za-function.ll
llvm/test/CodeGen/AArch64/sme-shared-za-interface.ll
llvm/test/CodeGen/AArch64/sme-zt0-state.ll
llvm/test/Transforms/Inline/AArch64/sme-pstateza-attrs.ll
llvm/test/Verifier/sme-attributes.ll
llvm/unittests/Target/AArch64/SMEAttributesTest.cpp
mlir/include/mlir/Dialect/ArmSME/Transforms/Passes.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/lib/Target/LLVMIR/ModuleImport.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Dialect/ArmSME/enable-arm-za.mlir
mlir/test/Target/LLVMIR/Import/function-attributes.ll
mlir/test/Target/LLVMIR/llvmir.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index f3ab5ad7b08ec..196be813a4896 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10676,10 +10676,8 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 llvm::FunctionType::get(StructType::get(CGM.Int64Ty, CGM.Int64Ty), {},
 false),
 "__arm_sme_state"));
-auto Attrs =
-AttributeList()
-.addFnAttribute(getLLVMContext(), "aarch64_pstate_sm_compatible")
-.addFnAttribute(getLLVMContext(), "aarch64_pstate_za_preserved");
+auto Attrs = AttributeList().addFnAttribute(getLLVMContext(),
+
"aarch64_pstate_sm_compatible");
 CI->setAttributes(Attrs);
 CI->setCallingConv(
 llvm::CallingConv::

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 28c211aa631e4..657666c9bda4e 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1774,14 +1774,14 @@ static void 
AddAttributesFromFunctionProtoType(ASTContext &Ctx,
 FuncAttrs.addAttribute("aarch64_pstate_sm_compatible");
 
   // ZA
-  if (FunctionType::getArmZAState(SMEBits) == FunctionType::ARM_Out ||
-  FunctionType::getArmZAState(SMEBits) == FunctionType::ARM_InOut)
-FuncAttrs.addAttribute("aarch64_pstate_za_shared");
-  if (FunctionType::getArmZAState(SMEBits) == FunctionType::ARM_Preserves ||
-  FunctionType::getArmZAState(SMEBits) == FunctionType::ARM_In) {
-FuncAttrs.addAttribute("aarch64_pstate_za_shared");
-FuncAttrs.addAttribute("aarch64_pstate_za_preserved");
-  }
+  if (FunctionType::getArmZAState(SMEBits) == FunctionType::ARM_Preserves)
+FuncAttrs.addAttribute("aarch64_preserves_za");
+  if (FunctionType::getArmZAState(SMEBits) == FunctionType::ARM_In)
+FuncA

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

2024-02-01 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm closed 
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] [coverage] fix crash in code coverage and `if constexpr` with `ExprWithCleanups` (PR #80292)

2024-02-01 Thread via cfe-commits


@@ -1808,12 +1808,24 @@ struct CounterCoverageMappingBuilder
 }
   }
 
+private:
+  static bool evaluateConstantCondition(const Expr *Condition) {
+if (const auto *Expr = dyn_cast(Condition))
+  return Expr->getResultAsAPSInt().getExtValue();
+
+if (const auto *Expr = dyn_cast(Condition))
+  return evaluateConstantCondition(Expr->getSubExpr()); // recursion
+
+assert(false && "Unexpected node in 'if constexpr' condition");
+return false;
+  }
+
+public:

cor3ntin wrote:

@AaronBallman This is basically an `IgnoreImpCast` except we want to stop at 
the first ConstantExpr (which is a FullExpr) - do you think this is worth 
adding a way to do that In `Expr`? 

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


[clang] [Clang][AArch64] Add missing SME macros (PR #80293)

2024-02-01 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm created 
https://github.com/llvm/llvm-project/pull/80293

__ARM_STATE_ZA and __ARM_STATE_ZT0 are set when the compiler can parse 
the "za" and "zt0" strings in the SME attributes.

__ARM_FEATURE_SME and __ARM_FEATURE_SME2 are set when the compiler can 
generate code for attributes with "za" and "zt0" state, respectively.

__ARM_FEATURE_LOCALLY_STREAMING is set when the compiler supports the
__arm_locally_streaming attribute.


>From 9333ffada8819d748b9986352d7724c8f1038f2b Mon Sep 17 00:00:00 2001
From: Sander de Smalen 
Date: Thu, 1 Feb 2024 09:24:15 +
Subject: [PATCH] [Clang][AArch64] Add missing SME macros

__ARM_STATE_ZA and __ARM_STATE_ZT0 are set when the compiler can parse
the "za" and "zt0" strings in the SME attributes.

__ARM_FEATURE_SME and __ARM_FEATURE_SME2 are set when the compiler
can generate code for attributes with "za" and "zt0" state, respectively.

__ARM_FEATURE_LOCALLY_STREAMING is set when the compiler supports
the __arm_locally_streaming attribute.
---
 clang/lib/Basic/Targets/AArch64.cpp   | 23 +++
 clang/lib/Basic/Targets/AArch64.h |  1 +
 .../Preprocessor/aarch64-target-features.c| 13 +++
 clang/test/Preprocessor/init-aarch64.c|  2 ++
 4 files changed, 39 insertions(+)

diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index c89e16677e974..dd47f65f4be21 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -387,6 +387,11 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   Builder.defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4");
 
+  // These macros are set when Clang can parse declarations with these
+  // attributes.
+  Builder.defineMacro("__ARM_STATE_ZA", "1");
+  Builder.defineMacro("__ARM_STATE_ZT0", "1");
+
   // 0xe implies support for half, single and double precision operations.
   if (FPU & FPUMode)
 Builder.defineMacro("__ARM_FP", "0xE");
@@ -431,6 +436,17 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasSVE2 && HasSVE2SM4)
 Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1");
 
+  if (HasSME) {
+Builder.defineMacro("__ARM_FEATURE_SME");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
+  if (HasSME2) {
+Builder.defineMacro("__ARM_FEATURE_SME");
+Builder.defineMacro("__ARM_FEATURE_SME2");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
   if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -686,6 +702,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
   .Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
   .Case("sme", HasSME)
+  .Case("sme2", HasSME2)
   .Case("sme-f64f64", HasSMEF64F64)
   .Case("sme-i16i64", HasSMEI16I64)
   .Case("sme-fa64", HasSMEFA64)
@@ -806,6 +823,12 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasBFloat16 = true;
   HasFullFP16 = true;
 }
+if (Feature == "+sme2") {
+  HasSME = true;
+  HasSME2 = true;
+  HasBFloat16 = true;
+  HasFullFP16 = true;
+}
 if (Feature == "+sme-f64f64") {
   HasSME = true;
   HasSMEF64F64 = true;
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 9f5e88a6ddd99..b5802a67f3584 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -68,6 +68,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasCCDP = false;
   bool HasFRInt3264 = false;
   bool HasSME = false;
+  bool HasSME2 = false;
   bool HasSMEF64F64 = false;
   bool HasSMEI16I64 = false;
   bool HasSB = false;
diff --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 15879da04fcf0..9914775097e57 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -60,6 +60,10 @@
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 512
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 1024
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 2048
+// CHECK: __ARM_STATE_ZA 1
+// CHECK: __ARM_STATE_ZT0 1
+// CHECK-NOT: __ARM_FEATURE_SME
+// CHECK-NOT: __ARM_FEATURE_SME2
 
 // RUN: %clang -target aarch64-none-elf -march=armv8-r -x c -E -dM %s -o - | 
FileCheck %s -check-prefix CHECK-R-PROFILE
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-r -x c -E -dM %s -o - 
| FileCheck %s -check-prefix CHECK-R-PROFILE
@@ -634,3 +638,12 @@
 
 // RUN: %clang --target=aarch64 -march=armv8.2-a+rcpc3 -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-RCPC3 %s
 // CHECK-RCPC3: __ARM_FEATURE_RCPC 3
+
+// RUN: %clang --target=aarch64 -march=armv9-a+sme -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-SME %s
+// CHECK-SME: __ARM_FEATURE_LOCALLY_STREAMING 1
+// CHECK-SME: __ARM_FEATURE_SME 1
+//
+// RUN: %clang --targe

[clang] [Clang][AArch64] Add missing SME macros (PR #80293)

2024-02-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Sander de Smalen (sdesmalen-arm)


Changes

__ARM_STATE_ZA and __ARM_STATE_ZT0 are set when the compiler can parse 
the "za" and "zt0" strings in the SME attributes.

__ARM_FEATURE_SME and __ARM_FEATURE_SME2 are set when the compiler can 
generate code for attributes with "za" and "zt0" state, respectively.

__ARM_FEATURE_LOCALLY_STREAMING is set when the compiler supports the
__arm_locally_streaming attribute.


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


4 Files Affected:

- (modified) clang/lib/Basic/Targets/AArch64.cpp (+23) 
- (modified) clang/lib/Basic/Targets/AArch64.h (+1) 
- (modified) clang/test/Preprocessor/aarch64-target-features.c (+13) 
- (modified) clang/test/Preprocessor/init-aarch64.c (+2) 


``diff
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index c89e16677e974..dd47f65f4be21 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -387,6 +387,11 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   Builder.defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4");
 
+  // These macros are set when Clang can parse declarations with these
+  // attributes.
+  Builder.defineMacro("__ARM_STATE_ZA", "1");
+  Builder.defineMacro("__ARM_STATE_ZT0", "1");
+
   // 0xe implies support for half, single and double precision operations.
   if (FPU & FPUMode)
 Builder.defineMacro("__ARM_FP", "0xE");
@@ -431,6 +436,17 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasSVE2 && HasSVE2SM4)
 Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1");
 
+  if (HasSME) {
+Builder.defineMacro("__ARM_FEATURE_SME");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
+  if (HasSME2) {
+Builder.defineMacro("__ARM_FEATURE_SME");
+Builder.defineMacro("__ARM_FEATURE_SME2");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
   if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -686,6 +702,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
   .Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
   .Case("sme", HasSME)
+  .Case("sme2", HasSME2)
   .Case("sme-f64f64", HasSMEF64F64)
   .Case("sme-i16i64", HasSMEI16I64)
   .Case("sme-fa64", HasSMEFA64)
@@ -806,6 +823,12 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasBFloat16 = true;
   HasFullFP16 = true;
 }
+if (Feature == "+sme2") {
+  HasSME = true;
+  HasSME2 = true;
+  HasBFloat16 = true;
+  HasFullFP16 = true;
+}
 if (Feature == "+sme-f64f64") {
   HasSME = true;
   HasSMEF64F64 = true;
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 9f5e88a6ddd99..b5802a67f3584 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -68,6 +68,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasCCDP = false;
   bool HasFRInt3264 = false;
   bool HasSME = false;
+  bool HasSME2 = false;
   bool HasSMEF64F64 = false;
   bool HasSMEI16I64 = false;
   bool HasSB = false;
diff --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 15879da04fcf0..9914775097e57 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -60,6 +60,10 @@
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 512
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 1024
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 2048
+// CHECK: __ARM_STATE_ZA 1
+// CHECK: __ARM_STATE_ZT0 1
+// CHECK-NOT: __ARM_FEATURE_SME
+// CHECK-NOT: __ARM_FEATURE_SME2
 
 // RUN: %clang -target aarch64-none-elf -march=armv8-r -x c -E -dM %s -o - | 
FileCheck %s -check-prefix CHECK-R-PROFILE
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-r -x c -E -dM %s -o - 
| FileCheck %s -check-prefix CHECK-R-PROFILE
@@ -634,3 +638,12 @@
 
 // RUN: %clang --target=aarch64 -march=armv8.2-a+rcpc3 -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-RCPC3 %s
 // CHECK-RCPC3: __ARM_FEATURE_RCPC 3
+
+// RUN: %clang --target=aarch64 -march=armv9-a+sme -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-SME %s
+// CHECK-SME: __ARM_FEATURE_LOCALLY_STREAMING 1
+// CHECK-SME: __ARM_FEATURE_SME 1
+//
+// RUN: %clang --target=aarch64 -march=armv9-a+sme2 -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-SME2 %s
+// CHECK-SME2: __ARM_FEATURE_LOCALLY_STREAMING 1
+// CHECK-SME2: __ARM_FEATURE_SME 1
+// CHECK-SME2: __ARM_FEATURE_SME2 1
diff --git a/clang/test/Preprocessor/init-aarch64.c 
b/clang/test/Preprocessor/init-aarch64.c
index f1f1bbbf66945..cf96870b27acb 100644
--- a/clang/test/Preprocessor/init-aarch64.c
+++ b/clang/test/Preprocessor/init-aarch64.c
@@ -32,6 +32,8 @@
 // AARCH64-NEXT: #define __ARM_PCS

[clang] [Clang][AArch64] Add missing SME macros (PR #80293)

2024-02-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Sander de Smalen (sdesmalen-arm)


Changes

__ARM_STATE_ZA and __ARM_STATE_ZT0 are set when the compiler can parse 
the "za" and "zt0" strings in the SME attributes.

__ARM_FEATURE_SME and __ARM_FEATURE_SME2 are set when the compiler can 
generate code for attributes with "za" and "zt0" state, respectively.

__ARM_FEATURE_LOCALLY_STREAMING is set when the compiler supports the
__arm_locally_streaming attribute.


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


4 Files Affected:

- (modified) clang/lib/Basic/Targets/AArch64.cpp (+23) 
- (modified) clang/lib/Basic/Targets/AArch64.h (+1) 
- (modified) clang/test/Preprocessor/aarch64-target-features.c (+13) 
- (modified) clang/test/Preprocessor/init-aarch64.c (+2) 


``diff
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index c89e16677e974..dd47f65f4be21 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -387,6 +387,11 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   Builder.defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4");
 
+  // These macros are set when Clang can parse declarations with these
+  // attributes.
+  Builder.defineMacro("__ARM_STATE_ZA", "1");
+  Builder.defineMacro("__ARM_STATE_ZT0", "1");
+
   // 0xe implies support for half, single and double precision operations.
   if (FPU & FPUMode)
 Builder.defineMacro("__ARM_FP", "0xE");
@@ -431,6 +436,17 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasSVE2 && HasSVE2SM4)
 Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1");
 
+  if (HasSME) {
+Builder.defineMacro("__ARM_FEATURE_SME");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
+  if (HasSME2) {
+Builder.defineMacro("__ARM_FEATURE_SME");
+Builder.defineMacro("__ARM_FEATURE_SME2");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
   if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -686,6 +702,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
   .Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
   .Case("sme", HasSME)
+  .Case("sme2", HasSME2)
   .Case("sme-f64f64", HasSMEF64F64)
   .Case("sme-i16i64", HasSMEI16I64)
   .Case("sme-fa64", HasSMEFA64)
@@ -806,6 +823,12 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasBFloat16 = true;
   HasFullFP16 = true;
 }
+if (Feature == "+sme2") {
+  HasSME = true;
+  HasSME2 = true;
+  HasBFloat16 = true;
+  HasFullFP16 = true;
+}
 if (Feature == "+sme-f64f64") {
   HasSME = true;
   HasSMEF64F64 = true;
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 9f5e88a6ddd99..b5802a67f3584 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -68,6 +68,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasCCDP = false;
   bool HasFRInt3264 = false;
   bool HasSME = false;
+  bool HasSME2 = false;
   bool HasSMEF64F64 = false;
   bool HasSMEI16I64 = false;
   bool HasSB = false;
diff --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 15879da04fcf0..9914775097e57 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -60,6 +60,10 @@
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 512
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 1024
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 2048
+// CHECK: __ARM_STATE_ZA 1
+// CHECK: __ARM_STATE_ZT0 1
+// CHECK-NOT: __ARM_FEATURE_SME
+// CHECK-NOT: __ARM_FEATURE_SME2
 
 // RUN: %clang -target aarch64-none-elf -march=armv8-r -x c -E -dM %s -o - | 
FileCheck %s -check-prefix CHECK-R-PROFILE
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-r -x c -E -dM %s -o - 
| FileCheck %s -check-prefix CHECK-R-PROFILE
@@ -634,3 +638,12 @@
 
 // RUN: %clang --target=aarch64 -march=armv8.2-a+rcpc3 -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-RCPC3 %s
 // CHECK-RCPC3: __ARM_FEATURE_RCPC 3
+
+// RUN: %clang --target=aarch64 -march=armv9-a+sme -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-SME %s
+// CHECK-SME: __ARM_FEATURE_LOCALLY_STREAMING 1
+// CHECK-SME: __ARM_FEATURE_SME 1
+//
+// RUN: %clang --target=aarch64 -march=armv9-a+sme2 -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-SME2 %s
+// CHECK-SME2: __ARM_FEATURE_LOCALLY_STREAMING 1
+// CHECK-SME2: __ARM_FEATURE_SME 1
+// CHECK-SME2: __ARM_FEATURE_SME2 1
diff --git a/clang/test/Preprocessor/init-aarch64.c 
b/clang/test/Preprocessor/init-aarch64.c
index f1f1bbbf66945..cf96870b27acb 100644
--- a/clang/test/Preprocessor/init-aarch64.c
+++ b/clang/test/Preprocessor/init-aarch64.c
@@ -32,6 +32,8 @@
 // AARCH64-NEXT: #define

[clang] [AMDGPU] Allow w64 ballot to be used on w32 targets (PR #80183)

2024-02-01 Thread Joseph Huber via cfe-commits


@@ -4,13 +4,10 @@
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx1010 -target-feature 
-wavefrontsize64 -verify -S -o - %s
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx1010 -verify -S -o - %s
 
+// expected-no-diagnostics
+
 typedef unsigned long ulong;
 
 void test_ballot_wave64(global ulong* out, int a, int b) {
-  *out = __builtin_amdgcn_ballot_w64(a == b);  // expected-error 
{{'__builtin_amdgcn_ballot_w64' needs target feature wavefrontsize64}}
-}
-
-__attribute__((target("wavefrontsize64")))
-void test_ballot_wave64_target_attr(global ulong* out, int a, int b) {

jhuber6 wrote:

If I kept the attribute it would result in 
```
(frontend): invalid feature combination: 'wavefrontsize32' and 
'wavefrontsize64' are mutually exclusive
```

https://github.com/llvm/llvm-project/pull/80183
___
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   >