[compiler-rt] [flang] [libcxx] [clang] [clang-tools-extra] [llvm] [Clang][Sema] Fix qualifier restriction of overriden methods (PR #71696)
https://github.com/ecnelises updated https://github.com/llvm/llvm-project/pull/71696 >From 1d0109b7f370a3689a92e20ab52597b112669e47 Mon Sep 17 00:00:00 2001 From: Qiu Chaofan Date: Thu, 9 Nov 2023 00:00:26 +0800 Subject: [PATCH 1/4] [Clang][Sema] Fix qualifier restriction of overriden methods If return type of overriden method is pointer or reference to non-class type, qualifiers cannot be dropped. This also fixes check when qualifier of overriden method's class return type is not subset of super method's. --- .../clang/Basic/DiagnosticSemaKinds.td| 2 +- clang/lib/Sema/SemaDeclCXX.cpp| 15 +- clang/test/SemaCXX/virtual-override.cpp | 28 ++- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 18c2e861385e4..e60a7513d54e5 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2115,7 +2115,7 @@ def err_covariant_return_type_different_qualifications : Error< def err_covariant_return_type_class_type_more_qualified : Error< "return type of virtual function %0 is not covariant with the return type of " "the function it overrides (class type %1 is more qualified than class " - "type %2">; + "type %2)">; // C++ implicit special member functions def note_in_declaration_of_implicit_special_member : Note< diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 60786a880b9d3..b2c1f1fff9d7e 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -18469,7 +18469,7 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New, // The new class type must have the same or less qualifiers as the old type. - if (NewClassTy.isMoreQualifiedThan(OldClassTy)) { + if (!OldClassTy.isAtLeastAsQualifiedAs(NewClassTy)) { Diag(New->getLocation(), diag::err_covariant_return_type_class_type_more_qualified) << New->getDeclName() << NewTy << OldTy @@ -18479,6 +18479,19 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New, return true; } + // Non-class return types should not drop qualifiers in overriden method. + if (!OldClassTy->isStructureOrClassType() && + OldClassTy.getLocalCVRQualifiers() != + NewClassTy.getLocalCVRQualifiers()) { +Diag(New->getLocation(), + diag::err_covariant_return_type_different_qualifications) +<< New->getDeclName() << NewTy << OldTy +<< New->getReturnTypeSourceRange(); +Diag(Old->getLocation(), diag::note_overridden_virtual_function) +<< Old->getReturnTypeSourceRange(); +return true; + } + return false; } diff --git a/clang/test/SemaCXX/virtual-override.cpp b/clang/test/SemaCXX/virtual-override.cpp index 72abfc3cf51e1..003f4826a3d6c 100644 --- a/clang/test/SemaCXX/virtual-override.cpp +++ b/clang/test/SemaCXX/virtual-override.cpp @@ -87,7 +87,7 @@ class A { class B : A { virtual a* f(); - virtual const a* g(); // expected-error{{return type of virtual function 'g' is not covariant with the return type of the function it overrides (class type 'const a *' is more qualified than class type 'a *'}} + virtual const a* g(); // expected-error{{return type of virtual function 'g' is not covariant with the return type of the function it overrides (class type 'const a *' is more qualified than class type 'a *')}} }; } @@ -289,3 +289,29 @@ namespace PR8168 { static void foo() {} // expected-error{{'static' member function 'foo' overrides a virtual function}} }; } + +namespace T13 { + class A { + public: +virtual const int* foo(); // expected-note{{overridden virtual function is here}} + }; + + class B: public A { + public: +virtual int* foo(); // expected-error{{return type of virtual function 'foo' is not covariant with the return type of the function it overrides ('int *' has different qualifiers than 'const int *')}} + }; +} + +namespace T14 { + struct a {}; + + class A { + public: +virtual const a* foo(); // expected-note{{overridden virtual function is here}} + }; + + class B: public A { + public: +virtual volatile a* foo(); // expected-error{{return type of virtual function 'foo' is not covariant with the return type of the function it overrides (class type 'volatile a *' is more qualified than class type 'const a *')}} + }; +} >From 5f64fec64b51542abd72a9a870ae9e5fe357d026 Mon Sep 17 00:00:00 2001 From: Qiu Chaofan Date: Thu, 9 Nov 2023 17:49:33 +0800 Subject: [PATCH 2/4] Say 'different qualifiers' instead of 'more qualified' --- clang/test/SemaCXX/virtual-override.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/SemaCXX/virtual-override.cpp b/clang/test/SemaCXX/virtual-override.cpp index 003f4826a3d6c..3a10e15a663a5 100644 --- a/clang/test/SemaCXX/virtual-o
[clang] [clang-format][NFC] Use `prog` in clang-format-diff.py (PR #74399)
serge-sans-paille wrote: Much better! You can remove the useless `import os` then :-) https://github.com/llvm/llvm-project/pull/74399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Exclude non-template classes when checking if constraint refers to containing template arguments (PR #74265)
@@ -1714,6 +1714,8 @@ class ConstraintRefersToContainingTemplateChecker // Friend, likely because it was referred to without its template arguments. void CheckIfContainingRecord(const CXXRecordDecl *CheckingRD) { CheckingRD = CheckingRD->getMostRecentDecl(); +if (!CheckingRD->isTemplated()) antangelo wrote: What do you think about this example, which exercises this issue in the above case? https://godbolt.org/z/Yz1WEqM7M If I switch from `isTemplated()` to `getDescribedTemplate()` to only check `CheckingRD` itself, then clang will accept that code. Otherwise, as the patch is now, the example is rejected. What should be the correct behavior? https://github.com/llvm/llvm-project/pull/74265 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [flang] [clang] [clang-tools-extra] [llvm] [PowerPC][CodeGen] Exploit STMW and LMW in 32-bit big-endian mode. (PR #74415)
https://github.com/EsmeYi updated https://github.com/llvm/llvm-project/pull/74415 >From f6d0ef8357540c61a9c20774e3b170a8db5b72ca Mon Sep 17 00:00:00 2001 From: esmeyi Date: Tue, 5 Dec 2023 00:44:04 -0500 Subject: [PATCH 1/2] Exploit STMW and LMW in 32-bit big-endian mode. --- llvm/lib/Target/PowerPC/PPCFrameLowering.cpp | 76 - llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | 4 + llvm/test/CodeGen/PowerPC/stm-lm-merge.ll| 110 +++ 3 files changed, 188 insertions(+), 2 deletions(-) create mode 100644 llvm/test/CodeGen/PowerPC/stm-lm-merge.ll diff --git a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp index eb3bf3b2690b2..4d4ef6251a999 100644 --- a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp @@ -40,6 +40,12 @@ EnablePEVectorSpills("ppc-enable-pe-vector-spills", cl::desc("Enable spills in prologue to vector registers."), cl::init(false), cl::Hidden); +static cl::opt +EnableLoadStoreMultiple("ppc-enable-load-store-multiple", +cl::desc("Enable load/store multiple (only " + "support in 32-bit big-endian mode)."), +cl::init(false), cl::Hidden); + static unsigned computeReturnSaveOffset(const PPCSubtarget &STI) { if (STI.isAIXABI()) return STI.isPPC64() ? 16 : 8; @@ -2407,6 +2413,30 @@ bool PPCFrameLowering::assignCalleeSavedSpillSlots( return AllSpilledToReg; } +static void findContinuousLoadStore(ArrayRef CSI, +Register &MergeFrom) { + CalleeSavedInfo BeginI = CSI[0]; + unsigned I = 1, E = CSI.size(); + for (; I < E; ++I) { +// Find continuous store/load. +unsigned RegDiff = CSI[I].getReg() - CSI[I - 1].getReg(); +unsigned FrameIdxDiff = CSI[I - 1].getFrameIdx() - CSI[I].getFrameIdx(); +Register BeginReg = BeginI.getReg(); +if (BeginReg < PPC::R0 || BeginReg > PPC::R31 || BeginI.isSpilledToReg() || +RegDiff != 1 || FrameIdxDiff != 1) + BeginI = CSI[I]; +if (CSI[I].getReg() == PPC::R31) + break; + } + + if (I == E || BeginI.getReg() == PPC::R31) +return; + + // Record the first reg that STMW/LMW are going to merge since STMW/LMW save + // from rN to r31. + MergeFrom = BeginI.getReg(); +} + bool PPCFrameLowering::spillCalleeSavedRegisters( MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef CSI, const TargetRegisterInfo *TRI) const { @@ -2437,6 +2467,11 @@ bool PPCFrameLowering::spillCalleeSavedRegisters( } } + Register MergeFrom = PPC::R31; + if (EnableLoadStoreMultiple && !Subtarget.isLittleEndian() && + !Subtarget.isPPC64()) +findContinuousLoadStore(CSI, MergeFrom); + for (const CalleeSavedInfo &I : CSI) { Register Reg = I.getReg(); @@ -2521,7 +2556,23 @@ bool PPCFrameLowering::spillCalleeSavedRegisters( !MF->getFunction().hasFnAttribute(Attribute::NoUnwind)) TII.storeRegToStackSlotNoUpd(MBB, MI, Reg, !IsLiveIn, I.getFrameIdx(), RC, TRI); -else +else if (MergeFrom < PPC::R31 && Reg == MergeFrom) { + // Build an STMW instruction. + int FrameIdx = I.getFrameIdx(); + MachineInstrBuilder MIB = + BuildMI(MBB, MBB.begin(), DL, TII.get(PPC::STMW)); + MIB.addReg(Reg, getKillRegState(!IsLiveIn)); + // Add frame reference. + MIB.addImm(0).addFrameIndex(FrameIdx); + const MachineFrameInfo &MFI = MF->getFrameInfo(); + MachineMemOperand *MMO = MF->getMachineMemOperand( + MachinePointerInfo::getFixedStack(*MF, FrameIdx), + MachineMemOperand::MOStore, MFI.getObjectSize(FrameIdx), + MFI.getObjectAlign(FrameIdx)); + MIB.addMemOperand(MMO); +} else if (Reg > MergeFrom && Reg <= PPC::R31) + continue; + else TII.storeRegToStackSlot(MBB, MI, Reg, !IsLiveIn, I.getFrameIdx(), RC, TRI, Register()); } @@ -2615,6 +2666,11 @@ bool PPCFrameLowering::restoreCalleeSavedRegisters( unsigned CSIIndex = 0; BitVector Restored(TRI->getNumRegs()); + Register MergeFrom = PPC::R31; + if (EnableLoadStoreMultiple && !Subtarget.isLittleEndian() && + !Subtarget.isPPC64()) +findContinuousLoadStore(CSI, MergeFrom); + // Initialize insertion-point logic; we will be restoring in reverse // order of spill. MachineBasicBlock::iterator I = MI, BeforeI = I; @@ -2694,7 +2750,23 @@ bool PPCFrameLowering::restoreCalleeSavedRegisters( !MF->getFunction().hasFnAttribute(Attribute::NoUnwind)) TII.loadRegFromStackSlotNoUpd(MBB, I, Reg, CSI[i].getFrameIdx(), RC, TRI); -else +else if (MergeFrom < PPC::R31 && Reg == MergeFrom) { + // Buil
[clang] [clang] Add per-global code model attribute (PR #72078)
https://github.com/heiher updated https://github.com/llvm/llvm-project/pull/72078 >From e3863873ab817dacf8680763bb42d91f005fe5ea Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Fri, 10 Nov 2023 21:07:48 -0600 Subject: [PATCH 1/3] [clang] Add per-global code model attribute This patch adds a per-global code model attribute, which can override the target's code model to access global variables. Currently, the code model attribute is only supported on LoongArch. This patch also maps GCC's code model names to LLVM's, which allows for better compatibility between the two compilers. Suggested-by: Arthur Eubanks Signed-off-by: WANG Rui Link: https://discourse.llvm.org/t/how-to-best-implement-code-model-overriding-for-certain-values/71816 Link: https://discourse.llvm.org/t/rfc-add-per-global-code-model-attribute/74944 --- clang/include/clang/Basic/Attr.td | 8 + clang/include/clang/Basic/AttrDocs.td | 9 ++ .../clang/Basic/DiagnosticSemaKinds.td| 2 ++ clang/lib/CodeGen/CodeGenModule.cpp | 13 clang/lib/Sema/SemaDeclAttr.cpp | 30 +++ clang/test/CodeGen/LoongArch/attributes.c | 10 +++ ...a-attribute-supported-attributes-list.test | 1 + clang/test/Sema/loongarch-attr-model.c| 13 8 files changed, 86 insertions(+) create mode 100644 clang/test/CodeGen/LoongArch/attributes.c create mode 100644 clang/test/Sema/loongarch-attr-model.c diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 1800f584c7e10..d5b5717f3d77c 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -2718,6 +2718,14 @@ def PragmaClangTextSection : InheritableAttr { let Documentation = [InternalOnly]; } +def CodeModel : InheritableAttr { + let Spellings = [GCC<"model">]; + let Args = [StringArgument<"Model">]; + let Subjects = + SubjectList<[ GlobalVar ], ErrorDiag>; + let Documentation = [CodeModelDocs]; +} + def Sentinel : InheritableAttr { let Spellings = [GCC<"sentinel">]; let Args = [DefaultIntArgument<"Sentinel", 0>, diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index b45ec6bbb8d37..1d37c2da6bec0 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -57,6 +57,15 @@ global variable or function should be in after translation. let Heading = "section, __declspec(allocate)"; } +def CodeModelDocs : Documentation { + let Category = DocCatVariable; + let Content = [{ +The ``model`` attribute allows you to specify a specific code model a +global variable should be in after translation. + }]; + let Heading = "model"; +} + def UsedDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 6dfb2d7195203..d438fdde9ac7e 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3408,6 +3408,8 @@ def warn_objc_redundant_literal_use : Warning< def err_attr_tlsmodel_arg : Error<"tls_model must be \"global-dynamic\", " "\"local-dynamic\", \"initial-exec\" or \"local-exec\"">; +def err_attr_codemodel_arg : Error<"code_model '%0' is not yet supported on this target">; + def err_aix_attr_unsupported_tls_model : Error<"TLS model '%0' is not yet supported on AIX">; def err_tls_var_aligned_over_maximum : Error< diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index dea58a7ff4146..1f49721e79ddc 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4841,6 +4841,19 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty, isExternallyVisible(D->getLinkageAndVisibility().getLinkage())) GV->setSection(".cp.rodata"); +// Handle code model attribute +if (D->hasAttr()) { + if (const CodeModelAttr *CMA = D->getAttr()) { +auto CM = llvm::StringSwitch(CMA->getModel()) + .Case("tiny", llvm::CodeModel::Tiny) + .Case("kernel", llvm::CodeModel::Kernel) + .Case("medium", llvm::CodeModel::Medium) + .Case("large", llvm::CodeModel::Large) + .Default(llvm::CodeModel::Small); +GV->setCodeModel(CM); + } +} + // Check if we a have a const declaration with an initializer, we may be // able to emit it as available_externally to expose it's value to the // optimizer. diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 87c78d742d0ff..64aa242dbb04f 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -3369,6 +3369,33 @@ static void handleSectionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { } } +static void handleCodeModelAttr(
[clang] [clang-format][NFC] Use `prog` in clang-format-diff.py (PR #74399)
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/74399 >From ee039e7c50751fabdbaadae73a0a09bc905620f2 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Mon, 4 Dec 2023 17:33:47 -0800 Subject: [PATCH 1/3] [clang-format][NFC] Use `prog` in clang-format-diff.py This is a minor improvement to #73491. --- clang/tools/clang-format/clang-format-diff.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py index b25ee8f433751..946e28163420d 100755 --- a/clang/tools/clang-format/clang-format-diff.py +++ b/clang/tools/clang-format/clang-format-diff.py @@ -37,9 +37,8 @@ def main(): -basename = os.path.basename(sys.argv[0]) parser = argparse.ArgumentParser( -description=__doc__.format(clang_format_diff=basename), +description=__doc__.format(clang_format_diff='%(prog)s'), formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument( >From d8b2dab602b41deda70abd0f219ca88d5fd69c36 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Mon, 4 Dec 2023 17:41:58 -0800 Subject: [PATCH 2/3] Use double quotes instead. --- clang/tools/clang-format/clang-format-diff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py index 946e28163420d..9f3538608aaba 100755 --- a/clang/tools/clang-format/clang-format-diff.py +++ b/clang/tools/clang-format/clang-format-diff.py @@ -38,7 +38,7 @@ def main(): parser = argparse.ArgumentParser( -description=__doc__.format(clang_format_diff='%(prog)s'), +description=__doc__.format(clang_format_diff="%(prog)s"), formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument( >From 6ff8c2870bfb093cc5a02d0f6caa5c869cf5ec29 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 5 Dec 2023 00:51:16 -0800 Subject: [PATCH 3/3] Remove now unneeded `import os`. --- clang/tools/clang-format/clang-format-diff.py | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py index 9f3538608aaba..0a2c24743678d 100755 --- a/clang/tools/clang-format/clang-format-diff.py +++ b/clang/tools/clang-format/clang-format-diff.py @@ -25,7 +25,6 @@ import argparse import difflib -import os import re import subprocess import sys ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Use `prog` in clang-format-diff.py (PR #74399)
owenca wrote: > You can remove the useless `import os` then :-) Good catch! https://github.com/llvm/llvm-project/pull/74399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][SME2] Add _x2/_x4 svqrshr builtins. (PR #74100)
https://github.com/sdesmalen-arm approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/74100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][SME2] Remove IsPreservesZA from ldr_zt builtin (PR #74303)
https://github.com/sdesmalen-arm approved this pull request. https://github.com/llvm/llvm-project/pull/74303 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [compiler-rt] [clang-tools-extra] [clang] [llvm] [PowerPC][CodeGen] Exploit STMW and LMW in 32-bit big-endian mode. (PR #74415)
https://github.com/EsmeYi updated https://github.com/llvm/llvm-project/pull/74415 >From f6d0ef8357540c61a9c20774e3b170a8db5b72ca Mon Sep 17 00:00:00 2001 From: esmeyi Date: Tue, 5 Dec 2023 00:44:04 -0500 Subject: [PATCH 1/3] Exploit STMW and LMW in 32-bit big-endian mode. --- llvm/lib/Target/PowerPC/PPCFrameLowering.cpp | 76 - llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | 4 + llvm/test/CodeGen/PowerPC/stm-lm-merge.ll| 110 +++ 3 files changed, 188 insertions(+), 2 deletions(-) create mode 100644 llvm/test/CodeGen/PowerPC/stm-lm-merge.ll diff --git a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp index eb3bf3b2690b2..4d4ef6251a999 100644 --- a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp @@ -40,6 +40,12 @@ EnablePEVectorSpills("ppc-enable-pe-vector-spills", cl::desc("Enable spills in prologue to vector registers."), cl::init(false), cl::Hidden); +static cl::opt +EnableLoadStoreMultiple("ppc-enable-load-store-multiple", +cl::desc("Enable load/store multiple (only " + "support in 32-bit big-endian mode)."), +cl::init(false), cl::Hidden); + static unsigned computeReturnSaveOffset(const PPCSubtarget &STI) { if (STI.isAIXABI()) return STI.isPPC64() ? 16 : 8; @@ -2407,6 +2413,30 @@ bool PPCFrameLowering::assignCalleeSavedSpillSlots( return AllSpilledToReg; } +static void findContinuousLoadStore(ArrayRef CSI, +Register &MergeFrom) { + CalleeSavedInfo BeginI = CSI[0]; + unsigned I = 1, E = CSI.size(); + for (; I < E; ++I) { +// Find continuous store/load. +unsigned RegDiff = CSI[I].getReg() - CSI[I - 1].getReg(); +unsigned FrameIdxDiff = CSI[I - 1].getFrameIdx() - CSI[I].getFrameIdx(); +Register BeginReg = BeginI.getReg(); +if (BeginReg < PPC::R0 || BeginReg > PPC::R31 || BeginI.isSpilledToReg() || +RegDiff != 1 || FrameIdxDiff != 1) + BeginI = CSI[I]; +if (CSI[I].getReg() == PPC::R31) + break; + } + + if (I == E || BeginI.getReg() == PPC::R31) +return; + + // Record the first reg that STMW/LMW are going to merge since STMW/LMW save + // from rN to r31. + MergeFrom = BeginI.getReg(); +} + bool PPCFrameLowering::spillCalleeSavedRegisters( MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef CSI, const TargetRegisterInfo *TRI) const { @@ -2437,6 +2467,11 @@ bool PPCFrameLowering::spillCalleeSavedRegisters( } } + Register MergeFrom = PPC::R31; + if (EnableLoadStoreMultiple && !Subtarget.isLittleEndian() && + !Subtarget.isPPC64()) +findContinuousLoadStore(CSI, MergeFrom); + for (const CalleeSavedInfo &I : CSI) { Register Reg = I.getReg(); @@ -2521,7 +2556,23 @@ bool PPCFrameLowering::spillCalleeSavedRegisters( !MF->getFunction().hasFnAttribute(Attribute::NoUnwind)) TII.storeRegToStackSlotNoUpd(MBB, MI, Reg, !IsLiveIn, I.getFrameIdx(), RC, TRI); -else +else if (MergeFrom < PPC::R31 && Reg == MergeFrom) { + // Build an STMW instruction. + int FrameIdx = I.getFrameIdx(); + MachineInstrBuilder MIB = + BuildMI(MBB, MBB.begin(), DL, TII.get(PPC::STMW)); + MIB.addReg(Reg, getKillRegState(!IsLiveIn)); + // Add frame reference. + MIB.addImm(0).addFrameIndex(FrameIdx); + const MachineFrameInfo &MFI = MF->getFrameInfo(); + MachineMemOperand *MMO = MF->getMachineMemOperand( + MachinePointerInfo::getFixedStack(*MF, FrameIdx), + MachineMemOperand::MOStore, MFI.getObjectSize(FrameIdx), + MFI.getObjectAlign(FrameIdx)); + MIB.addMemOperand(MMO); +} else if (Reg > MergeFrom && Reg <= PPC::R31) + continue; + else TII.storeRegToStackSlot(MBB, MI, Reg, !IsLiveIn, I.getFrameIdx(), RC, TRI, Register()); } @@ -2615,6 +2666,11 @@ bool PPCFrameLowering::restoreCalleeSavedRegisters( unsigned CSIIndex = 0; BitVector Restored(TRI->getNumRegs()); + Register MergeFrom = PPC::R31; + if (EnableLoadStoreMultiple && !Subtarget.isLittleEndian() && + !Subtarget.isPPC64()) +findContinuousLoadStore(CSI, MergeFrom); + // Initialize insertion-point logic; we will be restoring in reverse // order of spill. MachineBasicBlock::iterator I = MI, BeforeI = I; @@ -2694,7 +2750,23 @@ bool PPCFrameLowering::restoreCalleeSavedRegisters( !MF->getFunction().hasFnAttribute(Attribute::NoUnwind)) TII.loadRegFromStackSlotNoUpd(MBB, I, Reg, CSI[i].getFrameIdx(), RC, TRI); -else +else if (MergeFrom < PPC::R31 && Reg == MergeFrom) { + // Buil
[llvm] [clang] [clang][RISCV] Change default abi when only have f extension but no d extension (PR #73489)
jacquesguan wrote: soft ping... Any more advice? https://github.com/llvm/llvm-project/pull/73489 ___ 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,233 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2 + +// 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: define dso_local @test_svluti4_lane_zt_u16 +// CHECK-SAME: ( [[ZN:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call { , , , } @llvm.aarch64.sme.luti4.lane.zt.x4.nxv8i16(i32 0, [[ZN]], i32 0) +// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , , , } [[TMP0]], 0 +// CHECK-NEXT:[[TMP2:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( poison, [[TMP1]], i64 0) +// CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , , , } [[TMP0]], 1 +// CHECK-NEXT:[[TMP4:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP2]], [[TMP3]], i64 8) +// CHECK-NEXT:[[TMP5:%.*]] = extractvalue { , , , } [[TMP0]], 2 +// CHECK-NEXT:[[TMP6:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP4]], [[TMP5]], i64 16) +// CHECK-NEXT:[[TMP7:%.*]] = extractvalue { , , , } [[TMP0]], 3 +// CHECK-NEXT:[[TMP8:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP6]], [[TMP7]], i64 24) +// CHECK-NEXT:ret [[TMP8]] +// +// CPP-CHECK-LABEL: define dso_local @_Z24test_svluti4_lane_zt_u16u11__SVUint8_t +// CPP-CHECK-SAME: ( [[ZN:%.*]]) #[[ATTR0:[0-9]+]] { +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call { , , , } @llvm.aarch64.sme.luti4.lane.zt.x4.nxv8i16(i32 0, [[ZN]], i32 0) +// CPP-CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , , , } [[TMP0]], 0 +// CPP-CHECK-NEXT:[[TMP2:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( poison, [[TMP1]], i64 0) +// CPP-CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , , , } [[TMP0]], 1 +// CPP-CHECK-NEXT:[[TMP4:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP2]], [[TMP3]], i64 8) +// CPP-CHECK-NEXT:[[TMP5:%.*]] = extractvalue { , , , } [[TMP0]], 2 +// CPP-CHECK-NEXT:[[TMP6:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP4]], [[TMP5]], i64 16) +// CPP-CHECK-NEXT:[[TMP7:%.*]] = extractvalue { , , , } [[TMP0]], 3 +// CPP-CHECK-NEXT:[[TMP8:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP6]], [[TMP7]], i64 24) +// CPP-CHECK-NEXT:ret [[TMP8]] +// +svuint16x4_t test_svluti4_lane_zt_u16(svuint8_t zn) __arm_streaming __arm_shared_za __arm_preserves_za { + return svluti4_lane_zt_u16_x4(0, zn, 0); sdesmalen-arm wrote: ```suggestion return svluti4_lane_zt_u16_x4(0, zn, 1); ``` Rather than using `0` as the immediate, can you use the maximum range value in this and other tests? 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] [SME2] Add LUTI2 and LUTI4 quad Builtins and Intrinsics (PR #73317)
https://github.com/sdesmalen-arm edited 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] [SME2] Add LUTI2 and LUTI4 quad Builtins and Intrinsics (PR #73317)
https://github.com/sdesmalen-arm commented: Looks mostly fine, just have a few nits. 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
[clang] [llvm] [SME2] Add LUTI2 and LUTI4 quad Builtins and Intrinsics (PR #73317)
@@ -321,9 +321,18 @@ 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 // +let TargetGuard = "sme2" in { sdesmalen-arm wrote: nit: I'm not really sure why this is formatted like: ``` let TargetGuard = "sme2" in { A } let TargetGuard = "sme2" in { B } let TargetGuard = "sme2" in { C } ``` Rather than: ``` let TargetGuard = "sme2" in { A B C } ``` 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
[clang] [llvm] [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 sdesmalen-arm wrote: Do we actually need `-target-feature +sve` here? 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] [SME2] Add LUTI2 and LUTI4 quad Builtins and Intrinsics (PR #73317)
@@ -1864,6 +1866,35 @@ void AArch64DAGToDAGISel::SelectFrintFromVT(SDNode *N, unsigned NumVecs, SelectUnaryMultiIntrinsic(N, NumVecs, true, Opcode); } +void AArch64DAGToDAGISel::SelectMultiVectorLuti(SDNode *Node, +unsigned NumOutVecs, +unsigned Opc, +uint32_t MaxImm) { + if (ConstantSDNode *Imm = dyn_cast(Node->getOperand(4))) +if (Imm->getZExtValue() > MaxImm) + return; + + SDValue ZtValue; + if (!ImmToReg(Node->getOperand(2), ZtValue)) +return; + SDValue Ops[] = {ZtValue, Node->getOperand(3), Node->getOperand(4)}; + SDLoc DL(Node); + EVT VT = Node->getValueType(0); + + SDNode *Instruction = + CurDAG->getMachineNode(Opc, DL, {MVT::Untyped, MVT::Other}, Ops); + SDValue SuperReg = SDValue(Instruction, 0); + + for (unsigned i = 0; i < NumOutVecs; ++i) sdesmalen-arm wrote: nit: variable names should start with upper-case ```suggestion for (unsigned I = 0; I < NumOutVecs; ++I) ``` 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
[clang] [Sema] Warning for _Float16 passed to format specifier '%f' (PR #74439)
https://github.com/Luhaocong created https://github.com/llvm/llvm-project/pull/74439 According to https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2844.pdf, default argument promotions for _FloatN types has been removed. A warning is needed to notice user to promote _Float16 to double explicitly, and then pass it to format specifier '%f', which is consistent with GCC. Fixes: https://github.com/llvm/llvm-project/issues/68538 >From 10c48f5c8c50617929cc72401721afc379131346 Mon Sep 17 00:00:00 2001 From: Lu Haocong Date: Tue, 5 Dec 2023 16:45:22 +0800 Subject: [PATCH] [Sema] Warning for _Float16 passed to format specifier '%f' According to https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2844.pdf, default argument promotions for _FloatN types has been removed. A warning is needed to notice user to promote _Float16 to double explicitly, and then pass it to format specifier '%f', which is consistent with GCC. --- clang/lib/AST/FormatString.cpp | 1 - clang/test/AST/variadic-promotion.c | 5 + clang/test/Sema/attr-format.c | 7 +++ clang/test/SemaCXX/attr-format.cpp | 1 + clang/test/SemaCXX/format-strings-scanf.cpp | 16 ++-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index e0c9e18cfe3a2..c5d14b4af7ff1 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -488,7 +488,6 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { return NoMatchPromotionTypeConfusion; break; case BuiltinType::Half: -case BuiltinType::Float16: case BuiltinType::Float: if (T == C.DoubleTy) return MatchPromotion; diff --git a/clang/test/AST/variadic-promotion.c b/clang/test/AST/variadic-promotion.c index 41c7fec8d7943..7cbadb832ca80 100644 --- a/clang/test/AST/variadic-promotion.c +++ b/clang/test/AST/variadic-promotion.c @@ -18,3 +18,8 @@ void test_floating_promotion(__fp16 *f16, float f32, double f64) { // CHECK: ImplicitCastExpr {{.*}} 'double' // CHECK-NEXT: 'float' } + +void test_Float16_no_default_promotion(_Float16 f16) { + variadic(1, f16); +// CHECK-NOT: ImplicitCastExpr {{.*}} 'double' +} diff --git a/clang/test/Sema/attr-format.c b/clang/test/Sema/attr-format.c index 1f4c864d4f78b..bdfd8425c4e9a 100644 --- a/clang/test/Sema/attr-format.c +++ b/clang/test/Sema/attr-format.c @@ -16,6 +16,8 @@ typedef const char *xpto; void j(xpto c, va_list list) __attribute__((format(printf, 1, 0))); // no-error void k(xpto c) __attribute__((format(printf, 1, 0))); // no-error +void l(char *a, _Float16 b) __attribute__((format(printf, 1, 2))); // expected-warning {{GCC requires a function with the 'format' attribute to be variadic}} + void y(char *str) __attribute__((format(strftime, 1, 0))); // no-error void z(char *str, int c, ...) __attribute__((format(strftime, 1, 2))); // expected-error {{strftime format attribute requires 3rd parameter to be 0}} @@ -93,6 +95,11 @@ void call_nonvariadic(void) { d3("%s", 123); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} } +void call_no_default_promotion(void) { + a("%f", (_Float16)1.0); // expected-warning{{format specifies type 'double' but the argument has type '_Float16'}} + l("%f", (_Float16)1.0); // expected-warning{{format specifies type 'double' but the argument has type '_Float16'}} +} + __attribute__((format(printf, 1, 2))) void forward_fixed(const char *fmt, _Bool b, char i, short j, int k, float l, double m) { // expected-warning{{GCC requires a function with the 'format' attribute to be variadic}} forward_fixed(fmt, b, i, j, k, l, m); diff --git a/clang/test/SemaCXX/attr-format.cpp b/clang/test/SemaCXX/attr-format.cpp index adc05fc46776c..4509c3a95e8ef 100644 --- a/clang/test/SemaCXX/attr-format.cpp +++ b/clang/test/SemaCXX/attr-format.cpp @@ -81,6 +81,7 @@ void do_format() { format("%c %c %hhd %hd %d\n", (char)'a', 'a', 'a', (short)123, (int)123); format("%f %f %f\n", (__fp16)123.f, 123.f, 123.); + format("%f", (_Float16)123.f);// expected-warning{{format specifies type 'double' but the argument has type '_Float16'}} format("%Lf", (__fp16)123.f); // expected-warning{{format specifies type 'long double' but the argument has type '__fp16'}} format("%Lf", 123.f); // expected-warning{{format specifies type 'long double' but the argument has type 'float'}} format("%hhi %hhu %hi %hu %i %u", b, b, b, b, b, b); diff --git a/clang/test/SemaCXX/format-strings-scanf.cpp b/clang/test/SemaCXX/format-strings-scanf.cpp index 25fe5346791a0..406c2069e28ca 100644 --- a/clang/test/SemaCXX/format-strings-scanf.cpp +++ b/clang/test/SemaCXX/format-strings-scanf.cpp @@ -22,6 +22,7 @@ union bag { unsigned long long ull; signed long long sll; __fp16 f16; +_Float16 Float16;
[clang] [Sema] Warning for _Float16 passed to format specifier '%f' (PR #74439)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Haocong Lu (Luhaocong) Changes According to https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2844.pdf, default argument promotions for _FloatN types has been removed. A warning is needed to notice user to promote _Float16 to double explicitly, and then pass it to format specifier '%f', which is consistent with GCC. Fixes: https://github.com/llvm/llvm-project/issues/68538 --- Full diff: https://github.com/llvm/llvm-project/pull/74439.diff 5 Files Affected: - (modified) clang/lib/AST/FormatString.cpp (-1) - (modified) clang/test/AST/variadic-promotion.c (+5) - (modified) clang/test/Sema/attr-format.c (+7) - (modified) clang/test/SemaCXX/attr-format.cpp (+1) - (modified) clang/test/SemaCXX/format-strings-scanf.cpp (+10-6) ``diff diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index e0c9e18cfe3a2..c5d14b4af7ff1 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -488,7 +488,6 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { return NoMatchPromotionTypeConfusion; break; case BuiltinType::Half: -case BuiltinType::Float16: case BuiltinType::Float: if (T == C.DoubleTy) return MatchPromotion; diff --git a/clang/test/AST/variadic-promotion.c b/clang/test/AST/variadic-promotion.c index 41c7fec8d7943..7cbadb832ca80 100644 --- a/clang/test/AST/variadic-promotion.c +++ b/clang/test/AST/variadic-promotion.c @@ -18,3 +18,8 @@ void test_floating_promotion(__fp16 *f16, float f32, double f64) { // CHECK: ImplicitCastExpr {{.*}} 'double' // CHECK-NEXT: 'float' } + +void test_Float16_no_default_promotion(_Float16 f16) { + variadic(1, f16); +// CHECK-NOT: ImplicitCastExpr {{.*}} 'double' +} diff --git a/clang/test/Sema/attr-format.c b/clang/test/Sema/attr-format.c index 1f4c864d4f78b..bdfd8425c4e9a 100644 --- a/clang/test/Sema/attr-format.c +++ b/clang/test/Sema/attr-format.c @@ -16,6 +16,8 @@ typedef const char *xpto; void j(xpto c, va_list list) __attribute__((format(printf, 1, 0))); // no-error void k(xpto c) __attribute__((format(printf, 1, 0))); // no-error +void l(char *a, _Float16 b) __attribute__((format(printf, 1, 2))); // expected-warning {{GCC requires a function with the 'format' attribute to be variadic}} + void y(char *str) __attribute__((format(strftime, 1, 0))); // no-error void z(char *str, int c, ...) __attribute__((format(strftime, 1, 2))); // expected-error {{strftime format attribute requires 3rd parameter to be 0}} @@ -93,6 +95,11 @@ void call_nonvariadic(void) { d3("%s", 123); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} } +void call_no_default_promotion(void) { + a("%f", (_Float16)1.0); // expected-warning{{format specifies type 'double' but the argument has type '_Float16'}} + l("%f", (_Float16)1.0); // expected-warning{{format specifies type 'double' but the argument has type '_Float16'}} +} + __attribute__((format(printf, 1, 2))) void forward_fixed(const char *fmt, _Bool b, char i, short j, int k, float l, double m) { // expected-warning{{GCC requires a function with the 'format' attribute to be variadic}} forward_fixed(fmt, b, i, j, k, l, m); diff --git a/clang/test/SemaCXX/attr-format.cpp b/clang/test/SemaCXX/attr-format.cpp index adc05fc46776c..4509c3a95e8ef 100644 --- a/clang/test/SemaCXX/attr-format.cpp +++ b/clang/test/SemaCXX/attr-format.cpp @@ -81,6 +81,7 @@ void do_format() { format("%c %c %hhd %hd %d\n", (char)'a', 'a', 'a', (short)123, (int)123); format("%f %f %f\n", (__fp16)123.f, 123.f, 123.); + format("%f", (_Float16)123.f);// expected-warning{{format specifies type 'double' but the argument has type '_Float16'}} format("%Lf", (__fp16)123.f); // expected-warning{{format specifies type 'long double' but the argument has type '__fp16'}} format("%Lf", 123.f); // expected-warning{{format specifies type 'long double' but the argument has type 'float'}} format("%hhi %hhu %hi %hu %i %u", b, b, b, b, b, b); diff --git a/clang/test/SemaCXX/format-strings-scanf.cpp b/clang/test/SemaCXX/format-strings-scanf.cpp index 25fe5346791a0..406c2069e28ca 100644 --- a/clang/test/SemaCXX/format-strings-scanf.cpp +++ b/clang/test/SemaCXX/format-strings-scanf.cpp @@ -22,6 +22,7 @@ union bag { unsigned long long ull; signed long long sll; __fp16 f16; +_Float16 Float16; float ff; double fd; long double fl; @@ -51,18 +52,21 @@ void test(void) { // expected-warning@+1{{format specifies type 'int *' but the argument has type 'short *'}} scan("%hhi %i %li", &b.ss, &b.ss, &b.ss); -// expected-warning@+3{{format specifies type 'float *' but the argument has type '__fp16 *'}} +// expected-warning@+4{{format specifies type 'float *' but the argument has type '__fp16 *'}} +// expect
[llvm] [clang] [Sema] Implement support for -Wformat-signedness (PR #74440)
https://github.com/karka228 created https://github.com/llvm/llvm-project/pull/74440 In gcc there exist a modifier option -Wformat-signedness that turns on additional signedness warnings in the already existing -Wformat warning. This patch implements that support in clang. >From a80bf9d03f19d48c0aca4af7758dc49516da8825 Mon Sep 17 00:00:00 2001 From: Karl-Johan Karlsson Date: Tue, 5 Dec 2023 10:03:00 +0100 Subject: [PATCH] [Sema] Implement support for -Wformat-signedness In gcc there exist a modifier option -Wformat-signedness that turns on additional signedness warnings in the already existing -Wformat warning. This patch implements that support in clang. --- clang/include/clang/AST/FormatString.h| 2 + .../include/clang/Basic/DiagnosticOptions.def | 1 + clang/include/clang/Driver/Options.td | 3 + clang/lib/AST/FormatString.cpp| 29 +++-- clang/lib/Driver/ToolChains/Clang.cpp | 2 + clang/lib/Sema/SemaChecking.cpp | 26 - format-strings-signedness.c | 107 ++ 7 files changed, 158 insertions(+), 12 deletions(-) create mode 100644 format-strings-signedness.c diff --git a/clang/include/clang/AST/FormatString.h b/clang/include/clang/AST/FormatString.h index 5c4ad9baaef60..c267a32be4d6f 100644 --- a/clang/include/clang/AST/FormatString.h +++ b/clang/include/clang/AST/FormatString.h @@ -264,6 +264,8 @@ class ArgType { /// The conversion specifier and the argument type are compatible. For /// instance, "%d" and int. Match = 1, +/// The conversion specifier and the argument type have different sign +MatchSignedness, /// The conversion specifier and the argument type are compatible because of /// default argument promotions. For instance, "%hhd" and int. MatchPromotion, diff --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def index 6d0c1b14acc12..a9562e7d8dcb0 100644 --- a/clang/include/clang/Basic/DiagnosticOptions.def +++ b/clang/include/clang/Basic/DiagnosticOptions.def @@ -44,6 +44,7 @@ DIAGOPT(Name, Bits, Default) #endif SEMANTIC_DIAGOPT(IgnoreWarnings, 1, 0) /// -w +DIAGOPT(FormatSignedness, 1, 0) /// -Wformat-signedness DIAGOPT(NoRewriteMacros, 1, 0) /// -Wno-rewrite-macros DIAGOPT(Pedantic, 1, 0) /// -pedantic DIAGOPT(PedanticErrors, 1, 0) /// -pedantic-errors diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 1d04e4f6e7e6d..04fdf9a7eb92d 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -918,6 +918,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, HelpText<"Enable warnings for deprecated constructs and define __DEPRECATED">; def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, Visibility<[ClangOption, CC1Option]>; +def Wformat_signedness : Flag<["-"], "Wformat-signedness">, + Flags<[HelpHidden]>, Visibility<[ClangOption, CC1Option]>, + MarshallingInfoFlag>; def Wl_COMMA : CommaJoined<["-"], "Wl,">, Visibility<[ClangOption, FlangOption]>, Flags<[LinkerInput, RenderAsInput]>, HelpText<"Pass the comma separated arguments in to the linker">, diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index e0c9e18cfe3a2..670cde017d3ac 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -409,7 +409,7 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { return Match; if (const auto *BT = argTy->getAs()) { // Check if the only difference between them is signed vs unsigned -// if true, we consider they are compatible. +// if true, return match signedness. switch (BT->getKind()) { default: break; @@ -419,44 +419,53 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { [[fallthrough]]; case BuiltinType::Char_S: case BuiltinType::SChar: +if (T == C.UnsignedShortTy || T == C.ShortTy) + return NoMatchTypeConfusion; +if (T == C.UnsignedCharTy) + return MatchSignedness; +if (T == C.SignedCharTy) + return Match; +break; case BuiltinType::Char_U: case BuiltinType::UChar: if (T == C.UnsignedShortTy || T == C.ShortTy) return NoMatchTypeConfusion; -if (T == C.UnsignedCharTy || T == C.SignedCharTy) +if (T == C.UnsignedCharTy) return Match; +if (T == C.SignedCharTy) + return MatchSignedness; break; case BuiltinType::Short: if (T == C.UnsignedShortTy) - return Match; + return MatchSignedness; break; case BuiltinType::UShort: if (T == C.ShortTy) - return Match; + return MatchSignedn
[llvm] [clang] [Sema] Implement support for -Wformat-signedness (PR #74440)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Karl-Johan Karlsson (karka228) Changes In gcc there exist a modifier option -Wformat-signedness that turns on additional signedness warnings in the already existing -Wformat warning. This patch implements that support in clang. --- Full diff: https://github.com/llvm/llvm-project/pull/74440.diff 7 Files Affected: - (modified) clang/include/clang/AST/FormatString.h (+2) - (modified) clang/include/clang/Basic/DiagnosticOptions.def (+1) - (modified) clang/include/clang/Driver/Options.td (+3) - (modified) clang/lib/AST/FormatString.cpp (+19-10) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+2) - (modified) clang/lib/Sema/SemaChecking.cpp (+24-2) - (added) format-strings-signedness.c (+107) ``diff diff --git a/clang/include/clang/AST/FormatString.h b/clang/include/clang/AST/FormatString.h index 5c4ad9baaef60..c267a32be4d6f 100644 --- a/clang/include/clang/AST/FormatString.h +++ b/clang/include/clang/AST/FormatString.h @@ -264,6 +264,8 @@ class ArgType { /// The conversion specifier and the argument type are compatible. For /// instance, "%d" and int. Match = 1, +/// The conversion specifier and the argument type have different sign +MatchSignedness, /// The conversion specifier and the argument type are compatible because of /// default argument promotions. For instance, "%hhd" and int. MatchPromotion, diff --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def index 6d0c1b14acc12..a9562e7d8dcb0 100644 --- a/clang/include/clang/Basic/DiagnosticOptions.def +++ b/clang/include/clang/Basic/DiagnosticOptions.def @@ -44,6 +44,7 @@ DIAGOPT(Name, Bits, Default) #endif SEMANTIC_DIAGOPT(IgnoreWarnings, 1, 0) /// -w +DIAGOPT(FormatSignedness, 1, 0) /// -Wformat-signedness DIAGOPT(NoRewriteMacros, 1, 0) /// -Wno-rewrite-macros DIAGOPT(Pedantic, 1, 0) /// -pedantic DIAGOPT(PedanticErrors, 1, 0) /// -pedantic-errors diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 1d04e4f6e7e6d..04fdf9a7eb92d 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -918,6 +918,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, HelpText<"Enable warnings for deprecated constructs and define __DEPRECATED">; def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, Visibility<[ClangOption, CC1Option]>; +def Wformat_signedness : Flag<["-"], "Wformat-signedness">, + Flags<[HelpHidden]>, Visibility<[ClangOption, CC1Option]>, + MarshallingInfoFlag>; def Wl_COMMA : CommaJoined<["-"], "Wl,">, Visibility<[ClangOption, FlangOption]>, Flags<[LinkerInput, RenderAsInput]>, HelpText<"Pass the comma separated arguments in to the linker">, diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index e0c9e18cfe3a2..670cde017d3ac 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -409,7 +409,7 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { return Match; if (const auto *BT = argTy->getAs()) { // Check if the only difference between them is signed vs unsigned -// if true, we consider they are compatible. +// if true, return match signedness. switch (BT->getKind()) { default: break; @@ -419,44 +419,53 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { [[fallthrough]]; case BuiltinType::Char_S: case BuiltinType::SChar: +if (T == C.UnsignedShortTy || T == C.ShortTy) + return NoMatchTypeConfusion; +if (T == C.UnsignedCharTy) + return MatchSignedness; +if (T == C.SignedCharTy) + return Match; +break; case BuiltinType::Char_U: case BuiltinType::UChar: if (T == C.UnsignedShortTy || T == C.ShortTy) return NoMatchTypeConfusion; -if (T == C.UnsignedCharTy || T == C.SignedCharTy) +if (T == C.UnsignedCharTy) return Match; +if (T == C.SignedCharTy) + return MatchSignedness; break; case BuiltinType::Short: if (T == C.UnsignedShortTy) - return Match; + return MatchSignedness; break; case BuiltinType::UShort: if (T == C.ShortTy) - return Match; + return MatchSignedness; break; case BuiltinType::Int: if (T == C.UnsignedIntTy) - return Match; + return MatchSignedness; break; case BuiltinType::UInt: if (T == C.IntTy) - return Match; + return MatchSignedness; break; case BuiltinType::Long: if (T == C.
[llvm] [clang] [Sema] Implement support for -Wformat-signedness (PR #74440)
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 383e35048e16c85ab26bc46822d3ceb11fd4d3f2 a80bf9d03f19d48c0aca4af7758dc49516da8825 -- format-strings-signedness.c clang/include/clang/AST/FormatString.h clang/lib/AST/FormatString.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Sema/SemaChecking.cpp `` View the diff from clang-format here. ``diff diff --git a/format-strings-signedness.c b/format-strings-signedness.c index 02964def10..876094ea4f 100644 --- a/format-strings-signedness.c +++ b/format-strings-signedness.c @@ -1,65 +1,68 @@ -// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat -Wformat-signedness %s +// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat -Wformat-signedness +// %s int printf(const char *restrict format, ...); -int scanf(const char * restrict, ...); +int scanf(const char *restrict, ...); -void test_printf_bool(_Bool x) -{ -printf("%d", x); // no-warning -printf("%u", x); // expected-warning{{format specifies type 'unsigned int' but the argument has type '_Bool'}} -printf("%x", x); // expected-warning{{format specifies type 'unsigned int' but the argument has type '_Bool'}} +void test_printf_bool(_Bool x) { + printf("%d", x); // no-warning + printf("%u", x); // expected-warning{{format specifies type 'unsigned int' but + // the argument has type '_Bool'}} + printf("%x", x); // expected-warning{{format specifies type 'unsigned int' but + // the argument has type '_Bool'}} } -void test_printf_char(char x) -{ -printf("%c", x); // no-warning +void test_printf_char(char x) { + printf("%c", x); // no-warning } -void test_printf_unsigned_char(unsigned char x) -{ -printf("%c", x); // no-warning +void test_printf_unsigned_char(unsigned char x) { + printf("%c", x); // no-warning } -void test_printf_int(int x) -{ -printf("%d", x); // no-warning -printf("%u", x); // expected-warning{{format specifies type 'unsigned int' but the argument has type 'int'}} -printf("%x", x); // expected-warning{{format specifies type 'unsigned int' but the argument has type 'int'}} +void test_printf_int(int x) { + printf("%d", x); // no-warning + printf("%u", x); // expected-warning{{format specifies type 'unsigned int' but + // the argument has type 'int'}} + printf("%x", x); // expected-warning{{format specifies type 'unsigned int' but + // the argument has type 'int'}} } -void test_printf_unsigned(unsigned x) -{ -printf("%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'unsigned int'}} -printf("%u", x); // no-warning -printf("%x", x); // no-warning +void test_printf_unsigned(unsigned x) { + printf("%d", x); // expected-warning{{format specifies type 'int' but the + // argument has type 'unsigned int'}} + printf("%u", x); // no-warning + printf("%x", x); // no-warning } -void test_printf_long(long x) -{ -printf("%ld", x); // no-warning -printf("%lu", x); // expected-warning{{format specifies type 'unsigned long' but the argument has type 'long'}} -printf("%lx", x); // expected-warning{{format specifies type 'unsigned long' but the argument has type 'long'}} +void test_printf_long(long x) { + printf("%ld", x); // no-warning + printf("%lu", x); // expected-warning{{format specifies type 'unsigned long' +// but the argument has type 'long'}} + printf("%lx", x); // expected-warning{{format specifies type 'unsigned long' +// but the argument has type 'long'}} } -void test_printf_unsigned_long(unsigned long x) -{ -printf("%ld", x); // expected-warning{{format specifies type 'long' but the argument has type 'unsigned long'}} -printf("%lu", x); // no-warning -printf("%lx", x); // no-warning +void test_printf_unsigned_long(unsigned long x) { + printf("%ld", x); // expected-warning{{format specifies type 'long' but the +// argument has type 'unsigned long'}} + printf("%lu", x); // no-warning + printf("%lx", x); // no-warning } -void test_printf_long_long(long long x) -{ -printf("%lld", x); // no-warning -printf("%llu", x); // expected-warning{{format specifies type 'unsigned long long' but the argument has type 'long long'}} -printf("%llx", x); // expected-warning{{format specifies type 'unsigned long long' but the argument has type 'long long'}} +void test_printf_long_long(long long x) { + printf("%lld", x); // no-warning + printf("%llu", x); // expected-warning{{format specifies type 'unsigned long + // long' but the argument has type 'long long'}} + printf("%llx", x); // expected-warning{{format specifies type 'unsigned long + // long' but the argument has type
[flang] [mlir] [compiler-rt] [clang-tools-extra] [clang] [libcxx] [llvm] [mlir] Fix a zero stride canonicalizer crash (PR #74200)
https://github.com/rikhuijzer updated https://github.com/llvm/llvm-project/pull/74200 >From 22928e7e5da508d8d9dc8d4b7e54f84cccadef06 Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Mon, 20 Nov 2023 09:02:41 +0100 Subject: [PATCH 1/6] [mlir][tensor] Fix canon via `hasNegativeDimension` --- mlir/include/mlir/Dialect/Tensor/IR/Tensor.h | 6 ++ mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | 15 +++ mlir/test/Dialect/Tensor/canonicalize.mlir | 10 ++ 3 files changed, 31 insertions(+) diff --git a/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h b/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h index 06642adda42b3..0d027057b3a95 100644 --- a/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h +++ b/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h @@ -150,6 +150,12 @@ LogicalResult getOrCreateDestinations(OpBuilder &b, Location loc, Operation *op, /// Tests if types are the same when ignoring encoding on ranked tensors. bool isSameTypeWithoutEncoding(Type tp1, Type tp2); +/// Helper function to check whether the dimensions are non-negative. This +/// check also occurs in the verifier, but we need it at later stages too +/// because the verifier ignores dynamic dimensions, but later stages might +/// have constant folded those to (negative) constants. +bool hasNegativeDimension(SmallVector shape); + /// Function to control the folding of constant and extract slice. using ControlConstantExtractSliceFusionFn = std::function; diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp index e469815496e18..3297ef673ca2e 100644 --- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp +++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp @@ -125,6 +125,12 @@ bool tensor::isSameTypeWithoutEncoding(Type tp1, Type tp2) { return tp1 == tp2; // default implementation } +bool tensor::hasNegativeDimension(SmallVector shape) { + return llvm::any_of(shape, [](int64_t dim) { +return !ShapedType::isDynamic(dim) && dim < 0; + }); +} + /// Compute the dropped dimensions of a rank-reducing tensor.extract_slice op or /// rank-extending tensor.insert_slice op. static llvm::SmallBitVector getDroppedDims(ArrayRef reducedShape, @@ -1801,6 +1807,10 @@ RankedTensorType ExtractSliceOp::inferCanonicalRankReducedResultType( dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets); dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes); dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides); + if (hasNegativeDimension(staticOffsets)) +return {}; + if (hasNegativeDimension(staticSizes)) +return {}; return ExtractSliceOp::inferCanonicalRankReducedResultType( desiredResultRank, sourceRankedTensorType, staticOffsets, staticSizes, staticStrides); @@ -2370,6 +2380,8 @@ class InsertSliceOpConstantArgumentFolder final auto sourceType = ExtractSliceOp::inferCanonicalRankReducedResultType( insertSliceOp.getSourceType().getRank(), insertSliceOp.getDestType(), mixedOffsets, mixedSizes, mixedStrides); +if (!sourceType) + return failure(); Value toInsert = insertSliceOp.getSource(); if (sourceType != insertSliceOp.getSourceType()) { OpBuilder::InsertionGuard g(rewriter); @@ -2500,6 +2512,8 @@ struct InsertSliceOpSourceCastInserter final getConstantIntValue(insertSliceOp.getMixedSizes()[i])) newSrcShape[i] = *constInt; } +// if (hasNegativeDimension(newSrcShape)) +// return failure(); RankedTensorType newSrcType = RankedTensorType::get(newSrcShape, srcType.getElementType()); @@ -2521,6 +2535,7 @@ struct InsertSliceOpSourceCastInserter final rewriter.setInsertionPoint(insertSliceOp->getParentOp()); Value cast = rewriter.create( insertSliceOp.getLoc(), newSrcType, insertSliceOp.getSource()); + rewriter.replaceOpWithNewOp( insertSliceOp, cast, insertSliceOp.getDest(), insertSliceOp.getMixedOffsets(), insertSliceOp.getMixedSizes(), diff --git a/mlir/test/Dialect/Tensor/canonicalize.mlir b/mlir/test/Dialect/Tensor/canonicalize.mlir index ea8c17640d7c1..88f27d3d36b04 100644 --- a/mlir/test/Dialect/Tensor/canonicalize.mlir +++ b/mlir/test/Dialect/Tensor/canonicalize.mlir @@ -1102,6 +1102,16 @@ func.func @no_fold_collapse_of_expand_empty_expr(%arg0: tensor<3x2x2xf32>) // - +func.func @no_fold_extract_slice_negative_offset(%arg0: tensor<8xf32>) -> tensor { + %c-1 = arith.constant -1 : index + %e = tensor.extract_slice %arg0[1] [%c-1] [1] : tensor<8xf32> to tensor + return %e : tensor +} +// CHECK-LABEL: func @no_fold_extract_slice_negative_offset +// CHECK: tensor.extract_slice + +// - + func.func @reshape_splat_constant_int32() -> tensor<2x4x2xi32> { %c0 = arith.constant dense<42> : tensor<2x8xi32> %0 = tensor.expand_shape %c0 [[0], [1, 2]] >From ecef5428c160cb72103e06a160c450440ce1f416 Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Mon, 20 Nov 2023 16:27:53 +0100
[llvm] [clang] main (PR #74441)
https://github.com/andreas-schwab created https://github.com/llvm/llvm-project/pull/74441 - [Bazel] Add support for targeting Linux riscv64 - [Driver] Add riscv64-suse-linux triple >From fa28e94a057a8916843178c4948d9f7a8ab7c146 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 2 May 2022 16:10:05 +0200 Subject: [PATCH 1/2] [Bazel] Add support for targeting Linux riscv64 --- utils/bazel/llvm-project-overlay/llvm/config.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl index b15ec9e1bb399..6538da1cf38b4 100644 --- a/utils/bazel/llvm-project-overlay/llvm/config.bzl +++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl @@ -93,6 +93,7 @@ llvm_config_defines = os_defines + select({ "@bazel_tools//src/conditions:darwin_x86_64": native_arch_defines("X86", "x86_64-unknown-darwin"), "@bazel_tools//src/conditions:linux_aarch64": native_arch_defines("AArch64", "aarch64-unknown-linux-gnu"), "@bazel_tools//src/conditions:linux_ppc64le": native_arch_defines("PowerPC", "powerpc64le-unknown-linux-gnu"), +"@bazel_tools//src/conditions:linux_riscv64": native_arch_defines("RISCV", "riscv64-unknown-linux-gnu"), "@bazel_tools//src/conditions:linux_s390x": native_arch_defines("SystemZ", "systemz-unknown-linux_gnu"), "//conditions:default": native_arch_defines("X86", "x86_64-unknown-linux-gnu"), }) + [ >From 488ecd555ff5572663d75cd3a92de3ea856d5d57 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 4 Dec 2023 15:47:24 +0100 Subject: [PATCH 2/2] [Driver] Add riscv64-suse-linux triple Fixes: 72256 --- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index b875991844fff..00269e2d52e1c 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2423,7 +2423,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"}; static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu", "riscv64-linux-gnu", - "riscv64-unknown-elf"}; + "riscv64-unknown-elf", + "riscv64-suse-linux"}; static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] main (PR #74441)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Andreas Schwab (andreas-schwab) Changes - [Bazel] Add support for targeting Linux riscv64 - [Driver] Add riscv64-suse-linux triple --- Full diff: https://github.com/llvm/llvm-project/pull/74441.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+2-1) - (modified) utils/bazel/llvm-project-overlay/llvm/config.bzl (+1) ``diff diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index b875991844fff..00269e2d52e1c 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2423,7 +2423,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"}; static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu", "riscv64-linux-gnu", - "riscv64-unknown-elf"}; + "riscv64-unknown-elf", + "riscv64-suse-linux"}; static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl index b15ec9e1bb399..6538da1cf38b4 100644 --- a/utils/bazel/llvm-project-overlay/llvm/config.bzl +++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl @@ -93,6 +93,7 @@ llvm_config_defines = os_defines + select({ "@bazel_tools//src/conditions:darwin_x86_64": native_arch_defines("X86", "x86_64-unknown-darwin"), "@bazel_tools//src/conditions:linux_aarch64": native_arch_defines("AArch64", "aarch64-unknown-linux-gnu"), "@bazel_tools//src/conditions:linux_ppc64le": native_arch_defines("PowerPC", "powerpc64le-unknown-linux-gnu"), +"@bazel_tools//src/conditions:linux_riscv64": native_arch_defines("RISCV", "riscv64-unknown-linux-gnu"), "@bazel_tools//src/conditions:linux_s390x": native_arch_defines("SystemZ", "systemz-unknown-linux_gnu"), "//conditions:default": native_arch_defines("X86", "x86_64-unknown-linux-gnu"), }) + [ `` https://github.com/llvm/llvm-project/pull/74441 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [mlir] [compiler-rt] [clang-tools-extra] [clang] [libcxx] [llvm] [mlir] Fix a zero stride canonicalizer crash (PR #74200)
@@ -0,0 +1,14 @@ +// RUN: mlir-opt %s -inline -split-input-file | FileCheck %s + +// CHECK-LABEL: func @inline_negative_stride +func.func @inline_negative_stride(%arg0 : memref<10xf32>) -> memref<1xf32, strided<[?], offset: 1>> { + cf.br ^bb1(%arg0 : memref<10xf32>) +^bb1(%m: memref<10xf32>): + %c0 = arith.constant 0 : index + %c1 = arith.constant 1 : index + %1 = memref.subview %m[1] [1] [%c0] : memref<10xf32> to memref<1xf32, strided<[?], offset: 1>> + return %1 : memref<1xf32, strided<[?], offset: 1>> +} +// CHECK-NEXT: arith.constant 0 : index +// CHECK-NEXT: %[[SUBVIEW:.*]] = memref.subview +// CHECK-NEXT: return %[[SUBVIEW]] : memref<1xf32, strided<[?], offset: 1>> rikhuijzer wrote: I removed this file again. 👍 https://github.com/llvm/llvm-project/pull/74200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[mlir] [llvm] [clang] [flang] [compiler-rt] [clang-tools-extra] [libcxx] [mlir] Fix a zero stride canonicalizer crash (PR #74200)
https://github.com/rikhuijzer edited https://github.com/llvm/llvm-project/pull/74200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] main (PR #74441)
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 383e35048e16c85ab26bc46822d3ceb11fd4d3f2 488ecd555ff5572663d75cd3a92de3ea856d5d57 -- clang/lib/Driver/ToolChains/Gnu.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index 00269e2d52..b6a2700881 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2421,10 +2421,9 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( "riscv32-linux-gnu", "riscv32-unknown-elf"}; static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"}; - static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu", - "riscv64-linux-gnu", - "riscv64-unknown-elf", - "riscv64-suse-linux"}; + static const char *const RISCV64Triples[] = { + "riscv64-unknown-linux-gnu", "riscv64-linux-gnu", "riscv64-unknown-elf", + "riscv64-suse-linux"}; static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", `` https://github.com/llvm/llvm-project/pull/74441 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[mlir] [llvm] [clang] [flang] [compiler-rt] [clang-tools-extra] [libcxx] [mlir] Fix a zero stride canonicalizer crash (PR #74200)
https://github.com/rikhuijzer edited https://github.com/llvm/llvm-project/pull/74200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Warning for _Float16 passed to format specifier '%f' (PR #74439)
https://github.com/Luhaocong updated https://github.com/llvm/llvm-project/pull/74439 >From afb0d3909cde31cf73e2baf3efd13d584943704f Mon Sep 17 00:00:00 2001 From: Lu Haocong Date: Tue, 5 Dec 2023 16:45:22 +0800 Subject: [PATCH] [Sema] Warning for _Float16 passed to format specifier '%f' According to https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2844.pdf, default argument promotions for _FloatN types has been removed. A warning is needed to notice user to promote _Float16 to double explicitly, and then pass it to format specifier '%f', which is consistent with GCC. --- clang/lib/AST/FormatString.cpp | 1 - clang/test/AST/variadic-promotion.c | 5 + clang/test/Sema/attr-format.c | 7 +++ clang/test/SemaCXX/attr-format.cpp | 1 + clang/test/SemaCXX/format-strings-scanf.cpp | 16 ++-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index e0c9e18cfe3a2..c5d14b4af7ff1 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -488,7 +488,6 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { return NoMatchPromotionTypeConfusion; break; case BuiltinType::Half: -case BuiltinType::Float16: case BuiltinType::Float: if (T == C.DoubleTy) return MatchPromotion; diff --git a/clang/test/AST/variadic-promotion.c b/clang/test/AST/variadic-promotion.c index 41c7fec8d7943..7cbadb832ca80 100644 --- a/clang/test/AST/variadic-promotion.c +++ b/clang/test/AST/variadic-promotion.c @@ -18,3 +18,8 @@ void test_floating_promotion(__fp16 *f16, float f32, double f64) { // CHECK: ImplicitCastExpr {{.*}} 'double' // CHECK-NEXT: 'float' } + +void test_Float16_no_default_promotion(_Float16 f16) { + variadic(1, f16); +// CHECK-NOT: ImplicitCastExpr {{.*}} 'double' +} diff --git a/clang/test/Sema/attr-format.c b/clang/test/Sema/attr-format.c index 1f4c864d4f78b..bdfd8425c4e9a 100644 --- a/clang/test/Sema/attr-format.c +++ b/clang/test/Sema/attr-format.c @@ -16,6 +16,8 @@ typedef const char *xpto; void j(xpto c, va_list list) __attribute__((format(printf, 1, 0))); // no-error void k(xpto c) __attribute__((format(printf, 1, 0))); // no-error +void l(char *a, _Float16 b) __attribute__((format(printf, 1, 2))); // expected-warning {{GCC requires a function with the 'format' attribute to be variadic}} + void y(char *str) __attribute__((format(strftime, 1, 0))); // no-error void z(char *str, int c, ...) __attribute__((format(strftime, 1, 2))); // expected-error {{strftime format attribute requires 3rd parameter to be 0}} @@ -93,6 +95,11 @@ void call_nonvariadic(void) { d3("%s", 123); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} } +void call_no_default_promotion(void) { + a("%f", (_Float16)1.0); // expected-warning{{format specifies type 'double' but the argument has type '_Float16'}} + l("%f", (_Float16)1.0); // expected-warning{{format specifies type 'double' but the argument has type '_Float16'}} +} + __attribute__((format(printf, 1, 2))) void forward_fixed(const char *fmt, _Bool b, char i, short j, int k, float l, double m) { // expected-warning{{GCC requires a function with the 'format' attribute to be variadic}} forward_fixed(fmt, b, i, j, k, l, m); diff --git a/clang/test/SemaCXX/attr-format.cpp b/clang/test/SemaCXX/attr-format.cpp index adc05fc46776c..4509c3a95e8ef 100644 --- a/clang/test/SemaCXX/attr-format.cpp +++ b/clang/test/SemaCXX/attr-format.cpp @@ -81,6 +81,7 @@ void do_format() { format("%c %c %hhd %hd %d\n", (char)'a', 'a', 'a', (short)123, (int)123); format("%f %f %f\n", (__fp16)123.f, 123.f, 123.); + format("%f", (_Float16)123.f);// expected-warning{{format specifies type 'double' but the argument has type '_Float16'}} format("%Lf", (__fp16)123.f); // expected-warning{{format specifies type 'long double' but the argument has type '__fp16'}} format("%Lf", 123.f); // expected-warning{{format specifies type 'long double' but the argument has type 'float'}} format("%hhi %hhu %hi %hu %i %u", b, b, b, b, b, b); diff --git a/clang/test/SemaCXX/format-strings-scanf.cpp b/clang/test/SemaCXX/format-strings-scanf.cpp index 25fe5346791a0..406c2069e28ca 100644 --- a/clang/test/SemaCXX/format-strings-scanf.cpp +++ b/clang/test/SemaCXX/format-strings-scanf.cpp @@ -22,6 +22,7 @@ union bag { unsigned long long ull; signed long long sll; __fp16 f16; +_Float16 Float16; float ff; double fd; long double fl; @@ -51,18 +52,21 @@ void test(void) { // expected-warning@+1{{format specifies type 'int *' but the argument has type 'short *'}} scan("%hhi %i %li", &b.ss, &b.ss, &b.ss); -// expected-warning@+3{{format specifies type 'float *' but the argument has type '__fp16 *'}} +// expe
[llvm] [clang] [SME2] Add LUTI2 and LUTI4 quad Builtins and Intrinsics (PR #73317)
@@ -321,9 +321,18 @@ 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 // +let TargetGuard = "sme2" in { MDevereau wrote: I think these were added in individually which might explain it. The blocks of instructions are separated by the comments, and maybe it makes it easier to see what individual instructions need once the list of defs grow in size? I've no objections to your suggestion, but the rest of this file doesn't really follow it I think? 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] [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 MDevereau wrote: I'm not sure if this is a diagnostic problem but I get errors about requiring sve when using the C tuple types. 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
[clang-tools-extra] [libc] [compiler-rt] [lldb] [flang] [clang] [llvm] [mlir] [DAGCombiner] Combine frem into fdiv+ftrunc+fma (PR #67642)
ecnelises wrote: I tested with a number of random floating values. In most of the cases, the expanded result is exactly the same as libcall result. But when `fmod(a,b)` is very close to `b` (smaller than `1e-10`, for example, `fmod(521862.045173469, 31.048432006988875)`), the result would be totally wrong.. I'm thinking about a solution. https://github.com/llvm/llvm-project/pull/67642 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang] [XCOFF][obj2yaml] support parsing auxiliary symbols for XCOFF (PR #70642)
@@ -106,6 +126,210 @@ Error XCOFFDumper::dumpSections(ArrayRef Sections) { return Error::success(); } +Error XCOFFDumper::dumpFileAuxSym(XCOFFYAML::Symbol &Sym, + const XCOFFSymbolRef &SymbolEntRef) { + for (uint8_t I = 1; I <= Sym.NumberOfAuxEntries; ++I) { +uintptr_t AuxAddress = XCOFFObjectFile::getAdvancedSymbolEntryAddress( +SymbolEntRef.getEntryAddress(), I); +const XCOFFFileAuxEnt *FileAuxEntPtr = +getAuxEntPtr(AuxAddress); +auto FileNameOrError = Obj.getCFileName(FileAuxEntPtr); +if (!FileNameOrError) + return FileNameOrError.takeError(); + +XCOFFYAML::FileAuxEnt FileAuxSym; +FileAuxSym.FileNameOrString = FileNameOrError.get(); +FileAuxSym.FileStringType = FileAuxEntPtr->Type; +Sym.AuxEntries.push_back( EsmeYi wrote: If I understand you correctly, I think currently we have print the aux type in the yaml file regardless of whether it is 32-bit or 64-bit. There is a constructor in each aux symbol struct, like `FileAuxEnt():AuxSymbolEnt(AuxSymbolType::AUX_FILE) {}`, and we can verify this in the test file llvm/test/tools/obj2yaml/XCOFF/aux-symbols.yaml ( Although auxiliary symbol entries in XCOFF32 do not really have the x_auxtype field, it's no harm to print the info in yaml and it's helpful when transforming yaml to object. https://github.com/llvm/llvm-project/pull/70642 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6b8d659 - [flang] remove -f[no-]alias-analysis (#74343)
Author: Tom Eccles Date: 2023-12-05T10:03:57Z New Revision: 6b8d659062a0f9a7daa641432701dc6996939dc5 URL: https://github.com/llvm/llvm-project/commit/6b8d659062a0f9a7daa641432701dc6996939dc5 DIFF: https://github.com/llvm/llvm-project/commit/6b8d659062a0f9a7daa641432701dc6996939dc5.diff LOG: [flang] remove -f[no-]alias-analysis (#74343) Now that tbaa tags pass is enabled by default, I would like to remove these flags. `-fno-alias-analysis` was originally intended to be useful for debugging, but as it also disables tbaa tag generation in codegen, it turned out to be too noisy. @banach-space expressed that these flags felt too non-standard. The tbaa tags pass can be toggled using `-mllvm -disable-fir-alias-tags=0` Added: Modified: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp flang/lib/Frontend/CompilerInvocation.cpp flang/test/Driver/driver-help-hidden.f90 flang/test/Driver/driver-help.f90 flang/test/Driver/falias-analysis.f90 Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 1d04e4f6e7e6d..db2190318c931 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6344,9 +6344,6 @@ defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays", defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stride", PosFlag, NegFlag>; -defm alias_analysis : BoolOptionWithoutMarshalling<"f", "alias-analysis", - PosFlag, - NegFlag>; } // let Visibility = [FC1Option, FlangOption] def J : JoinedOrSeparate<["-"], "J">, diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 9db19e30a9f1f..9b21fe952af7a 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -143,33 +143,11 @@ void Flang::addCodegenOptions(const ArgList &Args, if (shouldLoopVersion(Args)) CmdArgs.push_back("-fversion-loops-for-stride"); - Arg *aliasAnalysis = Args.getLastArg(options::OPT_falias_analysis, - options::OPT_fno_alias_analysis); - // only pass on the argument if it does not match that implied by the - // optimization level: so if optimization is requested, only forward - // -fno-alias-analysis. If optimization is not requested, only forward - // -falias-analysis. - Arg *optLevel = - Args.getLastArg(options::OPT_Ofast, options::OPT_O, options::OPT_O4); - if (aliasAnalysis) { -bool faliasAnalysis = -aliasAnalysis->getOption().matches(options::OPT_falias_analysis); -if (optLevel && !faliasAnalysis) { - CmdArgs.push_back("-fno-alias-analysis"); -} else { - if (faliasAnalysis) -// requested alias analysis but no optimization enabled -CmdArgs.push_back("-falias-analysis"); -} - } - Args.addAllArgs(CmdArgs, {options::OPT_flang_experimental_hlfir, options::OPT_flang_deprecated_no_hlfir, options::OPT_flang_experimental_polymorphism, options::OPT_fno_ppc_native_vec_elem_order, -options::OPT_fppc_native_vec_elem_order, -options::OPT_falias_analysis, -options::OPT_fno_alias_analysis}); +options::OPT_fppc_native_vec_elem_order}); } void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const { diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 62b6c38768773..c623969a21e5e 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -243,11 +243,6 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts, opts.LoopVersioning = 1; opts.AliasAnalysis = opts.OptimizationLevel > 0; - if (auto *arg = - args.getLastArg(clang::driver::options::OPT_falias_analysis, - clang::driver::options::OPT_fno_alias_analysis)) -opts.AliasAnalysis = -arg->getOption().matches(clang::driver::options::OPT_falias_analysis); for (auto *a : args.filtered(clang::driver::options::OPT_fpass_plugin_EQ)) opts.LLVMPassPlugins.push_back(a->getValue()); diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90 index f420f1ef3290f..8cb8b54d59412 100644 --- a/flang/test/Driver/driver-help-hidden.f90 +++ b/flang/test/Driver/driver-help-hidden.f90 @@ -26,7 +26,6 @@ ! CHECK-NEXT: -D = Define to (or 1 if omitted) ! CHECK-NEXT: -emit-llvm Use the LLVM representation for assembler and object files ! CHECK-NEXT: -E Only run the preprocessor -! CHECK-NEXT: -falias-analysisPass alias information on to LLVM (default when op
[flang] [clang] [flang] remove -f[no-]alias-analysis (PR #74343)
https://github.com/tblah closed https://github.com/llvm/llvm-project/pull/74343 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Let the checkers query upper and lower bounds on symbols (PR #74141)
DonatNagyE wrote: With Z3 the new functionality does not work, but its absence is handled gracefully (the new methods return `NULL` and `core.BitwiseShift` emits the "old" message). The Z3 solver is very "shaky" ground for me (if I understand it correctly it's too slow for stand-alone use, and so I didn't pay too much attention to it), so I don't have the confidence to create FIXMEs/tickets (my understanding of the goals is too vague and I don't understand the priorities/importance at all). https://github.com/llvm/llvm-project/pull/74141 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libc] [clang-tools-extra] [flang] [compiler-rt] [llvm] [libc][NFC] Remove __support/bit.h and use __support/CPP/bit.h instead (PR #73939)
https://github.com/gchatelet updated https://github.com/llvm/llvm-project/pull/73939 >From 651cdece9397cf643cfafef7c65f4b8f44148d29 Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Thu, 30 Nov 2023 13:53:28 + Subject: [PATCH 1/3] [libc][NFC] Remove __support/bit.h and use __support/CPP/bit.h instead --- libc/src/__support/CMakeLists.txt | 8 +- libc/src/__support/FPUtil/CMakeLists.txt | 2 - libc/src/__support/FPUtil/FPBits.h| 3 +- libc/src/__support/FPUtil/Hypot.h | 11 +- .../__support/FPUtil/generic/CMakeLists.txt | 5 +- libc/src/__support/FPUtil/generic/FMA.h | 8 +- libc/src/__support/FPUtil/generic/FMod.h | 8 +- libc/src/__support/FPUtil/generic/sqrt.h | 13 +- .../FPUtil/generic/sqrt_80_bit_long_double.h | 6 +- libc/src/__support/HashTable/CMakeLists.txt | 12 +- libc/src/__support/HashTable/bitmask.h| 4 +- libc/src/__support/HashTable/table.h | 7 +- libc/src/__support/UInt.h | 4 +- libc/src/__support/bit.h | 117 -- libc/src/__support/hash.h | 8 +- libc/src/__support/integer_utils.h| 1 - libc/src/__support/memory_size.h | 17 ++- libc/src/__support/str_to_float.h | 5 +- libc/src/math/generic/CMakeLists.txt | 1 - libc/src/math/generic/powf.cpp| 5 +- libc/src/string/memory_utils/op_builtin.h | 22 ++-- libc/src/string/memory_utils/utils.h | 47 ++- libc/test/src/__support/CMakeLists.txt| 13 -- .../src/__support/HashTable/table_test.cpp| 3 +- libc/test/src/__support/bit_test.cpp | 67 -- libc/test/src/__support/memory_size_test.cpp | 11 ++ libc/test/src/search/hsearch_test.cpp | 4 +- .../src/string/memory_utils/utils_test.cpp| 60 - .../llvm-project-overlay/libc/BUILD.bazel | 19 +-- .../libc/test/src/__support/BUILD.bazel | 6 - .../test/src/math/libc_math_test_rules.bzl| 1 - 31 files changed, 105 insertions(+), 393 deletions(-) delete mode 100644 libc/src/__support/bit.h delete mode 100644 libc/test/src/__support/bit_test.cpp diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt index a76b22960f5a5..03305a2f06aae 100644 --- a/libc/src/__support/CMakeLists.txt +++ b/libc/src/__support/CMakeLists.txt @@ -140,13 +140,13 @@ add_header_library( .str_to_num_result .uint128 libc.src.__support.common +libc.src.__support.CPP.bit libc.src.__support.CPP.limits libc.src.__support.CPP.optional libc.src.__support.FPUtil.dyadic_float libc.src.__support.FPUtil.fenv_impl libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.rounding_mode -libc.src.__support.bit libc.src.errno.errno ) @@ -194,9 +194,9 @@ add_header_library( HDRS integer_utils.h DEPENDS -.bit .number_pair libc.src.__support.common +libc.src.__support.CPP.bit libc.src.__support.CPP.type_traits ) @@ -205,11 +205,11 @@ add_header_library( HDRS UInt.h DEPENDS -.bit .integer_utils .math_extras .number_pair libc.src.__support.CPP.array +libc.src.__support.CPP.bit libc.src.__support.CPP.type_traits libc.src.__support.macros.optimization ) @@ -236,8 +236,8 @@ add_header_library( HDRS hash.h DEPENDS -.bit .uint128 +libc.src.__support.CPP.bit libc.src.__support.macros.attributes ) diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt index 58a182eaa797b..3d6d712fc2058 100644 --- a/libc/src/__support/FPUtil/CMakeLists.txt +++ b/libc/src/__support/FPUtil/CMakeLists.txt @@ -41,7 +41,6 @@ add_header_library( libc.src.__support.common libc.src.__support.CPP.bit libc.src.__support.CPP.type_traits -libc.src.__support.bit ) add_header_library( @@ -146,7 +145,6 @@ add_header_library( libc.src.__support.common libc.src.__support.CPP.bit libc.src.__support.CPP.type_traits -libc.src.__support.bit libc.src.__support.uint128 ) diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h index 76a9fc6d772bf..dba0c7e0745c2 100644 --- a/libc/src/__support/FPUtil/FPBits.h +++ b/libc/src/__support/FPUtil/FPBits.h @@ -11,7 +11,6 @@ #include "src/__support/CPP/bit.h" #include "src/__support/CPP/type_traits.h" -#include "src/__support/bit.h" #include "src/__support/common.h" #include "src/__support/macros/attributes.h" // LIBC_INLINE @@ -222,7 +221,7 @@ template struct FPBits { LIBC_INLINE static constexpr FPBits make_value(UIntType number, int ep) { FPBits result; // offset: +1 for sign, but -1 for implicit first bit -int lz = unsafe_clz(number) - FloatProp::EXPONENT_WIDTH; +int lz = cpp::countl_zero(number) - FloatProp::EXPONENT_WIDTH; num
[flang] [clang] [flang][driver] Add -fno-fortran-main (link time) option to remove Fortran_main from link line (PR #74139)
https://github.com/tblah approved this pull request. Thanks for the fix. LGTM https://github.com/llvm/llvm-project/pull/74139 ___ 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)
nikic wrote: The problem for mpeg2decode seems to be that we do more `add` to `or disjoint` conversions. But `or disjoint` is still being implemented, so e.g. in SCEV we don't recognize it yet and fail to create an `add` SCEV for it. So I think we need to do some more work on `or disjoint` and then try again. 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] [llvm] [Sema] Implement support for -Wformat-signedness (PR #74440)
https://github.com/karka228 updated https://github.com/llvm/llvm-project/pull/74440 >From a80bf9d03f19d48c0aca4af7758dc49516da8825 Mon Sep 17 00:00:00 2001 From: Karl-Johan Karlsson Date: Tue, 5 Dec 2023 10:03:00 +0100 Subject: [PATCH 1/2] [Sema] Implement support for -Wformat-signedness In gcc there exist a modifier option -Wformat-signedness that turns on additional signedness warnings in the already existing -Wformat warning. This patch implements that support in clang. --- clang/include/clang/AST/FormatString.h| 2 + .../include/clang/Basic/DiagnosticOptions.def | 1 + clang/include/clang/Driver/Options.td | 3 + clang/lib/AST/FormatString.cpp| 29 +++-- clang/lib/Driver/ToolChains/Clang.cpp | 2 + clang/lib/Sema/SemaChecking.cpp | 26 - format-strings-signedness.c | 107 ++ 7 files changed, 158 insertions(+), 12 deletions(-) create mode 100644 format-strings-signedness.c diff --git a/clang/include/clang/AST/FormatString.h b/clang/include/clang/AST/FormatString.h index 5c4ad9baaef60..c267a32be4d6f 100644 --- a/clang/include/clang/AST/FormatString.h +++ b/clang/include/clang/AST/FormatString.h @@ -264,6 +264,8 @@ class ArgType { /// The conversion specifier and the argument type are compatible. For /// instance, "%d" and int. Match = 1, +/// The conversion specifier and the argument type have different sign +MatchSignedness, /// The conversion specifier and the argument type are compatible because of /// default argument promotions. For instance, "%hhd" and int. MatchPromotion, diff --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def index 6d0c1b14acc12..a9562e7d8dcb0 100644 --- a/clang/include/clang/Basic/DiagnosticOptions.def +++ b/clang/include/clang/Basic/DiagnosticOptions.def @@ -44,6 +44,7 @@ DIAGOPT(Name, Bits, Default) #endif SEMANTIC_DIAGOPT(IgnoreWarnings, 1, 0) /// -w +DIAGOPT(FormatSignedness, 1, 0) /// -Wformat-signedness DIAGOPT(NoRewriteMacros, 1, 0) /// -Wno-rewrite-macros DIAGOPT(Pedantic, 1, 0) /// -pedantic DIAGOPT(PedanticErrors, 1, 0) /// -pedantic-errors diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 1d04e4f6e7e6d..04fdf9a7eb92d 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -918,6 +918,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, HelpText<"Enable warnings for deprecated constructs and define __DEPRECATED">; def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, Visibility<[ClangOption, CC1Option]>; +def Wformat_signedness : Flag<["-"], "Wformat-signedness">, + Flags<[HelpHidden]>, Visibility<[ClangOption, CC1Option]>, + MarshallingInfoFlag>; def Wl_COMMA : CommaJoined<["-"], "Wl,">, Visibility<[ClangOption, FlangOption]>, Flags<[LinkerInput, RenderAsInput]>, HelpText<"Pass the comma separated arguments in to the linker">, diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index e0c9e18cfe3a2..670cde017d3ac 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -409,7 +409,7 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { return Match; if (const auto *BT = argTy->getAs()) { // Check if the only difference between them is signed vs unsigned -// if true, we consider they are compatible. +// if true, return match signedness. switch (BT->getKind()) { default: break; @@ -419,44 +419,53 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { [[fallthrough]]; case BuiltinType::Char_S: case BuiltinType::SChar: +if (T == C.UnsignedShortTy || T == C.ShortTy) + return NoMatchTypeConfusion; +if (T == C.UnsignedCharTy) + return MatchSignedness; +if (T == C.SignedCharTy) + return Match; +break; case BuiltinType::Char_U: case BuiltinType::UChar: if (T == C.UnsignedShortTy || T == C.ShortTy) return NoMatchTypeConfusion; -if (T == C.UnsignedCharTy || T == C.SignedCharTy) +if (T == C.UnsignedCharTy) return Match; +if (T == C.SignedCharTy) + return MatchSignedness; break; case BuiltinType::Short: if (T == C.UnsignedShortTy) - return Match; + return MatchSignedness; break; case BuiltinType::UShort: if (T == C.ShortTy) - return Match; + return MatchSignedness; break; case BuiltinType::Int: if (T == C.UnsignedIntTy) - return Match; + return MatchSignedness; break;
[clang] [libc] [clang-tools-extra] [flang] [compiler-rt] [llvm] [libc][NFC] Remove __support/bit.h and use __support/CPP/bit.h instead (PR #73939)
https://github.com/gchatelet closed https://github.com/llvm/llvm-project/pull/73939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA][Win32] Add `fma(long double,..)` to math forward declares. (PR #73756)
@@ -70,6 +70,9 @@ __DEVICE__ double floor(double); __DEVICE__ float floor(float); __DEVICE__ double fma(double, double, double); __DEVICE__ float fma(float, float, float); +#ifdef _MSC_VER +__DEVICE__ long double fma(long double, long double, long double); emankov wrote: Yes, we have. But how do we prevent them from running on GPU? https://github.com/llvm/llvm-project/pull/73756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 900bb31 - [clang-format][NFC] Use `prog` in clang-format-diff.py (#74399)
Author: Owen Pan Date: 2023-12-05T10:36:14Z New Revision: 900bb318b5b8c485e57cf810253a656b0fb683bc URL: https://github.com/llvm/llvm-project/commit/900bb318b5b8c485e57cf810253a656b0fb683bc DIFF: https://github.com/llvm/llvm-project/commit/900bb318b5b8c485e57cf810253a656b0fb683bc.diff LOG: [clang-format][NFC] Use `prog` in clang-format-diff.py (#74399) This is a minor improvement to #73491. Added: Modified: clang/tools/clang-format/clang-format-diff.py Removed: diff --git a/clang/tools/clang-format/clang-format- diff .py b/clang/tools/clang-format/clang-format- diff .py index b25ee8f433751..0a2c24743678d 100755 --- a/clang/tools/clang-format/clang-format- diff .py +++ b/clang/tools/clang-format/clang-format- diff .py @@ -25,7 +25,6 @@ import argparse import diff lib -import os import re import subprocess import sys @@ -37,9 +36,8 @@ def main(): -basename = os.path.basename(sys.argv[0]) parser = argparse.ArgumentParser( -description=__doc__.format(clang_format_ diff =basename), +description=__doc__.format(clang_format_ diff ="%(prog)s"), formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Use `prog` in clang-format-diff.py (PR #74399)
https://github.com/serge-sans-paille closed https://github.com/llvm/llvm-project/pull/74399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang][driver] Add -fno-fortran-main (link time) option to remove Fortran_main from link line (PR #74139)
mjklemm wrote: @DavidTruby If you are OK with the way I handled MSVC, please approve and I will merge the PR (or change it if you want some changes to be made). https://github.com/llvm/llvm-project/pull/74139 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Use `prog` in clang-format-diff.py (PR #74399)
serge-sans-paille wrote: thanks :bow: https://github.com/llvm/llvm-project/pull/74399 ___ 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)
@@ -289,7 +283,7 @@ ARM_STREAMING_ATTR void test_svst1_ver_vnum_za64(uint32_t slice_base, svbool_t p // CHECK-CXX-NEXT:tail call void @llvm.aarch64.sme.st1q.vert( [[TMP0]], ptr [[TMP2]], i32 15, i32 [[SLICE_BASE]]) // CHECK-CXX-NEXT:ret void // -ARM_STREAMING_ATTR void test_svst1_ver_vnum_za128(uint32_t slice_base, svbool_t pg, void *ptr, int64_t vnum) { +void test_svst1_ver_vnum_za128(uint32_t slice_base, svbool_t pg, void *ptr, int64_t vnum) __arm_streaming { SamTebbs33 wrote: Sure thing. 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
[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #74064)
@@ -6,20 +6,20 @@ #include __attribute__((target("sme"))) -void test_sme(svbool_t pg, void *ptr) { +void test_sme(svbool_t pg, void *ptr) __arm_streaming { svld1_hor_za8(0, 0, pg, ptr); } __attribute__((target("arch=armv8-a+sme"))) -void test_arch_sme(svbool_t pg, void *ptr) { +void test_arch_sme(svbool_t pg, void *ptr) __arm_streaming { svld1_hor_vnum_za32(0, 0, pg, ptr, 0); } __attribute__((target("+sme"))) -void test_plus_sme(svbool_t pg, void *ptr) { +void test_plus_sme(svbool_t pg, void *ptr) __arm_streaming { svst1_ver_za16(0, 0, pg, ptr); } -void undefined(svbool_t pg, void *ptr) { - svst1_ver_vnum_za64(0, 0, pg, ptr, 0); // expected-error {{'svst1_ver_vnum_za64' needs target feature sme}} +void undefined(svbool_t pg, void *ptr) __arm_streaming { // expected-error {{function executed in streaming-SVE mode requires 'sme'}} SamTebbs33 wrote: With the streaming attribute added, the error is thrown for the function signature line, so it has to be on this line. 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
[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; SamTebbs33 wrote: I
[compiler-rt] [libcxx] [clang-tools-extra] [flang] [libc] [mlir] [clang] [llvm] [mlir][llvm] Fix verifier for const int and dense (PR #74340)
https://github.com/rikhuijzer updated https://github.com/llvm/llvm-project/pull/74340 >From 47140903675a902a5803ef170bcd928783217a5f Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Mon, 4 Dec 2023 16:57:08 +0100 Subject: [PATCH 1/4] [mlir][llvm] Fix verifier for const int --- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 4 mlir/test/Target/LLVMIR/llvmir-invalid.mlir | 8 2 files changed, 12 insertions(+) diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 71860363b8ea5..b1c1c2ba04e4c 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -2539,6 +2539,10 @@ LogicalResult LLVM::ConstantOp::verify() { if (!llvm::isa(getValue())) return emitOpError() << "only supports integer, float, string or elements attributes"; + if (auto intAttr = dyn_cast(getValue())) { +if (!llvm::isa(getType())) + return emitOpError() << "expected integer constant to have integer type"; + } if (auto floatAttr = dyn_cast(getValue())) { const llvm::fltSemantics &sem = floatAttr.getValue().getSemantics(); unsigned floatWidth = APFloat::getSizeInBits(sem); diff --git a/mlir/test/Target/LLVMIR/llvmir-invalid.mlir b/mlir/test/Target/LLVMIR/llvmir-invalid.mlir index 0def5895fb330..fb1fb7cf13d7f 100644 --- a/mlir/test/Target/LLVMIR/llvmir-invalid.mlir +++ b/mlir/test/Target/LLVMIR/llvmir-invalid.mlir @@ -31,6 +31,14 @@ llvm.func @struct_wrong_attribute_element_type() -> !llvm.struct<(f64, f64)> { // - +llvm.func @integer_with_float_type() -> f32 { + // expected-error @+1 {{expected integer constant to have integer type}} + %0 = llvm.mlir.constant(1 : index) : f32 + llvm.return %0 : f32 +} + +// - + llvm.func @incompatible_float_attribute_type() -> f32 { // expected-error @below{{expected float type of width 64}} %cst = llvm.mlir.constant(1.0 : f64) : f32 >From ee0a857ab3fb2e93e51d56d565d29e79f7cdcb67 Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Mon, 4 Dec 2023 17:40:32 +0100 Subject: [PATCH 2/4] Throw error on vector attr with float type --- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 7 ++- mlir/test/Target/LLVMIR/llvmir-invalid.mlir | 10 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index b1c1c2ba04e4c..705788d237d7f 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -2541,7 +2541,7 @@ LogicalResult LLVM::ConstantOp::verify() { << "only supports integer, float, string or elements attributes"; if (auto intAttr = dyn_cast(getValue())) { if (!llvm::isa(getType())) - return emitOpError() << "expected integer constant to have integer type"; + return emitOpError() << "expected integer type"; } if (auto floatAttr = dyn_cast(getValue())) { const llvm::fltSemantics &sem = floatAttr.getValue().getSemantics(); @@ -2557,6 +2557,11 @@ LogicalResult LLVM::ConstantOp::verify() { return emitOpError() << "expected integer type of width " << floatWidth; } } + if (auto splatAttr = dyn_cast(getValue())) { +if (!getType().isa() && !getType().isa() && +!getType().isa() && !getType().isa()) + return emitOpError() << "expected vector or array type"; + } return success(); } diff --git a/mlir/test/Target/LLVMIR/llvmir-invalid.mlir b/mlir/test/Target/LLVMIR/llvmir-invalid.mlir index fb1fb7cf13d7f..117a6b8269089 100644 --- a/mlir/test/Target/LLVMIR/llvmir-invalid.mlir +++ b/mlir/test/Target/LLVMIR/llvmir-invalid.mlir @@ -7,6 +7,14 @@ func.func @foo() { // - +llvm.func @vector_with_non_vector_type() -> f32 { + // expected-error @below{{expected vector or array type}} + %cst = llvm.mlir.constant(dense<100.0> : vector<1xf64>) : f32 + llvm.return %cst : f32 +} + +// - + llvm.func @no_non_complex_struct() -> !llvm.array<2 x array<2 x array<2 x struct<(i32) { // expected-error @below{{expected struct type to be a complex number}} %0 = llvm.mlir.constant(dense<[[[1, 2], [3, 4]], [[42, 43], [44, 45]]]> : tensor<2x2x2xi32>) : !llvm.array<2 x array<2 x array<2 x struct<(i32) @@ -32,7 +40,7 @@ llvm.func @struct_wrong_attribute_element_type() -> !llvm.struct<(f64, f64)> { // - llvm.func @integer_with_float_type() -> f32 { - // expected-error @+1 {{expected integer constant to have integer type}} + // expected-error @+1 {{expected integer type}} %0 = llvm.mlir.constant(1 : index) : f32 llvm.return %0 : f32 } >From f55e793aa1f6daa4cd56ebd63dd65d53159fcc20 Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Mon, 4 Dec 2023 18:02:13 +0100 Subject: [PATCH 3/4] Apply `clang-format` --- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR
[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #74064)
@@ -6,20 +6,20 @@ #include __attribute__((target("sme"))) -void test_sme(svbool_t pg, void *ptr) { +void test_sme(svbool_t pg, void *ptr) __arm_streaming { svld1_hor_za8(0, 0, pg, ptr); } __attribute__((target("arch=armv8-a+sme"))) -void test_arch_sme(svbool_t pg, void *ptr) { +void test_arch_sme(svbool_t pg, void *ptr) __arm_streaming { svld1_hor_vnum_za32(0, 0, pg, ptr, 0); } __attribute__((target("+sme"))) -void test_plus_sme(svbool_t pg, void *ptr) { +void test_plus_sme(svbool_t pg, void *ptr) __arm_streaming { svst1_ver_za16(0, 0, pg, ptr); } -void undefined(svbool_t pg, void *ptr) { - svst1_ver_vnum_za64(0, 0, pg, ptr, 0); // expected-error {{'svst1_ver_vnum_za64' needs target feature sme}} +void undefined(svbool_t pg, void *ptr) __arm_streaming { // expected-error {{function executed in streaming-SVE mode requires 'sme'}} sdesmalen-arm wrote: Ah, I see that the actual message changed too. It's now complaining about `__arm_streaming` on a non-SME function, whereas before it was testing that the builtin was predicated with the correct attribute. This is already tested in `aarch64-sme-func-attrs-without-target-feature.cpp`. I think instead you want to compile this test with `__attribute__((target("+sme")))` but without the `__arm_streaming` to ensure you get a diagnostic on the builtin call that the behaviour is undefined when the (parent) function is not a streaming function. 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
[clang] 7788ef4 - [AArch64][SME2] Remove IsPreservesZA from ldr_zt builtin (#74303)
Author: Matthew Devereau Date: 2023-12-05T10:55:41Z New Revision: 7788ef4be19fdbcd0c1f5ecf9f5cc52ab8b4ac1e URL: https://github.com/llvm/llvm-project/commit/7788ef4be19fdbcd0c1f5ecf9f5cc52ab8b4ac1e DIFF: https://github.com/llvm/llvm-project/commit/7788ef4be19fdbcd0c1f5ecf9f5cc52ab8b4ac1e.diff LOG: [AArch64][SME2] Remove IsPreservesZA from ldr_zt builtin (#74303) Added: Modified: clang/include/clang/Basic/arm_sme.td clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_ldr_str_zt.c clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp Removed: diff --git a/clang/include/clang/Basic/arm_sme.td b/clang/include/clang/Basic/arm_sme.td index 34dbfff6c4c85..7cdb531b5aae4 100644 --- a/clang/include/clang/Basic/arm_sme.td +++ b/clang/include/clang/Basic/arm_sme.td @@ -319,7 +319,7 @@ let TargetGuard = "sme2" in { // 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 SVLDR_ZT : Inst<"svldr_zt", "viQ", "", MergeNone, "aarch64_sme_ldr_zt", [IsOverloadNone, IsStreamingCompatible, IsSharedZA], [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 index 126a4fc104585..83fbd6e5855ca 100644 --- 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 @@ -20,7 +20,7 @@ // 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 { +void test_svldr_zt(const void *base) __arm_streaming_compatible __arm_shared_za { svldr_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 70987ad395f73..33a4ed7c77c2f 100644 --- a/clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp +++ b/clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp @@ -20,7 +20,11 @@ void test_outer_product(svbool_t pred, svint16_t s16, svuint16_t u16, svint32_t svbmops_za32_s32_m(4, pred, pred, s32, s32); // expected-error {{argument value 4 is outside the valid range [0, 3]}} } -void test_ldr_str_zt(const void *const_base, void *base) __arm_streaming_compatible __arm_shared_za __arm_preserves_za { +void test_ldr_zt(const void *const_base) __arm_streaming_compatible __arm_shared_za { svldr_zt(1, const_base); // expected-error {{argument value 1 is outside the valid range [0, 0]}} +} + +void test_str_zt(void *base) __arm_streaming_compatible __arm_shared_za __arm_preserves_za { svstr_zt(1, base); // expected-error {{argument value 1 is outside the valid range [0, 0]}} } + ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][SME2] Remove IsPreservesZA from ldr_zt builtin (PR #74303)
https://github.com/MDevereau closed https://github.com/llvm/llvm-project/pull/74303 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Sema] Implement support for -Wformat-signedness (PR #74440)
@@ -918,6 +918,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, HelpText<"Enable warnings for deprecated constructs and define __DEPRECATED">; def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, Visibility<[ClangOption, CC1Option]>; +def Wformat_signedness : Flag<["-"], "Wformat-signedness">, hazohelet wrote: I think the warning option config should go to `clang/include/clang/Basic/DiagnosticSemaKinds.td` instead of the toplevel driver setting. For example, you wouldn't have `-Wno-format-signedness` atm. https://github.com/llvm/llvm-project/pull/74440 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Re-land: Retrieve members from accessors called usi… (PR #74336)
https://github.com/martinboehme approved this pull request. https://github.com/llvm/llvm-project/pull/74336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 40381d1 - [clang][dataflow] Re-land: Retrieve members from accessors called usi… (#74336)
Author: Samira Bazuzi Date: 2023-12-05T12:09:33+01:00 New Revision: 40381d12640932a4e8185d18e5a0da84b4e449c0 URL: https://github.com/llvm/llvm-project/commit/40381d12640932a4e8185d18e5a0da84b4e449c0 DIFF: https://github.com/llvm/llvm-project/commit/40381d12640932a4e8185d18e5a0da84b4e449c0.diff LOG: [clang][dataflow] Re-land: Retrieve members from accessors called usi… (#74336) …ng member pointers. This initially landed with a broken test due to a mid-air collision with a new requirement for Environment initialization before field modeling. Have added that initialization in the test. >From first landing: getMethodDecl does not handle pointers to members and returns nullptr for them. getMethodDecl contains a decade-plus-old FIXME to handle pointers to members, but two approaches I looked at for fixing it are more invasive or complex than simply swapping to getCalleeDecl. The first, have getMethodDecl call getCalleeDecl, creates a large tree of const-ness mismatches due to getMethodDecl returning a non-const value while being a const member function and getCalleeDecl only being a const member function when it returns a const value. The second, implementing an AST walk to match how CXXMemberCallExpr::getImplicitObjectArgument grabs the LHS of the binary operator, is basically reimplementing Expr::getReferencedDeclOfCallee, which is used by Expr::getCalleeDecl. We don't need another copy of that code. Added: Modified: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp Removed: diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp index 042402a129d10..b98037b736452 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -300,9 +300,12 @@ static void insertIfFunction(const Decl &D, } static MemberExpr *getMemberForAccessor(const CXXMemberCallExpr &C) { - if (!C.getMethodDecl()) + // Use getCalleeDecl instead of getMethodDecl in order to handle + // pointer-to-member calls. + const auto *MethodDecl = dyn_cast_or_null(C.getCalleeDecl()); + if (!MethodDecl) return nullptr; - auto *Body = dyn_cast_or_null(C.getMethodDecl()->getBody()); + auto *Body = dyn_cast_or_null(MethodDecl->getBody()); if (!Body || Body->size() != 1) return nullptr; if (auto *RS = dyn_cast(*Body->body_begin())) diff --git a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp index 3569b0eac7005..003434a58b107 100644 --- a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp @@ -25,6 +25,7 @@ namespace { using namespace clang; using namespace dataflow; using ::clang::dataflow::test::getFieldValue; +using ::testing::Contains; using ::testing::IsNull; using ::testing::NotNull; @@ -311,6 +312,57 @@ TEST_F(EnvironmentTest, InitGlobalVarsConstructor) { EXPECT_THAT(Env.getValue(*Var), NotNull()); } +// Pointers to Members are a tricky case of accessor calls, complicated further +// when using templates where the pointer to the member is a template argument. +// This is a repro of a failure case seen in the wild. +TEST_F(EnvironmentTest, + ModelMemberForAccessorUsingMethodPointerThroughTemplate) { + using namespace ast_matchers; + + std::string Code = R"cc( + struct S { +int accessor() {return member;} + +int member = 0; + }; + + template + int Target(S* S) { +return (S->*method)(); + } + + // We want to analyze the instantiation of Target for the accessor. + int Instantiator () {S S; return Target<&S::accessor>(&S); } + )cc"; + + auto Unit = + // C++17 for the simplifying use of auto in the template declaration. + tooling::buildASTFromCodeWithArgs(Code, {"-fsyntax-only", "-std=c++17"}); + auto &Context = Unit->getASTContext(); + + ASSERT_EQ(Context.getDiagnostics().getClient()->getNumErrors(), 0U); + + auto Results = match( + decl(anyOf(functionDecl(hasName("Target"), isTemplateInstantiation()) + .bind("target"), + fieldDecl(hasName("member")).bind("member"), + recordDecl(hasName("S")).bind("struct"))), + Context); + const auto *Fun = selectFirst("target", Results); + const auto *Struct = selectFirst("struct", Results); + const auto *Member = selectFirst("member", Results); + ASSERT_THAT(Fun, NotNull()); + ASSERT_THAT(Struct, NotNull()); + ASSERT_THAT(Member, NotNull()); + + // Verify that `member` is modeled for `S` when we analyze + // `Target<&S::accessor>`. + Environment Env(DAContext, *Fun); + Env.initialize(); + EXPECT_THAT(DAContext.getModel
[clang] [clang][dataflow] Re-land: Retrieve members from accessors called usi… (PR #74336)
https://github.com/martinboehme closed https://github.com/llvm/llvm-project/pull/74336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [libc] [mlir] [clang-tools-extra] [clang] [libcxx] [compiler-rt] [flang] [mlir][llvm] Fix verifier for const int and dense (PR #74340)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/74340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][SME2] Add multi-vector builtins for cvt (PR #74450)
https://github.com/MDevereau created https://github.com/llvm/llvm-project/pull/74450 Adds builtins for: - FCVT - BFCVT - FCVTZS - FCVTZU - SCVTF - UCVTF - BFCVTN - FCVTN - SQCVT - SQCVTU - UQCVT - SQCVTN - SQCVTUN - UQCVTN See https://github.com/ARM-software/acle/pull/217 >From 07244773d0733906fd485b1cf997f941009ecbec Mon Sep 17 00:00:00 2001 From: Matt Devereau Date: Thu, 30 Nov 2023 15:10:10 + Subject: [PATCH] [AArch64][SME2] Add multi-vector builtins for cvt Adds builtins for: - FCVT - BFCVT - FCVTZS - FCVTZU - SCVTF - UCVTF - BFCVTN - FCVTN - SQCVT - SQCVTU - UQCVT - SQCVTN - SQCVTUN - UQCVTN See https://github.com/ARM-software/acle/pull/217 --- clang/include/clang/Basic/arm_sve.td | 60 +++ .../aarch64-sme2-intrinsics/acle_sme2_cvt.c | 499 ++ .../aarch64-sme2-intrinsics/acle_sme2_cvtn.c | 242 + 3 files changed, 801 insertions(+) create mode 100644 clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_cvt.c create mode 100644 clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_cvtn.c diff --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td index 4fcc9327f22fe..a73ac75e3bbc0 100644 --- a/clang/include/clang/Basic/arm_sve.td +++ b/clang/include/clang/Basic/arm_sve.td @@ -2149,3 +2149,63 @@ let TargetGuard = "sve2p1" in { defm SVPMOV_TO_VEC_LANE_S : PMOV_TO_VEC<"svpmov", "iUi", "aarch64_sve_pmov_to_vector_lane", [], ImmCheck1_3>; defm SVPMOV_TO_VEC_LANE_D : PMOV_TO_VEC<"svpmov", "lUl", "aarch64_sve_pmov_to_vector_lane" ,[], ImmCheck1_7>; } + +// +// Multi-vector convert to/from floating-point. +// +let TargetGuard = "sme2" in { + def SVCVT_F16_X2 : SInst<"svcvt_f16[_f32_x2]", "e2", "f", MergeNone, "aarch64_sve_fcvt_x2", [IsStreaming],[]>; + def SVCVT_BF16_X2 : SInst<"svcvt_bf16[_f32_x2]", "$2", "f", MergeNone, "aarch64_sve_bfcvt_x2", [IsOverloadNone, IsStreaming],[]>; + + def SVCVT_F32_U32_X2 : SInst<"svcvt_{d}[_u32_x2]", "2.d2.u", "f", MergeNone, "aarch64_sve_fcvtu_x2", [IsStreaming], []>; + def SVCVT_U32_F32_X2 : SInst<"svcvt_u32[_{d}_x2]", "2.u2.d", "f", MergeNone, "aarch64_sve_ucvtf_x2", [IsStreaming], []>; + def SVCVT_F32_S32_X2 : SInst<"svcvt_{d}[_s32_x2]", "2.d2.x", "f", MergeNone, "aarch64_sve_fcvts_x2", [IsStreaming], []>; + def SVCVT_S32_F32_X2 : SInst<"svcvt_s32[_{d}_x2]", "2.x2.d", "f", MergeNone, "aarch64_sve_scvtf_x2", [IsStreaming], []>; + + def SVCVT_F32_U32_X4 : SInst<"svcvt_{d}[_u32_x4]", "4.d4.u", "f", MergeNone, "aarch64_sve_fcvtu_x4", [IsStreaming], []>; + def SVCVT_U32_F32_X4 : SInst<"svcvt_u32[_{d}_x4]", "4.u4.d", "f", MergeNone, "aarch64_sve_ucvtf_x4", [IsStreaming], []>; + def SVCVT_F32_S32_X4 : SInst<"svcvt_{d}[_s32_x4]", "4.d4.x", "f", MergeNone, "aarch64_sve_fcvts_x4", [IsStreaming], []>; + def SVCVT_S32_F32_X4 : SInst<"svcvt_s32[_{d}_x4]", "4.x4.d", "f", MergeNone, "aarch64_sve_scvtf_x4", [IsStreaming], []>; +} + +// +// Multi-vector floating-point convert from single-precision to interleaved half-precision/BFloat16 +// +let TargetGuard = "sme2" in { + def SVCVTN_F16_X2 : SInst<"svcvtn_f16[_f32_x2]", "e2", "f", MergeNone, "aarch64_sve_fcvtn_x2", [IsStreaming],[]>; + def SVCVTN_BF16_X2 : SInst<"svcvtn_bf16[_f32_x2]", "$2", "f", MergeNone, "aarch64_sve_bfcvtn_x2", [IsOverloadNone, IsStreaming],[]>; +} + +// +// Multi-vector saturating extract narrow +// +let TargetGuard = "sme2" in { + def SVQCVT_S16_S32_X2 : SInst<"svqcvt_s16[_{d}_x2]", "h2.d", "i", MergeNone, "aarch64_sve_sqcvt_x2", [IsStreaming], []>; + def SVQCVT_U16_U32_X2 : SInst<"svqcvt_u16[_{d}_x2]", "e2.d", "Ui", MergeNone, "aarch64_sve_uqcvt_x2", [IsStreaming], []>; + def SVQCVT_U16_S32_X2 : SInst<"svqcvt_u16[_{d}_x2]", "e2.d", "i", MergeNone, "aarch64_sve_sqcvtu_x2", [IsStreaming], []>; + + def SVQCVT_S8_S32_X4 : SInst<"svqcvt_s8[_{d}_x4]", "q4.d", "i", MergeNone, "aarch64_sve_sqcvt_x4", [IsStreaming], []>; + def SVQCVT_U8_U32_X4 : SInst<"svqcvt_u8[_{d}_x4]", "b4.d", "Ui", MergeNone, "aarch64_sve_uqcvt_x4", [IsStreaming], []>; + def SVQCVT_U8_S32_X4 : SInst<"svqcvt_u8[_{d}_x4]", "b4.d", "i", MergeNone, "aarch64_sve_sqcvtu_x4", [IsStreaming], []>; + + def SVQCVT_S16_S64_X4 : SInst<"svqcvt_s16[_{d}_x4]", "q4.d", "l", MergeNone, "aarch64_sve_sqcvt_x4", [IsStreaming], []>; + def SVQCVT_U16_U64_X4 : SInst<"svqcvt_u16[_{d}_x4]", "b4.d", "Ul", MergeNone, "aarch64_sve_uqcvt_x4", [IsStreaming], []>; + def SVQCVT_U16_S64_X4 : SInst<"svqcvt_u16[_{d}_x4]", "b4.d", "l", MergeNone, "aarch64_sve_sqcvtu_x4", [IsStreaming], []>; +} + +// +// Multi-vector saturating extract narrow and interleave +// +let TargetGuard = "sme2" in { + def SVQCVTN_S16_S32_X2 : SInst<"svqcvtn_s16[_{d}_x2]", "h2.d", "i", MergeNone, "aarch64_sve_sqcvtn_x2", [IsStreamingCompatible], []>; + def SVQCVTN_U16_U32_X2 : SInst<"svqcvtn_u16[_{d}_x2]", "e2.d", "Ui", MergeNone, "aarch64_sve_uqcvtn_x2", [IsStreamingCompatible], []>; + def SVQCVTN_U16_S32_X2 : SInst<"svqcvtn_u16[_{d}_x2]", "e2.d", "i", MergeNone, "aarch64_sve_sqc
[clang] [AArch64][SME2] Add multi-vector builtins for cvt (PR #74450)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Matthew Devereau (MDevereau) Changes Adds builtins for: - FCVT - BFCVT - FCVTZS - FCVTZU - SCVTF - UCVTF - BFCVTN - FCVTN - SQCVT - SQCVTU - UQCVT - SQCVTN - SQCVTUN - UQCVTN See https://github.com/ARM-software/acle/pull/217 --- Patch is 71.11 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74450.diff 3 Files Affected: - (modified) clang/include/clang/Basic/arm_sve.td (+60) - (added) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_cvt.c (+499) - (added) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_cvtn.c (+242) ``diff diff --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td index 4fcc9327f22fe..a73ac75e3bbc0 100644 --- a/clang/include/clang/Basic/arm_sve.td +++ b/clang/include/clang/Basic/arm_sve.td @@ -2149,3 +2149,63 @@ let TargetGuard = "sve2p1" in { defm SVPMOV_TO_VEC_LANE_S : PMOV_TO_VEC<"svpmov", "iUi", "aarch64_sve_pmov_to_vector_lane", [], ImmCheck1_3>; defm SVPMOV_TO_VEC_LANE_D : PMOV_TO_VEC<"svpmov", "lUl", "aarch64_sve_pmov_to_vector_lane" ,[], ImmCheck1_7>; } + +// +// Multi-vector convert to/from floating-point. +// +let TargetGuard = "sme2" in { + def SVCVT_F16_X2 : SInst<"svcvt_f16[_f32_x2]", "e2", "f", MergeNone, "aarch64_sve_fcvt_x2", [IsStreaming],[]>; + def SVCVT_BF16_X2 : SInst<"svcvt_bf16[_f32_x2]", "$2", "f", MergeNone, "aarch64_sve_bfcvt_x2", [IsOverloadNone, IsStreaming],[]>; + + def SVCVT_F32_U32_X2 : SInst<"svcvt_{d}[_u32_x2]", "2.d2.u", "f", MergeNone, "aarch64_sve_fcvtu_x2", [IsStreaming], []>; + def SVCVT_U32_F32_X2 : SInst<"svcvt_u32[_{d}_x2]", "2.u2.d", "f", MergeNone, "aarch64_sve_ucvtf_x2", [IsStreaming], []>; + def SVCVT_F32_S32_X2 : SInst<"svcvt_{d}[_s32_x2]", "2.d2.x", "f", MergeNone, "aarch64_sve_fcvts_x2", [IsStreaming], []>; + def SVCVT_S32_F32_X2 : SInst<"svcvt_s32[_{d}_x2]", "2.x2.d", "f", MergeNone, "aarch64_sve_scvtf_x2", [IsStreaming], []>; + + def SVCVT_F32_U32_X4 : SInst<"svcvt_{d}[_u32_x4]", "4.d4.u", "f", MergeNone, "aarch64_sve_fcvtu_x4", [IsStreaming], []>; + def SVCVT_U32_F32_X4 : SInst<"svcvt_u32[_{d}_x4]", "4.u4.d", "f", MergeNone, "aarch64_sve_ucvtf_x4", [IsStreaming], []>; + def SVCVT_F32_S32_X4 : SInst<"svcvt_{d}[_s32_x4]", "4.d4.x", "f", MergeNone, "aarch64_sve_fcvts_x4", [IsStreaming], []>; + def SVCVT_S32_F32_X4 : SInst<"svcvt_s32[_{d}_x4]", "4.x4.d", "f", MergeNone, "aarch64_sve_scvtf_x4", [IsStreaming], []>; +} + +// +// Multi-vector floating-point convert from single-precision to interleaved half-precision/BFloat16 +// +let TargetGuard = "sme2" in { + def SVCVTN_F16_X2 : SInst<"svcvtn_f16[_f32_x2]", "e2", "f", MergeNone, "aarch64_sve_fcvtn_x2", [IsStreaming],[]>; + def SVCVTN_BF16_X2 : SInst<"svcvtn_bf16[_f32_x2]", "$2", "f", MergeNone, "aarch64_sve_bfcvtn_x2", [IsOverloadNone, IsStreaming],[]>; +} + +// +// Multi-vector saturating extract narrow +// +let TargetGuard = "sme2" in { + def SVQCVT_S16_S32_X2 : SInst<"svqcvt_s16[_{d}_x2]", "h2.d", "i", MergeNone, "aarch64_sve_sqcvt_x2", [IsStreaming], []>; + def SVQCVT_U16_U32_X2 : SInst<"svqcvt_u16[_{d}_x2]", "e2.d", "Ui", MergeNone, "aarch64_sve_uqcvt_x2", [IsStreaming], []>; + def SVQCVT_U16_S32_X2 : SInst<"svqcvt_u16[_{d}_x2]", "e2.d", "i", MergeNone, "aarch64_sve_sqcvtu_x2", [IsStreaming], []>; + + def SVQCVT_S8_S32_X4 : SInst<"svqcvt_s8[_{d}_x4]", "q4.d", "i", MergeNone, "aarch64_sve_sqcvt_x4", [IsStreaming], []>; + def SVQCVT_U8_U32_X4 : SInst<"svqcvt_u8[_{d}_x4]", "b4.d", "Ui", MergeNone, "aarch64_sve_uqcvt_x4", [IsStreaming], []>; + def SVQCVT_U8_S32_X4 : SInst<"svqcvt_u8[_{d}_x4]", "b4.d", "i", MergeNone, "aarch64_sve_sqcvtu_x4", [IsStreaming], []>; + + def SVQCVT_S16_S64_X4 : SInst<"svqcvt_s16[_{d}_x4]", "q4.d", "l", MergeNone, "aarch64_sve_sqcvt_x4", [IsStreaming], []>; + def SVQCVT_U16_U64_X4 : SInst<"svqcvt_u16[_{d}_x4]", "b4.d", "Ul", MergeNone, "aarch64_sve_uqcvt_x4", [IsStreaming], []>; + def SVQCVT_U16_S64_X4 : SInst<"svqcvt_u16[_{d}_x4]", "b4.d", "l", MergeNone, "aarch64_sve_sqcvtu_x4", [IsStreaming], []>; +} + +// +// Multi-vector saturating extract narrow and interleave +// +let TargetGuard = "sme2" in { + def SVQCVTN_S16_S32_X2 : SInst<"svqcvtn_s16[_{d}_x2]", "h2.d", "i", MergeNone, "aarch64_sve_sqcvtn_x2", [IsStreamingCompatible], []>; + def SVQCVTN_U16_U32_X2 : SInst<"svqcvtn_u16[_{d}_x2]", "e2.d", "Ui", MergeNone, "aarch64_sve_uqcvtn_x2", [IsStreamingCompatible], []>; + def SVQCVTN_U16_S32_X2 : SInst<"svqcvtn_u16[_{d}_x2]", "e2.d", "i", MergeNone, "aarch64_sve_sqcvtun_x2", [IsStreamingCompatible], []>; + + def SVQCVTN_S8_S32_X4 : SInst<"svqcvtn_s8[_{d}_x4]", "q4.d", "i", MergeNone, "aarch64_sve_sqcvtn_x4", [IsStreaming], []>; + def SVQCVTN_U8_U32_X4 : SInst<"svqcvtn_u8[_{d}_x4]", "b4.d", "Ui", MergeNone, "aarch64_sve_uqcvtn_x4", [IsStreaming], []>; + def SVQCVTN_U8_S32_X4 : SInst<"svqcvtn_u8[_{d}_x4]", "b4.d", "i", MergeNone, "aarch64_sve_sqcvtun_x4
[clang] [flang] [flang] Update -falias-analysis help text (PR #73548)
tblah wrote: Closing this because I decided to just remove the `-f[no-]alias-analysis` flags instead. https://github.com/llvm/llvm-project/pull/74343 https://github.com/llvm/llvm-project/pull/73548 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang] Update -falias-analysis help text (PR #73548)
https://github.com/tblah closed https://github.com/llvm/llvm-project/pull/73548 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Let the checkers query upper and lower bounds on symbols (PR #74141)
steakhal wrote: My take is that the z3-based solver is crashing all over the place. So its not just slower. We anyways don't have CI checks for it. Given all these, I'd rather not put more burden to the issue tracker regarding this. I'd consider it if these issues wouldn't be present though, but we are really far from that. https://github.com/llvm/llvm-project/pull/74141 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [libc] [mlir] [clang-tools-extra] [clang] [libcxx] [compiler-rt] [flang] [mlir][llvm] Fix verifier for const int and dense (PR #74340)
https://github.com/rikhuijzer closed https://github.com/llvm/llvm-project/pull/74340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [Sema] Implement support for -Wformat-signedness (PR #74440)
@@ -918,6 +918,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, HelpText<"Enable warnings for deprecated constructs and define __DEPRECATED">; def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, Visibility<[ClangOption, CC1Option]>; +def Wformat_signedness : Flag<["-"], "Wformat-signedness">, karka228 wrote: I have tried to mimic the gcc behavior when implementing this and in gcc it seems like -Wformat-signedness don't introduce a new warning but only modify the behavior of the already existing -Wformat warning. If I place the warning option config in clang/include/clang/Basic/DiagnosticSemaKinds.td as you suggest don't I then also create a new warning with a new warning text? ... that is not what gcc do (as far as I understand). Well, with that said we don't have to follow exactly how gcc implemented this if we think there is a better way to implement this in clang. I agree that support for -Wno-format-signednes is missing from my patch and that should be added. https://github.com/llvm/llvm-project/pull/74440 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64] Add soft-float ABI (PR #74460)
https://github.com/ostannard created https://github.com/llvm/llvm-project/pull/74460 This adds support for the AArch64 soft-float ABI. The specification for this ABI is currently in review at https://github.com/ARM-software/abi-aa/pull/232, and I won't commit this until that PR is merged. Because all existing AArch64 hardware has floating-point hardware, we expect this to be a niche option, only used for embedded systems on R-profile systems. We are going to document that SysV-like systems should only ever use the base (hard-float) PCS variant: https://github.com/ARM-software/abi-aa/pull/233. For that reason, I've not added an option to select the ABI independently of the FPU hardware, instead the new ABI is enabled iff the target architecture does not have an FPU. For testing, I have run this through an ABI fuzzer, but since this is the first implementation it can only test for internal consistency (callers and callees agree on the PCS), not for conformance to the ABI spec. >From 316854b6558811aaa03b9f96be1849e0426f8aac Mon Sep 17 00:00:00 2001 From: Oliver Stannard Date: Fri, 1 Dec 2023 10:06:57 + Subject: [PATCH 1/4] [AArch64] Split feature tests for FP and SIMD AArch64TargetInfo defaults to having the FP feature enabled, but this function was ignoring that and checking for SIMD instructions instead. This won't affect most users, because the driver explicitly enables or disables fp-armv8, which gets handled by AArch64TargetInfo::handleTargetFeatures to turn FP and SIMD on or off. However, it will make testing future patches easier, and allow testing for the presense of FP registers/instructions in CC1 tests. Change-Id: I2d2b3569dca5fa1dc40c5c6d1dabf7741b8c480e --- clang/lib/Basic/Targets/AArch64.cpp | 3 +- .../test/CodeGen/attr-target-clones-aarch64.c | 126 +++--- 2 files changed, 107 insertions(+), 22 deletions(-) diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index c31f2e0bee543..23090dad83ad7 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -649,7 +649,8 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const { return llvm::StringSwitch(Feature) .Cases("aarch64", "arm64", "arm", true) .Case("fmv", HasFMV) - .Cases("neon", "fp", "simd", FPU & NeonMode) + .Case("fp", FPU & FPUMode) + .Cases("neon", "simd", FPU & NeonMode) .Case("jscvt", HasJSCVT) .Case("fcma", HasFCMA) .Case("rng", HasRandGen) diff --git a/clang/test/CodeGen/attr-target-clones-aarch64.c b/clang/test/CodeGen/attr-target-clones-aarch64.c index 3f2f2fdd24e8a..4404dd0da8e5e 100644 --- a/clang/test/CodeGen/attr-target-clones-aarch64.c +++ b/clang/test/CodeGen/attr-target-clones-aarch64.c @@ -1,6 +1,6 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes --check-globals --include-generated-funcs -// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -S -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv -S -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fp-armv8 -S -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fp-armv8 -target-feature -fmv -S -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV int __attribute__((target_clones("lse+aes", "sve2"))) ftc(void) { return 0; } int __attribute__((target_clones("sha2", "sha2+memtag2", " default "))) ftc_def(void) { return 1; } @@ -22,6 +22,8 @@ int __attribute__((target_clones("default"))) main() { inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))) ftc_inline2(void) { return 2; }; + +//. // CHECK: @__aarch64_cpu_features = external dso_local global { i64 } // CHECK: @ftc.ifunc = weak_odr ifunc i32 (), ptr @ftc.resolver // CHECK: @ftc_def.ifunc = weak_odr ifunc i32 (), ptr @ftc_def.resolver @@ -30,19 +32,25 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default")) // CHECK: @ftc_inline1.ifunc = weak_odr ifunc i32 (), ptr @ftc_inline1.resolver // CHECK: @ftc_inline2.ifunc = weak_odr ifunc i32 (), ptr @ftc_inline2.resolver // CHECK: @ftc_inline3.ifunc = weak_odr ifunc i32 (), ptr @ftc_inline3.resolver - +//. // CHECK: Function Attrs: noinline nounwind optnone // CHECK-LABEL: @ftc._MlseMaes( // CHECK-NEXT: entry: // CHECK-NEXT:ret i32 0 +// +// // CHECK: Function Attrs: noinline nounwind optnone // CHECK-LABEL: @ftc._Msve2( // CHECK-NEXT: entry: // CHECK-NEXT:ret i32 0 +// +// // CHECK: Function Attrs: noinline nounwind optnone // CHECK-LABEL: @ftc( // CHECK-NEXT: entry: // CHECK-NEXT:ret i32 0 +// +// // CHECK-LABEL: @ftc.resolver( // CHECK-NEXT: resolver_entry: // CHECK-NEXT:call void @__init_cpu_features_resolver() @@ -63,18 +71,26 @@ inline int
[clang] [AArch64] Add soft-float ABI (PR #74460)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: None (ostannard) Changes This adds support for the AArch64 soft-float ABI. The specification for this ABI is currently in review at https://github.com/ARM-software/abi-aa/pull/232, and I won't commit this until that PR is merged. Because all existing AArch64 hardware has floating-point hardware, we expect this to be a niche option, only used for embedded systems on R-profile systems. We are going to document that SysV-like systems should only ever use the base (hard-float) PCS variant: https://github.com/ARM-software/abi-aa/pull/233. For that reason, I've not added an option to select the ABI independently of the FPU hardware, instead the new ABI is enabled iff the target architecture does not have an FPU. For testing, I have run this through an ABI fuzzer, but since this is the first implementation it can only test for internal consistency (callers and callees agree on the PCS), not for conformance to the ABI spec. --- Patch is 22.14 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74460.diff 6 Files Affected: - (modified) clang/lib/Basic/Targets/AArch64.cpp (+2-1) - (modified) clang/lib/CodeGen/CodeGenModule.cpp (+2) - (modified) clang/lib/CodeGen/TargetInfo.h (+1) - (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+12-5) - (added) clang/test/CodeGen/aarch64-soft-float-abi.c (+53) - (modified) clang/test/CodeGen/attr-target-clones-aarch64.c (+105-21) ``diff diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index c31f2e0bee543..23090dad83ad7 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -649,7 +649,8 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const { return llvm::StringSwitch(Feature) .Cases("aarch64", "arm64", "arm", true) .Case("fmv", HasFMV) - .Cases("neon", "fp", "simd", FPU & NeonMode) + .Case("fp", FPU & FPUMode) + .Cases("neon", "simd", FPU & NeonMode) .Case("jscvt", HasJSCVT) .Case("fcma", HasFCMA) .Case("rng", HasRandGen) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index dea58a7ff4146..2e730fdb0b83f 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -143,6 +143,8 @@ createTargetCodeGenInfo(CodeGenModule &CGM) { Kind = AArch64ABIKind::DarwinPCS; else if (Triple.isOSWindows()) return createWindowsAArch64TargetCodeGenInfo(CGM, AArch64ABIKind::Win64); +else if (!Target.hasFeature("fp")) + Kind = AArch64ABIKind::AAPCSSoft; return createAArch64TargetCodeGenInfo(CGM, Kind); } diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h index 0c0781a2d5ab9..0b69d92b70cee 100644 --- a/clang/lib/CodeGen/TargetInfo.h +++ b/clang/lib/CodeGen/TargetInfo.h @@ -416,6 +416,7 @@ enum class AArch64ABIKind { AAPCS = 0, DarwinPCS, Win64, + AAPCSSoft, }; std::unique_ptr diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp index be5145daa00b7..a4089bb6c70f1 100644 --- a/clang/lib/CodeGen/Targets/AArch64.cpp +++ b/clang/lib/CodeGen/Targets/AArch64.cpp @@ -53,8 +53,8 @@ class AArch64ABIInfo : public ABIInfo { Address EmitDarwinVAArg(Address VAListAddr, QualType Ty, CodeGenFunction &CGF) const; - Address EmitAAPCSVAArg(Address VAListAddr, QualType Ty, - CodeGenFunction &CGF) const; + Address EmitAAPCSVAArg(Address VAListAddr, QualType Ty, CodeGenFunction &CGF, + AArch64ABIKind Kind) const; Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty) const override { @@ -65,7 +65,7 @@ class AArch64ABIInfo : public ABIInfo { return Kind == AArch64ABIKind::Win64 ? EmitMSVAArg(CGF, VAListAddr, Ty) : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF) - : EmitAAPCSVAArg(VAListAddr, Ty, CGF); + : EmitAAPCSVAArg(VAListAddr, Ty, CGF, Kind); } Address EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr, @@ -478,6 +478,11 @@ bool AArch64SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, } bool AArch64ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const { + // For the soft-float ABI variant, no types are considered to be homogeneous + // aggregates. + if (Kind == AArch64ABIKind::AAPCSSoft) +return false; + // Homogeneous aggregates for AAPCS64 must have base types of a floating // point type or a short-vector type. This is the same as the 32-bit ABI, // but with the difference that any floating-point type is allowed, @@ -509,7 +514,8 @@ bool AArch64ABIInfo::isZeroLengthBitfieldPermittedInHomogeneousAggregate() } Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualT
[clang] [AArch64] Add soft-float ABI (PR #74460)
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 ecf881838045985f381003cc27569c73a207d0cc b68ed60a3fe78bc0e9f57b45bed9dd78ed851904 -- clang/test/CodeGen/aarch64-soft-float-abi.c clang/lib/Basic/Targets/AArch64.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/TargetInfo.h clang/lib/CodeGen/Targets/AArch64.cpp clang/test/CodeGen/attr-target-clones-aarch64.c `` View the diff from clang-format here. ``diff diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp index a4089bb6c7..d2ce4c0fce 100644 --- a/clang/lib/CodeGen/Targets/AArch64.cpp +++ b/clang/lib/CodeGen/Targets/AArch64.cpp @@ -65,7 +65,7 @@ private: return Kind == AArch64ABIKind::Win64 ? EmitMSVAArg(CGF, VAListAddr, Ty) : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF) - : EmitAAPCSVAArg(VAListAddr, Ty, CGF, Kind); + : EmitAAPCSVAArg(VAListAddr, Ty, CGF, Kind); } Address EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr, `` https://github.com/llvm/llvm-project/pull/74460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64] Add soft-float ABI (PR #74460)
DavidSpickett wrote: (maybe this is for a later patch but...) Does this patch include the clang side options for the ABI or does `-march=...+no-fp-armv8` already work for that? https://github.com/llvm/llvm-project/pull/74460 ___ 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 quad Builtins and Intrinsics (PR #73317)
@@ -0,0 +1,233 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2 + +// 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: define dso_local @test_svluti4_lane_zt_u16 +// CHECK-SAME: ( [[ZN:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call { , , , } @llvm.aarch64.sme.luti4.lane.zt.x4.nxv8i16(i32 0, [[ZN]], i32 0) +// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , , , } [[TMP0]], 0 +// CHECK-NEXT:[[TMP2:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( poison, [[TMP1]], i64 0) +// CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , , , } [[TMP0]], 1 +// CHECK-NEXT:[[TMP4:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP2]], [[TMP3]], i64 8) +// CHECK-NEXT:[[TMP5:%.*]] = extractvalue { , , , } [[TMP0]], 2 +// CHECK-NEXT:[[TMP6:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP4]], [[TMP5]], i64 16) +// CHECK-NEXT:[[TMP7:%.*]] = extractvalue { , , , } [[TMP0]], 3 +// CHECK-NEXT:[[TMP8:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP6]], [[TMP7]], i64 24) +// CHECK-NEXT:ret [[TMP8]] +// +// CPP-CHECK-LABEL: define dso_local @_Z24test_svluti4_lane_zt_u16u11__SVUint8_t +// CPP-CHECK-SAME: ( [[ZN:%.*]]) #[[ATTR0:[0-9]+]] { +// CPP-CHECK-NEXT: entry: +// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call { , , , } @llvm.aarch64.sme.luti4.lane.zt.x4.nxv8i16(i32 0, [[ZN]], i32 0) +// CPP-CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , , , } [[TMP0]], 0 +// CPP-CHECK-NEXT:[[TMP2:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( poison, [[TMP1]], i64 0) +// CPP-CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , , , } [[TMP0]], 1 +// CPP-CHECK-NEXT:[[TMP4:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP2]], [[TMP3]], i64 8) +// CPP-CHECK-NEXT:[[TMP5:%.*]] = extractvalue { , , , } [[TMP0]], 2 +// CPP-CHECK-NEXT:[[TMP6:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP4]], [[TMP5]], i64 16) +// CPP-CHECK-NEXT:[[TMP7:%.*]] = extractvalue { , , , } [[TMP0]], 3 +// CPP-CHECK-NEXT:[[TMP8:%.*]] = tail call @llvm.vector.insert.nxv32i16.nxv8i16( [[TMP6]], [[TMP7]], i64 24) +// CPP-CHECK-NEXT:ret [[TMP8]] +// +svuint16x4_t test_svluti4_lane_zt_u16(svuint8_t zn) __arm_streaming __arm_shared_za __arm_preserves_za { + return svluti4_lane_zt_u16_x4(0, zn, 0); MDevereau wrote: Done 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
[clang] [llvm] [SME2] Add LUTI2 and LUTI4 quad Builtins and Intrinsics (PR #73317)
@@ -1864,6 +1866,35 @@ void AArch64DAGToDAGISel::SelectFrintFromVT(SDNode *N, unsigned NumVecs, SelectUnaryMultiIntrinsic(N, NumVecs, true, Opcode); } +void AArch64DAGToDAGISel::SelectMultiVectorLuti(SDNode *Node, +unsigned NumOutVecs, +unsigned Opc, +uint32_t MaxImm) { + if (ConstantSDNode *Imm = dyn_cast(Node->getOperand(4))) +if (Imm->getZExtValue() > MaxImm) + return; + + SDValue ZtValue; + if (!ImmToReg(Node->getOperand(2), ZtValue)) +return; + SDValue Ops[] = {ZtValue, Node->getOperand(3), Node->getOperand(4)}; + SDLoc DL(Node); + EVT VT = Node->getValueType(0); + + SDNode *Instruction = + CurDAG->getMachineNode(Opc, DL, {MVT::Untyped, MVT::Other}, Ops); + SDValue SuperReg = SDValue(Instruction, 0); + + for (unsigned i = 0; i < NumOutVecs; ++i) MDevereau wrote: Done 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
[clang] [AArch64] Add soft-float ABI (PR #74460)
ostannard wrote: This doesn't add any new options, and I'd like to avoid that if possible, instead it is turned on by `-march=...+nofp`. https://github.com/llvm/llvm-project/pull/74460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [flang] [clang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)
https://github.com/DominikAdamski updated https://github.com/llvm/llvm-project/pull/73944 >From 60ceda3d1025891f5037f020a2efe35108f62ca3 Mon Sep 17 00:00:00 2001 From: Dominik Adamski Date: Thu, 30 Nov 2023 08:06:12 -0600 Subject: [PATCH 1/2] [NFC][AMDGPU] Move address space enum to LLVM directory Types of AMDGPU address space were defined in Clang-specific class. In consequence this enum cannot be reused by other frontends like Flang. If we move address space enum to LLVM directory, then we can reuse it in other frontends like Flang. --- clang/lib/Basic/Targets/AMDGPU.cpp| 80 +-- clang/lib/Basic/Targets/AMDGPU.h | 17 ++-- flang/lib/Frontend/FrontendActions.cpp| 10 +-- llvm/include/llvm/TargetParser/TargetParser.h | 9 +++ 4 files changed, 56 insertions(+), 60 deletions(-) diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp index 409ae32ab4242..3fe9f9fa9c42d 100644 --- a/clang/lib/Basic/Targets/AMDGPU.cpp +++ b/clang/lib/Basic/Targets/AMDGPU.cpp @@ -37,50 +37,50 @@ static const char *const DataLayoutStringAMDGCN = "-ni:7:8"; const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = { -Generic, // Default -Global, // opencl_global -Local,// opencl_local -Constant, // opencl_constant -Private, // opencl_private -Generic, // opencl_generic -Global, // opencl_global_device -Global, // opencl_global_host -Global, // cuda_device -Constant, // cuda_constant -Local,// cuda_shared -Global, // sycl_global -Global, // sycl_global_device -Global, // sycl_global_host -Local,// sycl_local -Private, // sycl_private -Generic, // ptr32_sptr -Generic, // ptr32_uptr -Generic, // ptr64 -Generic, // hlsl_groupshared +llvm::AMDGPU::Generic, // Default +llvm::AMDGPU::Global, // opencl_global +llvm::AMDGPU::Local,// opencl_local +llvm::AMDGPU::Constant, // opencl_constant +llvm::AMDGPU::Private, // opencl_private +llvm::AMDGPU::Generic, // opencl_generic +llvm::AMDGPU::Global, // opencl_global_device +llvm::AMDGPU::Global, // opencl_global_host +llvm::AMDGPU::Global, // cuda_device +llvm::AMDGPU::Constant, // cuda_constant +llvm::AMDGPU::Local,// cuda_shared +llvm::AMDGPU::Global, // sycl_global +llvm::AMDGPU::Global, // sycl_global_device +llvm::AMDGPU::Global, // sycl_global_host +llvm::AMDGPU::Local,// sycl_local +llvm::AMDGPU::Private, // sycl_private +llvm::AMDGPU::Generic, // ptr32_sptr +llvm::AMDGPU::Generic, // ptr32_uptr +llvm::AMDGPU::Generic, // ptr64 +llvm::AMDGPU::Generic, // hlsl_groupshared }; const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = { -Private, // Default -Global, // opencl_global -Local,// opencl_local -Constant, // opencl_constant -Private, // opencl_private -Generic, // opencl_generic -Global, // opencl_global_device -Global, // opencl_global_host -Global, // cuda_device -Constant, // cuda_constant -Local,// cuda_shared +llvm::AMDGPU::Private, // Default +llvm::AMDGPU::Global, // opencl_global +llvm::AMDGPU::Local,// opencl_local +llvm::AMDGPU::Constant, // opencl_constant +llvm::AMDGPU::Private, // opencl_private +llvm::AMDGPU::Generic, // opencl_generic +llvm::AMDGPU::Global, // opencl_global_device +llvm::AMDGPU::Global, // opencl_global_host +llvm::AMDGPU::Global, // cuda_device +llvm::AMDGPU::Constant, // cuda_constant +llvm::AMDGPU::Local,// cuda_shared // SYCL address space values for this map are dummy -Generic, // sycl_global -Generic, // sycl_global_device -Generic, // sycl_global_host -Generic, // sycl_local -Generic, // sycl_private -Generic, // ptr32_sptr -Generic, // ptr32_uptr -Generic, // ptr64 -Generic, // hlsl_groupshared +llvm::AMDGPU::Generic, // sycl_global +llvm::AMDGPU::Generic, // sycl_global_device +llvm::AMDGPU::Generic, // sycl_global_host +llvm::AMDGPU::Generic, // sycl_local +llvm::AMDGPU::Generic, // sycl_private +llvm::AMDGPU::Generic, // ptr32_sptr +llvm::AMDGPU::Generic, // ptr32_uptr +llvm::AMDGPU::Generic, // ptr64 +llvm::AMDGPU::Generic, // hlsl_groupshared }; } // namespace targets diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h index 300d9691d8a0f..1e12f9e12af59 100644 --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -29,13 +29,6 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { static const char *const GCCRegNames[]; - enum AddrSpace { -Generic = 0, -Global = 1, -Local = 3, -Constant = 4, -Private = 5 - }; static const LangASMap AMDGPUDefIsGenMap; static const LangASMap AMDGPUDefIsPrivMap; @@ -106,7 +99
[llvm] [flang] [clang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)
@@ -31,6 +31,15 @@ class Triple; // back-end to TableGen to create these clean tables. namespace AMDGPU { +/// Address space values for AMD GPUs +enum AddrSpace { + Generic = 0, DominikAdamski wrote: Done. Moved to enum class. https://github.com/llvm/llvm-project/pull/73944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [flang] [clang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)
https://github.com/skatrak approved this pull request. LGTM, thanks! Please wait for one more approval before merging. https://github.com/llvm/llvm-project/pull/73944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [flang] [clang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)
DominikAdamski wrote: The address spaces for AMDGPU defined [here](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/AMDGPU.h#L395-L456) contain more types of address spaces in comparison to the enum defined in clang. Is it ok to extend number of address space types for clang? https://github.com/llvm/llvm-project/pull/73944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [flang] [clang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)
kparzysz wrote: > The address spaces for AMDGPU defined > [here](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/AMDGPU.h#L395-L456) > contain more types of address spaces in comparison to the enum defined in > clang. Is it ok to extend number of address space types for clang? I'd just move these definitions to their own file, and use that file in clang/flang/llvm backend. So, indirectly, yes. https://github.com/llvm/llvm-project/pull/73944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [flang] [clang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)
lenary wrote: The reason TargetParser exists is because Target directories are only added to the include path if you enable that target, but some cross-project target code needs to always be available, such as the code for Triples, even when the relevant targets are disabled. I think these address space constants have the same needs, so this location makes sense to me, but I could be wrong. It is strange that the AMDGPU stuff is in the file called TargetParser.h, but that's because I wasn't able to move that code around when I originally split out TargetParser. Now might be a good time to put it in its own header, like was done for all other targets. https://github.com/llvm/llvm-project/pull/73944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64] Add soft-float ABI (PR #74460)
DavidSpickett wrote: That makes sense. Didn't realise we had an `fp` flag, I don't see it in `llvm/include/llvm/TargetParser/AArch64TargetParser.h`. https://github.com/llvm/llvm-project/pull/74460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)
kparzysz wrote: > I'd just move these definitions to their own file, and use that file in > clang/flang/llvm backend. So, indirectly, yes. Sorry, didn't notice you have already created a separate file: 👍 I'd just use the address space identifiers that you quoted instead. https://github.com/llvm/llvm-project/pull/73944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0626ced - [clang][NFC] Replace ARM_STREAMING_ATTR in tests with SME streaming attribute
Author: Samuel Tebbs Date: 2023-12-05T13:35:23Z New Revision: 0626cedb17555ee003bec7588c7b3d51353793a2 URL: https://github.com/llvm/llvm-project/commit/0626cedb17555ee003bec7588c7b3d51353793a2 DIFF: https://github.com/llvm/llvm-project/commit/0626cedb17555ee003bec7588c7b3d51353793a2.diff LOG: [clang][NFC] Replace ARM_STREAMING_ATTR in tests with SME streaming attribute Some tests were testing SME builtins before the streaming attributes existed, and so either inserted them or not depending on a macro definition. The intention was for the macro to be defined once the attributes were added to clang, but it never was defined. This change removes the macro logic and adds the attribute now that they have been added to clang. Added: Modified: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1.c clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1_vnum.c clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_st1.c clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_st1_vnum.c Removed: diff --git a/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1.c b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1.c index 72d159b19118e..5622568c4cd76 100644 --- a/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1.c +++ b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1.c @@ -1,17 +1,11 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 3 // REQUIRES: aarch64-registered-target -// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C -// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX -// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -o /dev/null %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -o /dev/null %s #include -#ifdef DISABLE_SME_ATTRIBUTES -#define ARM_STREAMING_ATTR -#else -#define ARM_STREAMING_ATTR __attribute__((arm_streaming)) -#endif - // CHECK-C-LABEL: define dso_local void @test_svld1_hor_za8( // CHECK-C-SAME: i32 noundef [[SLICE_BASE:%.*]], [[PG:%.*]], ptr noundef [[PTR:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-C-NEXT: entry: @@ -28,7 +22,7 @@ // CHECK-CXX-NEXT:tail call void @llvm.aarch64.sme.ld1b.horiz( [[PG]], ptr [[PTR]], i32 0, i32 [[ADD]]) // CHECK-CXX-NEXT:ret void // -ARM_STREAMING_ATTR void test_svld1_hor_za8(uint32_t slice_base, svbool_t pg, const void *ptr) { +void test_svld1_hor_za8(uint32_t slice_base, svbool_t pg, const void *ptr) __arm_streaming { svld1_hor_za8(0, slice_base, pg, ptr); svld1_hor_za8(0, slice_base + 15, pg, ptr); } @@ -51,7 +45,7 @@ ARM_STREAMING_ATTR void test_svld1_hor_za8(uint32_t slice_base, svbool_t pg, con // CHECK-CXX-NEXT:tail call void @llvm.aarch64.sme.ld1h.horiz( [[TMP0]], ptr [[PTR]], i32 1, i32 [[ADD]]) // CHECK-CXX-NEXT:ret void // -ARM_STREAMING_ATTR void test_svld1_hor_za16(uint32_t slice_base, svbool_t pg, const void *ptr) { +void test_svld1_hor_za16(uint32_t slice_base, svbool_t pg, const void *ptr) __arm_streaming { svld1_hor_za16(0, slice_base, pg, ptr); svld1_hor_za16(1, slice_base + 7, pg, ptr); } @@ -74,7 +68,7 @@ ARM_STREAMING_ATTR void test_svld1_hor_za16(uint32_t slice_base, svbool_t pg, co // CHECK-CXX-NEXT:tail call void @llvm.aarch64.sme.ld1w.horiz( [[TMP0]], ptr [[PTR]], i32 3, i32 [[ADD]]) // CHECK-CXX-NEXT:ret void // -ARM_STREAMING_ATTR void test_svld1_hor_za32(uint32_t slice_base, svbool_t pg, const void *ptr) { +void test_svld1_hor_za32(uint32_t slice_base, svbool_t pg, const void *ptr) __arm_streaming { svld1_hor_za32(0, slice_base, pg, ptr); svld1_hor_za32(3, slice_base + 3, pg, ptr); } @@ -97,7 +91,7 @@ ARM_STREAMING_ATTR void test_svld1_hor_za32(uint32_t slice_base, svbool_t pg, co // CHECK-CXX-NEXT:tail call void @llvm.aarch64.sme.ld1d.horiz( [[TMP0]], ptr [[PTR]], i32 7, i32 [[ADD]]) // CHECK-CXX-NEXT:ret void // -ARM_STREAMING_ATTR void test_svld1_hor_za64(uint32_t slice_base, svbool_t pg, const void *ptr) { +void test_svld1_hor_za64(uint32_t slice_base, svbool_t pg, const void *ptr) __arm_streaming { svld1_hor_za64(0, slice_base, pg, ptr); svld1_hor_za6
[llvm] [clang] [flang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)
@@ -0,0 +1,31 @@ +//=== AMDGPUAddrSpace.h -*- C++ -*-===// +// +// 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 +// +//===--===// +// +/// \file +/// AMDGPU address space definition +/// +// +//===--===// + +#ifndef LLVM_SUPPORT_AMDGPUADDRSPACE_H +#define LLVM_SUPPORT_AMDGPUADDRSPACE_H + +namespace llvm { +namespace AMDGPU { +enum class AddrSpace { kparzysz wrote: You can explicitly say `enum class AddrSpace : unsigned { ...` to avoid the need for the static_casts to unsigned. https://github.com/llvm/llvm-project/pull/73944 ___ 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)
@@ -289,7 +283,7 @@ ARM_STREAMING_ATTR void test_svst1_ver_vnum_za64(uint32_t slice_base, svbool_t p // CHECK-CXX-NEXT:tail call void @llvm.aarch64.sme.st1q.vert( [[TMP0]], ptr [[TMP2]], i32 15, i32 [[SLICE_BASE]]) // CHECK-CXX-NEXT:ret void // -ARM_STREAMING_ATTR void test_svst1_ver_vnum_za128(uint32_t slice_base, svbool_t pg, void *ptr, int64_t vnum) { +void test_svst1_ver_vnum_za128(uint32_t slice_base, svbool_t pg, void *ptr, int64_t vnum) __arm_streaming { SamTebbs33 wrote: Done 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
[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #74064)
@@ -3023,6 +3151,66 @@ static void checkArmStreamingBuiltin(Sema &S, CallExpr *TheCall, << TheCall->getSourceRange() << "streaming compatible"; return; } + + if (FnType == ArmNonStreaming && BuiltinType == ArmStreaming) { +S.Diag(TheCall->getBeginLoc(), diag::warn_attribute_arm_sm_incompat_builtin) +<< TheCall->getSourceRange() << "non-streaming"; + } +} + +static bool hasSMEZAState(const FunctionDecl *FD) { + if (FD->hasAttr()) +return true; + if (const auto *T = FD->getType()->getAs()) +if (T->getAArch64SMEAttributes() & FunctionType::SME_PStateZASharedMask) + return true; + return false; +} + +static bool hasSMEZAState(unsigned BuiltinID) { + switch (BuiltinID) { + default: +return false; +#define GET_SME_BUILTIN_HAS_ZA_STATE +#include "clang/Basic/arm_sme_builtins_za_state.inc" +#undef GET_SME_BUILTIN_HAS_ZA_STATE + } +} + +bool Sema::CheckSMEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { + if (const FunctionDecl *FD = getCurFunctionDecl()) { +bool debug = FD->getDeclName().getAsString() == "incompat_sve_sm"; +std::optional BuiltinType; + +switch (BuiltinID) { +default: + break; +#define GET_SME_STREAMING_ATTRS +#include "clang/Basic/arm_sme_streaming_attrs.inc" SamTebbs33 wrote: Kept the function separate as per our offline discussion. 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
[llvm] [clang] Include LLVM_VERSION_SUFFIX in the Clang version string. (PR #74469)
https://github.com/jyknight created https://github.com/llvm/llvm-project/pull/74469 This causes current mainline to now report "18.0.0git" instead of "18.0.0". Fixes #53825 >From 00f710804e77ccc001025a4524ab6882377d1089 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Tue, 5 Dec 2023 08:41:08 -0500 Subject: [PATCH] Include LLVM_VERSION_SUFFIX in the Clang version string. This causes current mainline to now report "18.0.0git" instead of "18.0.0". Fixes #53825 --- clang/CMakeLists.txt | 6 -- clang/test/Frontend/sarif-diagnostics.cpp | 4 ++-- llvm/utils/UpdateTestChecks/common.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 9b52c58be41e7..65ed790e69c2a 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -290,8 +290,10 @@ endif() if(NOT DEFINED CLANG_VERSION_PATCHLEVEL) set(CLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH}) endif() -# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX. -set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}") +if(NOT DEFINED CLANG_VERSION_SUFFIX) + set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) +endif() +set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${LLVM_VERSION_SUFFIX}") message(STATUS "Clang version: ${CLANG_VERSION}") # Configure the Version.inc file. diff --git a/clang/test/Frontend/sarif-diagnostics.cpp b/clang/test/Frontend/sarif-diagnostics.cpp index 9a4e686389a2e..767c5802ca13d 100644 --- a/clang/test/Frontend/sarif-diagnostics.cpp +++ b/clang/test/Frontend/sarif-diagnostics.cpp @@ -64,5 +64,5 @@ void f1(t1 x, t1 y) { // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"{{[0-9]+}}","name":""},{"defaultConfiguration": // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"{{[0-9]+}}","name":""},{"defaultConfiguration": // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription": -// CHECK: {"text":""},"id":"{{[0-9]+}}","name":""}],"version":"{{[0-9]+\.[0-9]+\.[0-9]+}}"}}}],"version":"2.1.0"} -// CHECK: 2 warnings and 6 errors generated. \ No newline at end of file +// CHECK: {"text":""},"id":"{{[0-9]+}}","name":""}],"version":"{{[0-9]+\.[0-9]+\.[0-9]+[^" ]*}}"}}}],"version":"2.1.0"} +// CHECK: 2 warnings and 6 errors generated. diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 5c3775e3d0859..0fe0dfc506b05 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -1701,7 +1701,7 @@ def add(var): METADATA_FILTERS = [ ( -r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?", +r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?:[^\" ]*)(?: \([^)]+\))?", r"{{.*}}\2{{.*}}", ), # preface with glob also, to capture optional CLANG_VENDOR (r'(!DIFile\(filename: ".+", directory: )".+"', r"\1{{.*}}"), ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Include LLVM_VERSION_SUFFIX in the Clang version string. (PR #74469)
llvmbot wrote: @llvm/pr-subscribers-clang Author: James Y Knight (jyknight) Changes This causes current mainline to now report "18.0.0git" instead of "18.0.0". Fixes #53825 --- Full diff: https://github.com/llvm/llvm-project/pull/74469.diff 3 Files Affected: - (modified) clang/CMakeLists.txt (+4-2) - (modified) clang/test/Frontend/sarif-diagnostics.cpp (+2-2) - (modified) llvm/utils/UpdateTestChecks/common.py (+1-1) ``diff diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 9b52c58be41e7..65ed790e69c2a 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -290,8 +290,10 @@ endif() if(NOT DEFINED CLANG_VERSION_PATCHLEVEL) set(CLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH}) endif() -# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX. -set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}") +if(NOT DEFINED CLANG_VERSION_SUFFIX) + set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) +endif() +set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${LLVM_VERSION_SUFFIX}") message(STATUS "Clang version: ${CLANG_VERSION}") # Configure the Version.inc file. diff --git a/clang/test/Frontend/sarif-diagnostics.cpp b/clang/test/Frontend/sarif-diagnostics.cpp index 9a4e686389a2e..767c5802ca13d 100644 --- a/clang/test/Frontend/sarif-diagnostics.cpp +++ b/clang/test/Frontend/sarif-diagnostics.cpp @@ -64,5 +64,5 @@ void f1(t1 x, t1 y) { // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"{{[0-9]+}}","name":""},{"defaultConfiguration": // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"{{[0-9]+}}","name":""},{"defaultConfiguration": // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription": -// CHECK: {"text":""},"id":"{{[0-9]+}}","name":""}],"version":"{{[0-9]+\.[0-9]+\.[0-9]+}}"}}}],"version":"2.1.0"} -// CHECK: 2 warnings and 6 errors generated. \ No newline at end of file +// CHECK: {"text":""},"id":"{{[0-9]+}}","name":""}],"version":"{{[0-9]+\.[0-9]+\.[0-9]+[^" ]*}}"}}}],"version":"2.1.0"} +// CHECK: 2 warnings and 6 errors generated. diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 5c3775e3d0859..0fe0dfc506b05 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -1701,7 +1701,7 @@ def add(var): METADATA_FILTERS = [ ( -r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?", +r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?:[^\" ]*)(?: \([^)]+\))?", r"{{.*}}\2{{.*}}", ), # preface with glob also, to capture optional CLANG_VENDOR (r'(!DIFile\(filename: ".+", directory: )".+"', r"\1{{.*}}"), `` https://github.com/llvm/llvm-project/pull/74469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Include LLVM_VERSION_SUFFIX in the Clang version string. (PR #74469)
https://github.com/jyknight updated https://github.com/llvm/llvm-project/pull/74469 >From 00f710804e77ccc001025a4524ab6882377d1089 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Tue, 5 Dec 2023 08:41:08 -0500 Subject: [PATCH 1/2] Include LLVM_VERSION_SUFFIX in the Clang version string. This causes current mainline to now report "18.0.0git" instead of "18.0.0". Fixes #53825 --- clang/CMakeLists.txt | 6 -- clang/test/Frontend/sarif-diagnostics.cpp | 4 ++-- llvm/utils/UpdateTestChecks/common.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 9b52c58be41e7..65ed790e69c2a 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -290,8 +290,10 @@ endif() if(NOT DEFINED CLANG_VERSION_PATCHLEVEL) set(CLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH}) endif() -# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX. -set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}") +if(NOT DEFINED CLANG_VERSION_SUFFIX) + set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) +endif() +set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${LLVM_VERSION_SUFFIX}") message(STATUS "Clang version: ${CLANG_VERSION}") # Configure the Version.inc file. diff --git a/clang/test/Frontend/sarif-diagnostics.cpp b/clang/test/Frontend/sarif-diagnostics.cpp index 9a4e686389a2e..767c5802ca13d 100644 --- a/clang/test/Frontend/sarif-diagnostics.cpp +++ b/clang/test/Frontend/sarif-diagnostics.cpp @@ -64,5 +64,5 @@ void f1(t1 x, t1 y) { // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"{{[0-9]+}}","name":""},{"defaultConfiguration": // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"{{[0-9]+}}","name":""},{"defaultConfiguration": // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription": -// CHECK: {"text":""},"id":"{{[0-9]+}}","name":""}],"version":"{{[0-9]+\.[0-9]+\.[0-9]+}}"}}}],"version":"2.1.0"} -// CHECK: 2 warnings and 6 errors generated. \ No newline at end of file +// CHECK: {"text":""},"id":"{{[0-9]+}}","name":""}],"version":"{{[0-9]+\.[0-9]+\.[0-9]+[^" ]*}}"}}}],"version":"2.1.0"} +// CHECK: 2 warnings and 6 errors generated. diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 5c3775e3d0859..0fe0dfc506b05 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -1701,7 +1701,7 @@ def add(var): METADATA_FILTERS = [ ( -r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?", +r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?:[^\" ]*)(?: \([^)]+\))?", r"{{.*}}\2{{.*}}", ), # preface with glob also, to capture optional CLANG_VENDOR (r'(!DIFile\(filename: ".+", directory: )".+"', r"\1{{.*}}"), >From bc27175cb8bb3a6500f1101385ad7b02badd1470 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Tue, 5 Dec 2023 09:00:28 -0500 Subject: [PATCH 2/2] Meant to use CLANG_VERSION_SUFFIX. --- clang/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 65ed790e69c2a..2ca6db02e5879 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -293,7 +293,7 @@ endif() if(NOT DEFINED CLANG_VERSION_SUFFIX) set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) endif() -set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${LLVM_VERSION_SUFFIX}") +set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}") message(STATUS "Clang version: ${CLANG_VERSION}") # Configure the Version.inc file. @@ -652,6 +652,7 @@ if (CLANG_ENABLE_BOOTSTRAP) CLANG_VERSION_MAJOR CLANG_VERSION_MINOR CLANG_VERSION_PATCHLEVEL +CLANG_VERSION_SUFFIX CLANG_VENDOR LLVM_VERSION_SUFFIX LLVM_BINUTILS_INCDIR ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analyzer][NFC] Supplement comments in `evalFtell` of StreamChecker (PR #74291)
https://github.com/balazske approved this pull request. https://github.com/llvm/llvm-project/pull/74291 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang] [XCOFF][obj2yaml] support parsing auxiliary symbols for XCOFF (PR #70642)
@@ -106,6 +126,210 @@ Error XCOFFDumper::dumpSections(ArrayRef Sections) { return Error::success(); } +Error XCOFFDumper::dumpFileAuxSym(XCOFFYAML::Symbol &Sym, + const XCOFFSymbolRef &SymbolEntRef) { + for (uint8_t I = 1; I <= Sym.NumberOfAuxEntries; ++I) { +uintptr_t AuxAddress = XCOFFObjectFile::getAdvancedSymbolEntryAddress( +SymbolEntRef.getEntryAddress(), I); +const XCOFFFileAuxEnt *FileAuxEntPtr = +getAuxEntPtr(AuxAddress); +auto FileNameOrError = Obj.getCFileName(FileAuxEntPtr); +if (!FileNameOrError) + return FileNameOrError.takeError(); + +XCOFFYAML::FileAuxEnt FileAuxSym; +FileAuxSym.FileNameOrString = FileNameOrError.get(); +FileAuxSym.FileStringType = FileAuxEntPtr->Type; +Sym.AuxEntries.push_back( diggerlin wrote: > If I understand you correctly, I think currently we have print the aux type > in the yaml file regardless of whether it is 32-bit or 64-bit. There is a > constructor in each aux symbol struct, like > `FileAuxEnt():AuxSymbolEnt(AuxSymbolType::AUX_FILE) {}`, and we can verify > this in the test file llvm/test/tools/obj2yaml/XCOFF/aux-symbols.yaml > > ( Although auxiliary symbol entries in XCOFF32 do not really have the > x_auxtype field, it's no harm to print the info in yaml and it's helpful when > transforming yaml to object. My understand we should print out the fields as it is in the object file. what is James' opinion ? @jh7370 https://github.com/llvm/llvm-project/pull/70642 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 94708fb - [clang][NFC] Fill in historical data on when C++ DRs 600-699 were fixed
Author: Vlad Serebrennikov Date: 2023-12-05T17:16:10+03:00 New Revision: 94708fbc0fa06b18c9b263ecb78d20a95a194e7f URL: https://github.com/llvm/llvm-project/commit/94708fbc0fa06b18c9b263ecb78d20a95a194e7f DIFF: https://github.com/llvm/llvm-project/commit/94708fbc0fa06b18c9b263ecb78d20a95a194e7f.diff LOG: [clang][NFC] Fill in historical data on when C++ DRs 600-699 were fixed Added: Modified: clang/test/CXX/drs/dr6xx.cpp clang/www/cxx_dr_status.html Removed: diff --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp index c5cd478c5e331..4cba1f057cb27 100644 --- a/clang/test/CXX/drs/dr6xx.cpp +++ b/clang/test/CXX/drs/dr6xx.cpp @@ -5,7 +5,7 @@ // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking // RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -namespace dr600 { // dr600: yes +namespace dr600 { // dr600: 2.8 struct S { void f(int); @@ -82,7 +82,7 @@ namespace dr603 { // dr603: yes // dr604: na // dr605 needs IRGen test -namespace dr606 { // dr606: yes +namespace dr606 { // dr606: 3.0 #if __cplusplus >= 201103L template struct S {}; template void f(S &&); // expected-note {{expects an rvalue}} @@ -266,7 +266,7 @@ namespace dr627 { // dr627: yes // dr628: na -namespace dr629 { // dr629: yes +namespace dr629 { // dr629: 2.9 typedef int T; int n = 1; void f() { @@ -399,7 +399,7 @@ namespace dr638 { // dr638: no }; } -namespace dr639 { // dr639: yes +namespace dr639 { // dr639: 3.3 void f(int i) { void((i = 0) + (i = 0)); // expected-warning {{unsequenced}} } @@ -462,7 +462,7 @@ namespace dr642 { // dr642: yes } #if __cplusplus >= 201103L -namespace dr643 { // dr643: yes +namespace dr643 { // dr643: 3.2 struct A { int x; auto f() -> decltype(this->x); @@ -522,7 +522,7 @@ namespace dr646 { // dr646: sup 981 #endif #if __cplusplus >= 201103L -namespace dr647 { // dr647: yes +namespace dr647 { // dr647: 3.1 // This is partially superseded by dr1358. struct A { constexpr virtual void f() const; @@ -594,7 +594,7 @@ namespace dr648 { // dr648: yes #endif #if __cplusplus >= 201103L -namespace dr649 { // dr649: yes +namespace dr649 { // dr649: 3.5 alignas(0x2) int n; // expected-error {{requested alignment}}1 struct alignas(0x2) X {}; // expected-error {{requested alignment}} struct Y { @@ -728,7 +728,7 @@ namespace dr657 { // dr657: partial // dr658 FIXME: add codegen test #if __cplusplus >= 201103L -namespace dr659 { // dr659: yes +namespace dr659 { // dr659: 3.0 static_assert(alignof(char) == alignof(char&), ""); static_assert(alignof(int) == alignof(int&), ""); int n = alignof(int(&)()); // expected-error {{application of 'alignof' to a function type}} @@ -738,7 +738,7 @@ namespace dr659 { // dr659: yes #endif #if __cplusplus >= 201103L -namespace dr660 { // dr660: yes +namespace dr660 { // dr660: 3.0 enum : int { a }; enum class { b }; // expected-error {{requires a name}} auto x = a; @@ -779,7 +779,7 @@ namespace dr664 { // dr664: yes } #endif -namespace dr665 { // dr665: yes +namespace dr665 { // dr665: 2.8 struct A { virtual ~A(); }; struct B : A {} *b; struct C : private A {} *c; // expected-note {{here}} @@ -799,7 +799,7 @@ namespace dr665 { // dr665: yes } } -namespace dr666 { // dr666: yes +namespace dr666 { // dr666: 2.8 struct P { friend P operator*(P, P); P(int); } p(0); template int f(); @@ -816,7 +816,7 @@ namespace dr666 { // dr666: yes // Triviality is entirely diff erent in C++98. #if __cplusplus >= 201103L -namespace dr667 { // dr667: yes +namespace dr667 { // dr667: 8 struct A { A() = default; // expected-warning {{explicitly defaulted default constructor is implicitly deleted}} expected-note{{replace 'default'}} int &r; // expected-note {{because field 'r' of reference type 'int &' would not be initialized}} @@ -868,7 +868,7 @@ namespace dr669 { // dr669: yes } #endif -namespace dr671 { // dr671: yes +namespace dr671 { // dr671: 2.9 enum class E { e }; // expected-error 0-1 {{C++11}} E e = static_cast(0); int n = static_cast(E::e); // expected-error 0-1 {{C++11}} @@ -1064,7 +1064,7 @@ namespace dr685 { // dr685: yes int x = k(g); } -namespace dr686 { // dr686: yes +namespace dr686 { // dr686: 3.0 void f() { (void)dynamic_cast(0); // expected-error {{incomplete}} expected-note {{forward}} (void)dynamic_cast(0); // expected-error {{cannot be defined in a type specifier}} @@ -1190,7 +1190,7 @@ namespace dr692 { // dr692: 16 } } -namespace dr696 { // dr696: yes +namespace dr696 { // dr696: 3.1 void f(const int*); void g() { const int N = 10; // expected-note 1+{{here}} diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_s
[clang] [Clang][OpenMP] Fix private variables registration in `simd` (PR #74105)
https://github.com/shiltian closed https://github.com/llvm/llvm-project/pull/74105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Include LLVM_VERSION_SUFFIX in the Clang version string. (PR #74469)
https://github.com/zmodem edited https://github.com/llvm/llvm-project/pull/74469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Include LLVM_VERSION_SUFFIX in the Clang version string. (PR #74469)
@@ -650,6 +652,7 @@ if (CLANG_ENABLE_BOOTSTRAP) CLANG_VERSION_MAJOR CLANG_VERSION_MINOR CLANG_VERSION_PATCHLEVEL +CLANG_VERSION_SUFFIX zmodem wrote: There's currently nothing in clang/include/clang/Basic/Version.inc.in using this. Should we add it while we're here? Otherwise perhaps we should leave it out. https://github.com/llvm/llvm-project/pull/74469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Include LLVM_VERSION_SUFFIX in the Clang version string. (PR #74469)
https://github.com/zmodem approved this pull request. lgtm! https://github.com/llvm/llvm-project/pull/74469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)
@@ -10044,6 +10044,8 @@ def warn_missing_case : Warning<"%plural{" "3:enumeration values %1, %2, and %3 not handled in switch|" ":%0 enumeration values not handled in switch: %1, %2, %3...}0">, InGroup; +def warn_switch_default : Warning<"switch missing default case">, AaronBallman wrote: ```suggestion def warn_switch_default : Warning<"'switch' missing 'default' label">, ``` https://github.com/llvm/llvm-project/pull/73077 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Refactor expected directives in C++ DRs 600-699 (PR #74477)
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/74477 [clang][NFC] Refactor expected directives in C++ DRs 600-699 This patch continues the work started with https://github.com/llvm/llvm-project/commit/ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details. >From 12cc446ecd55936518cb3e8b13c4840bc008d2c8 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Tue, 5 Dec 2023 17:14:37 +0300 Subject: [PATCH] [clang][NFC] Refactor expected directives in C++ DRs 600-699 This patch continues the work started with ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details. --- clang/test/CXX/drs/dr6xx.cpp | 656 ++- 1 file changed, 418 insertions(+), 238 deletions(-) diff --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp index 4cba1f057cb27..37694e3647c63 100644 --- a/clang/test/CXX/drs/dr6xx.cpp +++ b/clang/test/CXX/drs/dr6xx.cpp @@ -1,22 +1,24 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98-17,cxx98-14,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11,cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++14 %s -verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++17 %s -verify=expected,cxx98-17,cxx11-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking namespace dr600 { // dr600: 2.8 struct S { void f(int); private: - void f(double); // expected-note {{declared private here}} + void f(double); // #dr600-f-double }; void g(S *sp) { sp->f(2); // access control is applied after overload resolution - sp->f(2.2); // expected-error {{is a private member}} + sp->f(2.2); + // expected-error@-1 {{'f' is a private member of 'dr600::S'}} + // expected-note@#dr600-f-double {{declared private here}} } } // namespace dr600 @@ -41,7 +43,8 @@ namespace dr601 { // dr601: yes #endif #if __INT_MAX__ == 0x7FFF -_Static_assert(0x8000 < -1, "0x8000 should be unsigned"); // expected-error {{C11}} +_Static_assert(0x8000 < -1, "0x8000 should be unsigned"); +// expected-error@-1 {{'_Static_assert' is a C11 extension}} #endif #if MAX > 0x && 0x8000 < -1 @@ -49,7 +52,7 @@ _Static_assert(0x8000 < -1, "0x8000 should be unsigned"); // expected-er #endif #if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFF -static_assert(0x8000 < -1, "0x8000 should be unsigned"); // expected-error {{C11}} +static_assert(0x8000 < -1, "0x8000 should be unsigned"); #endif #undef MAX @@ -74,9 +77,7 @@ namespace dr603 { // dr603: yes template struct S {}; typedef S<'\001'> S1; typedef S<(1ul << __CHAR_BIT__) + 1> S1; -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be narrowed}} -#endif + // since-cxx11-error@-1 {{cannot be narrowed}} } // dr604: na @@ -85,14 +86,18 @@ namespace dr603 { // dr603: yes namespace dr606 { // dr606: 3.0 #if __cplusplus >= 201103L template struct S {}; - template void f(S &&); // expected-note {{expects an rvalue}} + template void f(S &&); // #dr606-f template void g(T &&); - template void h(const T &&); // expected-note {{expects an rvalue}} + template void h(const T &&); // #dr606-h void test(S s) { -f(s); // expected-error {{no match}} +f(s); +// since-cxx11-error@-1 {{no matching function for call to 'f'}} +// since-cxx11-note@#dr606-f {{candidate function [with T = int] not viable: expects an rvalue for 1st argument}} g(s); -h(s); // expected-error {{no match}} +h(s); +// since-cxx11-error@-1 {{no matching function for call to 'h'}} +// since-cxx11-note@#dr606-h {{candidate function [with T = dr606::S] not viabl
[clang] [clang][NFC] Refactor expected directives in C++ DRs 600-699 (PR #74477)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) Changes [clang][NFC] Refactor expected directives in C++ DRs 600-699 This patch continues the work started with https://github.com/llvm/llvm-project/commit/ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details. --- Patch is 55.30 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74477.diff 1 Files Affected: - (modified) clang/test/CXX/drs/dr6xx.cpp (+418-238) ``diff diff --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp index 4cba1f057cb27..37694e3647c63 100644 --- a/clang/test/CXX/drs/dr6xx.cpp +++ b/clang/test/CXX/drs/dr6xx.cpp @@ -1,22 +1,24 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98-17,cxx98-14,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11,cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++14 %s -verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++17 %s -verify=expected,cxx98-17,cxx11-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking namespace dr600 { // dr600: 2.8 struct S { void f(int); private: - void f(double); // expected-note {{declared private here}} + void f(double); // #dr600-f-double }; void g(S *sp) { sp->f(2); // access control is applied after overload resolution - sp->f(2.2); // expected-error {{is a private member}} + sp->f(2.2); + // expected-error@-1 {{'f' is a private member of 'dr600::S'}} + // expected-note@#dr600-f-double {{declared private here}} } } // namespace dr600 @@ -41,7 +43,8 @@ namespace dr601 { // dr601: yes #endif #if __INT_MAX__ == 0x7FFF -_Static_assert(0x8000 < -1, "0x8000 should be unsigned"); // expected-error {{C11}} +_Static_assert(0x8000 < -1, "0x8000 should be unsigned"); +// expected-error@-1 {{'_Static_assert' is a C11 extension}} #endif #if MAX > 0x && 0x8000 < -1 @@ -49,7 +52,7 @@ _Static_assert(0x8000 < -1, "0x8000 should be unsigned"); // expected-er #endif #if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFF -static_assert(0x8000 < -1, "0x8000 should be unsigned"); // expected-error {{C11}} +static_assert(0x8000 < -1, "0x8000 should be unsigned"); #endif #undef MAX @@ -74,9 +77,7 @@ namespace dr603 { // dr603: yes template struct S {}; typedef S<'\001'> S1; typedef S<(1ul << __CHAR_BIT__) + 1> S1; -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be narrowed}} -#endif + // since-cxx11-error@-1 {{cannot be narrowed}} } // dr604: na @@ -85,14 +86,18 @@ namespace dr603 { // dr603: yes namespace dr606 { // dr606: 3.0 #if __cplusplus >= 201103L template struct S {}; - template void f(S &&); // expected-note {{expects an rvalue}} + template void f(S &&); // #dr606-f template void g(T &&); - template void h(const T &&); // expected-note {{expects an rvalue}} + template void h(const T &&); // #dr606-h void test(S s) { -f(s); // expected-error {{no match}} +f(s); +// since-cxx11-error@-1 {{no matching function for call to 'f'}} +// since-cxx11-note@#dr606-f {{candidate function [with T = int] not viable: expects an rvalue for 1st argument}} g(s); -h(s); // expected-error {{no match}} +h(s); +// since-cxx11-error@-1 {{no matching function for call to 'h'}} +// since-cxx11-note@#dr606-h {{candidate function [with T = dr606::S] not viable: expects an rvalue for 1st argument}} g(test); h(test); // ok, an rvalue reference can bind to a function lvalue @@ -152,33 +157,32 @@ namespace dr613 { // dr613: yes c++11 B &g(int); int an1 = sizeof(A::n); + // cxx98-error@-1 {{invalid
[clang] [clang][NFC] Refactor expected directives in C++ DRs 600-699 (PR #74477)
Endilll wrote: This PR is created to check the patch against CI. https://github.com/llvm/llvm-project/pull/74477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)
AaronBallman wrote: > I think there is value to adding this if only for the GCC compat story here. > I realize we don't like non-on-by-default warnings, but it IS something that > folks use reasonably often, and we've even acquiesced to making it an ignored > flag IIRC. Aaron is the real decision maker here, but I think I'd have no > problem holding my nose and allowing the non-on-by-default here, if only to > match GCC. I think GCC compatibility is sufficient reason to support this despite being off-by-default and basically no hope of ever enabling it by default. There's evidence that people enable this in the wild, so I think it meets the bar: https://sourcegraph.com/search?q=context%3Aglobal+-Wswitch-default+-file%3A.*clang.*+-file%3A.*gcc.*&patternType=standard&sm=1&groupBy=repo https://github.com/llvm/llvm-project/pull/73077 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits