[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-init: Add a hook... (PR #73921)
@@ -302,6 +303,20 @@ void UnnecessaryCopyInitialization::check( } } +void UnnecessaryCopyInitialization::makeDiagnostic( +DiagnosticBuilder Diagnostic, const VarDecl &Var, const Stmt &BlockStmt, PiotrZSL wrote: Then create 2 "makeDiagnostic", one for one and one for other. https://github.com/llvm/llvm-project/pull/73921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [RISCV] Always emit relocations for resolved symbols and relax (PR #73793)
andcarminati wrote: > As far as I can tell this is pointless. If you want relaxation you need > R_RISCV_RELAX and R_RISC_ALIGN relocations to be emitted. If you don't want > relaxation you don't need these. Therefore it seems like all this does is > emit a whole bunch of useless relocations for the case when you're not > enabling relaxation at compile time and thus cannot possibly enable it at > link time? Hi @jrtc27, thank you for your comment, understood your point. For relaxation, I think we need also the branch relocation/anything relative, as we are removing some lui instructions. My original idea was based on the case that relaxation is a default ON feature for RISCV, but I honestly don't know the use cases to disable it. Just to follow the discussion, I can consider the following use case: clang [...] -c -o myobject.o (just compile) clang [...] my0bject.o -o myobject.elf -mno-relax (linking) In this case, myobject.elf will be relaxed, the -mno-relax will be silently ignored. Maybe we have two different things to handle. Regards. https://github.com/llvm/llvm-project/pull/73793 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU] precommit test for ballot on Windows (PR #73920)
https://github.com/ssahasra updated https://github.com/llvm/llvm-project/pull/73920 >From 8ecb6310a4912de50628cf3db5ff8488fa919bb1 Mon Sep 17 00:00:00 2001 From: Sameer Sahasrabuddhe Date: Fri, 1 Dec 2023 14:24:30 +0530 Subject: [PATCH] [clang][AMDGPU] precommit test for ballot on Windows The Clang declaration of the wave-64 builtin uses "UL" as the return type, which is interpreted as a 32-bit unsigned integer on Windows. This emits an incorrect LLVM declaration with i32 return type instead of i64. The clang declaration needs to be fixed to use "WU" instead. --- clang/test/CodeGenHIP/ballot.cpp | 27 +++ 1 file changed, 27 insertions(+) create mode 100644 clang/test/CodeGenHIP/ballot.cpp diff --git a/clang/test/CodeGenHIP/ballot.cpp b/clang/test/CodeGenHIP/ballot.cpp new file mode 100644 index 000..6e1cbbdfc7af170 --- /dev/null +++ b/clang/test/CodeGenHIP/ballot.cpp @@ -0,0 +1,27 @@ +// REQUIRES: amdgpu-registered-target +// XFAIL: * +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -S -fcuda-is-device -o - %s | FileCheck %s --check-prefix=GFX9 + +// Unlike OpenCL, HIP depends on the C++ interpration of "unsigned long", which +// is 64 bits long on Linux and 32 bits long on Windows. The return type of the +// ballot intrinsic needs to be a 64 bit integer on both platforms. This test +// cross-compiles to Windows to confirm that the return type is indeed 64 bits +// on Windows. + +// FIXME: The Clang declaration of the wave-64 builtin uses "UL" as the return +// type, which is interpreted as a 32-bit unsigned integer on Windows. This +// emits an incorrect LLVM declaration with i32 return type instead of i64. The +// clang declaration needs to be fixed to use "WU" instead. + +// CHECK-LABEL: @_Z3fooi +// CHECK: call i64 @llvm.amdgcn.ballot.i64 + +// GFX9-LABEL: _Z3fooi: +// GFX9: v_cmp_ne_u32_e64 + +#define __device__ __attribute__((device)) + +__device__ unsigned long long foo(int p) { + return __builtin_amdgcn_ballot_w64(p); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU] fix the return type for ballot (PR #73906)
https://github.com/ssahasra updated https://github.com/llvm/llvm-project/pull/73906 >From 8ecb6310a4912de50628cf3db5ff8488fa919bb1 Mon Sep 17 00:00:00 2001 From: Sameer Sahasrabuddhe Date: Fri, 1 Dec 2023 14:24:30 +0530 Subject: [PATCH 1/2] [clang][AMDGPU] precommit test for ballot on Windows The Clang declaration of the wave-64 builtin uses "UL" as the return type, which is interpreted as a 32-bit unsigned integer on Windows. This emits an incorrect LLVM declaration with i32 return type instead of i64. The clang declaration needs to be fixed to use "WU" instead. --- clang/test/CodeGenHIP/ballot.cpp | 27 +++ 1 file changed, 27 insertions(+) create mode 100644 clang/test/CodeGenHIP/ballot.cpp diff --git a/clang/test/CodeGenHIP/ballot.cpp b/clang/test/CodeGenHIP/ballot.cpp new file mode 100644 index 000..6e1cbbdfc7af170 --- /dev/null +++ b/clang/test/CodeGenHIP/ballot.cpp @@ -0,0 +1,27 @@ +// REQUIRES: amdgpu-registered-target +// XFAIL: * +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -S -fcuda-is-device -o - %s | FileCheck %s --check-prefix=GFX9 + +// Unlike OpenCL, HIP depends on the C++ interpration of "unsigned long", which +// is 64 bits long on Linux and 32 bits long on Windows. The return type of the +// ballot intrinsic needs to be a 64 bit integer on both platforms. This test +// cross-compiles to Windows to confirm that the return type is indeed 64 bits +// on Windows. + +// FIXME: The Clang declaration of the wave-64 builtin uses "UL" as the return +// type, which is interpreted as a 32-bit unsigned integer on Windows. This +// emits an incorrect LLVM declaration with i32 return type instead of i64. The +// clang declaration needs to be fixed to use "WU" instead. + +// CHECK-LABEL: @_Z3fooi +// CHECK: call i64 @llvm.amdgcn.ballot.i64 + +// GFX9-LABEL: _Z3fooi: +// GFX9: v_cmp_ne_u32_e64 + +#define __device__ __attribute__((device)) + +__device__ unsigned long long foo(int p) { + return __builtin_amdgcn_ballot_w64(p); +} >From bfcff343a601923da554cafda26568a445fc39b0 Mon Sep 17 00:00:00 2001 From: Sameer Sahasrabuddhe Date: Thu, 30 Nov 2023 12:14:38 +0530 Subject: [PATCH 2/2] [clang][AMDGPU] fix the return type for ballot In the builtins declaration, "ULi" is a 32-bit integer on Windows. Use "WUi" instead to ensure a 64-bit integer on all platforms. --- clang/include/clang/Basic/BuiltinsAMDGPU.def | 4 ++-- clang/test/CodeGenHIP/ballot.cpp | 6 -- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index a19c8bd5f219ec6..8b59b3790d7bc66 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -150,8 +150,8 @@ BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") // Ballot builtins. //===--===// -TARGET_BUILTIN(__builtin_amdgcn_ballot_w32, "Uib", "nc", "wavefrontsize32") -TARGET_BUILTIN(__builtin_amdgcn_ballot_w64, "LUib", "nc", "wavefrontsize64") +TARGET_BUILTIN(__builtin_amdgcn_ballot_w32, "ZUib", "nc", "wavefrontsize32") +TARGET_BUILTIN(__builtin_amdgcn_ballot_w64, "WUib", "nc", "wavefrontsize64") // Deprecated intrinsics in favor of __builtin_amdgn_ballot_{w32|w64} BUILTIN(__builtin_amdgcn_uicmp, "WUiUiUiIi", "nc") diff --git a/clang/test/CodeGenHIP/ballot.cpp b/clang/test/CodeGenHIP/ballot.cpp index 6e1cbbdfc7af170..a1c23e2136c7153 100644 --- a/clang/test/CodeGenHIP/ballot.cpp +++ b/clang/test/CodeGenHIP/ballot.cpp @@ -1,5 +1,4 @@ // REQUIRES: amdgpu-registered-target -// XFAIL: * // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck %s // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -S -fcuda-is-device -o - %s | FileCheck %s --check-prefix=GFX9 @@ -9,11 +8,6 @@ // cross-compiles to Windows to confirm that the return type is indeed 64 bits // on Windows. -// FIXME: The Clang declaration of the wave-64 builtin uses "UL" as the return -// type, which is interpreted as a 32-bit unsigned integer on Windows. This -// emits an incorrect LLVM declaration with i32 return type instead of i64. The -// clang declaration needs to be fixed to use "WU" instead. - // CHECK-LABEL: @_Z3fooi // CHECK: call i64 @llvm.amdgcn.ballot.i64 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU] fix the return type for ballot (PR #73906)
@@ -150,8 +150,8 @@ BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") // Ballot builtins. //===--===// -TARGET_BUILTIN(__builtin_amdgcn_ballot_w32, "Uib", "nc", "wavefrontsize32") -TARGET_BUILTIN(__builtin_amdgcn_ballot_w64, "LUib", "nc", "wavefrontsize64") +TARGET_BUILTIN(__builtin_amdgcn_ballot_w32, "ZUib", "nc", "wavefrontsize32") +TARGET_BUILTIN(__builtin_amdgcn_ballot_w64, "WUib", "nc", "wavefrontsize64") ssahasra wrote: I checked now. The tell is whether the builtin uses "L" in its type descriptor. None of them do except ballot. https://github.com/llvm/llvm-project/pull/73906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU] fix the return type for ballot (PR #73906)
@@ -0,0 +1,15 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx900 -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx900 -x hip -S -fcuda-is-device -o - %s | FileCheck %s --check-prefix=GFX9 ssahasra wrote: You're right. The precommit test needed fixing. The updated version uses an aux-triple to specify a Windows host. Now the test exposes the problem even on a Linux build when trying cross-compile to Windows. Added another note in the test: The same problem does not arise with existing OpenCL tests because the language fully specifies that "long" is 64 bits on all platforms. https://github.com/llvm/llvm-project/pull/73906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [SME2] Add LUTI2 and LUTI4 quad Builtins and Intrinsics (PR #73317)
@@ -0,0 +1,280 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -o /dev/null %s + +#include + +// CHECK-LABEL: @test_svluti2_lane_zt_u8( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call { , , , } @llvm.aarch64.sme.luti2.lane.zt.x4.nxv16i8(i32 0, [[ZN:%.*]], i32 0) +// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , , , } [[TMP0]], 0 +// CHECK-NEXT:[[TMP2:%.*]] = tail call @llvm.vector.insert.nxv64i8.nxv16i8( poison, [[TMP1]], i64 0) +// CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , , , } [[TMP0]], 1 +// CHECK-NEXT:[[TMP4:%.*]] = tail call @llvm.vector.insert.nxv64i8.nxv16i8( [[TMP2]], [[TMP3]], i64 16) +// CHECK-NEXT:[[TMP5:%.*]] = extractvalue { , , , } [[TMP0]], 2 +// CHECK-NEXT:[[TMP6:%.*]] = tail call @llvm.vector.insert.nxv64i8.nxv16i8( [[TMP4]], [[TMP5]], i64 32) +// CHECK-NEXT:[[TMP7:%.*]] = extractvalue { , , , } [[TMP0]], 3 +// CHECK-NEXT:[[TMP8:%.*]] = tail call @llvm.vector.insert.nxv64i8.nxv16i8( [[TMP6]], [[TMP7]], i64 48) +// CHECK-NEXT:ret [[TMP8]] +// +// CPP-CHECK-LABEL: @_Z23test_svluti2_lane_zt_u8u11__SVUint8_t( +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call { , , , } @llvm.aarch64.sme.luti2.lane.zt.x4.nxv16i8(i32 0, [[ZN:%.*]], i32 0) +// CPP-CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , , , } [[TMP0]], 0 +// CPP-CHECK-NEXT:[[TMP2:%.*]] = tail call @llvm.vector.insert.nxv64i8.nxv16i8( poison, [[TMP1]], i64 0) +// CPP-CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , , , } [[TMP0]], 1 +// CPP-CHECK-NEXT:[[TMP4:%.*]] = tail call @llvm.vector.insert.nxv64i8.nxv16i8( [[TMP2]], [[TMP3]], i64 16) +// CPP-CHECK-NEXT:[[TMP5:%.*]] = extractvalue { , , , } [[TMP0]], 2 +// CPP-CHECK-NEXT:[[TMP6:%.*]] = tail call @llvm.vector.insert.nxv64i8.nxv16i8( [[TMP4]], [[TMP5]], i64 32) +// CPP-CHECK-NEXT:[[TMP7:%.*]] = extractvalue { , , , } [[TMP0]], 3 +// CPP-CHECK-NEXT:[[TMP8:%.*]] = tail call @llvm.vector.insert.nxv64i8.nxv16i8( [[TMP6]], [[TMP7]], i64 48) +// CPP-CHECK-NEXT:ret [[TMP8]] +// +svuint8x4_t test_svluti2_lane_zt_u8(svuint8_t zn) __arm_streaming __arm_shared_za __arm_preserves_za { david-arm wrote: OK that's fair enough! https://github.com/llvm/llvm-project/pull/73317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [ASAN] For Asan instrumented global, emit two symbols, one with actual size and other with instrumented size. (PR #70166)
https://github.com/skc7 updated https://github.com/llvm/llvm-project/pull/70166 >From dcb104a61666e75b4b21b7a119524c32b22262b8 Mon Sep 17 00:00:00 2001 From: skc7 Date: Wed, 25 Oct 2023 10:46:10 +0530 Subject: [PATCH] [ASAN] For Asan instrumented globals, emit two symbols, with actual size and instrumented size. --- clang/test/CodeGen/asan_globals_symbols.cpp | 15 ++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 28 ++- .../Instrumentation/AddressSanitizer.cpp | 3 ++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/asan_globals_symbols.cpp diff --git a/clang/test/CodeGen/asan_globals_symbols.cpp b/clang/test/CodeGen/asan_globals_symbols.cpp new file mode 100644 index 000..d53afb2433b1715 --- /dev/null +++ b/clang/test/CodeGen/asan_globals_symbols.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -S -x c++ -std=c++11 -triple x86_64-linux \ +// RUN: -fsanitize=address -o %t.out %s +// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-A + +// CHECK-A: myGlobal: +// CHECK-A: .size myGlobal, 4 +// CHECK-A: myGlobal__sanitized_padded_global: +// CHECK-A .size myGlobal__sanitized_padded_global, 32 + +int myGlobal; + +int main() { +myGlobal = 0; +return 0; +} diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 15ff39883680369..49821be73716a2a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -766,6 +766,19 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) { // sections and expected to be contiguous (e.g. ObjC metadata). const Align Alignment = getGVAlignment(GV, DL); + // Identify globals with "SanitizedPaddedGlobal" attribute and extract + // the actual global variable size. + uint64_t ActualSize = 0; + if (GV->hasAttribute(Attribute::SanitizedPaddedGlobal)) { +StructType *ST = dyn_cast(GV->getValueType()); +if (ST && ST->getNumElements() == 2) { + auto *ET0 = ST->getElementType(0); + if (ET0 && isa(ST->getElementType(1))) { +ActualSize = DL.getTypeAllocSize(ET0); + } +} + } + for (const HandlerInfo &HI : Handlers) { NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName, HI.TimerGroupDescription, @@ -876,6 +889,18 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) { MCSymbol *EmittedInitSym = GVSym; + if (GV->hasAttribute(Attribute::SanitizedPaddedGlobal)) { +OutStreamer->switchSection(TheSection); +emitLinkage(GV, EmittedInitSym); +OutStreamer->emitLabel(EmittedInitSym); +if (MAI->hasDotTypeDotSizeDirective()) + OutStreamer->emitELFSize(EmittedInitSym, + MCConstantExpr::create(ActualSize, OutContext)); +EmittedInitSym = OutContext.getOrCreateSymbol( +GVSym->getName() + Twine("__sanitized_padded_global")); +emitVisibility(EmittedInitSym, GV->getVisibility(), !GV->isDeclaration()); + } + OutStreamer->switchSection(TheSection); emitLinkage(GV, EmittedInitSym); @@ -883,7 +908,8 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) { OutStreamer->emitLabel(EmittedInitSym); MCSymbol *LocalAlias = getSymbolPreferLocal(*GV); - if (LocalAlias != EmittedInitSym) + if ((LocalAlias != EmittedInitSym) && + !GV->hasAttribute(Attribute::SanitizedPaddedGlobal)) OutStreamer->emitLabel(LocalAlias); emitGlobalConstant(GV->getParent()->getDataLayout(), GV->getInitializer()); diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index da157c966bfcbed..172794dd3303c06 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -2456,6 +2456,9 @@ void ModuleAddressSanitizer::instrumentGlobals(IRBuilder<> &IRB, Module &M, // zero so we can copy the metadata over as is. NewGlobal->copyMetadata(G, 0); +// Attach "SanitizedPaddedGlobal" attribute to the new global. +NewGlobal->addAttribute(Attribute::SanitizedPaddedGlobal); + Value *Indices2[2]; Indices2[0] = IRB.getInt32(0); Indices2[1] = IRB.getInt32(0); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU] precommit test for ballot on Windows (PR #73920)
@@ -0,0 +1,27 @@ +// REQUIRES: amdgpu-registered-target +// XFAIL: * +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -S -fcuda-is-device -o - %s | FileCheck %s --check-prefix=GFX9 + +// Unlike OpenCL, HIP depends on the C++ interpration of "unsigned long", which +// is 64 bits long on Linux and 32 bits long on Windows. The return type of the +// ballot intrinsic needs to be a 64 bit integer on both platforms. This test +// cross-compiles to Windows to confirm that the return type is indeed 64 bits +// on Windows. + +// FIXME: The Clang declaration of the wave-64 builtin uses "UL" as the return +// type, which is interpreted as a 32-bit unsigned integer on Windows. This +// emits an incorrect LLVM declaration with i32 return type instead of i64. The +// clang declaration needs to be fixed to use "WU" instead. + +// CHECK-LABEL: @_Z3fooi +// CHECK: call i64 @llvm.amdgcn.ballot.i64 + +// GFX9-LABEL: _Z3fooi: +// GFX9: v_cmp_ne_u32_e64 vpykhtin wrote: Is it really needed to test codegen here? Nice find, BTW. https://github.com/llvm/llvm-project/pull/73920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU] fix the return type for ballot (PR #73906)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/73906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Reapply "InstCombine: Introduce SimplifyDemandedUseFPClass"" (PR #74056)
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/74056 This reverts commit ef388334ee5a3584255b9ef5b3fefdb244fa3fd7. The referenced issue violates the spec for finite-only math only by using a return value for a constant infinity. If the interpretation is results and arguments cannot violate nofpclass, then any std::numeric_limits::infinity() result is invalid under -ffinite-math-only. Without this interpretation the utility of nofpclass is slashed. >From 9be777d5b39852cf3c0b2538fd5f712922672caa Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 1 Dec 2023 18:00:13 +0900 Subject: [PATCH] Reapply "InstCombine: Introduce SimplifyDemandedUseFPClass"" This reverts commit ef388334ee5a3584255b9ef5b3fefdb244fa3fd7. The referenced issue violates the spec for finite-only math only by using a return value for a constant infinity. --- clang/test/Headers/__clang_hip_math.hip | 56 +++-- llvm/include/llvm/Analysis/ValueTracking.h| 4 + .../InstCombine/InstCombineInternal.h | 9 + .../InstCombineSimplifyDemanded.cpp | 140 +++- .../InstCombine/InstructionCombining.cpp | 18 +- .../InstCombine/simplify-demanded-fpclass.ll | 203 +++--- 6 files changed, 286 insertions(+), 144 deletions(-) diff --git a/clang/test/Headers/__clang_hip_math.hip b/clang/test/Headers/__clang_hip_math.hip index c0f4a06acbb8e32..9e15aec94dc28ab 100644 --- a/clang/test/Headers/__clang_hip_math.hip +++ b/clang/test/Headers/__clang_hip_math.hip @@ -2557,33 +2557,65 @@ extern "C" __device__ double test_nan(const char *tag) { return nan(tag); } -// CHECK-LABEL: @test_nanf_emptystr( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret float 0x7FF8 +// DEFAULT-LABEL: @test_nanf_emptystr( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret float 0x7FF8 +// +// FINITEONLY-LABEL: @test_nanf_emptystr( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret float poison +// +// APPROX-LABEL: @test_nanf_emptystr( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret float 0x7FF8 // extern "C" __device__ float test_nanf_emptystr() { return nanf(""); } -// CHECK-LABEL: @test_nan_emptystr( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret double 0x7FF8 +// DEFAULT-LABEL: @test_nan_emptystr( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret double 0x7FF8 +// +// FINITEONLY-LABEL: @test_nan_emptystr( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret double poison +// +// APPROX-LABEL: @test_nan_emptystr( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret double 0x7FF8 // extern "C" __device__ double test_nan_emptystr() { return nan(""); } -// CHECK-LABEL: @test_nanf_fill( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret float 0x7FF8 +// DEFAULT-LABEL: @test_nanf_fill( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret float 0x7FF8 +// +// FINITEONLY-LABEL: @test_nanf_fill( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret float poison +// +// APPROX-LABEL: @test_nanf_fill( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret float 0x7FF8 // extern "C" __device__ float test_nanf_fill() { return nanf("0x456"); } -// CHECK-LABEL: @test_nan_fill( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret double 0x7FF8 +// DEFAULT-LABEL: @test_nan_fill( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret double 0x7FF8 +// +// FINITEONLY-LABEL: @test_nan_fill( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret double poison +// +// APPROX-LABEL: @test_nan_fill( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret double 0x7FF8 // extern "C" __device__ double test_nan_fill() { return nan("0x123"); diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h index 82c87edd6297cdf..f9ce679bc74268f 100644 --- a/llvm/include/llvm/Analysis/ValueTracking.h +++ b/llvm/include/llvm/Analysis/ValueTracking.h @@ -243,6 +243,10 @@ struct KnownFPClass { /// definitely set or false if the sign bit is definitely unset. std::optional SignBit; + bool operator==(KnownFPClass Other) const { +return KnownFPClasses == Other.KnownFPClasses && SignBit == Other.SignBit; + } + /// Return true if it's known this can never be one of the mask entries. bool isKnownNever(FPClassTest Mask) const { return (KnownFPClasses & Mask) == fcNone; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h index 0bbb22be71569f6..9a66fb8f456f95b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -551,6 +551,15 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final APInt &UndefElts, unsigned Depth = 0, bool AllowMultipleUsers = false) override; + /// Attempts to replace
[llvm] [clang] Reapply "InstCombine: Introduce SimplifyDemandedUseFPClass"" (PR #74056)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-llvm-transforms Author: Matt Arsenault (arsenm) Changes This reverts commit ef388334ee5a3584255b9ef5b3fefdb244fa3fd7. The referenced issue violates the spec for finite-only math only by using a return value for a constant infinity. If the interpretation is results and arguments cannot violate nofpclass, then any std::numeric_limits::infinity() result is invalid under -ffinite-math-only. Without this interpretation the utility of nofpclass is slashed. --- Patch is 53.86 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74056.diff 6 Files Affected: - (modified) clang/test/Headers/__clang_hip_math.hip (+44-12) - (modified) llvm/include/llvm/Analysis/ValueTracking.h (+4) - (modified) llvm/lib/Transforms/InstCombine/InstCombineInternal.h (+9) - (modified) llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (+139-1) - (modified) llvm/lib/Transforms/InstCombine/InstructionCombining.cpp (+16-2) - (modified) llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll (+74-129) ``diff diff --git a/clang/test/Headers/__clang_hip_math.hip b/clang/test/Headers/__clang_hip_math.hip index c0f4a06acbb8e32..9e15aec94dc28ab 100644 --- a/clang/test/Headers/__clang_hip_math.hip +++ b/clang/test/Headers/__clang_hip_math.hip @@ -2557,33 +2557,65 @@ extern "C" __device__ double test_nan(const char *tag) { return nan(tag); } -// CHECK-LABEL: @test_nanf_emptystr( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret float 0x7FF8 +// DEFAULT-LABEL: @test_nanf_emptystr( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret float 0x7FF8 +// +// FINITEONLY-LABEL: @test_nanf_emptystr( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret float poison +// +// APPROX-LABEL: @test_nanf_emptystr( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret float 0x7FF8 // extern "C" __device__ float test_nanf_emptystr() { return nanf(""); } -// CHECK-LABEL: @test_nan_emptystr( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret double 0x7FF8 +// DEFAULT-LABEL: @test_nan_emptystr( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret double 0x7FF8 +// +// FINITEONLY-LABEL: @test_nan_emptystr( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret double poison +// +// APPROX-LABEL: @test_nan_emptystr( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret double 0x7FF8 // extern "C" __device__ double test_nan_emptystr() { return nan(""); } -// CHECK-LABEL: @test_nanf_fill( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret float 0x7FF8 +// DEFAULT-LABEL: @test_nanf_fill( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret float 0x7FF8 +// +// FINITEONLY-LABEL: @test_nanf_fill( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret float poison +// +// APPROX-LABEL: @test_nanf_fill( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret float 0x7FF8 // extern "C" __device__ float test_nanf_fill() { return nanf("0x456"); } -// CHECK-LABEL: @test_nan_fill( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret double 0x7FF8 +// DEFAULT-LABEL: @test_nan_fill( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret double 0x7FF8 +// +// FINITEONLY-LABEL: @test_nan_fill( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret double poison +// +// APPROX-LABEL: @test_nan_fill( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret double 0x7FF8 // extern "C" __device__ double test_nan_fill() { return nan("0x123"); diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h index 82c87edd6297cdf..f9ce679bc74268f 100644 --- a/llvm/include/llvm/Analysis/ValueTracking.h +++ b/llvm/include/llvm/Analysis/ValueTracking.h @@ -243,6 +243,10 @@ struct KnownFPClass { /// definitely set or false if the sign bit is definitely unset. std::optional SignBit; + bool operator==(KnownFPClass Other) const { +return KnownFPClasses == Other.KnownFPClasses && SignBit == Other.SignBit; + } + /// Return true if it's known this can never be one of the mask entries. bool isKnownNever(FPClassTest Mask) const { return (KnownFPClasses & Mask) == fcNone; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h index 0bbb22be71569f6..9a66fb8f456f95b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -551,6 +551,15 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final APInt &UndefElts, unsigned Depth = 0, bool AllowMultipleUsers = false) override; + /// Attempts to replace V with a simpler value based on the demanded + /// floating-point classes + Value *SimplifyDemandedUseFPClass(Value *V, FPClassTest DemandedMask, +
[clang] [llvm] Reapply "InstCombine: Introduce SimplifyDemandedUseFPClass"" (PR #74056)
llvmbot wrote: @llvm/pr-subscribers-llvm-analysis Author: Matt Arsenault (arsenm) Changes This reverts commit ef388334ee5a3584255b9ef5b3fefdb244fa3fd7. The referenced issue violates the spec for finite-only math only by using a return value for a constant infinity. If the interpretation is results and arguments cannot violate nofpclass, then any std::numeric_limits::infinity() result is invalid under -ffinite-math-only. Without this interpretation the utility of nofpclass is slashed. --- Patch is 53.86 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74056.diff 6 Files Affected: - (modified) clang/test/Headers/__clang_hip_math.hip (+44-12) - (modified) llvm/include/llvm/Analysis/ValueTracking.h (+4) - (modified) llvm/lib/Transforms/InstCombine/InstCombineInternal.h (+9) - (modified) llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (+139-1) - (modified) llvm/lib/Transforms/InstCombine/InstructionCombining.cpp (+16-2) - (modified) llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll (+74-129) ``diff diff --git a/clang/test/Headers/__clang_hip_math.hip b/clang/test/Headers/__clang_hip_math.hip index c0f4a06acbb8e32..9e15aec94dc28ab 100644 --- a/clang/test/Headers/__clang_hip_math.hip +++ b/clang/test/Headers/__clang_hip_math.hip @@ -2557,33 +2557,65 @@ extern "C" __device__ double test_nan(const char *tag) { return nan(tag); } -// CHECK-LABEL: @test_nanf_emptystr( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret float 0x7FF8 +// DEFAULT-LABEL: @test_nanf_emptystr( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret float 0x7FF8 +// +// FINITEONLY-LABEL: @test_nanf_emptystr( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret float poison +// +// APPROX-LABEL: @test_nanf_emptystr( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret float 0x7FF8 // extern "C" __device__ float test_nanf_emptystr() { return nanf(""); } -// CHECK-LABEL: @test_nan_emptystr( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret double 0x7FF8 +// DEFAULT-LABEL: @test_nan_emptystr( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret double 0x7FF8 +// +// FINITEONLY-LABEL: @test_nan_emptystr( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret double poison +// +// APPROX-LABEL: @test_nan_emptystr( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret double 0x7FF8 // extern "C" __device__ double test_nan_emptystr() { return nan(""); } -// CHECK-LABEL: @test_nanf_fill( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret float 0x7FF8 +// DEFAULT-LABEL: @test_nanf_fill( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret float 0x7FF8 +// +// FINITEONLY-LABEL: @test_nanf_fill( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret float poison +// +// APPROX-LABEL: @test_nanf_fill( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret float 0x7FF8 // extern "C" __device__ float test_nanf_fill() { return nanf("0x456"); } -// CHECK-LABEL: @test_nan_fill( -// CHECK-NEXT: entry: -// CHECK-NEXT:ret double 0x7FF8 +// DEFAULT-LABEL: @test_nan_fill( +// DEFAULT-NEXT: entry: +// DEFAULT-NEXT:ret double 0x7FF8 +// +// FINITEONLY-LABEL: @test_nan_fill( +// FINITEONLY-NEXT: entry: +// FINITEONLY-NEXT:ret double poison +// +// APPROX-LABEL: @test_nan_fill( +// APPROX-NEXT: entry: +// APPROX-NEXT:ret double 0x7FF8 // extern "C" __device__ double test_nan_fill() { return nan("0x123"); diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h index 82c87edd6297cdf..f9ce679bc74268f 100644 --- a/llvm/include/llvm/Analysis/ValueTracking.h +++ b/llvm/include/llvm/Analysis/ValueTracking.h @@ -243,6 +243,10 @@ struct KnownFPClass { /// definitely set or false if the sign bit is definitely unset. std::optional SignBit; + bool operator==(KnownFPClass Other) const { +return KnownFPClasses == Other.KnownFPClasses && SignBit == Other.SignBit; + } + /// Return true if it's known this can never be one of the mask entries. bool isKnownNever(FPClassTest Mask) const { return (KnownFPClasses & Mask) == fcNone; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h index 0bbb22be71569f6..9a66fb8f456f95b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -551,6 +551,15 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final APInt &UndefElts, unsigned Depth = 0, bool AllowMultipleUsers = false) override; + /// Attempts to replace V with a simpler value based on the demanded + /// floating-point classes + Value *SimplifyDemandedUseFPClass(Value *V, FPClassTest DemandedMask, +
[clang] 5fe7ae8 - [AArch64][SME2] Add ldr_zt, str_zt builtins and intrinsics (#72849)
Author: Matt Devereau Date: 2023-12-01T09:34:38Z New Revision: 5fe7ae848cc6cb2afc3aab332743ffa2bb635fc3 URL: https://github.com/llvm/llvm-project/commit/5fe7ae848cc6cb2afc3aab332743ffa2bb635fc3 DIFF: https://github.com/llvm/llvm-project/commit/5fe7ae848cc6cb2afc3aab332743ffa2bb635fc3.diff LOG: [AArch64][SME2] Add ldr_zt, str_zt builtins and intrinsics (#72849) Adds the builtins: void svldr_zt(uint64_t zt, const void *rn) void svstr_zt(uint64_t zt, void *rn) And the intrinsics: call void @llvm.aarch64.sme.ldr.zt(i32, ptr) tail call void @llvm.aarch64.sme.str.zt(i32, ptr) Patch by: Kerry McLaughlin kerry.mclaugh...@arm.com Added: clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_ldr_str_zt.c llvm/test/CodeGen/AArch64/sme2-intrinsics-zt0.ll Modified: clang/include/clang/Basic/arm_sme.td clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.h llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td llvm/lib/Target/AArch64/SMEInstrFormats.td Removed: diff --git a/clang/include/clang/Basic/arm_sme.td b/clang/include/clang/Basic/arm_sme.td index d55deeaa40bbcd5..7aae3c832bb1fe2 100644 --- a/clang/include/clang/Basic/arm_sme.td +++ b/clang/include/clang/Basic/arm_sme.td @@ -314,3 +314,11 @@ let TargetGuard = "sme2" in { def SVBMOPS : Inst<"svbmops_za32[_{d}]_m", "viPPdd", "iUi", MergeNone, "aarch64_sme_bmops_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, ImmCheck0_3>]>; } + +// +// Spill and fill of ZT0 +// +let TargetGuard = "sme2" in { + def SVLDR_ZT : Inst<"svldr_zt", "viQ", "", MergeNone, "aarch64_sme_ldr_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; + def SVSTR_ZT : Inst<"svstr_zt", "vi%", "", MergeNone, "aarch64_sme_str_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; +} diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_ldr_str_zt.c b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_ldr_str_zt.c new file mode 100644 index 000..126a4fc1045853f --- /dev/null +++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_ldr_str_zt.c @@ -0,0 +1,41 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s + +#include + +// LDR ZT0 + +// CHECK-LABEL: @test_svldr_zt( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.ldr.zt(i32 0, ptr [[BASE:%.*]]) +// CHECK-NEXT:ret void +// +// CPP-CHECK-LABEL: @_Z13test_svldr_ztPKv( +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:tail call void @llvm.aarch64.sme.ldr.zt(i32 0, ptr [[BASE:%.*]]) +// CPP-CHECK-NEXT:ret void +// +void test_svldr_zt(const void *base) __arm_streaming_compatible __arm_shared_za __arm_preserves_za { + svldr_zt(0, base); +} + +// STR ZT0 + +// CHECK-LABEL: @test_svstr_zt( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.str.zt(i32 0, ptr [[BASE:%.*]]) +// CHECK-NEXT:ret void +// +// CPP-CHECK-LABEL: @_Z13test_svstr_ztPv( +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:tail call void @llvm.aarch64.sme.str.zt(i32 0, ptr [[BASE:%.*]]) +// CPP-CHECK-NEXT:ret void +// +void test_svstr_zt(void *base) __arm_streaming_compatible __arm_shared_za __arm_preserves_za { + svstr_zt(0, base); +} diff --git a/clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp b/clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp index 4c35a238d9f9e2c..70987ad395f735a 100644 --- a/clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp +++ b/clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -triple aarch64-none-linux-gnu \ -// RUN:-target-feature +sve2 -target-feature +sme2 -target-feature +sve -fsyntax-only -verify %s +// RUN:-target-feature +sve2 -target-feature +sme2 -target-feature +sme-i16i64 -target-feature +sme-f64f64 -fsyntax-only -verify %s // REQUIRES: aarch64-registered-target @@ -19,3 +19,8 @@ void test_outer_product(svbool_t pred, svint16_t s16, svuint16_t u16, svint32_t svbmops_za32_u32_m(4, pred, pred, u32, u32); // expected-error {{argument
[llvm] [clang] [AArch64][SME2] Add ldr_zt, str_zt builtins and intrinsics (PR #72849)
https://github.com/MDevereau closed https://github.com/llvm/llvm-project/pull/72849 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [AArch64][SME2] Add ldr_zt, str_zt builtins and intrinsics (PR #72849)
@@ -326,9 +326,14 @@ class AArch64DAGToDAGISel : public SelectionDAGISel { return false; } - template bool ImmToTile(SDValue N, SDValue &Imm) { + template + bool ImmToTile(SDValue N, SDValue &Imm) { sdesmalen-arm wrote: If `ImmToTile` is now used for ZT, this is no longer the right name. Can you rename this to `ImmToReg` or something that like that instead? https://github.com/llvm/llvm-project/pull/72849 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-init: Add a hook... (PR #73921)
https://github.com/legrosbuffle updated https://github.com/llvm/llvm-project/pull/73921 >From 851460af6526f175bc34b105a0f5f130a2f1c6b1 Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Thu, 30 Nov 2023 11:08:51 +0100 Subject: [PATCH 1/2] [clang-tidy] performance-unnecessary-copy-init Refactor diagnostic emission and add a hook so that derived checks can observe for which variables a warning has been emitted. --- .../UnnecessaryCopyInitialization.cpp | 73 +-- .../UnnecessaryCopyInitialization.h | 7 ++ 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp index 990e20400fbfcd2..a9ef3faf8c343c9 100644 --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp @@ -15,6 +15,7 @@ #include "clang/AST/Decl.h" #include "clang/Basic/Diagnostic.h" #include +#include namespace clang::tidy::performance { namespace { @@ -302,6 +303,19 @@ void UnnecessaryCopyInitialization::check( } } +void UnnecessaryCopyInitialization::makeDiagnostic( +DiagnosticBuilder Diagnostic, const VarDecl &Var, const Stmt &BlockStmt, +const DeclStmt &Stmt, ASTContext &Context, bool IssueFix) { + const bool IsVarUnused = isVariableUnused(Var, BlockStmt, Context); + Diagnostic << &Var << IsVarUnused; + if (!IssueFix) +return; + if (IsVarUnused) +recordRemoval(Stmt, Context, Diagnostic); + else +recordFixes(Var, Context, Diagnostic); +} + void UnnecessaryCopyInitialization::handleCopyFromMethodReturn( const VarDecl &Var, const Stmt &BlockStmt, const DeclStmt &Stmt, bool IssueFix, const VarDecl *ObjectArg, ASTContext &Context) { @@ -312,52 +326,33 @@ void UnnecessaryCopyInitialization::handleCopyFromMethodReturn( !isInitializingVariableImmutable(*ObjectArg, BlockStmt, Context, ExcludedContainerTypes)) return; - if (isVariableUnused(Var, BlockStmt, Context)) { -auto Diagnostic = -diag(Var.getLocation(), - "the %select{|const qualified }0variable %1 is copy-constructed " - "from a const reference but is never used; consider " - "removing the statement") -<< IsConstQualified << &Var; -if (IssueFix) - recordRemoval(Stmt, Context, Diagnostic); - } else { -auto Diagnostic = -diag(Var.getLocation(), - "the %select{|const qualified }0variable %1 is copy-constructed " - "from a const reference%select{ but is only used as const " - "reference|}0; consider making it a const reference") -<< IsConstQualified << &Var; -if (IssueFix) - recordFixes(Var, Context, Diagnostic); - } + + auto Diagnostic = + diag(Var.getLocation(), + "the %select{|const qualified }0variable %1 is copy-constructed " + "from a const reference%select{" + "%select{ but is only used as const reference|}0" + "| but is never used}2; consider " + "%select{making it a const reference|removing the statement}2") + << IsConstQualified; + makeDiagnostic(std::move(Diagnostic), Var, BlockStmt, Stmt, Context, + IssueFix); } void UnnecessaryCopyInitialization::handleCopyFromLocalVar( -const VarDecl &NewVar, const VarDecl &OldVar, const Stmt &BlockStmt, +const VarDecl &Var, const VarDecl &OldVar, const Stmt &BlockStmt, const DeclStmt &Stmt, bool IssueFix, ASTContext &Context) { - if (!isOnlyUsedAsConst(NewVar, BlockStmt, Context) || + if (!isOnlyUsedAsConst(Var, BlockStmt, Context) || !isInitializingVariableImmutable(OldVar, BlockStmt, Context, ExcludedContainerTypes)) return; - - if (isVariableUnused(NewVar, BlockStmt, Context)) { -auto Diagnostic = diag(NewVar.getLocation(), - "local copy %0 of the variable %1 is never modified " - "and never used; " - "consider removing the statement") - << &NewVar << &OldVar; -if (IssueFix) - recordRemoval(Stmt, Context, Diagnostic); - } else { -auto Diagnostic = -diag(NewVar.getLocation(), - "local copy %0 of the variable %1 is never modified; " - "consider avoiding the copy") -<< &NewVar << &OldVar; -if (IssueFix) - recordFixes(NewVar, Context, Diagnostic); - } + auto Diagnostic = diag(Var.getLocation(), + "local copy %1 of the variable %0 is never modified" + "%select{| and never used}2; consider " + "%select{avoiding the copy|removing the statement}2") +<< &OldVar; + makeDiagnostic(std::move(Diagnostic), Var, BlockStmt,
[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-init: Add a hook... (PR #73921)
https://github.com/legrosbuffle updated https://github.com/llvm/llvm-project/pull/73921 >From 851460af6526f175bc34b105a0f5f130a2f1c6b1 Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Thu, 30 Nov 2023 11:08:51 +0100 Subject: [PATCH 1/2] [clang-tidy] performance-unnecessary-copy-init Refactor diagnostic emission and add a hook so that derived checks can observe for which variables a warning has been emitted. --- .../UnnecessaryCopyInitialization.cpp | 73 +-- .../UnnecessaryCopyInitialization.h | 7 ++ 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp index 990e20400fbfcd2..a9ef3faf8c343c9 100644 --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp @@ -15,6 +15,7 @@ #include "clang/AST/Decl.h" #include "clang/Basic/Diagnostic.h" #include +#include namespace clang::tidy::performance { namespace { @@ -302,6 +303,19 @@ void UnnecessaryCopyInitialization::check( } } +void UnnecessaryCopyInitialization::makeDiagnostic( +DiagnosticBuilder Diagnostic, const VarDecl &Var, const Stmt &BlockStmt, +const DeclStmt &Stmt, ASTContext &Context, bool IssueFix) { + const bool IsVarUnused = isVariableUnused(Var, BlockStmt, Context); + Diagnostic << &Var << IsVarUnused; + if (!IssueFix) +return; + if (IsVarUnused) +recordRemoval(Stmt, Context, Diagnostic); + else +recordFixes(Var, Context, Diagnostic); +} + void UnnecessaryCopyInitialization::handleCopyFromMethodReturn( const VarDecl &Var, const Stmt &BlockStmt, const DeclStmt &Stmt, bool IssueFix, const VarDecl *ObjectArg, ASTContext &Context) { @@ -312,52 +326,33 @@ void UnnecessaryCopyInitialization::handleCopyFromMethodReturn( !isInitializingVariableImmutable(*ObjectArg, BlockStmt, Context, ExcludedContainerTypes)) return; - if (isVariableUnused(Var, BlockStmt, Context)) { -auto Diagnostic = -diag(Var.getLocation(), - "the %select{|const qualified }0variable %1 is copy-constructed " - "from a const reference but is never used; consider " - "removing the statement") -<< IsConstQualified << &Var; -if (IssueFix) - recordRemoval(Stmt, Context, Diagnostic); - } else { -auto Diagnostic = -diag(Var.getLocation(), - "the %select{|const qualified }0variable %1 is copy-constructed " - "from a const reference%select{ but is only used as const " - "reference|}0; consider making it a const reference") -<< IsConstQualified << &Var; -if (IssueFix) - recordFixes(Var, Context, Diagnostic); - } + + auto Diagnostic = + diag(Var.getLocation(), + "the %select{|const qualified }0variable %1 is copy-constructed " + "from a const reference%select{" + "%select{ but is only used as const reference|}0" + "| but is never used}2; consider " + "%select{making it a const reference|removing the statement}2") + << IsConstQualified; + makeDiagnostic(std::move(Diagnostic), Var, BlockStmt, Stmt, Context, + IssueFix); } void UnnecessaryCopyInitialization::handleCopyFromLocalVar( -const VarDecl &NewVar, const VarDecl &OldVar, const Stmt &BlockStmt, +const VarDecl &Var, const VarDecl &OldVar, const Stmt &BlockStmt, const DeclStmt &Stmt, bool IssueFix, ASTContext &Context) { - if (!isOnlyUsedAsConst(NewVar, BlockStmt, Context) || + if (!isOnlyUsedAsConst(Var, BlockStmt, Context) || !isInitializingVariableImmutable(OldVar, BlockStmt, Context, ExcludedContainerTypes)) return; - - if (isVariableUnused(NewVar, BlockStmt, Context)) { -auto Diagnostic = diag(NewVar.getLocation(), - "local copy %0 of the variable %1 is never modified " - "and never used; " - "consider removing the statement") - << &NewVar << &OldVar; -if (IssueFix) - recordRemoval(Stmt, Context, Diagnostic); - } else { -auto Diagnostic = -diag(NewVar.getLocation(), - "local copy %0 of the variable %1 is never modified; " - "consider avoiding the copy") -<< &NewVar << &OldVar; -if (IssueFix) - recordFixes(NewVar, Context, Diagnostic); - } + auto Diagnostic = diag(Var.getLocation(), + "local copy %1 of the variable %0 is never modified" + "%select{| and never used}2; consider " + "%select{avoiding the copy|removing the statement}2") +<< &OldVar; + makeDiagnostic(std::move(Diagnostic), Var, BlockStmt,
[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-init: Add a hook... (PR #73921)
@@ -302,6 +303,20 @@ void UnnecessaryCopyInitialization::check( } } +void UnnecessaryCopyInitialization::makeDiagnostic( +DiagnosticBuilder Diagnostic, const VarDecl &Var, const Stmt &BlockStmt, legrosbuffle wrote: Done. I've kept the code common to these two functions factored out into `maybeIssueFixes`, and I've created a helper struct for the 5 common parameters to these two functions (and the additional 2 boolean variables that these two have in common). https://github.com/llvm/llvm-project/pull/73921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [SME2] Add LUTI2 and LUTI4 double Builtins and Intrinsics (PR #73305)
@@ -298,3 +298,11 @@ multiclass ZAAddSub { defm SVADD : ZAAddSub<"add">; defm SVSUB : ZAAddSub<"sub">; + +// +// lookup table expand two contiguous registers +// +let TargetGuard = "sme2" in { + def SVLUTI2_LANE_ZT_X2 : Inst<"svluti2_lane_zt_{d}_x2", "2.dmdm", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti2_lane_zt_x2", [IsStreaming, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_7>]>; sdesmalen-arm wrote: using `2.dmdm` doesn't seem right, as the specification requires a constant `uint64_t` for `zt` and `imm_idx`. whereas `m` maps to `uint32_t` instead. https://github.com/llvm/llvm-project/pull/73305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU] precommit test for ballot on Windows (PR #73920)
@@ -0,0 +1,27 @@ +// REQUIRES: amdgpu-registered-target +// XFAIL: * +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -S -fcuda-is-device -o - %s | FileCheck %s --check-prefix=GFX9 + +// Unlike OpenCL, HIP depends on the C++ interpration of "unsigned long", which +// is 64 bits long on Linux and 32 bits long on Windows. The return type of the +// ballot intrinsic needs to be a 64 bit integer on both platforms. This test +// cross-compiles to Windows to confirm that the return type is indeed 64 bits +// on Windows. + +// FIXME: The Clang declaration of the wave-64 builtin uses "UL" as the return +// type, which is interpreted as a 32-bit unsigned integer on Windows. This +// emits an incorrect LLVM declaration with i32 return type instead of i64. The +// clang declaration needs to be fixed to use "WU" instead. + +// CHECK-LABEL: @_Z3fooi +// CHECK: call i64 @llvm.amdgcn.ballot.i64 + +// GFX9-LABEL: _Z3fooi: +// GFX9: v_cmp_ne_u32_e64 ssahasra wrote: Yeah, we should check codegen because ultimately that was the symptom ... llc crashed when running hipcc on Windows. https://github.com/llvm/llvm-project/pull/73920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SME2] Add LUTI2 and LUTI4 double Builtins and Intrinsics (PR #73305)
@@ -298,3 +298,11 @@ multiclass ZAAddSub { defm SVADD : ZAAddSub<"add">; defm SVSUB : ZAAddSub<"sub">; + +// +// lookup table expand two contiguous registers +// +let TargetGuard = "sme2" in { + def SVLUTI2_LANE_ZT_X2 : Inst<"svluti2_lane_zt_{d}_x2", "2.dmdm", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti2_lane_zt_x2", [IsStreaming, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_7>]>; sdesmalen-arm wrote: Another thing is that the second input parameter must now always be `svuint8_t`, it can not be the default overloaded type, as per https://github.com/ARM-software/acle/pull/278 https://github.com/llvm/llvm-project/pull/73305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SME2] Add LUTI2 and LUTI4 single Builtins and Intrinsics (PR #73304)
https://github.com/sdesmalen-arm requested changes to this pull request. https://github.com/llvm/llvm-project/pull/73304 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [SME2] Add LUTI2 and LUTI4 single Builtins and Intrinsics (PR #73304)
https://github.com/sdesmalen-arm edited https://github.com/llvm/llvm-project/pull/73304 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [SME2] Add LUTI2 and LUTI4 single Builtins and Intrinsics (PR #73304)
@@ -298,3 +298,11 @@ multiclass ZAAddSub { defm SVADD : ZAAddSub<"add">; defm SVSUB : ZAAddSub<"sub">; + +// +// lookup table expand one register +// +let TargetGuard = "sme2" in { + def SVLUTI2_LANE_ZT : Inst<"svluti2_lane_zt_{d}", "didi", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti2_lane_zt", [IsStreaming, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_15>]>; sdesmalen-arm wrote: Same comment as on #73305 that you can't use the default overloaded type for the operand, as it should use svuint8_t instead. https://github.com/llvm/llvm-project/pull/73304 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [compiler-rt] [libcxx] [llvm] [libc] Ensure `lli --force-interpreter` disables the OrcJIT too (PR #73717)
zmodem wrote: Looks very reasonable to me, but it's not really my area. @lhames can you double check? https://github.com/llvm/llvm-project/pull/73717 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Treat printf as builtin for OpenCL (PR #72554)
@@ -406,5 +410,9 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_fp8_f32, "iffiIb", "nc", "fp8-insts") TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_bf8_f32, "ifiiIi", "nc", "fp8-insts") TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_fp8_f32, "ifiiIi", "nc", "fp8-insts") +// OpenCL +LANGBUILTIN(printf, "icC*4.", "fp:0:", ALL_OCL_LANGUAGES) ssahasra wrote: I think what @vikramRH is saying is that the magic number "4" for OpenCL address space "__constant" is specific to AMDGPU. https://github.com/llvm/llvm-project/pull/72554 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)
@@ -138,10 +164,34 @@ static const VersionTuple MultilibVersionCurrent(1, 0); struct MultilibSerialization { std::string Dir; std::vector Flags; + std::string Group; +}; + +struct MultilibGroupSerialization { + /* + * Future directions: + * + * If it's needed in future, we could introduce additional group types by + * permitting Type to contain strings other than "Exclusive". Another + * possibility is a group of library directories that are mutually + * _dependent_ rather than mutually exclusive: if you include one you must + * include them all. + * + * It might also be useful to allow groups to be members of other groups, so + * that a mutually exclusive group could contain a mutually dependent set of + * library directories, or vice versa. + * + * These additional features would need changes in the implementation, but + * the YAML schema is set up so they can be added without requiring changes + * in existing users' multilib.yaml files. + */ + std::string Name; + std::string Type; statham-arm wrote: Yes, apparently we can. I hadn't found that part of the `llvm::yaml` API yet, but defining a `ScalarEnumerationTraits` for the enum type seems to be the way to make it Just Work during decoding. Thanks. https://github.com/llvm/llvm-project/pull/69447 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 289fe74 - [clang][NFC] Fill in historical data on when C++ DRs 100-199 were fixed
Author: Vlad Serebrennikov Date: 2023-12-01T13:43:22+03:00 New Revision: 289fe74ddbb4c8aa7128f60db6b20c119922b542 URL: https://github.com/llvm/llvm-project/commit/289fe74ddbb4c8aa7128f60db6b20c119922b542 DIFF: https://github.com/llvm/llvm-project/commit/289fe74ddbb4c8aa7128f60db6b20c119922b542.diff LOG: [clang][NFC] Fill in historical data on when C++ DRs 100-199 were fixed Added: Modified: clang/test/CXX/drs/dr1xx.cpp clang/www/cxx_dr_status.html Removed: diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 60e80a4c0e1c4f9..50236eb7c9499d4 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -72,7 +72,7 @@ namespace dr107 { // dr107: yes extern "C" S operator+(S, S) { return S(); } } -namespace dr108 { // dr108: yes +namespace dr108 { // dr108: 2.9 template struct A { struct B { typedef int X; }; B::X x; @@ -143,7 +143,7 @@ namespace dr114 { // dr114: yes } b; // expected-error {{abstract}} } -namespace dr115 { // dr115: yes +namespace dr115 { // dr115: 3.0 template int f(T); // expected-note +{{}} template int g(T); // expected-note +{{}} template int g(T, int); // expected-note +{{}} @@ -480,7 +480,7 @@ namespace dr140 { // dr140: yes void g(int n) { n = 2; } } -namespace dr141 { // dr141: yes +namespace dr141 { // dr141: 3.1 template void f(); template struct S { int n; }; // expected-note {{'::dr141::S::n' declared here}} struct A : S { @@ -518,7 +518,7 @@ namespace dr141 { // dr141: yes void i() { C().i(); } // ok!! } -namespace dr142 { // dr142: yes +namespace dr142 { // dr142: 2.8 class B { // expected-note +{{here}} public: int mi; // expected-note +{{here}} @@ -602,7 +602,7 @@ namespace dr148 { // dr148: yes // dr149: na -namespace dr151 { // dr151: yes +namespace dr151 { // dr151: 3.1 struct X {}; typedef int X::*p; #if __cplusplus < 201103L @@ -655,7 +655,7 @@ namespace dr159 { // dr159: 3.5 // dr160: na -namespace dr161 { // dr161: yes +namespace dr161 { // dr161: 3.1 class A { protected: struct B { int n; } b; // expected-note 2{{here}} @@ -724,7 +724,7 @@ namespace dr165 { // dr165: no void N::g() {} } -namespace dr166 { // dr166: yes +namespace dr166 { // dr166: 2.9 namespace A { class X; } template int f(T t) { return t.n; } @@ -827,7 +827,7 @@ namespace dr173 { // dr173: yes // dr174: sup 1012 -namespace dr175 { // dr175: yes +namespace dr175 { // dr175: 2.8 struct A {}; // expected-note {{here}} struct B : private A {}; // expected-note {{constrained by private inheritance}} struct C : B { @@ -836,7 +836,7 @@ namespace dr175 { // dr175: yes }; } -namespace dr176 { // dr176: yes +namespace dr176 { // dr176: 3.1 template class Y; template<> class Y { void f() { @@ -904,7 +904,7 @@ namespace dr179 { // dr179: yes int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} } -namespace dr180 { // dr180: yes +namespace dr180 { // dr180: 2.8 template struct X : T, T::some_base { X() : T::some_type_that_might_be_T(), T::some_base() {} friend class T::some_class; diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 7cf657a47d64093..141b2aa515ad9ad 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -685,7 +685,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/108.html";>108 TC1 Are classes nested in templates dependent? -Yes +Clang 2.9 https://cplusplus.github.io/CWG/issues/109.html";>109 @@ -727,7 +727,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/115.html";>115 CD1 Address of template-id -Yes +Clang 3.0 https://cplusplus.github.io/CWG/issues/116.html";>116 @@ -883,13 +883,13 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/141.html";>141 CD1 Non-member function templates in member access expressions -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/142.html";>142 TC1 Injection-related errors in access example -Yes +Clang 2.8 https://cplusplus.github.io/CWG/issues/143.html";>143 @@ -943,7 +943,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/151.html";>151 TC1 Terminology of zero-initialization -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/152.html";>152 @@ -1003,7 +1003,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/161.html";>161 TC1 Access to protected nested type -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/162.html";>162 @@ -1033,7 +1033,7 @@ C++ defect report implementation
[clang] [Clang] Remove NetBSD/i386 workaround for FP eval method with older versions (PR #74025)
RKSimon wrote: This should be documented in the release notes in case somebody was still building for such an old netbsd. Should we emit any compile warnings/errors when building for this triple? https://github.com/llvm/llvm-project/pull/74025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)
https://github.com/statham-arm updated https://github.com/llvm/llvm-project/pull/69447 >From 1140903195e555643ee1a6b9f671b47b0c307f9e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 14 Sep 2023 14:51:17 +0100 Subject: [PATCH] [Driver] Add ExclusiveGroup feature to multilib.yaml. This allows a YAML-based multilib configuration to specify explicitly that a subset of its library directories are alternatives to each other, i.e. at most one of that subset should be selected. So if you have multiple sysroots each including a full set of headers and libraries, you can mark them as members of the same mutually exclusive group, and then you'll be sure that only one of them is selected, even if two or more are compatible with the compile options. This is particularly important in multilib setups including the libc++ headers, where selecting the include directories from two different sysroots can cause an actual build failure. This occurs when including , for example: libc++'s stdio.h is included first, and will try to use `#include_next` to fetch the underlying libc's version. But if there are two include directories from separate multilibs, then both of their C++ include directories will end up on the include path first, followed by both the C directories. So the `#include_next` from the first libc++ stdio.h will include the second libc++ stdio.h, which will do nothing because it has the same include guard macro, and the libc header won't ever be included at all. If more than one of the options in an exclusive group matches the given flags, the last one wins. The syntax for specifying this in multilib.yaml is to define a Groups section in which you specify your group names, and for each one, declare it to have Type: Exclusive. (This reserves space in the syntax for maybe adding other group types later, such as a group of mutually _dependent_ things that you must have all or none of.) Then each Variant record that's a member of a group has a Group: property giving that group's name. --- clang/include/clang/Driver/Multilib.h | 16 ++- clang/lib/Driver/Multilib.cpp | 108 -- .../baremetal-multilib-exclusive-group.yaml | 79 + .../baremetal-multilib-group-error.yaml | 27 + 4 files changed, 218 insertions(+), 12 deletions(-) create mode 100644 clang/test/Driver/baremetal-multilib-exclusive-group.yaml create mode 100644 clang/test/Driver/baremetal-multilib-group-error.yaml diff --git a/clang/include/clang/Driver/Multilib.h b/clang/include/clang/Driver/Multilib.h index 1416559414f894b..6a9533e6dd831f1 100644 --- a/clang/include/clang/Driver/Multilib.h +++ b/clang/include/clang/Driver/Multilib.h @@ -39,13 +39,22 @@ class Multilib { std::string IncludeSuffix; flags_list Flags; + // Optionally, a multilib can be assigned a string tag indicating that it's + // part of a group of mutually exclusive possibilities. If two or more + // multilibs have the same non-empty value of ExclusiveGroup, then only the + // last matching one of them will be selected. + // + // Setting this to the empty string is a special case, indicating that the + // directory is not mutually exclusive with anything else. + std::string ExclusiveGroup; + public: /// GCCSuffix, OSSuffix & IncludeSuffix will be appended directly to the /// sysroot string so they must either be empty or begin with a '/' character. /// This is enforced with an assert in the constructor. Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {}, - StringRef IncludeSuffix = {}, - const flags_list &Flags = flags_list()); + StringRef IncludeSuffix = {}, const flags_list &Flags = flags_list(), + StringRef ExclusiveGroup = {}); /// Get the detected GCC installation path suffix for the multi-arch /// target variant. Always starts with a '/', unless empty @@ -63,6 +72,9 @@ class Multilib { /// All elements begin with either '-' or '!' const flags_list &flags() const { return Flags; } + /// Get the exclusive group label. + const std::string &exclusiveGroup() const { return ExclusiveGroup; } + LLVM_DUMP_METHOD void dump() const; /// print summary of the Multilib void print(raw_ostream &OS) const; diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp index 48a494d9fa38db5..7681c1a3ce6756f 100644 --- a/clang/lib/Driver/Multilib.cpp +++ b/clang/lib/Driver/Multilib.cpp @@ -9,6 +9,7 @@ #include "clang/Driver/Multilib.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/Version.h" +#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" @@ -29,9 +30,10 @@ using namespace driver; using namespace llvm::sys; Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix, - StringRef IncludeSuffix, const flags_list &Flags) + StringRef IncludeSuffix, const flags_list &Flags,
[clang-tools-extra] [clang-tidy] Add new performance-use-starts-ends-with check (PR #72385)
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/72385 >From 316b45d612c63f8eea8f847d1cd39992898516f3 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Wed, 15 Nov 2023 01:13:10 -0800 Subject: [PATCH] [clang-tidy] Add new modernize-use-starts-ends-with check Match .find() and .rfind() calls compared to 0, and suggests replacing them with starts_with. --- .../abseil/StringFindStartswithCheck.h| 5 +- .../clang-tidy/modernize/CMakeLists.txt | 1 + .../modernize/ModernizeTidyModule.cpp | 3 + .../modernize/UseStartsEndsWithCheck.cpp | 113 .../modernize/UseStartsEndsWithCheck.h| 37 clang-tools-extra/docs/ReleaseNotes.rst | 7 + .../checks/abseil/string-find-startswith.rst | 4 + .../docs/clang-tidy/checks/list.rst | 1 + .../checks/modernize/use-starts-ends-with.rst | 22 +++ .../checkers/Inputs/Headers/stddef.h | 2 +- .../clang-tidy/checkers/Inputs/Headers/string | 16 +- .../abseil/string-find-startswith.cpp | 2 +- .../modernize/use-starts-ends-with.cpp| 167 ++ .../readability/container-size-empty.cpp | 4 +- 14 files changed, 378 insertions(+), 6 deletions(-) create mode 100644 clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp create mode 100644 clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.h create mode 100644 clang-tools-extra/docs/clang-tidy/checks/modernize/use-starts-ends-with.rst create mode 100644 clang-tools-extra/test/clang-tidy/checkers/modernize/use-starts-ends-with.cpp diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h index 923b5caece5439b..de3bd4d42220009 100644 --- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h +++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h @@ -21,7 +21,6 @@ namespace clang::tidy::abseil { // Find string.find(...) == 0 comparisons and suggest replacing with StartsWith. // FIXME(niko): Add similar check for EndsWith -// FIXME(niko): Add equivalent modernize checks for C++20's std::starts_With class StringFindStartswithCheck : public ClangTidyCheck { public: using ClangTidyCheck::ClangTidyCheck; @@ -31,6 +30,10 @@ class StringFindStartswithCheck : public ClangTidyCheck { void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; void storeOptions(ClangTidyOptions::OptionMap &Opts) override; + bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { +// Prefer modernize-use-starts-ends-with when C++20 is available. +return LangOpts.CPlusPlus && !LangOpts.CPlusPlus20; + } private: const std::vector StringLikeClasses; diff --git a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt index 717c400c4790330..c40065358d2dc3d 100644 --- a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt @@ -38,6 +38,7 @@ add_clang_library(clangTidyModernizeModule UseNoexceptCheck.cpp UseNullptrCheck.cpp UseOverrideCheck.cpp + UseStartsEndsWithCheck.cpp UseStdPrintCheck.cpp UseTrailingReturnTypeCheck.cpp UseTransparentFunctorsCheck.cpp diff --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp index 73751cf2705068d..e994ffd2a75c857 100644 --- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp @@ -39,6 +39,7 @@ #include "UseNoexceptCheck.h" #include "UseNullptrCheck.h" #include "UseOverrideCheck.h" +#include "UseStartsEndsWithCheck.h" #include "UseStdPrintCheck.h" #include "UseTrailingReturnTypeCheck.h" #include "UseTransparentFunctorsCheck.h" @@ -66,6 +67,8 @@ class ModernizeModule : public ClangTidyModule { CheckFactories.registerCheck("modernize-make-shared"); CheckFactories.registerCheck("modernize-make-unique"); CheckFactories.registerCheck("modernize-pass-by-value"); +CheckFactories.registerCheck( +"modernize-use-starts-ends-with"); CheckFactories.registerCheck("modernize-use-std-print"); CheckFactories.registerCheck( "modernize-raw-string-literal"); diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp new file mode 100644 index 000..83451e09e26eaa8 --- /dev/null +++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp @@ -0,0 +1,113 @@ +//===--- UseStartsEndsWithCheck.cpp - clang-tidy --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.t
[clang-tools-extra] [clang-tidy] Add new modernize-use-starts-ends-with check (PR #72385)
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/72385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add new modernize-use-starts-ends-with check (PR #72385)
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/72385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)
statham-arm wrote: (This final force-push is the squashed version of the previous stack, rebased to the current head of `main`, so that the builder can run a last test. Thanks both for the approvals; I'll merge it once the tests have finished.) https://github.com/llvm/llvm-project/pull/69447 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add new modernize-use-starts-ends-with check (PR #72385)
nicovank wrote: Thank you!! Modernize wins the vote, I've renamed the check. https://github.com/llvm/llvm-project/pull/72385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Add SME2 builtins for zero { zt0 } (PR #72274)
@@ -305,4 +305,9 @@ defm SVSUB : ZAAddSub<"sub">; let TargetGuard = "sme2" in { def SVLDR_ZT : Inst<"svldr_zt", "viQ", "", MergeNone, "aarch64_sme_ldr_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; def SVSTR_ZT : Inst<"svstr_zt", "vi%", "", MergeNone, "aarch64_sme_str_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; + +// +// Zero ZT0 +// + def SVZERO_ZT : Inst<"svzero_zt", "vi", "", MergeNone, "aarch64_sme_zero_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; sdesmalen-arm wrote: ```suggestion def SVZERO_ZT : Inst<"svzero_zt", "vi", "", MergeNone, "aarch64_sme_zero_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA], [ImmCheck<0, ImmCheck0_0>]>; ``` While this will change with [PR: Generalise the SME state management attributes](https://github.com/ARM-software/acle/pull/276), in the current version of the spec ZT is considered part of ZA, so zeroing ZT0 is not preserving ZA. See https://github.com/ARM-software/acle/blob/main/main/acle.md#__arm_preserves_za: > ZT state is also considered preserved when a function is marked with > [arm_preserves_za](https://github.com/llvm/llvm-project/pull/72274/files#arm_preserves_za). https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Add SME2 builtins for zero { zt0 } (PR #72274)
@@ -2746,19 +2746,25 @@ AArch64TargetLowering::EmitFill(MachineInstr &MI, MachineBasicBlock *BB) const { return BB; } -MachineBasicBlock *AArch64TargetLowering::EmitZTSpillFill(MachineInstr &MI, - MachineBasicBlock *BB, - bool IsSpill) const { +MachineBasicBlock *AArch64TargetLowering::EmitZTInstr(MachineInstr &MI, + MachineBasicBlock *BB, + unsigned Opcode, + bool IsZTDest) const { const TargetInstrInfo *TII = Subtarget->getInstrInfo(); MachineInstrBuilder MIB; - if (IsSpill) { -MIB = BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(AArch64::STR_TX)); -MIB.addReg(MI.getOperand(0).getReg()); - } else -MIB = BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(AArch64::LDR_TX), + + if (IsZTDest) +MIB = BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(Opcode), MI.getOperand(0).getReg()); - MIB.add(MI.getOperand(1)); // Base - MI.eraseFromParent(); // The pseudo is gone now. + else { +MIB = BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(Opcode)); +MIB.addReg(MI.getOperand(0).getReg()); + } + + for (unsigned I = 1; I < MI.getNumOperands(); ++I) +MIB.add(MI.getOperand(I)); sdesmalen-arm wrote: Can we write this as: ``` MIB = BuildMI(*BB, MI, MI.getDebugLoc(), TII->getOpcode()) .addReg(MI.getOperand(0).getReg(), IsZTDest ? RegState::Define : 0); for (unsigned I = 1; I < MI.getNumOperands(); ++I) MIB.add(MI.getOperand(I)); ``` https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Add SME2 builtins for zero { zt0 } (PR #72274)
@@ -2746,19 +2746,25 @@ AArch64TargetLowering::EmitFill(MachineInstr &MI, MachineBasicBlock *BB) const { return BB; } -MachineBasicBlock *AArch64TargetLowering::EmitZTSpillFill(MachineInstr &MI, - MachineBasicBlock *BB, - bool IsSpill) const { +MachineBasicBlock *AArch64TargetLowering::EmitZTInstr(MachineInstr &MI, + MachineBasicBlock *BB, + unsigned Opcode, + bool IsZTDest) const { sdesmalen-arm wrote: nit: ```suggestion bool Op0IsDef) const { ``` https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [OpenMP] return empty stmt for `nothing` (PR #74042)
https://github.com/alexey-bataev approved this pull request. https://github.com/llvm/llvm-project/pull/74042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [libcxx] [lld] [libc] [clang] [lldb] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/74061 This patch continues the work started with ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details. >From e6b9f54ce066e029b043e72281a7144338a84219 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Fri, 1 Dec 2023 13:35:23 +0300 Subject: [PATCH 1/2] [clang][NFC] Fill in historical data on when C++ DRs 100-199 were fixed --- clang/test/CXX/drs/dr1xx.cpp | 20 ++-- clang/www/cxx_dr_status.html | 20 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 60e80a4c0e1c4f9..50236eb7c9499d4 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -72,7 +72,7 @@ namespace dr107 { // dr107: yes extern "C" S operator+(S, S) { return S(); } } -namespace dr108 { // dr108: yes +namespace dr108 { // dr108: 2.9 template struct A { struct B { typedef int X; }; B::X x; @@ -143,7 +143,7 @@ namespace dr114 { // dr114: yes } b; // expected-error {{abstract}} } -namespace dr115 { // dr115: yes +namespace dr115 { // dr115: 3.0 template int f(T); // expected-note +{{}} template int g(T); // expected-note +{{}} template int g(T, int); // expected-note +{{}} @@ -480,7 +480,7 @@ namespace dr140 { // dr140: yes void g(int n) { n = 2; } } -namespace dr141 { // dr141: yes +namespace dr141 { // dr141: 3.1 template void f(); template struct S { int n; }; // expected-note {{'::dr141::S::n' declared here}} struct A : S { @@ -518,7 +518,7 @@ namespace dr141 { // dr141: yes void i() { C().i(); } // ok!! } -namespace dr142 { // dr142: yes +namespace dr142 { // dr142: 2.8 class B { // expected-note +{{here}} public: int mi; // expected-note +{{here}} @@ -602,7 +602,7 @@ namespace dr148 { // dr148: yes // dr149: na -namespace dr151 { // dr151: yes +namespace dr151 { // dr151: 3.1 struct X {}; typedef int X::*p; #if __cplusplus < 201103L @@ -655,7 +655,7 @@ namespace dr159 { // dr159: 3.5 // dr160: na -namespace dr161 { // dr161: yes +namespace dr161 { // dr161: 3.1 class A { protected: struct B { int n; } b; // expected-note 2{{here}} @@ -724,7 +724,7 @@ namespace dr165 { // dr165: no void N::g() {} } -namespace dr166 { // dr166: yes +namespace dr166 { // dr166: 2.9 namespace A { class X; } template int f(T t) { return t.n; } @@ -827,7 +827,7 @@ namespace dr173 { // dr173: yes // dr174: sup 1012 -namespace dr175 { // dr175: yes +namespace dr175 { // dr175: 2.8 struct A {}; // expected-note {{here}} struct B : private A {}; // expected-note {{constrained by private inheritance}} struct C : B { @@ -836,7 +836,7 @@ namespace dr175 { // dr175: yes }; } -namespace dr176 { // dr176: yes +namespace dr176 { // dr176: 3.1 template class Y; template<> class Y { void f() { @@ -904,7 +904,7 @@ namespace dr179 { // dr179: yes int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} } -namespace dr180 { // dr180: yes +namespace dr180 { // dr180: 2.8 template struct X : T, T::some_base { X() : T::some_type_that_might_be_T(), T::some_base() {} friend class T::some_class; diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 7cf657a47d64093..141b2aa515ad9ad 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -685,7 +685,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/108.html";>108 TC1 Are classes nested in templates dependent? -Yes +Clang 2.9 https://cplusplus.github.io/CWG/issues/109.html";>109 @@ -727,7 +727,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/115.html";>115 CD1 Address of template-id -Yes +Clang 3.0 https://cplusplus.github.io/CWG/issues/116.html";>116 @@ -883,13 +883,13 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/141.html";>141 CD1 Non-member function templates in member access expressions -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/142.html";>142 TC1 Injection-related errors in access example -Yes +Clang 2.8 https://cplusplus.github.io/CWG/issues/143.html";>143 @@ -943,7 +943,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/151.html";>151 TC1 Terminology of zero-initialization -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/152.html";>152 @@ -1003,7 +1003,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/161.html";>161 TC1 Access to protected nested type -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/162.html";>162 @@ -
[flang] [libcxx] [lld] [libc] [clang] [lldb] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) Changes This patch continues the work started with ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details. --- Patch is 54.76 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74061.diff 1 Files Affected: - (modified) clang/test/CXX/drs/dr1xx.cpp (+436-248) ``diff diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 50236eb7c9499d4..e80999e7a2d0cff 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -1,30 +1,31 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98,cxx98-11,cxx98-14,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,cxx98-11,cxx98-14,cxx98-17,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,cxx98-14,cxx98-17,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors namespace dr100 { // dr100: yes - template struct A {}; // expected-note 0-1{{declared here}} - template struct B {}; // expected-note 0-1{{declared here}} - template struct C {}; // expected-note 0-1{{declared here}} - template struct D {}; // expected-note 0-1{{declared here}} - A<&"foo"> a; // #100a - B<"bar"> b; // #100b - C<"baz"> c; // #100c - D<*"quux"> d; // #100d -#if __cplusplus < 201703L - // expected-error@#100a {{does not refer to any declaration}} - // expected-error@#100b {{does not refer to any declaration}} - // expected-error@#100c {{does not refer to any declaration}} - // expected-error@#100d {{does not refer to any declaration}} -#else - // expected-error@#100a {{pointer to string literal is not allowed in a template argument}} - // expected-error@#100b {{reference to string literal is not allowed in a template argument}} - // expected-error@#100c {{pointer to subobject of string literal is not allowed in a template argument}} - // expected-error@#100d {{reference to subobject of string literal is not allowed in a template argument}} -#endif + template struct A {}; // #dr100-A + template struct B {}; // #dr100-B + template struct C {}; // #dr100-C + template struct D {}; // #dr100-D + A<&"foo"> a; // #dr100-a + // cxx98-14-error@#dr100-a {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-A {{template parameter is declared here}} + // since-cxx17-error@#dr100-a {{pointer to string literal is not allowed in a template argument}} + B<"bar"> b; // #dr100-b + // cxx98-14-error@#dr100-b {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-B {{template parameter is declared here}} + // since-cxx17-error@#dr100-b {{reference to string literal is not allowed in a template argument}} + C<"baz"> c; // #dr100-c + // cxx98-14-error@#dr100-c {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-C {{template parameter is declared here}} + // since-cxx17-error@#dr100-c {{pointer to subobject of string literal is not allowed in a template argument}} + D<*"quux"> d; // #dr100-d + // cxx98-14-error@#dr100-d {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-D {{template parameter is declared here}} + // since-cxx17-error@#dr100-d {{reference to subobject of string literal is not allowed in a template argument}} } namespace dr101 { // dr101: 3.5 @@ -42,13 +43,16 @@ namespace dr101 { // dr101: 3.5 namespace dr102 { // dr102: yes namespace A { -template T
[flang] [libcxx] [lld] [libc] [clang] [lldb] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
Endilll wrote: This PR is created to run the patch through CI, so no review requested. https://github.com/llvm/llvm-project/pull/74061 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Add fix vector types to header into SVE (PR #73258)
@@ -0,0 +1,13 @@ +//===--- arm_vector_type.td - ARM Fixed vector types compiler interface ---===// CarolineConcatto wrote: We need for the file in CMakeLists.txt lang_generate_header(-gen-arm-vector-type arm_vector_types.td arm_vector_types.h) https://github.com/llvm/llvm-project/pull/73258 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Add fix vector types to header into SVE (PR #73258)
@@ -2546,6 +2548,44 @@ void NeonEmitter::runFP16(raw_ostream &OS) { OS << "#endif /* __ARM_FP16_H */\n"; } +void NeonEmitter::runVectorType(raw_ostream &OS) { + OS << "/*=== arm_vector_type - ARM vector type " +"--===\n" +" *\n" +" *\n" +" * Part of the LLVM Project, under the Apache License v2.0 with LLVM " +"Exceptions.\n" +" * See https://llvm.org/LICENSE.txt for license information.\n" +" * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n" +" *\n" +" *===-" +"--===\n" +" */\n\n"; + OS << "#ifndef __ARM_NEON_TYPES_H\n"; + OS << "#define __ARM_NEON_TYPES_H\n"; + OS << "#ifdef __cplusplus\n"; + OS << "extern \"C\" {\n"; + OS << "#endif\n"; + OS << "#ifndef __ARM_NEON_H\n"; + + std::string TypedefTypes("QcQsQiQlQUcQUsQUiQUlQhQfQdQb"); + std::vector TDTypeVec = TypeSpec::fromTypeSpecs(TypedefTypes); + for (auto &TS : TDTypeVec) { +Type T(TS, "."); +OS << "typedef __attribute__((vector_size(16))) "; CarolineConcatto wrote: I believe this problem is solved with the logic of the new headers now I did almost like this: https://godbolt.org/z/vYrcKKs3P https://github.com/llvm/llvm-project/pull/73258 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Add fix vector types to header into SVE (PR #73258)
@@ -2546,6 +2548,44 @@ void NeonEmitter::runFP16(raw_ostream &OS) { OS << "#endif /* __ARM_FP16_H */\n"; } +void NeonEmitter::runVectorType(raw_ostream &OS) { + OS << "/*=== arm_vector_type - ARM vector type " +"--===\n" +" *\n" +" *\n" +" * Part of the LLVM Project, under the Apache License v2.0 with LLVM " +"Exceptions.\n" +" * See https://llvm.org/LICENSE.txt for license information.\n" +" * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n" +" *\n" +" *===-" +"--===\n" +" */\n\n"; + OS << "#ifndef __ARM_NEON_TYPES_H\n"; + OS << "#define __ARM_NEON_TYPES_H\n"; + OS << "#ifdef __cplusplus\n"; + OS << "extern \"C\" {\n"; + OS << "#endif\n"; + OS << "#ifndef __ARM_NEON_H\n"; + + std::string TypedefTypes("QcQsQiQlQUcQUsQUiQUlQhQfQdQb"); CarolineConcatto wrote: I added all the types, so I am not sure I should change the name. Let me know if you still have the same opinion after the change. https://github.com/llvm/llvm-project/pull/73258 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)
@@ -75,7 +75,8 @@ define void @idom_sign_bit_check_edge_dominates_select(i64 %a, i64 %b) { ; CHECK: land.lhs.true: ; CHECK-NEXT:br label [[LOR_END:%.*]] ; CHECK: lor.rhs: -; CHECK-NEXT:[[CMP3_NOT:%.*]] = icmp eq i64 [[A]], [[B:%.*]] +; CHECK-NEXT:[[SELECT:%.*]] = call i64 @llvm.umax.i64(i64 [[A]], i64 5) nikic wrote: Fixed by https://github.com/llvm/llvm-project/commit/460faa0c87f0a9496cdaf6c856aff1886e29afe3! https://github.com/llvm/llvm-project/pull/73662 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #74064)
https://github.com/SamTebbs33 created https://github.com/llvm/llvm-project/pull/74064 This PR adds a warning that's emitted when a non-streaming or non-streaming-compatible builtin is called in an unsuitable function. Uses work by Kerry McLaughlin. >From f6a990a000b555d7f8ef0b2a99e3fea98420e899 Mon Sep 17 00:00:00 2001 From: Samuel Tebbs Date: Thu, 30 Nov 2023 13:42:50 + Subject: [PATCH] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function This PR adds a warning that's emitted when a non-streaming or non-streaming-compatible builtin is called in an unsuitable function. Uses work by Kerry McLaughlin. --- clang/include/clang/Basic/CMakeLists.txt | 6 + .../clang/Basic/DiagnosticSemaKinds.td| 3 + clang/include/clang/Sema/Sema.h | 3 + clang/lib/Sema/SemaChecking.cpp | 191 ++ .../Sema/aarch64-incompat-sm-builtin-calls.c | 21 ++ clang/utils/TableGen/SveEmitter.cpp | 68 +++ clang/utils/TableGen/TableGen.cpp | 9 + clang/utils/TableGen/TableGenBackends.h | 1 + 8 files changed, 302 insertions(+) diff --git a/clang/include/clang/Basic/CMakeLists.txt b/clang/include/clang/Basic/CMakeLists.txt index 085e316fcc671df..bdd72d1d63c431b 100644 --- a/clang/include/clang/Basic/CMakeLists.txt +++ b/clang/include/clang/Basic/CMakeLists.txt @@ -97,6 +97,12 @@ clang_tablegen(arm_sme_builtin_cg.inc -gen-arm-sme-builtin-codegen clang_tablegen(arm_sme_sema_rangechecks.inc -gen-arm-sme-sema-rangechecks SOURCE arm_sme.td TARGET ClangARMSmeSemaRangeChecks) +clang_tablegen(arm_sme_streaming_attrs.inc -gen-arm-sme-streaming-attrs + SOURCE arm_sme.td + TARGET ClangARMSmeStreamingAttrs) +clang_tablegen(arm_sme_builtins_za_state.inc -gen-arm-sme-builtin-za-state + SOURCE arm_sme.td + TARGET ClangARMSmeBuiltinsZAState) clang_tablegen(arm_cde_builtins.inc -gen-arm-cde-builtin-def SOURCE arm_cde.td TARGET ClangARMCdeBuiltinsDef) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 6dfb2d7195203a3..c7036fc881a13e1 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3151,6 +3151,9 @@ def err_attribute_arm_feature_sve_bits_unsupported : Error< def warn_attribute_arm_sm_incompat_builtin : Warning< "builtin call has undefined behaviour when called from a %0 function">, InGroup>; +def warn_attribute_arm_za_builtin_no_za_state : Warning< + "builtin call is not valid when calling from a function without active ZA state">, + InGroup>; def err_sve_vector_in_non_sve_target : Error< "SVE vector type %0 cannot be used in a target without sve">; def err_attribute_riscv_rvv_bits_unsupported : Error< diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 6de1a098e067a38..c13c6942c219700 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -13845,7 +13845,10 @@ class Sema final { bool CheckNeonBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); bool CheckMVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); + bool ParseSVEImmChecks(CallExpr *TheCall, + SmallVector, 3> &ImmChecks); bool CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); + bool CheckSMEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); bool CheckCDEBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); bool CheckARMCoprocessorImmediate(const TargetInfo &TI, const Expr *CoprocArg, diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 77c8334f3ca25d3..f27eb8ad95cc703 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2995,6 +2995,134 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, enum ArmStreamingType { ArmNonStreaming, ArmStreaming, ArmStreamingCompatible }; +bool Sema::ParseSVEImmChecks( +CallExpr *TheCall, SmallVector, 3> &ImmChecks) { + // Perform all the immediate checks for this builtin call. + bool HasError = false; + for (auto &I : ImmChecks) { +int ArgNum, CheckTy, ElementSizeInBits; +std::tie(ArgNum, CheckTy, ElementSizeInBits) = I; + +typedef bool (*OptionSetCheckFnTy)(int64_t Value); + +// Function that checks whether the operand (ArgNum) is an immediate +// that is one of the predefined values. +auto CheckImmediateInSet = [&](OptionSetCheckFnTy CheckImm, + int ErrDiag) -> bool { + // We can't check the value of a dependent argument. + Expr *Arg = TheCall->getArg(ArgNum); + if (Arg->isTypeDependent() || Arg->isValueDependent()) +return false; + + // Check constant-ness first. + llvm::APSInt Imm; + if
[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #74064)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Sam Tebbs (SamTebbs33) Changes This PR adds a warning that's emitted when a non-streaming or non-streaming-compatible builtin is called in an unsuitable function. Uses work by Kerry McLaughlin. --- Full diff: https://github.com/llvm/llvm-project/pull/74064.diff 8 Files Affected: - (modified) clang/include/clang/Basic/CMakeLists.txt (+6) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+3) - (modified) clang/include/clang/Sema/Sema.h (+3) - (modified) clang/lib/Sema/SemaChecking.cpp (+191) - (modified) clang/test/Sema/aarch64-incompat-sm-builtin-calls.c (+21) - (modified) clang/utils/TableGen/SveEmitter.cpp (+68) - (modified) clang/utils/TableGen/TableGen.cpp (+9) - (modified) clang/utils/TableGen/TableGenBackends.h (+1) ``diff diff --git a/clang/include/clang/Basic/CMakeLists.txt b/clang/include/clang/Basic/CMakeLists.txt index 085e316fcc671df..bdd72d1d63c431b 100644 --- a/clang/include/clang/Basic/CMakeLists.txt +++ b/clang/include/clang/Basic/CMakeLists.txt @@ -97,6 +97,12 @@ clang_tablegen(arm_sme_builtin_cg.inc -gen-arm-sme-builtin-codegen clang_tablegen(arm_sme_sema_rangechecks.inc -gen-arm-sme-sema-rangechecks SOURCE arm_sme.td TARGET ClangARMSmeSemaRangeChecks) +clang_tablegen(arm_sme_streaming_attrs.inc -gen-arm-sme-streaming-attrs + SOURCE arm_sme.td + TARGET ClangARMSmeStreamingAttrs) +clang_tablegen(arm_sme_builtins_za_state.inc -gen-arm-sme-builtin-za-state + SOURCE arm_sme.td + TARGET ClangARMSmeBuiltinsZAState) clang_tablegen(arm_cde_builtins.inc -gen-arm-cde-builtin-def SOURCE arm_cde.td TARGET ClangARMCdeBuiltinsDef) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 6dfb2d7195203a3..c7036fc881a13e1 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3151,6 +3151,9 @@ def err_attribute_arm_feature_sve_bits_unsupported : Error< def warn_attribute_arm_sm_incompat_builtin : Warning< "builtin call has undefined behaviour when called from a %0 function">, InGroup>; +def warn_attribute_arm_za_builtin_no_za_state : Warning< + "builtin call is not valid when calling from a function without active ZA state">, + InGroup>; def err_sve_vector_in_non_sve_target : Error< "SVE vector type %0 cannot be used in a target without sve">; def err_attribute_riscv_rvv_bits_unsupported : Error< diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 6de1a098e067a38..c13c6942c219700 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -13845,7 +13845,10 @@ class Sema final { bool CheckNeonBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); bool CheckMVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); + bool ParseSVEImmChecks(CallExpr *TheCall, + SmallVector, 3> &ImmChecks); bool CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); + bool CheckSMEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); bool CheckCDEBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); bool CheckARMCoprocessorImmediate(const TargetInfo &TI, const Expr *CoprocArg, diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 77c8334f3ca25d3..f27eb8ad95cc703 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2995,6 +2995,134 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, enum ArmStreamingType { ArmNonStreaming, ArmStreaming, ArmStreamingCompatible }; +bool Sema::ParseSVEImmChecks( +CallExpr *TheCall, SmallVector, 3> &ImmChecks) { + // Perform all the immediate checks for this builtin call. + bool HasError = false; + for (auto &I : ImmChecks) { +int ArgNum, CheckTy, ElementSizeInBits; +std::tie(ArgNum, CheckTy, ElementSizeInBits) = I; + +typedef bool (*OptionSetCheckFnTy)(int64_t Value); + +// Function that checks whether the operand (ArgNum) is an immediate +// that is one of the predefined values. +auto CheckImmediateInSet = [&](OptionSetCheckFnTy CheckImm, + int ErrDiag) -> bool { + // We can't check the value of a dependent argument. + Expr *Arg = TheCall->getArg(ArgNum); + if (Arg->isTypeDependent() || Arg->isValueDependent()) +return false; + + // Check constant-ness first. + llvm::APSInt Imm; + if (SemaBuiltinConstantArg(TheCall, ArgNum, Imm)) +return true; + + if (!CheckImm(Imm.getSExtValue())) +return Diag(TheCall->getBeginLoc(), ErrDiag) << Arg->getSourceRange(); + return false; +}; + +switch ((SVETypeFlags::ImmCheckType)CheckTy) { +case SVETypeFlags::ImmCheck0_31: +
[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #74064)
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 9468de48fcd413aa0895a78bd6f1aeb161b39294 f6a990a000b555d7f8ef0b2a99e3fea98420e899 -- clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaChecking.cpp clang/test/Sema/aarch64-incompat-sm-builtin-calls.c clang/utils/TableGen/SveEmitter.cpp clang/utils/TableGen/TableGen.cpp clang/utils/TableGen/TableGenBackends.h `` View the diff from clang-format here. ``diff diff --git a/clang/utils/TableGen/TableGen.cpp b/clang/utils/TableGen/TableGen.cpp index 9ba2fb07f1..3031a0dd5e 100644 --- a/clang/utils/TableGen/TableGen.cpp +++ b/clang/utils/TableGen/TableGen.cpp @@ -285,11 +285,14 @@ cl::opt Action( "Generate riscv_vector_builtin_cg.inc for clang"), clEnumValN(GenRISCVVectorBuiltinSema, "gen-riscv-vector-builtin-sema", "Generate riscv_vector_builtin_sema.inc for clang"), -clEnumValN(GenRISCVSiFiveVectorBuiltins, "gen-riscv-sifive-vector-builtins", +clEnumValN(GenRISCVSiFiveVectorBuiltins, + "gen-riscv-sifive-vector-builtins", "Generate riscv_sifive_vector_builtins.inc for clang"), -clEnumValN(GenRISCVSiFiveVectorBuiltinCG, "gen-riscv-sifive-vector-builtin-codegen", +clEnumValN(GenRISCVSiFiveVectorBuiltinCG, + "gen-riscv-sifive-vector-builtin-codegen", "Generate riscv_sifive_vector_builtin_cg.inc for clang"), -clEnumValN(GenRISCVSiFiveVectorBuiltinSema, "gen-riscv-sifive-vector-builtin-sema", +clEnumValN(GenRISCVSiFiveVectorBuiltinSema, + "gen-riscv-sifive-vector-builtin-sema", "Generate riscv_sifive_vector_builtin_sema.inc for clang"), clEnumValN(GenAttrDocs, "gen-attr-docs", "Generate attribute documentation"), `` https://github.com/llvm/llvm-project/pull/74064 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [llvm] [mlir] [clang-tools-extra] [clang] [clang] Fix a bug with qualified name lookup into current instantiation (PR #73018)
john-brawn-arm wrote: As a result of this commit clang no longer gives an error for ``` template struct X { enum E { a }; }; template struct Y : X { Y::E m; }; ``` where gcc (though not msvc) gives an error: https://godbolt.org/z/qGfnzhfsK https://github.com/llvm/llvm-project/pull/73018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][SME2] Add intrinsics & builtins for S/URSHL (single, multi) (PR #74066)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Dinar Temirbulatov (dtemirbulatov) Changes Patch by: Kerry McLaughlin--- Patch is 130.62 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74066.diff 2 Files Affected: - (modified) clang/include/clang/Basic/arm_sve.td (+11) - (added) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_rshl.c (+1144) ``diff diff --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td index 7d1af51fb30ba10..3f69a3df9e616ab 100644 --- a/clang/include/clang/Basic/arm_sve.td +++ b/clang/include/clang/Basic/arm_sve.td @@ -2119,6 +2119,17 @@ let TargetGuard = "sme2" in { // 2-way and 4-way selects def SVSEL_X2 : SInst<"svsel[_{d}_x2]", "2}22", "cUcsUsiUilUlbhfd", MergeNone, "aarch64_sve_sel_x2", [IsStreaming], []>; def SVSEL_X4 : SInst<"svsel[_{d}_x4]", "4}44", "cUcsUsiUilUlbhfd", MergeNone, "aarch64_sve_sel_x4", [IsStreaming], []>; + + // SRSHL / URSHL + def SVSRSHL_SINGLE_X2 : SInst<"svrshl[_single_{d}_x2]", "22d", "csil", MergeNone, "aarch64_sve_srshl_single_x2", [IsStreaming], []>; + def SVURSHL_SINGLE_X2 : SInst<"svrshl[_single_{d}_x2]", "22d", "UcUsUiUl", MergeNone, "aarch64_sve_urshl_single_x2", [IsStreaming], []>; + def SVSRSHL_SINGLE_X4 : SInst<"svrshl[_single_{d}_x4]", "44d", "csil", MergeNone, "aarch64_sve_srshl_single_x4", [IsStreaming], []>; + def SVURSHL_SINGLE_X4 : SInst<"svrshl[_single_{d}_x4]", "44d", "UcUsUiUl", MergeNone, "aarch64_sve_urshl_single_x4", [IsStreaming], []>; + + def SVSRSHL_X2 : SInst<"svrshl[_{d}_x2]", "222", "csil", MergeNone, "aarch64_sve_srshl_x2", [IsStreaming], []>; + def SVURSHL_X2 : SInst<"svrshl[_{d}_x2]", "222", "UcUsUiUl", MergeNone, "aarch64_sve_urshl_x2", [IsStreaming], []>; + def SVSRSHL_X4 : SInst<"svrshl[_{d}_x4]", "444", "csil", MergeNone, "aarch64_sve_srshl_x4", [IsStreaming], []>; + def SVURSHL_X4 : SInst<"svrshl[_{d}_x4]", "444", "UcUsUiUl", MergeNone, "aarch64_sve_urshl_x4", [IsStreaming], []>; } let TargetGuard = "sve2p1" in { diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_rshl.c b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_rshl.c new file mode 100644 index 000..ab4594b71293a6f --- /dev/null +++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_rshl.c @@ -0,0 +1,1144 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -o /dev/null %s +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED,A5) A1##A3##A5 +#else +#define SVE_ACLE_FUNC(A1,A2,A3,A4,A5) A1##A2##A3##A4##A5 +#endif + +// Single, x2 + +// CHECK-LABEL: @test_svrshl_single_s8_x2( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.vector.extract.nxv16i8.nxv32i8( [[ZDN:%.*]], i64 0) +// CHECK-NEXT:[[TMP1:%.*]] = tail call @llvm.vector.extract.nxv16i8.nxv32i8( [[ZDN]], i64 16) +// CHECK-NEXT:[[TMP2:%.*]] = tail call { , } @llvm.aarch64.sve.srshl.single.x2.nxv16i8( [[TMP0]], [[TMP1]], [[ZM:%.*]]) +// CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , } [[TMP2]], 0 +// CHECK-NEXT:[[TMP4:%.*]] = tail call @llvm.vector.insert.nxv32i8.nxv16i8( poison, [[TMP3]], i64 0) +// CHECK-NEXT:[[TMP5:%.*]] = extractvalue { , } [[TMP2]], 1 +// CHECK-NEXT:[[TMP6:%.*]] = tail call @llvm.vector.insert.nxv32i8.nxv16i8( [[TMP4]], [[TMP5]], i64 16) +// CHECK-NEXT:ret [[TMP6]] +// +// CPP-CHECK-LABEL: @_Z24test_svrshl_single_s8_x210svint8x2_tu10__SVInt8_t( +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.vector.extract.nxv16i8.nxv32i8( [[ZDN:%.*]], i64 0) +// CPP-CHECK-NEXT:[[TMP1:%.*]] = tail call @l
[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)
https://github.com/statham-arm closed https://github.com/llvm/llvm-project/pull/69447 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8727982 - [Driver] Add exclusive-group feature to multilib.yaml. (#69447)
Author: Simon Tatham Date: 2023-12-01T12:00:18Z New Revision: 8727982bdfb84ce4adbd138c146a6b7ecaf98fdb URL: https://github.com/llvm/llvm-project/commit/8727982bdfb84ce4adbd138c146a6b7ecaf98fdb DIFF: https://github.com/llvm/llvm-project/commit/8727982bdfb84ce4adbd138c146a6b7ecaf98fdb.diff LOG: [Driver] Add exclusive-group feature to multilib.yaml. (#69447) This allows a YAML-based multilib configuration to specify explicitly that a subset of its library directories are alternatives to each other, i.e. at most one of that subset should be selected. So if you have multiple sysroots each including a full set of headers and libraries, you can mark them as members of the same mutually exclusive group, and then you'll be sure that only one of them is selected, even if two or more are compatible with the compile options. This is particularly important in multilib setups including the libc++ headers, where selecting the include directories from two different sysroots can cause an actual build failure. This occurs when including , for example: libc++'s stdio.h is included first, and will try to use `#include_next` to fetch the underlying libc's version. But if there are two include directories from separate multilibs, then both of their C++ include directories will end up on the include path first, followed by both the C directories. So the `#include_next` from the first libc++ stdio.h will include the second libc++ stdio.h, which will do nothing because it has the same include guard macro, and the libc header won't ever be included at all. If more than one of the options in an exclusive group matches the given flags, the last one wins. The syntax for specifying this in multilib.yaml is to define a Groups section in which you specify your group names, and for each one, declare it to have Type: Exclusive. (This reserves space in the syntax for maybe adding other group types later, such as a group of mutually _dependent_ things that you must have all or none of.) Then each Variant record that's a member of a group has a Group: property giving that group's name. Added: clang/test/Driver/baremetal-multilib-exclusive-group.yaml clang/test/Driver/baremetal-multilib-group-error.yaml Modified: clang/include/clang/Driver/Multilib.h clang/lib/Driver/Multilib.cpp Removed: diff --git a/clang/include/clang/Driver/Multilib.h b/clang/include/clang/Driver/Multilib.h index 1416559414f894b..6a9533e6dd831f1 100644 --- a/clang/include/clang/Driver/Multilib.h +++ b/clang/include/clang/Driver/Multilib.h @@ -39,13 +39,22 @@ class Multilib { std::string IncludeSuffix; flags_list Flags; + // Optionally, a multilib can be assigned a string tag indicating that it's + // part of a group of mutually exclusive possibilities. If two or more + // multilibs have the same non-empty value of ExclusiveGroup, then only the + // last matching one of them will be selected. + // + // Setting this to the empty string is a special case, indicating that the + // directory is not mutually exclusive with anything else. + std::string ExclusiveGroup; + public: /// GCCSuffix, OSSuffix & IncludeSuffix will be appended directly to the /// sysroot string so they must either be empty or begin with a '/' character. /// This is enforced with an assert in the constructor. Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {}, - StringRef IncludeSuffix = {}, - const flags_list &Flags = flags_list()); + StringRef IncludeSuffix = {}, const flags_list &Flags = flags_list(), + StringRef ExclusiveGroup = {}); /// Get the detected GCC installation path suffix for the multi-arch /// target variant. Always starts with a '/', unless empty @@ -63,6 +72,9 @@ class Multilib { /// All elements begin with either '-' or '!' const flags_list &flags() const { return Flags; } + /// Get the exclusive group label. + const std::string &exclusiveGroup() const { return ExclusiveGroup; } + LLVM_DUMP_METHOD void dump() const; /// print summary of the Multilib void print(raw_ostream &OS) const; diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp index 48a494d9fa38db5..7681c1a3ce6756f 100644 --- a/clang/lib/Driver/Multilib.cpp +++ b/clang/lib/Driver/Multilib.cpp @@ -9,6 +9,7 @@ #include "clang/Driver/Multilib.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/Version.h" +#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" @@ -29,9 +30,10 @@ using namespace driver; using namespace llvm::sys; Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix, - StringRef IncludeSuffix, const flags_list &Flags) + StringRef IncludeSuffix, const flags_list &Flags, + StringRef ExclusiveGroup) : GCCSuffix(GCCSuffix),
[lld] [libc] [flang] [lldb] [libcxx] [clang] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/74061 >From e6b9f54ce066e029b043e72281a7144338a84219 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Fri, 1 Dec 2023 13:35:23 +0300 Subject: [PATCH 1/3] [clang][NFC] Fill in historical data on when C++ DRs 100-199 were fixed --- clang/test/CXX/drs/dr1xx.cpp | 20 ++-- clang/www/cxx_dr_status.html | 20 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 60e80a4c0e1c4f9..50236eb7c9499d4 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -72,7 +72,7 @@ namespace dr107 { // dr107: yes extern "C" S operator+(S, S) { return S(); } } -namespace dr108 { // dr108: yes +namespace dr108 { // dr108: 2.9 template struct A { struct B { typedef int X; }; B::X x; @@ -143,7 +143,7 @@ namespace dr114 { // dr114: yes } b; // expected-error {{abstract}} } -namespace dr115 { // dr115: yes +namespace dr115 { // dr115: 3.0 template int f(T); // expected-note +{{}} template int g(T); // expected-note +{{}} template int g(T, int); // expected-note +{{}} @@ -480,7 +480,7 @@ namespace dr140 { // dr140: yes void g(int n) { n = 2; } } -namespace dr141 { // dr141: yes +namespace dr141 { // dr141: 3.1 template void f(); template struct S { int n; }; // expected-note {{'::dr141::S::n' declared here}} struct A : S { @@ -518,7 +518,7 @@ namespace dr141 { // dr141: yes void i() { C().i(); } // ok!! } -namespace dr142 { // dr142: yes +namespace dr142 { // dr142: 2.8 class B { // expected-note +{{here}} public: int mi; // expected-note +{{here}} @@ -602,7 +602,7 @@ namespace dr148 { // dr148: yes // dr149: na -namespace dr151 { // dr151: yes +namespace dr151 { // dr151: 3.1 struct X {}; typedef int X::*p; #if __cplusplus < 201103L @@ -655,7 +655,7 @@ namespace dr159 { // dr159: 3.5 // dr160: na -namespace dr161 { // dr161: yes +namespace dr161 { // dr161: 3.1 class A { protected: struct B { int n; } b; // expected-note 2{{here}} @@ -724,7 +724,7 @@ namespace dr165 { // dr165: no void N::g() {} } -namespace dr166 { // dr166: yes +namespace dr166 { // dr166: 2.9 namespace A { class X; } template int f(T t) { return t.n; } @@ -827,7 +827,7 @@ namespace dr173 { // dr173: yes // dr174: sup 1012 -namespace dr175 { // dr175: yes +namespace dr175 { // dr175: 2.8 struct A {}; // expected-note {{here}} struct B : private A {}; // expected-note {{constrained by private inheritance}} struct C : B { @@ -836,7 +836,7 @@ namespace dr175 { // dr175: yes }; } -namespace dr176 { // dr176: yes +namespace dr176 { // dr176: 3.1 template class Y; template<> class Y { void f() { @@ -904,7 +904,7 @@ namespace dr179 { // dr179: yes int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} } -namespace dr180 { // dr180: yes +namespace dr180 { // dr180: 2.8 template struct X : T, T::some_base { X() : T::some_type_that_might_be_T(), T::some_base() {} friend class T::some_class; diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 7cf657a47d64093..141b2aa515ad9ad 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -685,7 +685,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/108.html";>108 TC1 Are classes nested in templates dependent? -Yes +Clang 2.9 https://cplusplus.github.io/CWG/issues/109.html";>109 @@ -727,7 +727,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/115.html";>115 CD1 Address of template-id -Yes +Clang 3.0 https://cplusplus.github.io/CWG/issues/116.html";>116 @@ -883,13 +883,13 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/141.html";>141 CD1 Non-member function templates in member access expressions -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/142.html";>142 TC1 Injection-related errors in access example -Yes +Clang 2.8 https://cplusplus.github.io/CWG/issues/143.html";>143 @@ -943,7 +943,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/151.html";>151 TC1 Terminology of zero-initialization -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/152.html";>152 @@ -1003,7 +1003,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/161.html";>161 TC1 Access to protected nested type -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/162.html";>162 @@ -1033,7 +1033,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/166.html";>166 TC1 Friend dec
[clang] [Clang][AArch64] Add fix vector types to header into SVE (PR #73258)
https://github.com/CarolineConcatto updated https://github.com/llvm/llvm-project/pull/73258 >From e0f245e8d6a395afac5de471b55358c7b730a170 Mon Sep 17 00:00:00 2001 From: Caroline Concatto Date: Wed, 22 Nov 2023 10:03:50 + Subject: [PATCH 1/3] [Clang][AArch64] Add fix vector types to header into SVE This patch is needed for the reduction instructions in sve2.1 It add ta new header to sve with all the fixed vector types. The new types are only added if neon is not declared. --- clang/include/clang/Basic/arm_vector_type.td | 13 ++ clang/lib/Headers/CMakeLists.txt | 3 + .../CodeGen/arm-vector_type-params-returns.c | 113 ++ clang/utils/TableGen/NeonEmitter.cpp | 44 +++ clang/utils/TableGen/SveEmitter.cpp | 2 + clang/utils/TableGen/TableGen.cpp | 15 ++- clang/utils/TableGen/TableGenBackends.h | 1 + 7 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 clang/include/clang/Basic/arm_vector_type.td create mode 100644 clang/test/CodeGen/arm-vector_type-params-returns.c diff --git a/clang/include/clang/Basic/arm_vector_type.td b/clang/include/clang/Basic/arm_vector_type.td new file mode 100644 index 000..5018b0cdfc13785 --- /dev/null +++ b/clang/include/clang/Basic/arm_vector_type.td @@ -0,0 +1,13 @@ +//===--- arm_vector_type.td - ARM Fixed vector types compiler interface ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines the TableGen definitions from which the ARM BF16 header +// file will be generated. +// +//===--===// +include "arm_neon_incl.td" diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt index 8b1e2bc4afa4dcd..0beb6ade4292045 100644 --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt @@ -385,6 +385,8 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST LLVM_TARGETS_TO_BUILD) clang_generate_header(-gen-arm-mve-header arm_mve.td arm_mve.h) # Generate arm_cde.h clang_generate_header(-gen-arm-cde-header arm_cde.td arm_cde.h) + # Generate arm_vector_type.h + clang_generate_header(-gen-arm-vector-type arm_vector_type.td arm_vector_type.h) # Add headers to target specific lists list(APPEND arm_common_generated_files @@ -401,6 +403,7 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST LLVM_TARGETS_TO_BUILD) "${CMAKE_CURRENT_BINARY_DIR}/arm_sve.h" "${CMAKE_CURRENT_BINARY_DIR}/arm_sme_draft_spec_subject_to_change.h" "${CMAKE_CURRENT_BINARY_DIR}/arm_bf16.h" +"${CMAKE_CURRENT_BINARY_DIR}/arm_vector_type.h" ) endif() if(RISCV IN_LIST LLVM_TARGETS_TO_BUILD) diff --git a/clang/test/CodeGen/arm-vector_type-params-returns.c b/clang/test/CodeGen/arm-vector_type-params-returns.c new file mode 100644 index 000..48c19d01b6257cc --- /dev/null +++ b/clang/test/CodeGen/arm-vector_type-params-returns.c @@ -0,0 +1,113 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 3 +// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -emit-llvm -O2 -o - %s | opt -S -passes=mem2reg,sroa | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o - /dev/null %s +#include + +// function return types +// CHECK-LABEL: define dso_local <8 x half> @test_ret_v8f16( +// CHECK-SAME: <8 x half> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:ret <8 x half> [[V]] +// +float16x8_t test_ret_v8f16(float16x8_t v) { + return v; +} + +// CHECK-LABEL: define dso_local <4 x float> @test_ret_v4f32( +// CHECK-SAME: <4 x float> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:ret <4 x float> [[V]] +// +float32x4_t test_ret_v4f32(float32x4_t v) { + return v; +} + +// CHECK-LABEL: define dso_local <2 x double> @test_ret_v2f64( +// CHECK-SAME: <2 x double> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:ret <2 x double> [[V]] +// +float64x2_t test_ret_v2f64(float64x2_t v) { + return v; +} + +// CHECK-LABEL: define dso_local <8 x bfloat> @test_ret_v8bf16( +// CHECK-SAME: <8 x bfloat> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:ret <8 x bfloat> [[V]] +// +bfloat16x8_t test_ret_v8bf16(bfloat16x8_t v) { + return v; +} + +// CHECK-LABEL: define dso_local <16 x i8> @test_ret_v16s8( +// CHECK-SAME: <16 x i8> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:ret
[clang] [AArch64][SME2] Add intrinsics & builtins for S/URSHL (single, multi) (PR #74066)
https://github.com/sdesmalen-arm approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/74066 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add new modernize-use-starts-ends-with check (PR #72385)
@@ -0,0 +1,22 @@ +.. title:: clang-tidy - modernize-use-starts-ends-with + +modernize-use-starts-ends-with + PiotrZSL wrote: make it shorter to match name https://github.com/llvm/llvm-project/pull/72385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add new modernize-use-starts-ends-with check (PR #72385)
https://github.com/PiotrZSL approved this pull request. For a starts_with looks fine, consider now adding support for ends_with, maybe in separate push request once this will be merged. https://github.com/llvm/llvm-project/pull/72385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Ensure LocationFileChecker doesn't try to traverse VFS when determining file path (PR #74071)
https://github.com/daniel-grumberg created https://github.com/llvm/llvm-project/pull/74071 As part of https://reviews.llvm.org/D154130 the logic of LocationFileChecker changed slightly to try and get the absolute external file path instead of the name as requested when the file was openened which would be before VFS mappings in our usage. Ensure that we only check against the name as requested instead of trying to generate the external canonical file path. rdar://115195433 >From 93f1bb149011be424ea2383ea21c99ba1ed595c8 Mon Sep 17 00:00:00 2001 From: Daniel Grumberg Date: Fri, 1 Dec 2023 12:19:38 + Subject: [PATCH] [clang][ExtractAPI] Ensure LocationFileChecker doesn't try to traverse VFS when determining file path As part of https://reviews.llvm.org/D154130 the logic of LocationFileChecker changed slightly to try and get the absolute external file path instead of the name as requested when the file was openened which would be before VFS mappings in our usage. Ensure that we only check against the name as requested instead of trying to generate the external canonical file path. rdar://115195433 --- clang/lib/ExtractAPI/ExtractAPIConsumer.cpp | 11 +- .../test/ExtractAPI/vfs_redirected_include.m | 211 ++ 2 files changed, 219 insertions(+), 3 deletions(-) create mode 100644 clang/test/ExtractAPI/vfs_redirected_include.m diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp index 3aba3bf44547cf6..fe282dfb19e8aa7 100644 --- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp +++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp @@ -17,6 +17,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" #include "clang/Basic/DiagnosticFrontend.h" +#include "clang/Basic/FileEntry.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" @@ -167,6 +168,12 @@ std::optional getRelativeIncludeName(const CompilerInstance &CI, return std::nullopt; } +std::optional getRelativeIncludeName(const CompilerInstance &CI, + FileEntryRef FE, + bool *IsQuoted = nullptr) { + return getRelativeIncludeName(CI, FE.getNameAsRequested(), IsQuoted); +} + struct LocationFileChecker { bool operator()(SourceLocation Loc) { // If the loc refers to a macro expansion we need to first get the file @@ -187,11 +194,9 @@ struct LocationFileChecker { if (ExternalFileEntries.count(*File)) return false; -StringRef FileName = SM.getFileManager().getCanonicalName(*File); - // Try to reduce the include name the same way we tried to include it. bool IsQuoted = false; -if (auto IncludeName = getRelativeIncludeName(CI, FileName, &IsQuoted)) +if (auto IncludeName = getRelativeIncludeName(CI, *File, &IsQuoted)) if (llvm::any_of(KnownFiles, [&IsQuoted, &IncludeName](const auto &KnownFile) { return KnownFile.first.equals(*IncludeName) && diff --git a/clang/test/ExtractAPI/vfs_redirected_include.m b/clang/test/ExtractAPI/vfs_redirected_include.m new file mode 100644 index 000..9ba7e1dedb601eb --- /dev/null +++ b/clang/test/ExtractAPI/vfs_redirected_include.m @@ -0,0 +1,211 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t + +// Setup framework root +// RUN: mkdir -p %t/Frameworks/MyFramework.framework/Headers +// RUN: cp %t/MyFramework.h %t/Frameworks/MyFramework.framework/Headers/ +// RUN: cp %t/MyHeader.h %t/Frameworks/MyFramework.framework/Headers/ + +// RUN: sed -e "s@SRCROOT@%{/t:regex_replacement}@g" \ +// RUN: %t/reference.output.json.in >> %t/reference.output.json + +// Create VFS overlay from framework headers to SRCROOT +// RUN: sed -e "s@SRCROOT@%{/t:regex_replacement}@g" -e "s@DSTROOT@%{/t:regex_replacement}@g" \ +// RUN: %t/vfsoverlay.yaml.in >> %t/vfsoverlay.yaml + +// Input headers use paths to the framework root/DSTROOT +// RUN: %clang_cc1 -extract-api -v --product-name=MyFramework \ +// RUN: -triple arm64-apple-macosx \ +// RUN: -iquote%t -ivfsoverlay %t/vfsoverlay.yaml -F%t/Frameworks \ +// RUN: -x objective-c-header \ +// RUN: %t/Frameworks/MyFramework.framework/Headers/MyFramework.h \ +// RUN: %t/Frameworks/MyFramework.framework/Headers/MyHeader.h \ +// RUN: %t/QuotedHeader.h \ +// RUN: -o %t/output.json 2>&1 -verify | FileCheck -allow-empty %s + +// Generator version is not consistent across test runs, normalize it. +// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \ +// RUN: %t/output.json >> %t/output-normalized.json +// RUN: diff %t/reference.output.json %t/output-normalized.json + +// CHECK: : +// CHECK-NEXT: #import +// CHECK-NEXT: #import +// CHECK-NEXT: #import "QuotedHeader.h" + +//--- vfsoverlay.yaml.in +{ +"case-sensitive": "false", +"roots": [ +{ +"contents": [ +{ +"external-
[clang] [clang][ExtractAPI] Ensure LocationFileChecker doesn't try to traverse VFS when determining file path (PR #74071)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Daniel Grumberg (daniel-grumberg) Changes As part of https://reviews.llvm.org/D154130 the logic of LocationFileChecker changed slightly to try and get the absolute external file path instead of the name as requested when the file was openened which would be before VFS mappings in our usage. Ensure that we only check against the name as requested instead of trying to generate the external canonical file path. rdar://115195433 --- Full diff: https://github.com/llvm/llvm-project/pull/74071.diff 2 Files Affected: - (modified) clang/lib/ExtractAPI/ExtractAPIConsumer.cpp (+8-3) - (added) clang/test/ExtractAPI/vfs_redirected_include.m (+211) ``diff diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp index 3aba3bf44547cf6..fe282dfb19e8aa7 100644 --- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp +++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp @@ -17,6 +17,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" #include "clang/Basic/DiagnosticFrontend.h" +#include "clang/Basic/FileEntry.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" @@ -167,6 +168,12 @@ std::optional getRelativeIncludeName(const CompilerInstance &CI, return std::nullopt; } +std::optional getRelativeIncludeName(const CompilerInstance &CI, + FileEntryRef FE, + bool *IsQuoted = nullptr) { + return getRelativeIncludeName(CI, FE.getNameAsRequested(), IsQuoted); +} + struct LocationFileChecker { bool operator()(SourceLocation Loc) { // If the loc refers to a macro expansion we need to first get the file @@ -187,11 +194,9 @@ struct LocationFileChecker { if (ExternalFileEntries.count(*File)) return false; -StringRef FileName = SM.getFileManager().getCanonicalName(*File); - // Try to reduce the include name the same way we tried to include it. bool IsQuoted = false; -if (auto IncludeName = getRelativeIncludeName(CI, FileName, &IsQuoted)) +if (auto IncludeName = getRelativeIncludeName(CI, *File, &IsQuoted)) if (llvm::any_of(KnownFiles, [&IsQuoted, &IncludeName](const auto &KnownFile) { return KnownFile.first.equals(*IncludeName) && diff --git a/clang/test/ExtractAPI/vfs_redirected_include.m b/clang/test/ExtractAPI/vfs_redirected_include.m new file mode 100644 index 000..9ba7e1dedb601eb --- /dev/null +++ b/clang/test/ExtractAPI/vfs_redirected_include.m @@ -0,0 +1,211 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t + +// Setup framework root +// RUN: mkdir -p %t/Frameworks/MyFramework.framework/Headers +// RUN: cp %t/MyFramework.h %t/Frameworks/MyFramework.framework/Headers/ +// RUN: cp %t/MyHeader.h %t/Frameworks/MyFramework.framework/Headers/ + +// RUN: sed -e "s@SRCROOT@%{/t:regex_replacement}@g" \ +// RUN: %t/reference.output.json.in >> %t/reference.output.json + +// Create VFS overlay from framework headers to SRCROOT +// RUN: sed -e "s@SRCROOT@%{/t:regex_replacement}@g" -e "s@DSTROOT@%{/t:regex_replacement}@g" \ +// RUN: %t/vfsoverlay.yaml.in >> %t/vfsoverlay.yaml + +// Input headers use paths to the framework root/DSTROOT +// RUN: %clang_cc1 -extract-api -v --product-name=MyFramework \ +// RUN: -triple arm64-apple-macosx \ +// RUN: -iquote%t -ivfsoverlay %t/vfsoverlay.yaml -F%t/Frameworks \ +// RUN: -x objective-c-header \ +// RUN: %t/Frameworks/MyFramework.framework/Headers/MyFramework.h \ +// RUN: %t/Frameworks/MyFramework.framework/Headers/MyHeader.h \ +// RUN: %t/QuotedHeader.h \ +// RUN: -o %t/output.json 2>&1 -verify | FileCheck -allow-empty %s + +// Generator version is not consistent across test runs, normalize it. +// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \ +// RUN: %t/output.json >> %t/output-normalized.json +// RUN: diff %t/reference.output.json %t/output-normalized.json + +// CHECK: : +// CHECK-NEXT: #import +// CHECK-NEXT: #import +// CHECK-NEXT: #import "QuotedHeader.h" + +//--- vfsoverlay.yaml.in +{ +"case-sensitive": "false", +"roots": [ +{ +"contents": [ +{ +"external-contents": "SRCROOT/MyHeader.h", +"name": "MyHeader.h", +"type": "file" +} +], +"name": "DSTROOT/Frameworks/MyFramework.framework/Headers", +"type": "directory" +} +], +"version": 0 +} + +//--- MyFramework.h +// Umbrella for MyFramework +#import +// expected-no-diagnostics + +//--- MyHeader.h +#import +int MyInt; +// expected-no-diagnostics + +//--- QuotedHeader.h +char MyChar; +// expected-no-diagnostics + +//--- Frameworks/OtherFramework.framework/Headers/OtherHeader.h +int OtherInt; +// expected-no-diagnostics + +//--- reference.ou
[clang] [clang][ExtractAPI] Ensure LocationFileChecker doesn't try to traverse VFS when determining file path (PR #74071)
daniel-grumberg wrote: Adding @compnerd since he committed (on behalf of someone else) the patch that caused this subtle problem in the first place. Do you know the original authors handle on GitHub? https://github.com/llvm/llvm-project/pull/74071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU] precommit test for ballot on Windows (PR #73920)
https://github.com/vpykhtin approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/73920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)
tblah wrote: Since this patch, I can no longer build spec2006 gromacs and calculix because they supply their own main function in a C file, then link using flang-new: leading to another definition of `main()` from the runtime. Do I need to use a special flag to avoid linking to libFortran_main? https://github.com/llvm/llvm-project/pull/73124 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add new modernize-use-starts-ends-with check (PR #72385)
https://github.com/nicovank updated https://github.com/llvm/llvm-project/pull/72385 >From 86292b1489a6e3998afb52e0625f0c38ff7657a5 Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Wed, 15 Nov 2023 01:13:10 -0800 Subject: [PATCH] [clang-tidy] Add new modernize-use-starts-ends-with check Match .find() and .rfind() calls compared to 0, and suggests replacing them with starts_with. --- .../abseil/StringFindStartswithCheck.h| 5 +- .../clang-tidy/modernize/CMakeLists.txt | 1 + .../modernize/ModernizeTidyModule.cpp | 3 + .../modernize/UseStartsEndsWithCheck.cpp | 113 .../modernize/UseStartsEndsWithCheck.h| 37 clang-tools-extra/docs/ReleaseNotes.rst | 7 + .../checks/abseil/string-find-startswith.rst | 4 + .../docs/clang-tidy/checks/list.rst | 1 + .../checks/modernize/use-starts-ends-with.rst | 22 +++ .../checkers/Inputs/Headers/stddef.h | 2 +- .../clang-tidy/checkers/Inputs/Headers/string | 16 +- .../abseil/string-find-startswith.cpp | 2 +- .../modernize/use-starts-ends-with.cpp| 167 ++ .../readability/container-size-empty.cpp | 4 +- 14 files changed, 378 insertions(+), 6 deletions(-) create mode 100644 clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp create mode 100644 clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.h create mode 100644 clang-tools-extra/docs/clang-tidy/checks/modernize/use-starts-ends-with.rst create mode 100644 clang-tools-extra/test/clang-tidy/checkers/modernize/use-starts-ends-with.cpp diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h index 923b5caece5439b..de3bd4d42220009 100644 --- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h +++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h @@ -21,7 +21,6 @@ namespace clang::tidy::abseil { // Find string.find(...) == 0 comparisons and suggest replacing with StartsWith. // FIXME(niko): Add similar check for EndsWith -// FIXME(niko): Add equivalent modernize checks for C++20's std::starts_With class StringFindStartswithCheck : public ClangTidyCheck { public: using ClangTidyCheck::ClangTidyCheck; @@ -31,6 +30,10 @@ class StringFindStartswithCheck : public ClangTidyCheck { void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; void storeOptions(ClangTidyOptions::OptionMap &Opts) override; + bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { +// Prefer modernize-use-starts-ends-with when C++20 is available. +return LangOpts.CPlusPlus && !LangOpts.CPlusPlus20; + } private: const std::vector StringLikeClasses; diff --git a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt index 717c400c4790330..c40065358d2dc3d 100644 --- a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt @@ -38,6 +38,7 @@ add_clang_library(clangTidyModernizeModule UseNoexceptCheck.cpp UseNullptrCheck.cpp UseOverrideCheck.cpp + UseStartsEndsWithCheck.cpp UseStdPrintCheck.cpp UseTrailingReturnTypeCheck.cpp UseTransparentFunctorsCheck.cpp diff --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp index 73751cf2705068d..e994ffd2a75c857 100644 --- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp @@ -39,6 +39,7 @@ #include "UseNoexceptCheck.h" #include "UseNullptrCheck.h" #include "UseOverrideCheck.h" +#include "UseStartsEndsWithCheck.h" #include "UseStdPrintCheck.h" #include "UseTrailingReturnTypeCheck.h" #include "UseTransparentFunctorsCheck.h" @@ -66,6 +67,8 @@ class ModernizeModule : public ClangTidyModule { CheckFactories.registerCheck("modernize-make-shared"); CheckFactories.registerCheck("modernize-make-unique"); CheckFactories.registerCheck("modernize-pass-by-value"); +CheckFactories.registerCheck( +"modernize-use-starts-ends-with"); CheckFactories.registerCheck("modernize-use-std-print"); CheckFactories.registerCheck( "modernize-raw-string-literal"); diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp new file mode 100644 index 000..83451e09e26eaa8 --- /dev/null +++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp @@ -0,0 +1,113 @@ +//===--- UseStartsEndsWithCheck.cpp - clang-tidy --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.t
[flang] [compiler-rt] [libunwind] [libcxx] [clang] [lld] [clang-tools-extra] [lldb] [libc] [llvm] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
@@ -286,7 +286,33 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, lmKind = LengthModifier::AsInt3264; break; case 'w': - lmKind = LengthModifier::AsWide; ++I; break; + ++I; + if (I == E) return false; + if (*I == 'f') { +lmKind = LengthModifier::AsWideFast; +++I; + } else { +lmKind = LengthModifier::AsWide; + } + + if (I == E) return false; + int s = 0; + while (unsigned(*I - '0') <= 9) { +s = 10 * s + unsigned(*I - '0'); +++I; + } + + // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows + // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) + if (s != 0) { AaronBallman wrote: Should we return false in the case `s == 0`? It would be good to add test coverage for parsing failures. https://github.com/llvm/llvm-project/pull/71771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [flang] [libunwind] [clang-tools-extra] [libcxx] [clang] [libc] [compiler-rt] [llvm] [lld] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
@@ -537,8 +557,12 @@ ArgType PrintfSpecifier::getScalarArgType(ASTContext &Ctx, ArgType(Ctx.getPointerDiffType(), "ptrdiff_t")); case LengthModifier::AsAllocate: case LengthModifier::AsMAllocate: - case LengthModifier::AsWide: return ArgType::Invalid(); + case LengthModifier::AsWide: + case LengthModifier::AsWideFast: +int s = getExplicitlyFixedSize(); +bool fast = LM.getKind() == LengthModifier::AsWideFast ? true : false; +return clang::analyze_format_string::wToArgType(s, fast, Ctx); AaronBallman wrote: ```suggestion int S = getExplicitlyFixedSize(); bool Fast = LM.getKind() == LengthModifier::AsWideFast ? true : false; return clang::analyze_format_string::wToArgType(S, Fast, Ctx); ``` Same below. https://github.com/llvm/llvm-project/pull/71771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [lld] [lldb] [libunwind] [flang] [llvm] [libcxx] [libc] [clang-tools-extra] [clang] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
@@ -286,7 +286,33 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, lmKind = LengthModifier::AsInt3264; break; case 'w': - lmKind = LengthModifier::AsWide; ++I; break; + ++I; + if (I == E) return false; + if (*I == 'f') { +lmKind = LengthModifier::AsWideFast; +++I; + } else { +lmKind = LengthModifier::AsWide; + } + + if (I == E) return false; + int s = 0; + while (unsigned(*I - '0') <= 9) { +s = 10 * s + unsigned(*I - '0'); +++I; + } + + // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows + // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) + if (s != 0) { +std::set supported_list {8, 16, 32, 64}; +if (supported_list.count(s) == 0) { + return false; +} AaronBallman wrote: ```suggestion if (supported_list.count(s) == 0) return false; ``` https://github.com/llvm/llvm-project/pull/71771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add new modernize-use-starts-ends-with check (PR #72385)
nicovank wrote: > Support for `ends_with`. Planning to look into it and other `starts_with` patterns. I do not have commit access, please merge for me (`Nicolas van Kempen `). https://github.com/llvm/llvm-project/pull/72385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [libc] [clang-tools-extra] [lld] [libcxx] [llvm] [libunwind] [flang] [compiler-rt] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
@@ -460,6 +463,14 @@ class FormatSpecifier { FieldWidth = Amt; } + void setExplicitlyFixedSize(unsigned s) { +ExplicitlyFixedSize = s; AaronBallman wrote: ```suggestion void setExplicitlyFixedSize(unsigned S) { ExplicitlyFixedSize = S; ``` https://github.com/llvm/llvm-project/pull/71771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Catch missing format attributes (PR #70024)
https://github.com/budimirarandjelovicsyrmia updated https://github.com/llvm/llvm-project/pull/70024 From a70de331784f4058f11ab6e01efaa025263bd232 Mon Sep 17 00:00:00 2001 From: budimirarandjelovicsyrmia Date: Fri, 13 Oct 2023 14:45:15 +0200 Subject: [PATCH] [clang] Catch missing format attributes --- clang/include/clang/Basic/DiagnosticGroups.td | 2 +- .../clang/Basic/DiagnosticSemaKinds.td| 5 + clang/include/clang/Sema/Sema.h | 4 + clang/lib/Sema/SemaChecking.cpp | 4 +- clang/lib/Sema/SemaDeclAttr.cpp | 107 ++ clang/test/Sema/attr-format-missing.c | 13 +++ 6 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 clang/test/Sema/attr-format-missing.c diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 17fdcffa2d42740..b8b77df84beb2be 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -482,7 +482,7 @@ def MainReturnType : DiagGroup<"main-return-type">; def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">; def MissingBraces : DiagGroup<"missing-braces">; def MissingDeclarations: DiagGroup<"missing-declarations">; -def : DiagGroup<"missing-format-attribute">; +def MissingFormatAttribute: DiagGroup<"missing-format-attribute">; def : DiagGroup<"missing-include-dirs">; def MissingNoreturn : DiagGroup<"missing-noreturn">; def MultiChar : DiagGroup<"multichar">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 6d6f474f6dcdab9..6864fe3057a1df9 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -936,6 +936,11 @@ def err_opencl_invalid_param : Error< def err_opencl_invalid_return : Error< "declaring function return value of type %0 is not allowed %select{; did you forget * ?|}1">; def warn_enum_value_overflow : Warning<"overflow in enumeration value">; +def warn_missing_format_attribute : Warning< + "diagnostic behavior may be improved by adding the %0 format attribute to the declaration of %1">, + InGroup, DefaultIgnore; +def note_insert_format_attribute_fixit: Note< + "insert %0 to silence this warning">; def warn_pragma_options_align_reset_failed : Warning< "#pragma options align=reset failed: %0">, InGroup; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 741c2503127af7a..064506e70960333 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -10615,6 +10615,10 @@ class Sema final { ChangedStateAtExit }; + void DiagnoseMissingFormatAttributes(const FunctionDecl *FDecl, + ArrayRef Args, + SourceLocation Loc); + void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc); void DiagnoseUnterminatedPragmaAlignPack(); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 4602284309491c1..d3ac6cb519c56ed 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -6014,8 +6014,10 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, } } - if (FD) + if (FD) { diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc); +DiagnoseMissingFormatAttributes(FD, Args, Range.getBegin()); + } } /// CheckConstructorCall - Check a constructor call for correctness and safety diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 1a0bfb3d91bcc87..ea3c50de3b51bf8 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -6849,6 +6849,113 @@ static void handleSwiftAsyncAttr(Sema &S, Decl *D, const ParsedAttr &AL) { checkSwiftAsyncErrorBlock(S, D, ErrorAttr, AsyncAttr); } +// Warn if passed function has format attribute and their parent not. +void Sema::DiagnoseMissingFormatAttributes(const FunctionDecl *FDecl, + ArrayRef Args, + SourceLocation Loc) { + assert(FDecl); + + unsigned BuiltinID = FDecl->getBuiltinID(/*ConsiderWrappers=*/true); + + // If function is builtin and not listed in switch, exit. + switch (BuiltinID) { + case Builtin::NotBuiltin: +break; + case Builtin::BIprintf: + case Builtin::BIfprintf: + case Builtin::BIsprintf: + case Builtin::BIscanf: + case Builtin::BIfscanf: + case Builtin::BIsscanf: + case Builtin::BIvprintf: + case Builtin::BIvfprintf: + case Builtin::BIvsprintf: +break; + // C99 mode + case Builtin::BIsnprintf: + case Builtin::BIvsnprintf: + case Builtin::BIvscanf: + case Builtin::BIvfscanf: + case Builtin::BIvsscanf: +if (!getLangOpts().C99) + return; +break; + default: +return; +
[clang] [clang] Catch missing format attributes (PR #70024)
https://github.com/budimirarandjelovicsyrmia updated https://github.com/llvm/llvm-project/pull/70024 From 845235ed5bb126458a792bc1051bb5b13b78a677 Mon Sep 17 00:00:00 2001 From: budimirarandjelovicsyrmia Date: Fri, 13 Oct 2023 14:45:15 +0200 Subject: [PATCH] [clang] Catch missing format attributes --- clang/include/clang/Basic/DiagnosticGroups.td | 2 +- .../clang/Basic/DiagnosticSemaKinds.td| 5 + clang/include/clang/Sema/Sema.h | 4 + clang/lib/Sema/SemaChecking.cpp | 4 +- clang/lib/Sema/SemaDeclAttr.cpp | 104 ++ clang/test/Sema/attr-format-missing.c | 13 +++ 6 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 clang/test/Sema/attr-format-missing.c diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 17fdcffa2d42740..b8b77df84beb2be 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -482,7 +482,7 @@ def MainReturnType : DiagGroup<"main-return-type">; def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">; def MissingBraces : DiagGroup<"missing-braces">; def MissingDeclarations: DiagGroup<"missing-declarations">; -def : DiagGroup<"missing-format-attribute">; +def MissingFormatAttribute: DiagGroup<"missing-format-attribute">; def : DiagGroup<"missing-include-dirs">; def MissingNoreturn : DiagGroup<"missing-noreturn">; def MultiChar : DiagGroup<"multichar">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 6d6f474f6dcdab9..6864fe3057a1df9 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -936,6 +936,11 @@ def err_opencl_invalid_param : Error< def err_opencl_invalid_return : Error< "declaring function return value of type %0 is not allowed %select{; did you forget * ?|}1">; def warn_enum_value_overflow : Warning<"overflow in enumeration value">; +def warn_missing_format_attribute : Warning< + "diagnostic behavior may be improved by adding the %0 format attribute to the declaration of %1">, + InGroup, DefaultIgnore; +def note_insert_format_attribute_fixit: Note< + "insert %0 to silence this warning">; def warn_pragma_options_align_reset_failed : Warning< "#pragma options align=reset failed: %0">, InGroup; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 741c2503127af7a..064506e70960333 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -10615,6 +10615,10 @@ class Sema final { ChangedStateAtExit }; + void DiagnoseMissingFormatAttributes(const FunctionDecl *FDecl, + ArrayRef Args, + SourceLocation Loc); + void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc); void DiagnoseUnterminatedPragmaAlignPack(); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 4602284309491c1..d3ac6cb519c56ed 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -6014,8 +6014,10 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, } } - if (FD) + if (FD) { diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc); +DiagnoseMissingFormatAttributes(FD, Args, Range.getBegin()); + } } /// CheckConstructorCall - Check a constructor call for correctness and safety diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 1a0bfb3d91bcc87..afa9648fdf0069e 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -6849,6 +6849,110 @@ static void handleSwiftAsyncAttr(Sema &S, Decl *D, const ParsedAttr &AL) { checkSwiftAsyncErrorBlock(S, D, ErrorAttr, AsyncAttr); } +// Warn if passed function has format attribute and their parent not. +void Sema::DiagnoseMissingFormatAttributes(const FunctionDecl *FDecl, + ArrayRef Args, + SourceLocation Loc) { + assert(FDecl); + + unsigned BuiltinID = FDecl->getBuiltinID(/*ConsiderWrappers=*/true); + + // If function is builtin and not listed in switch, exit. + switch (BuiltinID) { + case Builtin::NotBuiltin: +break; + case Builtin::BIprintf: + case Builtin::BIfprintf: + case Builtin::BIsprintf: + case Builtin::BIscanf: + case Builtin::BIfscanf: + case Builtin::BIsscanf: + case Builtin::BIvprintf: + case Builtin::BIvfprintf: + case Builtin::BIvsprintf: +break; + // C99 mode + case Builtin::BIsnprintf: + case Builtin::BIvsnprintf: + case Builtin::BIvscanf: + case Builtin::BIvfscanf: + case Builtin::BIvsscanf: +if (!getLangOpts().C99) + return; +break; + default: +return; +
[libcxx] [lldb] [flang] [lld] [clang] [llvm] [libc] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/74061 >From e6b9f54ce066e029b043e72281a7144338a84219 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Fri, 1 Dec 2023 13:35:23 +0300 Subject: [PATCH 1/4] [clang][NFC] Fill in historical data on when C++ DRs 100-199 were fixed --- clang/test/CXX/drs/dr1xx.cpp | 20 ++-- clang/www/cxx_dr_status.html | 20 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 60e80a4c0e1c4f9..50236eb7c9499d4 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -72,7 +72,7 @@ namespace dr107 { // dr107: yes extern "C" S operator+(S, S) { return S(); } } -namespace dr108 { // dr108: yes +namespace dr108 { // dr108: 2.9 template struct A { struct B { typedef int X; }; B::X x; @@ -143,7 +143,7 @@ namespace dr114 { // dr114: yes } b; // expected-error {{abstract}} } -namespace dr115 { // dr115: yes +namespace dr115 { // dr115: 3.0 template int f(T); // expected-note +{{}} template int g(T); // expected-note +{{}} template int g(T, int); // expected-note +{{}} @@ -480,7 +480,7 @@ namespace dr140 { // dr140: yes void g(int n) { n = 2; } } -namespace dr141 { // dr141: yes +namespace dr141 { // dr141: 3.1 template void f(); template struct S { int n; }; // expected-note {{'::dr141::S::n' declared here}} struct A : S { @@ -518,7 +518,7 @@ namespace dr141 { // dr141: yes void i() { C().i(); } // ok!! } -namespace dr142 { // dr142: yes +namespace dr142 { // dr142: 2.8 class B { // expected-note +{{here}} public: int mi; // expected-note +{{here}} @@ -602,7 +602,7 @@ namespace dr148 { // dr148: yes // dr149: na -namespace dr151 { // dr151: yes +namespace dr151 { // dr151: 3.1 struct X {}; typedef int X::*p; #if __cplusplus < 201103L @@ -655,7 +655,7 @@ namespace dr159 { // dr159: 3.5 // dr160: na -namespace dr161 { // dr161: yes +namespace dr161 { // dr161: 3.1 class A { protected: struct B { int n; } b; // expected-note 2{{here}} @@ -724,7 +724,7 @@ namespace dr165 { // dr165: no void N::g() {} } -namespace dr166 { // dr166: yes +namespace dr166 { // dr166: 2.9 namespace A { class X; } template int f(T t) { return t.n; } @@ -827,7 +827,7 @@ namespace dr173 { // dr173: yes // dr174: sup 1012 -namespace dr175 { // dr175: yes +namespace dr175 { // dr175: 2.8 struct A {}; // expected-note {{here}} struct B : private A {}; // expected-note {{constrained by private inheritance}} struct C : B { @@ -836,7 +836,7 @@ namespace dr175 { // dr175: yes }; } -namespace dr176 { // dr176: yes +namespace dr176 { // dr176: 3.1 template class Y; template<> class Y { void f() { @@ -904,7 +904,7 @@ namespace dr179 { // dr179: yes int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} } -namespace dr180 { // dr180: yes +namespace dr180 { // dr180: 2.8 template struct X : T, T::some_base { X() : T::some_type_that_might_be_T(), T::some_base() {} friend class T::some_class; diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 7cf657a47d64093..141b2aa515ad9ad 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -685,7 +685,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/108.html";>108 TC1 Are classes nested in templates dependent? -Yes +Clang 2.9 https://cplusplus.github.io/CWG/issues/109.html";>109 @@ -727,7 +727,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/115.html";>115 CD1 Address of template-id -Yes +Clang 3.0 https://cplusplus.github.io/CWG/issues/116.html";>116 @@ -883,13 +883,13 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/141.html";>141 CD1 Non-member function templates in member access expressions -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/142.html";>142 TC1 Injection-related errors in access example -Yes +Clang 2.8 https://cplusplus.github.io/CWG/issues/143.html";>143 @@ -943,7 +943,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/151.html";>151 TC1 Terminology of zero-initialization -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/152.html";>152 @@ -1003,7 +1003,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/161.html";>161 TC1 Access to protected nested type -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/162.html";>162 @@ -1033,7 +1033,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/166.html";>166 TC1 Friend dec
[clang] [llvm] Add SME2 builtins for zero { zt0 } (PR #72274)
https://github.com/MDevereau updated https://github.com/llvm/llvm-project/pull/72274 >From 86c61659cf99486965dffe201385b28420e93f41 Mon Sep 17 00:00:00 2001 From: Matt Devereau Date: Thu, 9 Nov 2023 16:08:57 + Subject: [PATCH 1/3] Add SME2 builtins for zero { zt0 } Patch by: Kerry McLaughlin kerry.mclaugh...@arm.com --- clang/include/clang/Basic/arm_sme.td | 5 +++ .../acle_sme2_zero_zt.c | 32 +++ llvm/include/llvm/IR/IntrinsicsAArch64.td | 4 +++ .../Target/AArch64/AArch64ISelLowering.cpp| 26 --- llvm/lib/Target/AArch64/AArch64ISelLowering.h | 4 +-- .../lib/Target/AArch64/AArch64SMEInstrInfo.td | 2 +- llvm/lib/Target/AArch64/SMEInstrFormats.td| 11 +++ .../AArch64/sme2-intrinsics-zero-zt.ll| 13 8 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-zero-zt.ll diff --git a/clang/include/clang/Basic/arm_sme.td b/clang/include/clang/Basic/arm_sme.td index 7aae3c832bb1fe20..48afd6431fc8b692 100644 --- a/clang/include/clang/Basic/arm_sme.td +++ b/clang/include/clang/Basic/arm_sme.td @@ -321,4 +321,9 @@ let TargetGuard = "sme2" in { let TargetGuard = "sme2" in { def SVLDR_ZT : Inst<"svldr_zt", "viQ", "", MergeNone, "aarch64_sme_ldr_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; def SVSTR_ZT : Inst<"svstr_zt", "vi%", "", MergeNone, "aarch64_sme_str_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; + +// +// Zero ZT0 +// + def SVZERO_ZT : Inst<"svzero_zt", "vi", "", MergeNone, "aarch64_sme_zero_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; } diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c new file mode 100644 index ..4ea26119301cab23 --- /dev/null +++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c @@ -0,0 +1,32 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1) A1 +#else +#define SVE_ACLE_FUNC(A1) A1 +#endif + +// CHECK-LABEL: @test_svzero_zt( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero.zt(i32 0) +// CHECK-NEXT:ret void +// +// CPP-CHECK-LABEL: @_Z14test_svzero_ztv( +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:tail call void @llvm.aarch64.sme.zero.zt(i32 0) +// CPP-CHECK-NEXT:ret void +// +void test_svzero_zt(void) __arm_streaming_compatible __arm_shared_za __arm_preserves_za { + svzero_zt(0); +} diff --git a/llvm/include/llvm/IR/IntrinsicsAArch64.td b/llvm/include/llvm/IR/IntrinsicsAArch64.td index 60a8d98f3bc0d262..3c0a07be50607bbc 100644 --- a/llvm/include/llvm/IR/IntrinsicsAArch64.td +++ b/llvm/include/llvm/IR/IntrinsicsAArch64.td @@ -3544,6 +3544,10 @@ let TargetPrefix = "aarch64" in { def int_aarch64_sme_ldr_zt : SME_LDR_STR_ZT_Intrinsic; def int_aarch64_sme_str_zt : SME_LDR_STR_ZT_Intrinsic; + // + // Zero ZT0 + // + def int_aarch64_sme_zero_zt : DefaultAttrsIntrinsic<[], [llvm_i32_ty], [ImmArg>, IntrWriteMem]>; } // SVE2.1 - ZIPQ1, ZIPQ2, UZPQ1, UZPQ2 diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 4379c3fde6f3c5dd..f0f0fe1e807b4be8 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -2753,17 +2753,19 @@ AArch64TargetLowering::EmitFill(MachineInstr &MI, MachineBasicBlock *BB) const { return BB; } -MachineBasicBlock *AArch64TargetLowering::EmitZ
[clang] [llvm] Add SME2 builtins for zero { zt0 } (PR #72274)
@@ -305,4 +305,9 @@ defm SVSUB : ZAAddSub<"sub">; let TargetGuard = "sme2" in { def SVLDR_ZT : Inst<"svldr_zt", "viQ", "", MergeNone, "aarch64_sme_ldr_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; def SVSTR_ZT : Inst<"svstr_zt", "vi%", "", MergeNone, "aarch64_sme_str_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; + +// +// Zero ZT0 +// + def SVZERO_ZT : Inst<"svzero_zt", "vi", "", MergeNone, "aarch64_sme_zero_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; MDevereau wrote: Removed. https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Add SME2 builtins for zero { zt0 } (PR #72274)
@@ -2746,19 +2746,25 @@ AArch64TargetLowering::EmitFill(MachineInstr &MI, MachineBasicBlock *BB) const { return BB; } -MachineBasicBlock *AArch64TargetLowering::EmitZTSpillFill(MachineInstr &MI, - MachineBasicBlock *BB, - bool IsSpill) const { +MachineBasicBlock *AArch64TargetLowering::EmitZTInstr(MachineInstr &MI, + MachineBasicBlock *BB, + unsigned Opcode, + bool IsZTDest) const { const TargetInstrInfo *TII = Subtarget->getInstrInfo(); MachineInstrBuilder MIB; - if (IsSpill) { -MIB = BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(AArch64::STR_TX)); -MIB.addReg(MI.getOperand(0).getReg()); - } else -MIB = BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(AArch64::LDR_TX), + + if (IsZTDest) +MIB = BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(Opcode), MI.getOperand(0).getReg()); - MIB.add(MI.getOperand(1)); // Base - MI.eraseFromParent(); // The pseudo is gone now. + else { +MIB = BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(Opcode)); +MIB.addReg(MI.getOperand(0).getReg()); + } + + for (unsigned I = 1; I < MI.getNumOperands(); ++I) +MIB.add(MI.getOperand(I)); MDevereau wrote: I've rebased this patch which includes a refactor of this function from 5fe7ae8. Your suggestion is still an improve to that though so I've added it. https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Add SME2 builtins for zero { zt0 } (PR #72274)
@@ -2746,19 +2746,25 @@ AArch64TargetLowering::EmitFill(MachineInstr &MI, MachineBasicBlock *BB) const { return BB; } -MachineBasicBlock *AArch64TargetLowering::EmitZTSpillFill(MachineInstr &MI, - MachineBasicBlock *BB, - bool IsSpill) const { +MachineBasicBlock *AArch64TargetLowering::EmitZTInstr(MachineInstr &MI, + MachineBasicBlock *BB, + unsigned Opcode, + bool IsZTDest) const { MDevereau wrote: Done. https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Add SME2 builtins for zero { zt0 } (PR #72274)
https://github.com/sdesmalen-arm edited https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Add SME2 builtins for zero { zt0 } (PR #72274)
https://github.com/sdesmalen-arm approved this pull request. LGTM with comment addressed. https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Add SME2 builtins for zero { zt0 } (PR #72274)
@@ -0,0 +1,23 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s + +#include + +// CHECK-LABEL: @test_svzero_zt( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero.zt(i32 0) +// CHECK-NEXT:ret void +// +// CPP-CHECK-LABEL: @_Z14test_svzero_ztv( +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:tail call void @llvm.aarch64.sme.zero.zt(i32 0) +// CPP-CHECK-NEXT:ret void +// +void test_svzero_zt(void) __arm_streaming_compatible __arm_shared_za __arm_preserves_za { sdesmalen-arm wrote: ```suggestion void test_svzero_zt(void) __arm_streaming_compatible __arm_shared_za __arm_preserves_za { ``` This should actually lead to a diagnostic (but I don't think we've implemented those yet), since svzero_zt doesn't preserve ZA. https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #74064)
@@ -2995,6 +2995,134 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, enum ArmStreamingType { ArmNonStreaming, ArmStreaming, ArmStreamingCompatible }; +bool Sema::ParseSVEImmChecks( +CallExpr *TheCall, SmallVector, 3> &ImmChecks) { + // Perform all the immediate checks for this builtin call. + bool HasError = false; + for (auto &I : ImmChecks) { +int ArgNum, CheckTy, ElementSizeInBits; +std::tie(ArgNum, CheckTy, ElementSizeInBits) = I; + +typedef bool (*OptionSetCheckFnTy)(int64_t Value); + +// Function that checks whether the operand (ArgNum) is an immediate +// that is one of the predefined values. +auto CheckImmediateInSet = [&](OptionSetCheckFnTy CheckImm, + int ErrDiag) -> bool { + // We can't check the value of a dependent argument. + Expr *Arg = TheCall->getArg(ArgNum); + if (Arg->isTypeDependent() || Arg->isValueDependent()) +return false; + + // Check constant-ness first. + llvm::APSInt Imm; + if (SemaBuiltinConstantArg(TheCall, ArgNum, Imm)) +return true; + + if (!CheckImm(Imm.getSExtValue())) +return Diag(TheCall->getBeginLoc(), ErrDiag) << Arg->getSourceRange(); + return false; +}; + +switch ((SVETypeFlags::ImmCheckType)CheckTy) { +case SVETypeFlags::ImmCheck0_31: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 31)) +HasError = true; + break; +case SVETypeFlags::ImmCheck0_13: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 13)) +HasError = true; + break; +case SVETypeFlags::ImmCheck1_16: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 1, 16)) +HasError = true; + break; +case SVETypeFlags::ImmCheck0_7: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 7)) +HasError = true; + break; +case SVETypeFlags::ImmCheckExtract: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, + (2048 / ElementSizeInBits) - 1)) +HasError = true; + break; +case SVETypeFlags::ImmCheckShiftRight: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 1, ElementSizeInBits)) +HasError = true; + break; +case SVETypeFlags::ImmCheckShiftRightNarrow: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 1, + ElementSizeInBits / 2)) +HasError = true; + break; +case SVETypeFlags::ImmCheckShiftLeft: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, + ElementSizeInBits - 1)) +HasError = true; + break; +case SVETypeFlags::ImmCheckLaneIndex: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, + (128 / (1 * ElementSizeInBits)) - 1)) +HasError = true; + break; +case SVETypeFlags::ImmCheckLaneIndexCompRotate: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, + (128 / (2 * ElementSizeInBits)) - 1)) +HasError = true; + break; +case SVETypeFlags::ImmCheckLaneIndexDot: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, + (128 / (4 * ElementSizeInBits)) - 1)) +HasError = true; + break; +case SVETypeFlags::ImmCheckComplexRot90_270: + if (CheckImmediateInSet([](int64_t V) { return V == 90 || V == 270; }, + diag::err_rotation_argument_to_cadd)) +HasError = true; + break; +case SVETypeFlags::ImmCheckComplexRotAll90: + if (CheckImmediateInSet( + [](int64_t V) { +return V == 0 || V == 90 || V == 180 || V == 270; + }, + diag::err_rotation_argument_to_cmla)) +HasError = true; + break; +case SVETypeFlags::ImmCheck0_1: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 1)) +HasError = true; + break; +case SVETypeFlags::ImmCheck0_2: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 2)) +HasError = true; + break; +case SVETypeFlags::ImmCheck0_3: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 3)) +HasError = true; + break; +case SVETypeFlags::ImmCheck0_0: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 0)) +HasError = true; + break; +case SVETypeFlags::ImmCheck0_15: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 15)) +HasError = true; + break; +case SVETypeFlags::ImmCheck0_255: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 255)) +HasError = true; + break; +case SVETypeFlags::ImmCheck2_4_Mul2: + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 2, 4) || + SemaBuiltinConstantArgMultiple(TheCall, ArgNum, 2)) +HasError = true; + break; kmclaughlin-arm wrote
[clang] [llvm] Add SME2 builtins for zero { zt0 } (PR #72274)
https://github.com/MDevereau updated https://github.com/llvm/llvm-project/pull/72274 >From 86c61659cf99486965dffe201385b28420e93f41 Mon Sep 17 00:00:00 2001 From: Matt Devereau Date: Thu, 9 Nov 2023 16:08:57 + Subject: [PATCH 1/4] Add SME2 builtins for zero { zt0 } Patch by: Kerry McLaughlin kerry.mclaugh...@arm.com --- clang/include/clang/Basic/arm_sme.td | 5 +++ .../acle_sme2_zero_zt.c | 32 +++ llvm/include/llvm/IR/IntrinsicsAArch64.td | 4 +++ .../Target/AArch64/AArch64ISelLowering.cpp| 26 --- llvm/lib/Target/AArch64/AArch64ISelLowering.h | 4 +-- .../lib/Target/AArch64/AArch64SMEInstrInfo.td | 2 +- llvm/lib/Target/AArch64/SMEInstrFormats.td| 11 +++ .../AArch64/sme2-intrinsics-zero-zt.ll| 13 8 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-zero-zt.ll diff --git a/clang/include/clang/Basic/arm_sme.td b/clang/include/clang/Basic/arm_sme.td index 7aae3c832bb1fe2..48afd6431fc8b69 100644 --- a/clang/include/clang/Basic/arm_sme.td +++ b/clang/include/clang/Basic/arm_sme.td @@ -321,4 +321,9 @@ let TargetGuard = "sme2" in { let TargetGuard = "sme2" in { def SVLDR_ZT : Inst<"svldr_zt", "viQ", "", MergeNone, "aarch64_sme_ldr_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; def SVSTR_ZT : Inst<"svstr_zt", "vi%", "", MergeNone, "aarch64_sme_str_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; + +// +// Zero ZT0 +// + def SVZERO_ZT : Inst<"svzero_zt", "vi", "", MergeNone, "aarch64_sme_zero_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; } diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c new file mode 100644 index 000..4ea26119301cab2 --- /dev/null +++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c @@ -0,0 +1,32 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1) A1 +#else +#define SVE_ACLE_FUNC(A1) A1 +#endif + +// CHECK-LABEL: @test_svzero_zt( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero.zt(i32 0) +// CHECK-NEXT:ret void +// +// CPP-CHECK-LABEL: @_Z14test_svzero_ztv( +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:tail call void @llvm.aarch64.sme.zero.zt(i32 0) +// CPP-CHECK-NEXT:ret void +// +void test_svzero_zt(void) __arm_streaming_compatible __arm_shared_za __arm_preserves_za { + svzero_zt(0); +} diff --git a/llvm/include/llvm/IR/IntrinsicsAArch64.td b/llvm/include/llvm/IR/IntrinsicsAArch64.td index 60a8d98f3bc0d26..3c0a07be50607bb 100644 --- a/llvm/include/llvm/IR/IntrinsicsAArch64.td +++ b/llvm/include/llvm/IR/IntrinsicsAArch64.td @@ -3544,6 +3544,10 @@ let TargetPrefix = "aarch64" in { def int_aarch64_sme_ldr_zt : SME_LDR_STR_ZT_Intrinsic; def int_aarch64_sme_str_zt : SME_LDR_STR_ZT_Intrinsic; + // + // Zero ZT0 + // + def int_aarch64_sme_zero_zt : DefaultAttrsIntrinsic<[], [llvm_i32_ty], [ImmArg>, IntrWriteMem]>; } // SVE2.1 - ZIPQ1, ZIPQ2, UZPQ1, UZPQ2 diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 4379c3fde6f3c5d..f0f0fe1e807b4be 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -2753,17 +2753,19 @@ AArch64TargetLowering::EmitFill(MachineInstr &MI, MachineBasicBlock *BB) const { return BB; } -MachineBasicBlock *AArch64TargetLowering::EmitZTSpillFi
[clang] [llvm] Add SME2 builtins for zero { zt0 } (PR #72274)
@@ -0,0 +1,23 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s + +#include + +// CHECK-LABEL: @test_svzero_zt( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero.zt(i32 0) +// CHECK-NEXT:ret void +// +// CPP-CHECK-LABEL: @_Z14test_svzero_ztv( +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:tail call void @llvm.aarch64.sme.zero.zt(i32 0) +// CPP-CHECK-NEXT:ret void +// +void test_svzero_zt(void) __arm_streaming_compatible __arm_shared_za __arm_preserves_za { MDevereau wrote: Removed it. I didn't see this fail when testing it locally when I expected it to, so what you say is correct. https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)
https://github.com/martinboehme updated https://github.com/llvm/llvm-project/pull/73860 >From a7138289989afaa1348185e52469d670c316eb45 Mon Sep 17 00:00:00 2001 From: Martin Braenne Date: Wed, 29 Nov 2023 21:32:55 + Subject: [PATCH 1/4] [clang][dataflow] Defer initialization of `Environment`. The `Environment` is now only initialized with storage locations and values for global variables, parameters, and the like after the analysis has been created. Followup commits will add the ability to set callbacks that create synthetic properties and associate these synthetic properties with values. The analysis needs to be able to set these callbacks before any storage locations and values are created. --- .../FlowSensitive/DataflowEnvironment.h | 22 +-- .../FlowSensitive/DataflowEnvironment.cpp | 61 +++ .../TypeErasedDataflowAnalysis.cpp| 61 ++- .../FlowSensitive/DataflowEnvironmentTest.cpp | 5 ++ 4 files changed, 91 insertions(+), 58 deletions(-) diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h index 7c1f5491096326b..7026f289d62403c 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h @@ -166,6 +166,10 @@ class Environment { /// with a symbolic representation of the `this` pointee. Environment(DataflowAnalysisContext &DACtx, const DeclContext &DeclCtx); + /// Assigns storage locations and values to all global variables, fields + /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body. + void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl); + /// Returns a new environment that is a copy of this one. /// /// The state of the program is initially the same, but can be mutated without @@ -283,7 +287,15 @@ class Environment { /// Returns the storage location assigned to the `this` pointee in the /// environment or null if the `this` pointee has no assigned storage location /// in the environment. - RecordStorageLocation *getThisPointeeStorageLocation() const; + RecordStorageLocation *getThisPointeeStorageLocation() const { +return ThisPointeeLoc; + } + + /// Sets the storage location assigned to the `this` pointee in the + /// environment. + void setThisPointeeStorageLocation(RecordStorageLocation &Loc) { +ThisPointeeLoc = &Loc; + } /// Returns the location of the result object for a record-type prvalue. /// @@ -570,6 +582,9 @@ class Environment { return dyn_cast(getDeclCtx()); } + /// Returns the size of the call stack. + size_t callStackSize() const { return CallStack.size(); } + /// Returns whether this `Environment` can be extended to analyze the given /// `Callee` (i.e. if `pushCall` can be used), with recursion disallowed and a /// given `MaxDepth`. @@ -629,10 +644,7 @@ class Environment { void pushCallInternal(const FunctionDecl *FuncDecl, ArrayRef Args); - /// Assigns storage locations and values to all global variables, fields - /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body. - void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl); - +private: // `DACtx` is not null and not owned by this object. DataflowAnalysisContext *DACtx; diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp index 525ab188b01b8aa..131a68c03ed7563 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -367,6 +367,16 @@ getFieldsGlobalsAndFuncs(const Stmt &S, FieldSet &Fields, } } +Environment::Environment(DataflowAnalysisContext &DACtx) +: DACtx(&DACtx), + FlowConditionToken(DACtx.arena().makeFlowConditionToken()) {} + +Environment::Environment(DataflowAnalysisContext &DACtx, + const DeclContext &DeclCtx) +: Environment(DACtx) { + CallStack.push_back(&DeclCtx); +} + // FIXME: Add support for resetting globals after function calls to enable // the implementation of sound analyses. void Environment::initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl) { @@ -416,59 +426,12 @@ void Environment::initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl) { } } -Environment::Environment(DataflowAnalysisContext &DACtx) -: DACtx(&DACtx), - FlowConditionToken(DACtx.arena().makeFlowConditionToken()) {} - Environment Environment::fork() const { Environment Copy(*this); Copy.FlowConditionToken = DACtx->forkFlowCondition(FlowConditionToken); return Copy; } -Environment::Environment(DataflowAnalysisContext &DACtx, - const DeclContext &DeclCtx) -: Environment(DACtx) { - CallStack.push_back(&DeclCtx); - - if (const auto *FuncDecl = dyn_cast(&DeclCtx)) { -assert(Fu
[clang] 6ab7662 - [clang][NFC] Refactor expected directives in C++ DRs 100-199 (#74061)
Author: Vlad Serebrennikov Date: 2023-12-01T17:56:27+04:00 New Revision: 6ab7662f35bb5bc1d19a7e68ec0a710bbf71c2c4 URL: https://github.com/llvm/llvm-project/commit/6ab7662f35bb5bc1d19a7e68ec0a710bbf71c2c4 DIFF: https://github.com/llvm/llvm-project/commit/6ab7662f35bb5bc1d19a7e68ec0a710bbf71c2c4.diff LOG: [clang][NFC] Refactor expected directives in C++ DRs 100-199 (#74061) This patch continues the work started with ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details. Added: Modified: clang/test/CXX/drs/dr0xx.cpp clang/test/CXX/drs/dr1xx.cpp Removed: diff --git a/clang/test/CXX/drs/dr0xx.cpp b/clang/test/CXX/drs/dr0xx.cpp index e79ce6daf2655c5..768da0f8e6fa777 100644 --- a/clang/test/CXX/drs/dr0xx.cpp +++ b/clang/test/CXX/drs/dr0xx.cpp @@ -89,12 +89,11 @@ namespace dr7 { // dr7: 3.4 class B : virtual private A {}; // #dr7-B class C : public B {} c; // #dr7-C // expected-error@#dr7-C {{inherited virtual base class 'A' has private destructor}} - // expected-note@#dr7-C {{in implicit default constructor for 'dr7::C' first required here}} - // expected-note@#dr7-B {{declared private here}} - + // expected-note@#dr7-C {{in implicit default constructor for 'dr7::C' first required here}} + // expected-note@#dr7-B {{declared private here}} // expected-error@#dr7-C {{inherited virtual base class 'A' has private destructor}} - // expected-note@#dr7-C {{in implicit destructor for 'dr7::C' first required here}} - // expected-note@#dr7-B {{declared private here}} + // expected-note@#dr7-C {{in implicit destructor for 'dr7::C' first required here}} + // expected-note@#dr7-B {{declared private here}} class VeryDerivedC : public B, virtual public A {} vdc; class X { ~X(); }; // #dr7-X @@ -237,11 +236,10 @@ namespace dr16 { // dr16: 2.8 // expected-note@#dr16-A-f-decl {{member is declared here}} A::f(); // #dr16-A-f-call // expected-error@#dr16-A-f-call {{'A' is a private member of 'dr16::A'}} - // expected-note@#dr16-B {{constrained by implicitly private inheritance here}} - // expected-note@#dr16-A {{member is declared here}} - + // expected-note@#dr16-B {{constrained by implicitly private inheritance here}} + // expected-note@#dr16-A {{member is declared here}} // expected-error@#dr16-A-f-call {{cannot cast 'dr16::C' to its private base class 'dr16::A'}} - // expected-note@#dr16-B {{implicitly declared private here}} + // expected-note@#dr16-B {{implicitly declared private here}} } }; } @@ -361,9 +359,9 @@ namespace dr26 { // dr26: yes // FIXME: In C++98, we diagnose this twice. B(const B &, B = B()); // cxx98-14-error@-1 {{recursive evaluation of default argument}} -// cxx98-14-note@-2 {{default argument used here}} +// cxx98-14-note@-2 {{default argument used here}} // cxx98-error@-3 {{recursive evaluation of default argument}} -// cxx98-note@-4 {{default argument used here}} +// cxx98-note@-4 {{default argument used here}} }; struct C { static C &f(); @@ -788,23 +786,20 @@ namespace dr49 { // dr49: 2.8 A<&k> a; A b; // #dr49-b // cxx98-error@#dr49-b {{non-type template argument referring to object 'p' with internal linkage is a C++11 extension}} - // cxx98-note@#dr49-p {{non-type template argument refers to object here}} - + // cxx98-note@#dr49-p {{non-type template argument refers to object here}} // cxx98-14-error@#dr49-b {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} - // cxx98-14-note@#dr49-A {{template parameter is declared here}} + // cxx98-14-note@#dr49-A {{template parameter is declared here}} int *q = &k; // #dr49-q A c; // #dr49-c // cxx98-error@#dr49-c {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} - // cxx98-note@#dr49-A {{template parameter is declared here}} - + // cxx98-note@#dr49-A {{template parameter is declared here}} // cxx11-14-error@#dr49-c {{non-type template argument of type 'int *' is not a constant expression}} - // cxx11-14-note@#dr49-c {{read of non-constexpr variable 'q' is not allowed in a constant expression}} - // cxx11-14-note@#dr49-q {{declared here}} - // cxx11-14-note@#dr49-A {{template parameter is declared here}} - + // cxx11-14-note@#dr49-c {{read of non-constexpr variable 'q' is not allowed in a constant expression}} + // cxx11-14-note@#dr49-q {{declared here}} + // cxx11-14-note@#dr49-A {{template parameter is declared here}} // since-cxx17-error@#dr49-c {{non-type template argument is not a constant expression}} - // since-cxx17-note@#dr49-c {{read of non-constexpr variable 'q' is not allowed in a constant expression}} - // since-cxx17-note@#dr49-q {{declared here}} + // since-
[libc] [libcxx] [llvm] [lld] [lldb] [clang] [flang] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/74061 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)
@@ -492,6 +492,56 @@ transferCFGBlock(const CFGBlock &Block, AnalysisContext &AC, return State; } +static Environment initializeEnvironment(const Environment &InitEnv) { martinboehme wrote: > Why not include this function as part of the Environment API? Good point -- done. `initFIeldsGlobalsAndFuncs()` is now private again. All in all, this makes the API feel cleaner. https://github.com/llvm/llvm-project/pull/73860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)
@@ -492,6 +492,56 @@ transferCFGBlock(const CFGBlock &Block, AnalysisContext &AC, return State; } +static Environment initializeEnvironment(const Environment &InitEnv) { + Environment ResultEnv = InitEnv.fork(); martinboehme wrote: Now that this code has been moved to `Environment::initialize()`, the initialization happens in place there, and that function doesn't contain a `fork()`. However, `runTypeErasedDataflowAnalysis()` now does a `fork()`, and I wanted to comment briefly on this. `runTypeErasedDataflowAnalysis()` takes a const reference to the `Environment`, so it can't initialize this existing `Environment` in place and instead has to fork it. (Previously, when the `Environment` constructor did all the initialization, this wasn't necessary because `runTypeErasedDataflowAnalysis()` received a fully initialized environment.) I had considered changing the interface of `runTypeErasedDataflowAnalysis()` to take the `Environment` either by non-const reference or by value (as the caller typically no longer needs the `Environment` it has), but I decided against this because it would require changes in multiple analyses. If we want to, we can always make this change in a followup patch. https://github.com/llvm/llvm-project/pull/73860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)
@@ -92,11 +96,39 @@ class DataflowAnalysisContext { /*Logger=*/nullptr}); ~DataflowAnalysisContext(); + /// Sets a callback that returns the names and types of the synthetic fields + /// to add to a `RecordStorageLocation` of a given type. + /// Typically, this is called from the constructor of a `DataflowAnalysis` + /// + /// To maintain the invariant that all `RecordStorageLocation`s of a given + /// type have the same fields: + /// * The callback must always return the same result for a given type + /// * `setSyntheticFieldCallback()` must be called before any + // `RecordStorageLocation`s are created. martinboehme wrote: > Can this be integrated into the constructor? Could be in a followup patch (to > minimize further churn in this one). Unfortunately, that doesn't work because `setSyntheticFieldCallback()` needs to be called by the `DataflowAnalysis`, and the `DataflowAnalysis` doesn't create the `DataflowAnalysisContext` (i.e. it can't pass anything to its constructor). I think we could consider changing this though: I don't think there's anything that would prevent the `DataflowAnalysis` itself from creating the `DataflowAnalysisContext`, and then the synthetic field callback could simply be a constructor parameter. This would require changing existing analyses, however, so I don't think this is something to tackle as part of this patch. https://github.com/llvm/llvm-project/pull/73860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Catch missing format attributes (PR #70024)
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 f1d0276e4c42301155e900424ea734aca7ec97a8 a70de331784f4058f11ab6e01efaa025263bd232 -- clang/test/Sema/attr-format-missing.c clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDeclAttr.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 064506e70960..3947ba26939e 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -2048,8 +2048,8 @@ public: QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity); QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, - Expr *ArraySize, unsigned Quals, - SourceRange Brackets, DeclarationName Entity); + Expr *ArraySize, unsigned Quals, SourceRange Brackets, + DeclarationName Entity); QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc); QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc); @@ -2141,14 +2141,11 @@ public: const FunctionProtoType *Old, SourceLocation OldLoc, const FunctionProtoType *New, SourceLocation NewLoc); bool handlerCanCatch(QualType HandlerType, QualType ExceptionType); - bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID, -const PartialDiagnostic &NestedDiagID, -const PartialDiagnostic &NoteID, -const PartialDiagnostic &NoThrowDiagID, -const FunctionProtoType *Superset, -SourceLocation SuperLoc, -const FunctionProtoType *Subset, -SourceLocation SubLoc); + bool CheckExceptionSpecSubset( + const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID, + const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID, + const FunctionProtoType *Superset, SourceLocation SuperLoc, + const FunctionProtoType *Subset, SourceLocation SubLoc); bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const FunctionProtoType *Target, @@ -3432,9 +3429,8 @@ public: void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl &AllIvarDecls); - Decl *ActOnIvar(Scope *S, SourceLocation DeclStart, - Declarator &D, Expr *BitfieldWidth, - tok::ObjCKeywordKind visibility); + Decl *ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, + Expr *BitfieldWidth, tok::ObjCKeywordKind visibility); // This is used for both record definitions and ObjC interface declarations. void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, @@ -3789,7 +3785,7 @@ public: bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType); bool IsBlockPointerConversion(QualType FromType, QualType ToType, -QualType& ConvertedType); +QualType &ConvertedType); bool FunctionParamTypesAreEqual(const FunctionProtoType *OldType, const FunctionProtoType *NewType, unsigned *ArgPos = nullptr, @@ -4145,8 +4141,7 @@ public: QualType DestTypeForComplaining = QualType(), unsigned DiagIDForComplaining = 0); - Expr *FixOverloadedFunctionReference(Expr *E, - DeclAccessPair FoundDecl, + Expr *FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn); ExprResult FixOverloadedFunctionReference(ExprResult, DeclAccessPair FoundDecl, @@ -6222,32 +6217,29 @@ public: /// \param ConstructKind - a CXXConstructExpr::ConstructionKind ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, -NamedDecl *FoundDecl, -CXXConstructorDecl *Constructor, MultiExprArg Exprs, -bool HadMultipleCandidates, bool IsListInitialization, -bool IsStdInitListInitialization, -bool RequiresZeroInit, unsigned ConstructKind, -SourceRange ParenRange); +NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, +
[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)
@@ -92,11 +96,39 @@ class DataflowAnalysisContext { /*Logger=*/nullptr}); ~DataflowAnalysisContext(); + /// Sets a callback that returns the names and types of the synthetic fields + /// to add to a `RecordStorageLocation` of a given type. + /// Typically, this is called from the constructor of a `DataflowAnalysis` + /// + /// To maintain the invariant that all `RecordStorageLocation`s of a given + /// type have the same fields: + /// * The callback must always return the same result for a given type + /// * `setSyntheticFieldCallback()` must be called before any + // `RecordStorageLocation`s are created. martinboehme wrote: > I was wondering if having a single `SyntheticFieldCallback` will be too > restrictive in the future. What if an ananlysis wants to use modeling both > for optionals and some other data structure, both having its own callbacks? A single synthetic field callback can handle any number of different types, so the analysis wouldn't need to set more than one callback. Maybe, however, you're thinking of a scenario where we might want to run several analyses at the same time? I think this is something we've discussed in the past, and in this scenario each analysis would of course potentially want to be able to set its own synthetic field callback. As we currently don't have the ability to run more than one analysis at the same time, I think it is currently sufficient to only support a single callback as well. https://github.com/llvm/llvm-project/pull/73860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)
@@ -73,7 +73,13 @@ class ScalarStorageLocation final : public StorageLocation { /// /// Contains storage locations for all modeled fields of the record (also /// referred to as "children"). The child map is flat, so accessible members of -/// the base class are directly accesible as children of this location. +/// the base class are directly accessible as children of this location. +/// +/// Record storage locations may also contain so-called synthetic fields. These +/// are typically used to the internal state of a class (e.g. the value stored martinboehme wrote: Thanks for catching -- done! https://github.com/llvm/llvm-project/pull/73860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)
@@ -54,6 +54,18 @@ void clang::dataflow::copyRecord(RecordStorageLocation &Src, } } + for (const auto &[Name, PropLocSrc] : Src.synthetic_fields()) { +if (PropLocSrc->getType()->isRecordType()) { + copyRecord(*cast(PropLocSrc), + cast(Dst.getSyntheticField(Name)), Env); +} else { + if (Value *Val = Env.getValue(*PropLocSrc)) martinboehme wrote: `else if` would reduce indentation, but it would also lose the grouping that we currently have: The outer `else` block handles the case where the synthetic field isn't a record type. Having this indented within its own block makes it clearer which parts of the code handle which case -- so unless you feel strongly, I'd like to keep this as is. https://github.com/llvm/llvm-project/pull/73860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)
@@ -92,11 +96,39 @@ class DataflowAnalysisContext { /*Logger=*/nullptr}); ~DataflowAnalysisContext(); + /// Sets a callback that returns the names and types of the synthetic fields + /// to add to a `RecordStorageLocation` of a given type. + /// Typically, this is called from the constructor of a `DataflowAnalysis` + /// + /// To maintain the invariant that all `RecordStorageLocation`s of a given + /// type have the same fields: + /// * The callback must always return the same result for a given type + /// * `setSyntheticFieldCallback()` must be called before any + // `RecordStorageLocation`s are created. + void setSyntheticFieldCallback( + std::function(QualType)> CB) { +assert(!RecordStorageLocationCreated); +SyntheticFieldCallback = CB; + } + /// Returns a new storage location appropriate for `Type`. /// /// A null `Type` is interpreted as the pointee type of `std::nullptr_t`. StorageLocation &createStorageLocation(QualType Type); + /// Creates a `RecordStorageLocation` for the given type and with the given + /// fields. + /// + /// Requirements: + /// + /// `FieldLocs` must contain exactly the fields returned by martinboehme wrote: I agree this would be nice (this is not the API that most callers should call), but this API is not just called from `Environment` (which is already a friend of the DataflowAnalysisContext) but also from Transfer.cpp -- and it's harder to set things up so that that latter call site is a friend. In the end, I don't think it's worth the effort of "locking down" this API -- the documentation makes it clear that the function has pretty exacting preconditions (which we assert within the implementation), which makes the function unattractive to a potential caller anyway. https://github.com/llvm/llvm-project/pull/73860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)
@@ -88,12 +94,12 @@ class ScalarStorageLocation final : public StorageLocation { class RecordStorageLocation final : public StorageLocation { public: using FieldToLoc = llvm::DenseMap; + using SyntheticFieldMap = llvm::StringMap; martinboehme wrote: This is an interesting idea, but I'm hesitant about mutating the `IdentifierTable` in something that is going to be used from a clang-tidy check, which will be sharing the `IdentifierTable` with other checks. I suppose we could always create our own mapping from strings to integers or pointers of some sort, which could then serve as the keys for the `SyntheticFieldMap` -- but I would lean towards leaving this as a potential future optimization that we would do if this does indeed turn out to be a performance issue. https://github.com/llvm/llvm-project/pull/73860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e59a0cd - [AArch64][SME2] Add SME2 builtins for zero { zt0 } (#72274)
Author: Matthew Devereau Date: 2023-12-01T14:30:39Z New Revision: e59a0cd7d80a9f1ab803c4ff7416c77e9a34ed1d URL: https://github.com/llvm/llvm-project/commit/e59a0cd7d80a9f1ab803c4ff7416c77e9a34ed1d DIFF: https://github.com/llvm/llvm-project/commit/e59a0cd7d80a9f1ab803c4ff7416c77e9a34ed1d.diff LOG: [AArch64][SME2] Add SME2 builtins for zero { zt0 } (#72274) See https://github.com/ARM-software/acle/pull/217 Patch by: Kerry McLaughlin kerry.mclaugh...@arm.com Added: clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c llvm/test/CodeGen/AArch64/sme2-intrinsics-zero-zt.ll Modified: clang/include/clang/Basic/arm_sme.td llvm/include/llvm/IR/IntrinsicsAArch64.td llvm/lib/Target/AArch64/AArch64ISelLowering.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.h llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td llvm/lib/Target/AArch64/SMEInstrFormats.td Removed: diff --git a/clang/include/clang/Basic/arm_sme.td b/clang/include/clang/Basic/arm_sme.td index 7aae3c832bb1fe2..34dbfff6c4c85cf 100644 --- a/clang/include/clang/Basic/arm_sme.td +++ b/clang/include/clang/Basic/arm_sme.td @@ -321,4 +321,9 @@ let TargetGuard = "sme2" in { let TargetGuard = "sme2" in { def SVLDR_ZT : Inst<"svldr_zt", "viQ", "", MergeNone, "aarch64_sme_ldr_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; def SVSTR_ZT : Inst<"svstr_zt", "vi%", "", MergeNone, "aarch64_sme_str_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA], [ImmCheck<0, ImmCheck0_0>]>; + +// +// Zero ZT0 +// + def SVZERO_ZT : Inst<"svzero_zt", "vi", "", MergeNone, "aarch64_sme_zero_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA], [ImmCheck<0, ImmCheck0_0>]>; } diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c new file mode 100644 index 000..31e8d6850fb289d --- /dev/null +++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_zero_zt.c @@ -0,0 +1,23 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s + +#include + +// CHECK-LABEL: @test_svzero_zt( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero.zt(i32 0) +// CHECK-NEXT:ret void +// +// CPP-CHECK-LABEL: @_Z14test_svzero_ztv( +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:tail call void @llvm.aarch64.sme.zero.zt(i32 0) +// CPP-CHECK-NEXT:ret void +// +void test_svzero_zt(void) __arm_streaming_compatible __arm_shared_za { + svzero_zt(0); +} diff --git a/llvm/include/llvm/IR/IntrinsicsAArch64.td b/llvm/include/llvm/IR/IntrinsicsAArch64.td index 60a8d98f3bc0d26..3c0a07be50607bb 100644 --- a/llvm/include/llvm/IR/IntrinsicsAArch64.td +++ b/llvm/include/llvm/IR/IntrinsicsAArch64.td @@ -3544,6 +3544,10 @@ let TargetPrefix = "aarch64" in { def int_aarch64_sme_ldr_zt : SME_LDR_STR_ZT_Intrinsic; def int_aarch64_sme_str_zt : SME_LDR_STR_ZT_Intrinsic; + // + // Zero ZT0 + // + def int_aarch64_sme_zero_zt : DefaultAttrsIntrinsic<[], [llvm_i32_ty], [ImmArg>, IntrWriteMem]>; } // SVE2.1 - ZIPQ1, ZIPQ2, UZPQ1, UZPQ2 diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 4379c3fde6f3c5d..68fa58dea5beb1f 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -2753,17 +2753,19 @@ AArch64TargetLowering::EmitFill(MachineInstr &MI, MachineBasicBlock *BB) const { return BB; } -MachineBasicBlock *AArch64TargetLowering::EmitZTSpillFill(MachineInstr &MI, - MachineBasicBlock *BB, - bool IsSpill) const { +MachineBasicBlock *AArch64TargetLowering::EmitZTInstr(MachineInstr &MI, + MachineBasicBlock *BB, + unsigned Opcode, + bool Op0IsDef) const { const TargetInstrInfo *TII = Subtarget->getInstrInfo(); MachineInstrBuilder MIB; - unsigned Opc = IsSpill ? AArch64::STR_TX : AArch64::LDR_TX; - auto Rs = IsSpill ? RegState::Kill : RegState::Define; - MI
[llvm] [clang] Add SME2 builtins for zero { zt0 } (PR #72274)
https://github.com/MDevereau closed https://github.com/llvm/llvm-project/pull/72274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Retrieve members from accessors called using member… (PR #73978)
ymand wrote: > @ymand Can you review? sure https://github.com/llvm/llvm-project/pull/73978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Retrieve members from accessors called using member… (PR #73978)
https://github.com/ymand edited https://github.com/llvm/llvm-project/pull/73978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Retrieve members from accessors called using member… (PR #73978)
https://github.com/ymand approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/73978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits