diff --git a/0001-PATCH-clang-Don-t-install-static-libraries.patch b/0001-PATCH-clang-Don-t-install-static-libraries.patch new file mode 100644 index 0000000000000000000000000000000000000000..c20ec493135988a743344a88d2bf62cfe1be6881 --- /dev/null +++ b/0001-PATCH-clang-Don-t-install-static-libraries.patch @@ -0,0 +1,24 @@ +From 88704fc2eabb9dd19a9c3eb81a9b3dc37d95651c Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Fri, 31 Jan 2020 11:04:57 -0800 +Subject: [PATCH][clang] Don't install static libraries + +--- + clang/cmake/modules/AddClang.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake +index 5752f4277444..0f52822d91f0 100644 +--- a/clang/cmake/modules/AddClang.cmake ++++ b/clang/cmake/modules/AddClang.cmake +@@ -113,7 +113,7 @@ macro(add_clang_library name) + if(TARGET ${lib}) + target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS}) + +- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN) ++ if (ARG_SHARED AND (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)) + get_target_export_arg(${name} Clang export_to_clangtargets UMBRELLA clang-libraries) + install(TARGETS ${lib} + COMPONENT ${lib} +-- +2.30.2 \ No newline at end of file diff --git a/1701-Always-build-shared-libs-for-LLD.patch b/1701-Always-build-shared-libs-for-LLD.patch new file mode 100644 index 0000000000000000000000000000000000000000..307727199f648e66d46cc9b693ef2f55a4bd4531 --- /dev/null +++ b/1701-Always-build-shared-libs-for-LLD.patch @@ -0,0 +1,29 @@ +From b1c60d7fa322a2d208556087df9e7ef94bfbffb8 Mon Sep 17 00:00:00 2001 +From: Nikita Popov +Date: Wed, 8 May 2024 12:30:36 +0900 +Subject: [PATCH] Always build shared libs for LLD + +We don't want to enable BUILD_SHARED_LIBS for the whole build, +but we do want to build lld libraries. +--- + lld/cmake/modules/AddLLD.cmake | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake +index 2ee066b41535..270c03f096ac 100644 +--- a/lld/cmake/modules/AddLLD.cmake ++++ b/lld/cmake/modules/AddLLD.cmake +@@ -7,9 +7,8 @@ macro(add_lld_library name) + "" + "" + ${ARGN}) +- if(ARG_SHARED) +- set(ARG_ENABLE_SHARED SHARED) +- endif() ++ # Always build shared libs for LLD. ++ set(ARG_ENABLE_SHARED SHARED) + llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS}) + set_target_properties(${name} PROPERTIES FOLDER "lld libraries") + +-- +2.44.0 \ No newline at end of file diff --git a/1702-fedora-standalone.patch b/1702-fedora-standalone.patch new file mode 100644 index 0000000000000000000000000000000000000000..1e4646a4a903c1b7c0e1e71a810055d7d8953681 --- /dev/null +++ b/1702-fedora-standalone.patch @@ -0,0 +1,22 @@ +From 0ef68aab2b08915b9144ffa67b3319e3e8332445 Mon Sep 17 00:00:00 2001 +From: Nikita Popov +Date: Thu, 4 Aug 2022 12:44:15 +0200 +Subject: [PATCH] Fix standalone build + +--- + libunwind/docs/CMakeLists.txt | 1 + + 1 files changed, 1 insertions(+) + +diff --git a/libunwind/docs/CMakeLists.txt b/libunwind/docs/CMakeLists.txt +index 79b87eb03b44..eaf6f3db5223 100644 +--- a/libunwind/docs/CMakeLists.txt ++++ b/libunwind/docs/CMakeLists.txt +@@ -1,5 +1,6 @@ + include(FindSphinx) + if (SPHINX_FOUND AND LLVM_ENABLE_SPHINX) ++ include(AddLLVM) + include(AddSphinxTarget) + if (${SPHINX_OUTPUT_HTML}) + add_sphinx_target(html libunwind) +-- +2.37.1 \ No newline at end of file diff --git a/1703-Revert-68-backport-Support-stack-clash-protection-in.patch b/1703-Revert-68-backport-Support-stack-clash-protection-in.patch new file mode 100644 index 0000000000000000000000000000000000000000..5cba8dd85a51d117ae91de70050030ae087f259c --- /dev/null +++ b/1703-Revert-68-backport-Support-stack-clash-protection-in.patch @@ -0,0 +1,4534 @@ +From c55ae6c29623f5e31eb3a9175ca50bf42a7d67a8 Mon Sep 17 00:00:00 2001 +From: liyunfei +Date: Fri, 17 Jan 2025 15:25:00 +0800 +Subject: [PATCH] Revert "!68 [backport] Support stack clash protection in + version 17.0.6" + +This reverts commit 6936efe8eafa228bb519303772310f5fbdaba75c, reversing +changes made to 64f328180a2ed7b28bae72a8efe1d45322f92a5f. +--- + clang/lib/CodeGen/CodeGenModule.cpp | 13 - + clang/lib/Driver/ToolChains/Clang.cpp | 2 +- + clang/test/CodeGen/stack-clash-protection.c | 18 +- + .../llvm/CodeGen/GlobalISel/LegalizerHelper.h | 4 - + llvm/include/llvm/Support/TargetOpcodes.def | 6 - + llvm/include/llvm/Target/GenericOpcodes.td | 12 - + llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 25 +- + .../CodeGen/GlobalISel/LegalizerHelper.cpp | 63 +- + .../Target/AArch64/AArch64FrameLowering.cpp | 439 ++--------- + .../lib/Target/AArch64/AArch64FrameLowering.h | 18 - + .../Target/AArch64/AArch64ISelLowering.cpp | 158 ++-- + llvm/lib/Target/AArch64/AArch64ISelLowering.h | 23 +- + llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 90 --- + llvm/lib/Target/AArch64/AArch64InstrInfo.h | 6 - + llvm/lib/Target/AArch64/AArch64InstrInfo.td | 38 +- + .../AArch64/AArch64MachineFunctionInfo.cpp | 43 +- + .../AArch64/AArch64MachineFunctionInfo.h | 6 - + .../AArch64/GISel/AArch64LegalizerInfo.cpp | 45 +- + .../AArch64/GISel/AArch64LegalizerInfo.h | 1 - + llvm/lib/Target/X86/X86LegalizerInfo.cpp | 4 - + .../AArch64/GlobalISel/arm64-irtranslator.ll | 4 +- + .../GlobalISel/legalize-dyn-alloca.mir | 254 ++---- + .../GlobalISel/legalizer-info-validation.mir | 17 +- + .../GlobalISel/stacksave-stackrestore.ll | 39 - + .../AArch64/framelayout-sve-basepointer.mir | 4 +- + .../framelayout-sve-fixed-width-access.mir | 2 +- + .../framelayout-sve-scavengingslot.mir | 4 +- + llvm/test/CodeGen/AArch64/framelayout-sve.mir | 54 +- + .../AArch64/spill-stack-realignment.mir | 2 +- + llvm/test/CodeGen/AArch64/stack-guard-sve.ll | 4 +- + .../test/CodeGen/AArch64/stack-probing-64k.ll | 392 ---------- + .../stack-probing-dynamic-no-frame-setup.ll | 14 - + .../CodeGen/AArch64/stack-probing-dynamic.ll | 365 --------- + .../AArch64/stack-probing-last-in-block.mir | 144 ---- + .../test/CodeGen/AArch64/stack-probing-sve.ll | 724 ------------------ + llvm/test/CodeGen/AArch64/stack-probing.ll | 539 ------------- + .../AArch64/sve-calling-convention-mixed.ll | 4 +- + .../CodeGen/AArch64/sve-fixed-length-fp128.ll | 4 +- + .../X86/GlobalISel/stacksave-stackrestore.ll | 43 -- + 39 files changed, 265 insertions(+), 3362 deletions(-) + delete mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/stacksave-stackrestore.ll + delete mode 100644 llvm/test/CodeGen/AArch64/stack-probing-64k.ll + delete mode 100644 llvm/test/CodeGen/AArch64/stack-probing-dynamic-no-frame-setup.ll + delete mode 100644 llvm/test/CodeGen/AArch64/stack-probing-dynamic.ll + delete mode 100644 llvm/test/CodeGen/AArch64/stack-probing-last-in-block.mir + delete mode 100644 llvm/test/CodeGen/AArch64/stack-probing-sve.ll + delete mode 100644 llvm/test/CodeGen/AArch64/stack-probing.ll + delete mode 100644 llvm/test/CodeGen/X86/GlobalISel/stacksave-stackrestore.ll + +diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp +index eabc4aabea06..f09d1129b128 100644 +--- a/clang/lib/CodeGen/CodeGenModule.cpp ++++ b/clang/lib/CodeGen/CodeGenModule.cpp +@@ -1067,15 +1067,6 @@ void CodeGenModule::Release() { + "sign-return-address-with-bkey", 1); + } + +- if (CodeGenOpts.StackClashProtector) +- getModule().addModuleFlag( +- llvm::Module::Override, "probe-stack", +- llvm::MDString::get(TheModule.getContext(), "inline-asm")); +- +- if (CodeGenOpts.StackProbeSize && CodeGenOpts.StackProbeSize != 4096) +- getModule().addModuleFlag(llvm::Module::Min, "stack-probe-size", +- CodeGenOpts.StackProbeSize); +- + if (!CodeGenOpts.MemoryProfileOutput.empty()) { + llvm::LLVMContext &Ctx = TheModule.getContext(); + getModule().addModuleFlag( +@@ -2270,10 +2261,6 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, + if (CodeGenOpts.StackClashProtector) + B.addAttribute("probe-stack", "inline-asm"); + +- if (CodeGenOpts.StackProbeSize && CodeGenOpts.StackProbeSize != 4096) +- B.addAttribute("stack-probe-size", +- std::to_string(CodeGenOpts.StackProbeSize)); +- + if (!hasUnwindExceptions(LangOpts)) + B.addAttribute(llvm::Attribute::NoUnwind); + +diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp +index 4e5f689498d6..5b618806b4db 100644 +--- a/clang/lib/Driver/ToolChains/Clang.cpp ++++ b/clang/lib/Driver/ToolChains/Clang.cpp +@@ -3479,7 +3479,7 @@ static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args, + return; + + if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() && +- !EffectiveTriple.isPPC64() && !EffectiveTriple.isAArch64()) ++ !EffectiveTriple.isPPC64()) + return; + + Args.addOptInFlag(CmdArgs, options::OPT_fstack_clash_protection, +diff --git a/clang/test/CodeGen/stack-clash-protection.c b/clang/test/CodeGen/stack-clash-protection.c +index dab9ee768c28..67571f5cdb2c 100644 +--- a/clang/test/CodeGen/stack-clash-protection.c ++++ b/clang/test/CodeGen/stack-clash-protection.c +@@ -1,9 +1,8 @@ + // Check the correct function attributes are generated +-// RUN: %clang_cc1 -triple x86_64-linux -O0 -S -emit-llvm -o- %s -fstack-clash-protection -mstack-probe-size=8192 | FileCheck %s +-// RUN: %clang_cc1 -triple s390x-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection -mstack-probe-size=8192 | FileCheck %s +-// RUN: %clang_cc1 -triple powerpc64le-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection -mstack-probe-size=8192 | FileCheck %s +-// RUN: %clang_cc1 -triple powerpc64-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection -mstack-probe-size=8192 | FileCheck %s +-// RUN: %clang_cc1 -triple aarch64-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection -mstack-probe-size=8192 | FileCheck %s ++// RUN: %clang_cc1 -triple x86_64-linux -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s ++// RUN: %clang_cc1 -triple s390x-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s ++// RUN: %clang_cc1 -triple powerpc64le-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s ++// RUN: %clang_cc1 -triple powerpc64-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s + + // CHECK: define{{.*}} void @large_stack() #[[A:.*]] { + void large_stack(void) { +@@ -12,18 +11,15 @@ void large_stack(void) { + stack[i] = i; + } + +-// CHECK: define{{.*}} void @vla({{.*}}) #[[A]] { ++// CHECK: define{{.*}} void @vla({{.*}}) #[[A:.*]] { + void vla(int n) { + volatile int vla[n]; + __builtin_memset(&vla[0], 0, 1); + } + +-// CHECK: define{{.*}} void @builtin_alloca({{.*}}) #[[A]] { ++// CHECK: define{{.*}} void @builtin_alloca({{.*}}) #[[A:.*]] { + void builtin_alloca(int n) { + volatile void *mem = __builtin_alloca(n); + } + +-// CHECK: attributes #[[A]] = {{.*}}"probe-stack"="inline-asm" {{.*}}"stack-probe-size"="8192" +- +-// CHECK: !{i32 4, !"probe-stack", !"inline-asm"} +-// CHECK: !{i32 8, !"stack-probe-size", i32 8192} ++// CHECK: attributes #[[A]] = {{.*}} "probe-stack"="inline-asm" +diff --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h +index 7abbd1f03f16..a568edd0e640 100644 +--- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h ++++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h +@@ -400,11 +400,7 @@ public: + LegalizeResult lowerUnmergeValues(MachineInstr &MI); + LegalizeResult lowerExtractInsertVectorElt(MachineInstr &MI); + LegalizeResult lowerShuffleVector(MachineInstr &MI); +- Register getDynStackAllocTargetPtr(Register SPReg, Register AllocSize, +- Align Alignment, LLT PtrTy); + LegalizeResult lowerDynStackAlloc(MachineInstr &MI); +- LegalizeResult lowerStackSave(MachineInstr &MI); +- LegalizeResult lowerStackRestore(MachineInstr &MI); + LegalizeResult lowerExtract(MachineInstr &MI); + LegalizeResult lowerInsert(MachineInstr &MI); + LegalizeResult lowerSADDO_SSUBO(MachineInstr &MI); +diff --git a/llvm/include/llvm/Support/TargetOpcodes.def b/llvm/include/llvm/Support/TargetOpcodes.def +index c92ce6dc701c..186bea75ae96 100644 +--- a/llvm/include/llvm/Support/TargetOpcodes.def ++++ b/llvm/include/llvm/Support/TargetOpcodes.def +@@ -763,12 +763,6 @@ HANDLE_TARGET_OPCODE(G_JUMP_TABLE) + /// Generic dynamic stack allocation. + HANDLE_TARGET_OPCODE(G_DYN_STACKALLOC) + +-/// Generic stack pointer save. +-HANDLE_TARGET_OPCODE(G_STACKSAVE) +- +-/// Generic stack pointer restore. +-HANDLE_TARGET_OPCODE(G_STACKRESTORE) +- + /// Strict floating point instructions. + HANDLE_TARGET_OPCODE(G_STRICT_FADD) + HANDLE_TARGET_OPCODE(G_STRICT_FSUB) +diff --git a/llvm/include/llvm/Target/GenericOpcodes.td b/llvm/include/llvm/Target/GenericOpcodes.td +index e8cfaeab3cd8..00d56d1c4bd5 100644 +--- a/llvm/include/llvm/Target/GenericOpcodes.td ++++ b/llvm/include/llvm/Target/GenericOpcodes.td +@@ -225,18 +225,6 @@ def G_DYN_STACKALLOC : GenericInstruction { + let hasSideEffects = true; + } + +-def G_STACKSAVE : GenericInstruction { +- let OutOperandList = (outs ptype0:$dst); +- let InOperandList = (ins); +- let hasSideEffects = true; +-} +- +-def G_STACKRESTORE : GenericInstruction { +- let OutOperandList = (outs); +- let InOperandList = (ins ptype0:$src); +- let hasSideEffects = true; +-} +- + def G_FREEZE : GenericInstruction { + let OutOperandList = (outs type0:$dst); + let InOperandList = (ins type0:$src); +diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +index e4b837c6b8ce..9a67a8d05a4d 100644 +--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp ++++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +@@ -2229,12 +2229,31 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, + return true; + } + case Intrinsic::stacksave: { +- MIRBuilder.buildInstr(TargetOpcode::G_STACKSAVE, {getOrCreateVReg(CI)}, {}); ++ // Save the stack pointer to the location provided by the intrinsic. ++ Register Reg = getOrCreateVReg(CI); ++ Register StackPtr = MF->getSubtarget() ++ .getTargetLowering() ++ ->getStackPointerRegisterToSaveRestore(); ++ ++ // If the target doesn't specify a stack pointer, then fall back. ++ if (!StackPtr) ++ return false; ++ ++ MIRBuilder.buildCopy(Reg, StackPtr); + return true; + } + case Intrinsic::stackrestore: { +- MIRBuilder.buildInstr(TargetOpcode::G_STACKRESTORE, {}, +- {getOrCreateVReg(*CI.getArgOperand(0))}); ++ // Restore the stack pointer from the location provided by the intrinsic. ++ Register Reg = getOrCreateVReg(*CI.getArgOperand(0)); ++ Register StackPtr = MF->getSubtarget() ++ .getTargetLowering() ++ ->getStackPointerRegisterToSaveRestore(); ++ ++ // If the target doesn't specify a stack pointer, then fall back. ++ if (!StackPtr) ++ return false; ++ ++ MIRBuilder.buildCopy(StackPtr, Reg); + return true; + } + case Intrinsic::cttz: +diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp +index 5557456e706d..f0da0d88140f 100644 +--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp ++++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp +@@ -3503,10 +3503,6 @@ LegalizerHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT LowerHintTy) { + return lowerShuffleVector(MI); + case G_DYN_STACKALLOC: + return lowerDynStackAlloc(MI); +- case G_STACKSAVE: +- return lowerStackSave(MI); +- case G_STACKRESTORE: +- return lowerStackRestore(MI); + case G_EXTRACT: + return lowerExtract(MI); + case G_INSERT: +@@ -6777,12 +6773,21 @@ LegalizerHelper::lowerShuffleVector(MachineInstr &MI) { + return Legalized; + } + +-Register LegalizerHelper::getDynStackAllocTargetPtr(Register SPReg, +- Register AllocSize, +- Align Alignment, +- LLT PtrTy) { ++LegalizerHelper::LegalizeResult ++LegalizerHelper::lowerDynStackAlloc(MachineInstr &MI) { ++ const auto &MF = *MI.getMF(); ++ const auto &TFI = *MF.getSubtarget().getFrameLowering(); ++ if (TFI.getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp) ++ return UnableToLegalize; ++ ++ Register Dst = MI.getOperand(0).getReg(); ++ Register AllocSize = MI.getOperand(1).getReg(); ++ Align Alignment = assumeAligned(MI.getOperand(2).getImm()); ++ ++ LLT PtrTy = MRI.getType(Dst); + LLT IntPtrTy = LLT::scalar(PtrTy.getSizeInBits()); + ++ Register SPReg = TLI.getStackPointerRegisterToSaveRestore(); + auto SPTmp = MIRBuilder.buildCopy(PtrTy, SPReg); + SPTmp = MIRBuilder.buildCast(IntPtrTy, SPTmp); + +@@ -6797,25 +6802,7 @@ Register LegalizerHelper::getDynStackAllocTargetPtr(Register SPReg, + Alloc = MIRBuilder.buildAnd(IntPtrTy, Alloc, AlignCst); + } + +- return MIRBuilder.buildCast(PtrTy, Alloc).getReg(0); +-} +- +-LegalizerHelper::LegalizeResult +-LegalizerHelper::lowerDynStackAlloc(MachineInstr &MI) { +- const auto &MF = *MI.getMF(); +- const auto &TFI = *MF.getSubtarget().getFrameLowering(); +- if (TFI.getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp) +- return UnableToLegalize; +- +- Register Dst = MI.getOperand(0).getReg(); +- Register AllocSize = MI.getOperand(1).getReg(); +- Align Alignment = assumeAligned(MI.getOperand(2).getImm()); +- +- LLT PtrTy = MRI.getType(Dst); +- Register SPReg = TLI.getStackPointerRegisterToSaveRestore(); +- Register SPTmp = +- getDynStackAllocTargetPtr(SPReg, AllocSize, Alignment, PtrTy); +- ++ SPTmp = MIRBuilder.buildCast(PtrTy, Alloc); + MIRBuilder.buildCopy(SPReg, SPTmp); + MIRBuilder.buildCopy(Dst, SPTmp); + +@@ -6823,28 +6810,6 @@ LegalizerHelper::lowerDynStackAlloc(MachineInstr &MI) { + return Legalized; + } + +-LegalizerHelper::LegalizeResult +-LegalizerHelper::lowerStackSave(MachineInstr &MI) { +- Register StackPtr = TLI.getStackPointerRegisterToSaveRestore(); +- if (!StackPtr) +- return UnableToLegalize; +- +- MIRBuilder.buildCopy(MI.getOperand(0), StackPtr); +- MI.eraseFromParent(); +- return Legalized; +-} +- +-LegalizerHelper::LegalizeResult +-LegalizerHelper::lowerStackRestore(MachineInstr &MI) { +- Register StackPtr = TLI.getStackPointerRegisterToSaveRestore(); +- if (!StackPtr) +- return UnableToLegalize; +- +- MIRBuilder.buildCopy(StackPtr, MI.getOperand(0)); +- MI.eraseFromParent(); +- return Legalized; +-} +- + LegalizerHelper::LegalizeResult + LegalizerHelper::lowerExtract(MachineInstr &MI) { + auto [DstReg, DstTy, SrcReg, SrcTy] = MI.getFirst2RegLLTs(); +diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +index fe21173f531f..4d5676f34101 100644 +--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp ++++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +@@ -300,7 +300,6 @@ static int64_t getArgumentStackToRestore(MachineFunction &MF, + static bool produceCompactUnwindFrame(MachineFunction &MF); + static bool needsWinCFI(const MachineFunction &MF); + static StackOffset getSVEStackSize(const MachineFunction &MF); +-static unsigned findScratchNonCalleeSaveRegister(MachineBasicBlock *MBB); + static bool needsShadowCallStackPrologueEpilogue(MachineFunction &MF); + + /// Returns true if a homogeneous prolog or epilog code can be emitted +@@ -462,11 +461,6 @@ bool AArch64FrameLowering::hasFP(const MachineFunction &MF) const { + /// included as part of the stack frame. + bool + AArch64FrameLowering::hasReservedCallFrame(const MachineFunction &MF) const { +- // The stack probing code for the dynamically allocated outgoing arguments +- // area assumes that the stack is probed at the top - either by the prologue +- // code, which issues a probe if `hasVarSizedObjects` return true, or by the +- // most recent variable-sized object allocation. Changing the condition here +- // may need to be followed up by changes to the probe issuing logic. + return !MF.getFrameInfo().hasVarSizedObjects(); + } + +@@ -475,9 +469,6 @@ MachineBasicBlock::iterator AArch64FrameLowering::eliminateCallFramePseudoInstr( + MachineBasicBlock::iterator I) const { + const AArch64InstrInfo *TII = + static_cast(MF.getSubtarget().getInstrInfo()); +- const AArch64TargetLowering *TLI = +- MF.getSubtarget().getTargetLowering(); +- MachineFrameInfo &MFI = MF.getFrameInfo(); + DebugLoc DL = I->getDebugLoc(); + unsigned Opc = I->getOpcode(); + bool IsDestroy = Opc == TII->getCallFrameDestroyOpcode(); +@@ -504,24 +495,6 @@ MachineBasicBlock::iterator AArch64FrameLowering::eliminateCallFramePseudoInstr( + // Most call frames will be allocated at the start of a function so + // this is OK, but it is a limitation that needs dealing with. + assert(Amount > -0xffffff && Amount < 0xffffff && "call frame too large"); +- +- if (TLI->hasInlineStackProbe(MF) && +- -Amount >= AArch64::StackProbeMaxUnprobedStack) { +- // When stack probing is enabled, the decrement of SP may need to be +- // probed. We only need to do this if the call site needs 1024 bytes of +- // space or more, because a region smaller than that is allowed to be +- // unprobed at an ABI boundary. We rely on the fact that SP has been +- // probed exactly at this point, either by the prologue or most recent +- // dynamic allocation. +- assert(MFI.hasVarSizedObjects() && +- "non-reserved call frame without var sized objects?"); +- Register ScratchReg = +- MF.getRegInfo().createVirtualRegister(&AArch64::GPR64RegClass); +- inlineStackProbeFixed(I, ScratchReg, -Amount, StackOffset::get(0, 0)); +- } else { +- emitFrameOffset(MBB, I, DL, AArch64::SP, AArch64::SP, +- StackOffset::getFixed(Amount), TII); +- } + emitFrameOffset(MBB, I, DL, AArch64::SP, AArch64::SP, + StackOffset::getFixed(Amount), TII); + } +@@ -698,154 +671,6 @@ void AArch64FrameLowering::emitCalleeSavedSVERestores( + emitCalleeSavedRestores(MBB, MBBI, true); + } + +-// Return the maximum possible number of bytes for `Size` due to the +-// architectural limit on the size of a SVE register. +-static int64_t upperBound(StackOffset Size) { +- static const int64_t MAX_BYTES_PER_SCALABLE_BYTE = 16; +- return Size.getScalable() * MAX_BYTES_PER_SCALABLE_BYTE + Size.getFixed(); +-} +- +-void AArch64FrameLowering::allocateStackSpace( +- MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, +- int64_t RealignmentPadding, StackOffset AllocSize, bool NeedsWinCFI, +- bool *HasWinCFI, bool EmitCFI, StackOffset InitialOffset, +- bool FollowupAllocs) const { +- +- if (!AllocSize) +- return; +- +- DebugLoc DL; +- MachineFunction &MF = *MBB.getParent(); +- const AArch64Subtarget &Subtarget = MF.getSubtarget(); +- const TargetInstrInfo &TII = *Subtarget.getInstrInfo(); +- AArch64FunctionInfo &AFI = *MF.getInfo(); +- const MachineFrameInfo &MFI = MF.getFrameInfo(); +- +- const int64_t MaxAlign = MFI.getMaxAlign().value(); +- const uint64_t AndMask = ~(MaxAlign - 1); +- +- if (!Subtarget.getTargetLowering()->hasInlineStackProbe(MF)) { +- Register TargetReg = RealignmentPadding +- ? findScratchNonCalleeSaveRegister(&MBB) +- : AArch64::SP; +- // SUB Xd/SP, SP, AllocSize +- emitFrameOffset(MBB, MBBI, DL, TargetReg, AArch64::SP, -AllocSize, &TII, +- MachineInstr::FrameSetup, false, NeedsWinCFI, HasWinCFI, +- EmitCFI, InitialOffset); +- +- if (RealignmentPadding) { +- // AND SP, X9, 0b11111...0000 +- BuildMI(MBB, MBBI, DL, TII.get(AArch64::ANDXri), AArch64::SP) +- .addReg(TargetReg, RegState::Kill) +- .addImm(AArch64_AM::encodeLogicalImmediate(AndMask, 64)) +- .setMIFlags(MachineInstr::FrameSetup); +- AFI.setStackRealigned(true); +- +- // No need for SEH instructions here; if we're realigning the stack, +- // we've set a frame pointer and already finished the SEH prologue. +- assert(!NeedsWinCFI); +- } +- return; +- } +- +- // +- // Stack probing allocation. +- // +- +- // Fixed length allocation. If we don't need to re-align the stack and don't +- // have SVE objects, we can use a more efficient sequence for stack probing. +- if (AllocSize.getScalable() == 0 && RealignmentPadding == 0) { +- Register ScratchReg = findScratchNonCalleeSaveRegister(&MBB); +- assert(ScratchReg != AArch64::NoRegister); +- BuildMI(MBB, MBBI, DL, TII.get(AArch64::PROBED_STACKALLOC)) +- .addDef(ScratchReg) +- .addImm(AllocSize.getFixed()) +- .addImm(InitialOffset.getFixed()) +- .addImm(InitialOffset.getScalable()); +- // The fixed allocation may leave unprobed bytes at the top of the +- // stack. If we have subsequent alocation (e.g. if we have variable-sized +- // objects), we need to issue an extra probe, so these allocations start in +- // a known state. +- if (FollowupAllocs) { +- // STR XZR, [SP] +- BuildMI(MBB, MBBI, DL, TII.get(AArch64::STRXui)) +- .addReg(AArch64::XZR) +- .addReg(AArch64::SP) +- .addImm(0) +- .setMIFlags(MachineInstr::FrameSetup); +- } +- +- return; +- } +- +- // Variable length allocation. +- +- // If the (unknown) allocation size cannot exceed the probe size, decrement +- // the stack pointer right away. +- int64_t ProbeSize = AFI.getStackProbeSize(); +- if (upperBound(AllocSize) + RealignmentPadding <= ProbeSize) { +- Register ScratchReg = RealignmentPadding +- ? findScratchNonCalleeSaveRegister(&MBB) +- : AArch64::SP; +- assert(ScratchReg != AArch64::NoRegister); +- // SUB Xd, SP, AllocSize +- emitFrameOffset(MBB, MBBI, DL, ScratchReg, AArch64::SP, -AllocSize, &TII, +- MachineInstr::FrameSetup, false, NeedsWinCFI, HasWinCFI, +- EmitCFI, InitialOffset); +- if (RealignmentPadding) { +- // AND SP, Xn, 0b11111...0000 +- BuildMI(MBB, MBBI, DL, TII.get(AArch64::ANDXri), AArch64::SP) +- .addReg(ScratchReg, RegState::Kill) +- .addImm(AArch64_AM::encodeLogicalImmediate(AndMask, 64)) +- .setMIFlags(MachineInstr::FrameSetup); +- AFI.setStackRealigned(true); +- } +- if (FollowupAllocs || upperBound(AllocSize) + RealignmentPadding > +- AArch64::StackProbeMaxUnprobedStack) { +- // STR XZR, [SP] +- BuildMI(MBB, MBBI, DL, TII.get(AArch64::STRXui)) +- .addReg(AArch64::XZR) +- .addReg(AArch64::SP) +- .addImm(0) +- .setMIFlags(MachineInstr::FrameSetup); +- } +- return; +- } +- +- // Emit a variable-length allocation probing loop. +- // TODO: As an optimisation, the loop can be "unrolled" into a few parts, +- // each of them guaranteed to adjust the stack by less than the probe size. +- Register TargetReg = findScratchNonCalleeSaveRegister(&MBB); +- assert(TargetReg != AArch64::NoRegister); +- // SUB Xd, SP, AllocSize +- emitFrameOffset(MBB, MBBI, DL, TargetReg, AArch64::SP, -AllocSize, &TII, +- MachineInstr::FrameSetup, false, NeedsWinCFI, HasWinCFI, +- EmitCFI, InitialOffset); +- +- if (RealignmentPadding) { +- // AND Xn, Xn, 0b11111...0000 +- BuildMI(MBB, MBBI, DL, TII.get(AArch64::ANDXri), TargetReg) +- .addReg(TargetReg, RegState::Kill) +- .addImm(AArch64_AM::encodeLogicalImmediate(AndMask, 64)) +- .setMIFlags(MachineInstr::FrameSetup); +- } +- +- BuildMI(MBB, MBBI, DL, TII.get(AArch64::PROBED_STACKALLOC_VAR)) +- .addReg(TargetReg); +- if (EmitCFI) { +- // Set the CFA register back to SP. +- unsigned Reg = +- Subtarget.getRegisterInfo()->getDwarfRegNum(AArch64::SP, true); +- unsigned CFIIndex = +- MF.addFrameInst(MCCFIInstruction::createDefCfaRegister(nullptr, Reg)); +- BuildMI(MBB, MBBI, DL, TII.get(TargetOpcode::CFI_INSTRUCTION)) +- .addCFIIndex(CFIIndex) +- .setMIFlags(MachineInstr::FrameSetup); +- } +- if (RealignmentPadding) +- AFI.setStackRealigned(true); +-} +- + static MCRegister getRegisterOrZero(MCRegister Reg, bool HasSVE) { + switch (Reg.id()) { + default: +@@ -1029,11 +854,9 @@ bool AArch64FrameLowering::canUseAsPrologue( + MachineBasicBlock *TmpMBB = const_cast(&MBB); + const AArch64Subtarget &Subtarget = MF->getSubtarget(); + const AArch64RegisterInfo *RegInfo = Subtarget.getRegisterInfo(); +- const AArch64TargetLowering *TLI = Subtarget.getTargetLowering(); + +- // Don't need a scratch register if we're not going to re-align the stack or +- // emit stack probes. +- if (!RegInfo->hasStackRealignment(*MF) && TLI->hasInlineStackProbe(*MF)) ++ // Don't need a scratch register if we're not going to re-align the stack. ++ if (!RegInfo->hasStackRealignment(*MF)) + return true; + // Otherwise, we can use any block as long as it has a scratch register + // available. +@@ -1043,11 +866,15 @@ bool AArch64FrameLowering::canUseAsPrologue( + static bool windowsRequiresStackProbe(MachineFunction &MF, + uint64_t StackSizeInBytes) { + const AArch64Subtarget &Subtarget = MF.getSubtarget(); +- const AArch64FunctionInfo &MFI = *MF.getInfo(); ++ if (!Subtarget.isTargetWindows()) ++ return false; ++ const Function &F = MF.getFunction(); + // TODO: When implementing stack protectors, take that into account + // for the probe threshold. +- return Subtarget.isTargetWindows() && MFI.hasStackProbing() && +- StackSizeInBytes >= uint64_t(MFI.getStackProbeSize()); ++ unsigned StackProbeSize = ++ F.getFnAttributeAsParsedInteger("stack-probe-size", 4096); ++ return (StackSizeInBytes >= StackProbeSize) && ++ !F.hasFnAttribute("no-stack-arg-probe"); + } + + static bool needsWinCFI(const MachineFunction &MF) { +@@ -1812,7 +1639,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF, + // Alignment is required for the parent frame, not the funclet + const bool NeedsRealignment = + NumBytes && !IsFunclet && RegInfo->hasStackRealignment(MF); +- const int64_t RealignmentPadding = ++ int64_t RealignmentPadding = + (NeedsRealignment && MFI.getMaxAlign() > Align(16)) + ? MFI.getMaxAlign().value() - 16 + : 0; +@@ -1942,14 +1769,12 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF, + } + } + +- StackOffset SVECalleeSavesSize = {}, SVELocalsSize = SVEStackSize; ++ StackOffset AllocateBefore = SVEStackSize, AllocateAfter = {}; + MachineBasicBlock::iterator CalleeSavesBegin = MBBI, CalleeSavesEnd = MBBI; + + // Process the SVE callee-saves to determine what space needs to be + // allocated. + if (int64_t CalleeSavedSize = AFI->getSVECalleeSavedStackSize()) { +- LLVM_DEBUG(dbgs() << "SVECalleeSavedStackSize = " << CalleeSavedSize +- << "\n"); + // Find callee save instructions in frame. + CalleeSavesBegin = MBBI; + assert(IsSVECalleeSave(CalleeSavesBegin) && "Unexpected instruction"); +@@ -1957,34 +1782,67 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF, + ++MBBI; + CalleeSavesEnd = MBBI; + +- SVECalleeSavesSize = StackOffset::getScalable(CalleeSavedSize); +- SVELocalsSize = SVEStackSize - SVECalleeSavesSize; ++ AllocateBefore = StackOffset::getScalable(CalleeSavedSize); ++ AllocateAfter = SVEStackSize - AllocateBefore; + } + + // Allocate space for the callee saves (if any). +- StackOffset CFAOffset = +- StackOffset::getFixed((int64_t)MFI.getStackSize() - NumBytes); +- StackOffset LocalsSize = SVELocalsSize + StackOffset::getFixed(NumBytes); +- allocateStackSpace(MBB, CalleeSavesBegin, 0, SVECalleeSavesSize, false, +- nullptr, EmitAsyncCFI && !HasFP, CFAOffset, +- MFI.hasVarSizedObjects() || LocalsSize); +- CFAOffset += SVECalleeSavesSize; ++ emitFrameOffset( ++ MBB, CalleeSavesBegin, DL, AArch64::SP, AArch64::SP, -AllocateBefore, TII, ++ MachineInstr::FrameSetup, false, false, nullptr, ++ EmitAsyncCFI && !HasFP && AllocateBefore, ++ StackOffset::getFixed((int64_t)MFI.getStackSize() - NumBytes)); + + if (EmitAsyncCFI) + emitCalleeSavedSVELocations(MBB, CalleeSavesEnd); + +- // Allocate space for the rest of the frame including SVE locals. Align the +- // stack as necessary. +- assert(!(canUseRedZone(MF) && NeedsRealignment) && +- "Cannot use redzone with stack realignment"); +- if (!canUseRedZone(MF)) { +- // FIXME: in the case of dynamic re-alignment, NumBytes doesn't have +- // the correct value here, as NumBytes also includes padding bytes, +- // which shouldn't be counted here. +- allocateStackSpace(MBB, CalleeSavesEnd, RealignmentPadding, +- SVELocalsSize + StackOffset::getFixed(NumBytes), +- NeedsWinCFI, &HasWinCFI, EmitAsyncCFI && !HasFP, +- CFAOffset, MFI.hasVarSizedObjects()); ++ // Finally allocate remaining SVE stack space. ++ emitFrameOffset(MBB, CalleeSavesEnd, DL, AArch64::SP, AArch64::SP, ++ -AllocateAfter, TII, MachineInstr::FrameSetup, false, false, ++ nullptr, EmitAsyncCFI && !HasFP && AllocateAfter, ++ AllocateBefore + StackOffset::getFixed( ++ (int64_t)MFI.getStackSize() - NumBytes)); ++ ++ // Allocate space for the rest of the frame. ++ if (NumBytes) { ++ unsigned scratchSPReg = AArch64::SP; ++ ++ if (NeedsRealignment) { ++ scratchSPReg = findScratchNonCalleeSaveRegister(&MBB); ++ assert(scratchSPReg != AArch64::NoRegister); ++ } ++ ++ // If we're a leaf function, try using the red zone. ++ if (!canUseRedZone(MF)) { ++ // FIXME: in the case of dynamic re-alignment, NumBytes doesn't have ++ // the correct value here, as NumBytes also includes padding bytes, ++ // which shouldn't be counted here. ++ emitFrameOffset( ++ MBB, MBBI, DL, scratchSPReg, AArch64::SP, ++ StackOffset::getFixed(-NumBytes), TII, MachineInstr::FrameSetup, ++ false, NeedsWinCFI, &HasWinCFI, EmitAsyncCFI && !HasFP, ++ SVEStackSize + ++ StackOffset::getFixed((int64_t)MFI.getStackSize() - NumBytes)); ++ } ++ if (NeedsRealignment) { ++ assert(MFI.getMaxAlign() > Align(1)); ++ assert(scratchSPReg != AArch64::SP); ++ ++ // SUB X9, SP, NumBytes ++ // -- X9 is temporary register, so shouldn't contain any live data here, ++ // -- free to use. This is already produced by emitFrameOffset above. ++ // AND SP, X9, 0b11111...0000 ++ uint64_t AndMask = ~(MFI.getMaxAlign().value() - 1); ++ ++ BuildMI(MBB, MBBI, DL, TII->get(AArch64::ANDXri), AArch64::SP) ++ .addReg(scratchSPReg, RegState::Kill) ++ .addImm(AArch64_AM::encodeLogicalImmediate(AndMask, 64)); ++ AFI->setStackRealigned(true); ++ ++ // No need for SEH instructions here; if we're realigning the stack, ++ // we've set a frame pointer and already finished the SEH prologue. ++ assert(!NeedsWinCFI); ++ } + } + + // If we need a base pointer, set it up here. It's whatever the value of the +@@ -4166,170 +4024,3 @@ void AArch64FrameLowering::orderFrameObjects( + dbgs() << "\n"; + }); + } +- +-/// Emit a loop to decrement SP until it is equal to TargetReg, with probes at +-/// least every ProbeSize bytes. Returns an iterator of the first instruction +-/// after the loop. The difference between SP and TargetReg must be an exact +-/// multiple of ProbeSize. +-MachineBasicBlock::iterator +-AArch64FrameLowering::inlineStackProbeLoopExactMultiple( +- MachineBasicBlock::iterator MBBI, int64_t ProbeSize, +- Register TargetReg) const { +- MachineBasicBlock &MBB = *MBBI->getParent(); +- MachineFunction &MF = *MBB.getParent(); +- const AArch64InstrInfo *TII = +- MF.getSubtarget().getInstrInfo(); +- DebugLoc DL = MBB.findDebugLoc(MBBI); +- +- MachineFunction::iterator MBBInsertPoint = std::next(MBB.getIterator()); +- MachineBasicBlock *LoopMBB = MF.CreateMachineBasicBlock(MBB.getBasicBlock()); +- MF.insert(MBBInsertPoint, LoopMBB); +- MachineBasicBlock *ExitMBB = MF.CreateMachineBasicBlock(MBB.getBasicBlock()); +- MF.insert(MBBInsertPoint, ExitMBB); +- +- // SUB SP, SP, #ProbeSize (or equivalent if ProbeSize is not encodable +- // in SUB). +- emitFrameOffset(*LoopMBB, LoopMBB->end(), DL, AArch64::SP, AArch64::SP, +- StackOffset::getFixed(-ProbeSize), TII, +- MachineInstr::FrameSetup); +- // STR XZR, [SP] +- BuildMI(*LoopMBB, LoopMBB->end(), DL, TII->get(AArch64::STRXui)) +- .addReg(AArch64::XZR) +- .addReg(AArch64::SP) +- .addImm(0) +- .setMIFlags(MachineInstr::FrameSetup); +- // CMP SP, TargetReg +- BuildMI(*LoopMBB, LoopMBB->end(), DL, TII->get(AArch64::SUBSXrx64), +- AArch64::XZR) +- .addReg(AArch64::SP) +- .addReg(TargetReg) +- .addImm(AArch64_AM::getArithExtendImm(AArch64_AM::UXTX, 0)) +- .setMIFlags(MachineInstr::FrameSetup); +- // B.CC Loop +- BuildMI(*LoopMBB, LoopMBB->end(), DL, TII->get(AArch64::Bcc)) +- .addImm(AArch64CC::NE) +- .addMBB(LoopMBB) +- .setMIFlags(MachineInstr::FrameSetup); +- +- LoopMBB->addSuccessor(ExitMBB); +- LoopMBB->addSuccessor(LoopMBB); +- // Synthesize the exit MBB. +- ExitMBB->splice(ExitMBB->end(), &MBB, MBBI, MBB.end()); +- ExitMBB->transferSuccessorsAndUpdatePHIs(&MBB); +- MBB.addSuccessor(LoopMBB); +- // Update liveins. +- recomputeLiveIns(*LoopMBB); +- recomputeLiveIns(*ExitMBB); +- +- return ExitMBB->begin(); +-} +- +-void AArch64FrameLowering::inlineStackProbeFixed( +- MachineBasicBlock::iterator MBBI, Register ScratchReg, int64_t FrameSize, +- StackOffset CFAOffset) const { +- MachineBasicBlock *MBB = MBBI->getParent(); +- MachineFunction &MF = *MBB->getParent(); +- const AArch64InstrInfo *TII = +- MF.getSubtarget().getInstrInfo(); +- AArch64FunctionInfo *AFI = MF.getInfo(); +- bool EmitAsyncCFI = AFI->needsAsyncDwarfUnwindInfo(MF); +- bool HasFP = hasFP(MF); +- +- DebugLoc DL; +- int64_t ProbeSize = MF.getInfo()->getStackProbeSize(); +- int64_t NumBlocks = FrameSize / ProbeSize; +- int64_t ResidualSize = FrameSize % ProbeSize; +- +- LLVM_DEBUG(dbgs() << "Stack probing: total " << FrameSize << " bytes, " +- << NumBlocks << " blocks of " << ProbeSize +- << " bytes, plus " << ResidualSize << " bytes\n"); +- +- // Decrement SP by NumBlock * ProbeSize bytes, with either unrolled or +- // ordinary loop. +- if (NumBlocks <= AArch64::StackProbeMaxLoopUnroll) { +- for (int i = 0; i < NumBlocks; ++i) { +- // SUB SP, SP, #ProbeSize (or equivalent if ProbeSize is not +- // encodable in a SUB). +- emitFrameOffset(*MBB, MBBI, DL, AArch64::SP, AArch64::SP, +- StackOffset::getFixed(-ProbeSize), TII, +- MachineInstr::FrameSetup, false, false, nullptr, +- EmitAsyncCFI && !HasFP, CFAOffset); +- CFAOffset += StackOffset::getFixed(ProbeSize); +- // STR XZR, [SP] +- BuildMI(*MBB, MBBI, DL, TII->get(AArch64::STRXui)) +- .addReg(AArch64::XZR) +- .addReg(AArch64::SP) +- .addImm(0) +- .setMIFlags(MachineInstr::FrameSetup); +- } +- } else if (NumBlocks != 0) { +- // SUB ScratchReg, SP, #FrameSize (or equivalent if FrameSize is not +- // encodable in ADD). ScrathReg may temporarily become the CFA register. +- emitFrameOffset(*MBB, MBBI, DL, ScratchReg, AArch64::SP, +- StackOffset::getFixed(-ProbeSize * NumBlocks), TII, +- MachineInstr::FrameSetup, false, false, nullptr, +- EmitAsyncCFI && !HasFP, CFAOffset); +- CFAOffset += StackOffset::getFixed(ProbeSize * NumBlocks); +- MBBI = inlineStackProbeLoopExactMultiple(MBBI, ProbeSize, ScratchReg); +- MBB = MBBI->getParent(); +- if (EmitAsyncCFI && !HasFP) { +- // Set the CFA register back to SP. +- const AArch64RegisterInfo &RegInfo = +- *MF.getSubtarget().getRegisterInfo(); +- unsigned Reg = RegInfo.getDwarfRegNum(AArch64::SP, true); +- unsigned CFIIndex = +- MF.addFrameInst(MCCFIInstruction::createDefCfaRegister(nullptr, Reg)); +- BuildMI(*MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) +- .addCFIIndex(CFIIndex) +- .setMIFlags(MachineInstr::FrameSetup); +- } +- } +- +- if (ResidualSize != 0) { +- // SUB SP, SP, #ResidualSize (or equivalent if ResidualSize is not encodable +- // in SUB). +- emitFrameOffset(*MBB, MBBI, DL, AArch64::SP, AArch64::SP, +- StackOffset::getFixed(-ResidualSize), TII, +- MachineInstr::FrameSetup, false, false, nullptr, +- EmitAsyncCFI && !HasFP, CFAOffset); +- if (ResidualSize > AArch64::StackProbeMaxUnprobedStack) { +- // STR XZR, [SP] +- BuildMI(*MBB, MBBI, DL, TII->get(AArch64::STRXui)) +- .addReg(AArch64::XZR) +- .addReg(AArch64::SP) +- .addImm(0) +- .setMIFlags(MachineInstr::FrameSetup); +- } +- } +-} +- +-void AArch64FrameLowering::inlineStackProbe(MachineFunction &MF, +- MachineBasicBlock &MBB) const { +- // Get the instructions that need to be replaced. We emit at most two of +- // these. Remember them in order to avoid complications coming from the need +- // to traverse the block while potentially creating more blocks. +- SmallVector ToReplace; +- for (MachineInstr &MI : MBB) +- if (MI.getOpcode() == AArch64::PROBED_STACKALLOC || +- MI.getOpcode() == AArch64::PROBED_STACKALLOC_VAR) +- ToReplace.push_back(&MI); +- +- for (MachineInstr *MI : ToReplace) { +- if (MI->getOpcode() == AArch64::PROBED_STACKALLOC) { +- Register ScratchReg = MI->getOperand(0).getReg(); +- int64_t FrameSize = MI->getOperand(1).getImm(); +- StackOffset CFAOffset = StackOffset::get(MI->getOperand(2).getImm(), +- MI->getOperand(3).getImm()); +- inlineStackProbeFixed(MI->getIterator(), ScratchReg, FrameSize, +- CFAOffset); +- } else { +- assert(MI->getOpcode() == AArch64::PROBED_STACKALLOC_VAR && +- "Stack probe pseudo-instruction expected"); +- const AArch64InstrInfo *TII = +- MI->getMF()->getSubtarget().getInstrInfo(); +- Register TargetReg = MI->getOperand(0).getReg(); +- (void)TII->probedStackAlloc(MI->getIterator(), TargetReg, true); +- } +- MI->eraseFromParent(); +- } +-} +\ No newline at end of file +diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.h b/llvm/lib/Target/AArch64/AArch64FrameLowering.h +index 941af03a78b7..147b5c181be5 100644 +--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.h ++++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.h +@@ -150,28 +150,10 @@ private: + MachineBasicBlock::iterator MBBI) const; + void emitCalleeSavedSVERestores(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI) const; +- void allocateStackSpace(MachineBasicBlock &MBB, +- MachineBasicBlock::iterator MBBI, +- int64_t RealignmentPadding, StackOffset AllocSize, +- bool NeedsWinCFI, bool *HasWinCFI, bool EmitCFI, +- StackOffset InitialOffset, bool FollowupAllocs) const; + + /// Emit target zero call-used regs. + void emitZeroCallUsedRegs(BitVector RegsToZero, + MachineBasicBlock &MBB) const override; +- +- /// Replace a StackProbe stub (if any) with the actual probe code inline +- void inlineStackProbe(MachineFunction &MF, +- MachineBasicBlock &PrologueMBB) const override; +- +- void inlineStackProbeFixed(MachineBasicBlock::iterator MBBI, +- Register ScratchReg, int64_t FrameSize, +- StackOffset CFAOffset) const; +- +- MachineBasicBlock::iterator +- inlineStackProbeLoopExactMultiple(MachineBasicBlock::iterator MBBI, +- int64_t NegProbeSize, +- Register TargetReg) const; + }; + + } // End llvm namespace +diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +index eff0722e1c77..6e721b937846 100644 +--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp ++++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +@@ -556,7 +556,10 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM, + setOperationAction(ISD::STACKSAVE, MVT::Other, Expand); + setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand); + +- setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64, Custom); ++ if (Subtarget->isTargetWindows()) ++ setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64, Custom); ++ else ++ setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64, Expand); + + // Constant pool entries + setOperationAction(ISD::ConstantPool, MVT::i64, Custom); +@@ -2285,7 +2288,6 @@ const char *AArch64TargetLowering::getTargetNodeName(unsigned Opcode) const { + MAKE_CASE(AArch64ISD::CSINC) + MAKE_CASE(AArch64ISD::THREAD_POINTER) + MAKE_CASE(AArch64ISD::TLSDESC_CALLSEQ) +- MAKE_CASE(AArch64ISD::PROBED_ALLOCA) + MAKE_CASE(AArch64ISD::ABDS_PRED) + MAKE_CASE(AArch64ISD::ABDU_PRED) + MAKE_CASE(AArch64ISD::HADDS_PRED) +@@ -2644,22 +2646,6 @@ MachineBasicBlock *AArch64TargetLowering::EmitLoweredCatchRet( + return BB; + } + +-MachineBasicBlock * +-AArch64TargetLowering::EmitDynamicProbedAlloc(MachineInstr &MI, +- MachineBasicBlock *MBB) const { +- MachineFunction &MF = *MBB->getParent(); +- MachineBasicBlock::iterator MBBI = MI.getIterator(); +- DebugLoc DL = MBB->findDebugLoc(MBBI); +- const AArch64InstrInfo &TII = +- *MF.getSubtarget().getInstrInfo(); +- Register TargetReg = MI.getOperand(0).getReg(); +- MachineBasicBlock::iterator NextInst = +- TII.probedStackAlloc(MBBI, TargetReg, false); +- +- MI.eraseFromParent(); +- return NextInst->getParent(); +-} +- + MachineBasicBlock * + AArch64TargetLowering::EmitTileLoad(unsigned Opc, unsigned BaseReg, + MachineInstr &MI, +@@ -2788,8 +2774,6 @@ MachineBasicBlock *AArch64TargetLowering::EmitInstrWithCustomInserter( + + case AArch64::CATCHRET: + return EmitLoweredCatchRet(MI, BB); +- case AArch64::PROBED_STACKALLOC_DYN: +- return EmitDynamicProbedAlloc(MI, BB); + case AArch64::LD1_MXIPXX_H_PSEUDO_B: + return EmitTileLoad(AArch64::LD1_MXIPXX_H_B, AArch64::ZAB0, MI, BB); + case AArch64::LD1_MXIPXX_H_PSEUDO_H: +@@ -13682,34 +13666,9 @@ SDValue AArch64TargetLowering::LowerATOMIC_LOAD_AND(SDValue Op, + AN->getMemOperand()); + } + +-SDValue +-AArch64TargetLowering::LowerWindowsDYNAMIC_STACKALLOC(SDValue Op, +- SelectionDAG &DAG) const { +- ++SDValue AArch64TargetLowering::LowerWindowsDYNAMIC_STACKALLOC( ++ SDValue Op, SDValue Chain, SDValue &Size, SelectionDAG &DAG) const { + SDLoc dl(Op); +- // Get the inputs. +- SDNode *Node = Op.getNode(); +- SDValue Chain = Op.getOperand(0); +- SDValue Size = Op.getOperand(1); +- MaybeAlign Align = +- cast(Op.getOperand(2))->getMaybeAlignValue(); +- EVT VT = Node->getValueType(0); +- +- if (DAG.getMachineFunction().getFunction().hasFnAttribute( +- "no-stack-arg-probe")) { +- SDValue SP = DAG.getCopyFromReg(Chain, dl, AArch64::SP, MVT::i64); +- Chain = SP.getValue(1); +- SP = DAG.getNode(ISD::SUB, dl, MVT::i64, SP, Size); +- if (Align) +- SP = DAG.getNode(ISD::AND, dl, VT, SP.getValue(0), +- DAG.getConstant(-(uint64_t)Align->value(), dl, VT)); +- Chain = DAG.getCopyToReg(Chain, dl, AArch64::SP, SP); +- SDValue Ops[2] = {SP, Chain}; +- return DAG.getMergeValues(Ops, dl); +- } +- +- Chain = DAG.getCALLSEQ_START(Chain, 0, 0, dl); +- + EVT PtrVT = getPointerTy(DAG.getDataLayout()); + SDValue Callee = DAG.getTargetExternalSymbol(Subtarget->getChkStkName(), + PtrVT, 0); +@@ -13733,59 +13692,7 @@ AArch64TargetLowering::LowerWindowsDYNAMIC_STACKALLOC(SDValue Op, + + Size = DAG.getNode(ISD::SHL, dl, MVT::i64, Size, + DAG.getConstant(4, dl, MVT::i64)); +- +- SDValue SP = DAG.getCopyFromReg(Chain, dl, AArch64::SP, MVT::i64); +- Chain = SP.getValue(1); +- SP = DAG.getNode(ISD::SUB, dl, MVT::i64, SP, Size); +- if (Align) +- SP = DAG.getNode(ISD::AND, dl, VT, SP.getValue(0), +- DAG.getConstant(-(uint64_t)Align->value(), dl, VT)); +- Chain = DAG.getCopyToReg(Chain, dl, AArch64::SP, SP); +- +- Chain = DAG.getCALLSEQ_END(Chain, 0, 0, SDValue(), dl); +- +- SDValue Ops[2] = {SP, Chain}; +- return DAG.getMergeValues(Ops, dl); +-} +- +-SDValue +-AArch64TargetLowering::LowerInlineDYNAMIC_STACKALLOC(SDValue Op, +- SelectionDAG &DAG) const { +- // Get the inputs. +- SDNode *Node = Op.getNode(); +- SDValue Chain = Op.getOperand(0); +- SDValue Size = Op.getOperand(1); +- +- MaybeAlign Align = +- cast(Op.getOperand(2))->getMaybeAlignValue(); +- SDLoc dl(Op); +- EVT VT = Node->getValueType(0); +- +- // Construct the new SP value in a GPR. +- SDValue SP = DAG.getCopyFromReg(Chain, dl, AArch64::SP, MVT::i64); +- Chain = SP.getValue(1); +- SP = DAG.getNode(ISD::SUB, dl, MVT::i64, SP, Size); +- if (Align) +- SP = DAG.getNode(ISD::AND, dl, VT, SP.getValue(0), +- DAG.getConstant(-(uint64_t)Align->value(), dl, VT)); +- +- // Set the real SP to the new value with a probing loop. +- Chain = DAG.getNode(AArch64ISD::PROBED_ALLOCA, dl, MVT::Other, Chain, SP); +- SDValue Ops[2] = {SP, Chain}; +- return DAG.getMergeValues(Ops, dl); +-} +- +-SDValue +-AArch64TargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op, +- SelectionDAG &DAG) const { +- MachineFunction &MF = DAG.getMachineFunction(); +- +- if (Subtarget->isTargetWindows()) +- return LowerWindowsDYNAMIC_STACKALLOC(Op, DAG); +- else if (hasInlineStackProbe(MF)) +- return LowerInlineDYNAMIC_STACKALLOC(Op, DAG); +- else +- return SDValue(); ++ return Chain; + } + + // When x and y are extended, lower: +@@ -13839,6 +13746,51 @@ SDValue AArch64TargetLowering::LowerAVG(SDValue Op, SelectionDAG &DAG, + return DAG.getNode(ISD::ADD, dl, VT, Add, tmp); + } + ++SDValue ++AArch64TargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op, ++ SelectionDAG &DAG) const { ++ assert(Subtarget->isTargetWindows() && ++ "Only Windows alloca probing supported"); ++ SDLoc dl(Op); ++ // Get the inputs. ++ SDNode *Node = Op.getNode(); ++ SDValue Chain = Op.getOperand(0); ++ SDValue Size = Op.getOperand(1); ++ MaybeAlign Align = ++ cast(Op.getOperand(2))->getMaybeAlignValue(); ++ EVT VT = Node->getValueType(0); ++ ++ if (DAG.getMachineFunction().getFunction().hasFnAttribute( ++ "no-stack-arg-probe")) { ++ SDValue SP = DAG.getCopyFromReg(Chain, dl, AArch64::SP, MVT::i64); ++ Chain = SP.getValue(1); ++ SP = DAG.getNode(ISD::SUB, dl, MVT::i64, SP, Size); ++ if (Align) ++ SP = DAG.getNode(ISD::AND, dl, VT, SP.getValue(0), ++ DAG.getConstant(-(uint64_t)Align->value(), dl, VT)); ++ Chain = DAG.getCopyToReg(Chain, dl, AArch64::SP, SP); ++ SDValue Ops[2] = {SP, Chain}; ++ return DAG.getMergeValues(Ops, dl); ++ } ++ ++ Chain = DAG.getCALLSEQ_START(Chain, 0, 0, dl); ++ ++ Chain = LowerWindowsDYNAMIC_STACKALLOC(Op, Chain, Size, DAG); ++ ++ SDValue SP = DAG.getCopyFromReg(Chain, dl, AArch64::SP, MVT::i64); ++ Chain = SP.getValue(1); ++ SP = DAG.getNode(ISD::SUB, dl, MVT::i64, SP, Size); ++ if (Align) ++ SP = DAG.getNode(ISD::AND, dl, VT, SP.getValue(0), ++ DAG.getConstant(-(uint64_t)Align->value(), dl, VT)); ++ Chain = DAG.getCopyToReg(Chain, dl, AArch64::SP, SP); ++ ++ Chain = DAG.getCALLSEQ_END(Chain, 0, 0, SDValue(), dl); ++ ++ SDValue Ops[2] = {SP, Chain}; ++ return DAG.getMergeValues(Ops, dl); ++} ++ + SDValue AArch64TargetLowering::LowerVSCALE(SDValue Op, + SelectionDAG &DAG) const { + EVT VT = Op.getValueType(); +@@ -26099,9 +26051,3 @@ bool AArch64TargetLowering::preferScalarizeSplat(SDNode *N) const { + } + return true; + } +- +-bool AArch64TargetLowering::hasInlineStackProbe( +- const MachineFunction &MF) const { +- return !Subtarget->isTargetWindows() && +- MF.getInfo()->hasStackProbing(); +-} +\ No newline at end of file +diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h +index 9b388c7f8668..aca45f113e73 100644 +--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h ++++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h +@@ -90,10 +90,6 @@ enum NodeType : unsigned { + ADC, + SBC, // adc, sbc instructions + +- // To avoid stack clash, allocation is performed by block and each block is +- // probed. +- PROBED_ALLOCA, +- + // Predicated instructions where inactive lanes produce undefined results. + ABDS_PRED, + ABDU_PRED, +@@ -512,13 +508,6 @@ const unsigned RoundingBitsPos = 22; + const ArrayRef getGPRArgRegs(); + const ArrayRef getFPRArgRegs(); + +-/// Maximum allowed number of unprobed bytes above SP at an ABI +-/// boundary. +-const unsigned StackProbeMaxUnprobedStack = 1024; +- +-/// Maximum number of iterations to unroll for a constant size probing loop. +-const unsigned StackProbeMaxLoopUnroll = 4; +- + } // namespace AArch64 + + class AArch64Subtarget; +@@ -614,9 +603,6 @@ public: + MachineBasicBlock *EmitLoweredCatchRet(MachineInstr &MI, + MachineBasicBlock *BB) const; + +- MachineBasicBlock *EmitDynamicProbedAlloc(MachineInstr &MI, +- MachineBasicBlock *MBB) const; +- + MachineBasicBlock *EmitTileLoad(unsigned Opc, unsigned BaseReg, + MachineInstr &MI, + MachineBasicBlock *BB) const; +@@ -956,9 +942,6 @@ public: + // used for 64bit and 128bit vectors as well. + bool useSVEForFixedLengthVectorVT(EVT VT, bool OverrideNEON = false) const; + +- /// True if stack clash protection is enabled for this functions. +- bool hasInlineStackProbe(const MachineFunction &MF) const override; +- + private: + /// Keep a pointer to the AArch64Subtarget around so that we can + /// make the right decision when generating code for different targets. +@@ -1120,10 +1103,10 @@ private: + SDValue LowerVECREDUCE(SDValue Op, SelectionDAG &DAG) const; + SDValue LowerATOMIC_LOAD_SUB(SDValue Op, SelectionDAG &DAG) const; + SDValue LowerATOMIC_LOAD_AND(SDValue Op, SelectionDAG &DAG) const; +- SDValue LowerWindowsDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const; +- SDValue LowerInlineDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const; + SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const; +- ++ SDValue LowerWindowsDYNAMIC_STACKALLOC(SDValue Op, SDValue Chain, ++ SDValue &Size, ++ SelectionDAG &DAG) const; + SDValue LowerAVG(SDValue Op, SelectionDAG &DAG, unsigned NewOp) const; + + SDValue LowerFixedLengthVectorIntDivideToSVE(SDValue Op, +diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +index b3b42a97e8c9..0691e07a639b 100644 +--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp ++++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +@@ -11,7 +11,6 @@ + //===----------------------------------------------------------------------===// + + #include "AArch64InstrInfo.h" +-#include "AArch64ExpandImm.h" + #include "AArch64MachineFunctionInfo.h" + #include "AArch64Subtarget.h" + #include "MCTargetDesc/AArch64AddressingModes.h" +@@ -19,7 +18,6 @@ + #include "llvm/ADT/ArrayRef.h" + #include "llvm/ADT/STLExtras.h" + #include "llvm/ADT/SmallVector.h" +-#include "llvm/CodeGen/LivePhysRegs.h" + #include "llvm/CodeGen/MachineBasicBlock.h" + #include "llvm/CodeGen/MachineCombinerPattern.h" + #include "llvm/CodeGen/MachineFrameInfo.h" +@@ -8430,94 +8428,6 @@ unsigned llvm::getBLRCallOpcode(const MachineFunction &MF) { + return AArch64::BLR; + } + +-MachineBasicBlock::iterator +-AArch64InstrInfo::probedStackAlloc(MachineBasicBlock::iterator MBBI, +- Register TargetReg, bool FrameSetup) const { +- assert(TargetReg != AArch64::SP && "New top of stack cannot aleady be in SP"); +- +- MachineBasicBlock &MBB = *MBBI->getParent(); +- MachineFunction &MF = *MBB.getParent(); +- const AArch64InstrInfo *TII = +- MF.getSubtarget().getInstrInfo(); +- int64_t ProbeSize = MF.getInfo()->getStackProbeSize(); +- DebugLoc DL = MBB.findDebugLoc(MBBI); +- +- MachineFunction::iterator MBBInsertPoint = std::next(MBB.getIterator()); +- MachineBasicBlock *LoopTestMBB = +- MF.CreateMachineBasicBlock(MBB.getBasicBlock()); +- MF.insert(MBBInsertPoint, LoopTestMBB); +- MachineBasicBlock *LoopBodyMBB = +- MF.CreateMachineBasicBlock(MBB.getBasicBlock()); +- MF.insert(MBBInsertPoint, LoopBodyMBB); +- MachineBasicBlock *ExitMBB = MF.CreateMachineBasicBlock(MBB.getBasicBlock()); +- MF.insert(MBBInsertPoint, ExitMBB); +- MachineInstr::MIFlag Flags = +- FrameSetup ? MachineInstr::FrameSetup : MachineInstr::NoFlags; +- +- // LoopTest: +- // SUB SP, SP, #ProbeSize +- emitFrameOffset(*LoopTestMBB, LoopTestMBB->end(), DL, AArch64::SP, +- AArch64::SP, StackOffset::getFixed(-ProbeSize), TII, Flags); +- +- // CMP SP, TargetReg +- BuildMI(*LoopTestMBB, LoopTestMBB->end(), DL, TII->get(AArch64::SUBSXrx64), +- AArch64::XZR) +- .addReg(AArch64::SP) +- .addReg(TargetReg) +- .addImm(AArch64_AM::getArithExtendImm(AArch64_AM::UXTX, 0)) +- .setMIFlags(Flags); +- +- // B. LoopExit +- BuildMI(*LoopTestMBB, LoopTestMBB->end(), DL, TII->get(AArch64::Bcc)) +- .addImm(AArch64CC::LE) +- .addMBB(ExitMBB) +- .setMIFlags(Flags); +- +- // STR XZR, [SP] +- BuildMI(*LoopBodyMBB, LoopBodyMBB->end(), DL, TII->get(AArch64::STRXui)) +- .addReg(AArch64::XZR) +- .addReg(AArch64::SP) +- .addImm(0) +- .setMIFlags(Flags); +- +- // B loop +- BuildMI(*LoopBodyMBB, LoopBodyMBB->end(), DL, TII->get(AArch64::B)) +- .addMBB(LoopTestMBB) +- .setMIFlags(Flags); +- +- // LoopExit: +- // MOV SP, TargetReg +- BuildMI(*ExitMBB, ExitMBB->end(), DL, TII->get(AArch64::ADDXri), AArch64::SP) +- .addReg(TargetReg) +- .addImm(0) +- .addImm(AArch64_AM::getShifterImm(AArch64_AM::LSL, 0)) +- .setMIFlags(Flags); +- +- // STR XZR, [SP] +- BuildMI(*ExitMBB, ExitMBB->end(), DL, TII->get(AArch64::STRXui)) +- .addReg(AArch64::XZR) +- .addReg(AArch64::SP) +- .addImm(0) +- .setMIFlags(Flags); +- +- ExitMBB->splice(ExitMBB->end(), &MBB, std::next(MBBI), MBB.end()); +- ExitMBB->transferSuccessorsAndUpdatePHIs(&MBB); +- +- LoopTestMBB->addSuccessor(ExitMBB); +- LoopTestMBB->addSuccessor(LoopBodyMBB); +- LoopBodyMBB->addSuccessor(LoopTestMBB); +- MBB.addSuccessor(LoopTestMBB); +- +- // Update liveins. +- if (MF.getRegInfo().reservedRegsFrozen()) { +- recomputeLiveIns(*LoopTestMBB); +- recomputeLiveIns(*LoopBodyMBB); +- recomputeLiveIns(*ExitMBB); +- } +- +- return ExitMBB->begin(); +-} +- + #define GET_INSTRINFO_HELPERS + #define GET_INSTRMAP_INFO + #include "AArch64GenInstrInfo.inc" +diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.h b/llvm/lib/Target/AArch64/AArch64InstrInfo.h +index 7e84b86fc52c..20210a96d67a 100644 +--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.h ++++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.h +@@ -340,12 +340,6 @@ public: + static void decomposeStackOffsetForDwarfOffsets(const StackOffset &Offset, + int64_t &ByteSized, + int64_t &VGSized); +- // Decrement the SP, issuing probes along the way. `TargetReg` is the new top +- // of the stack. `FrameSetup` is passed as true, if the allocation is a part +- // of constructing the activation frame of a function. +- MachineBasicBlock::iterator probedStackAlloc(MachineBasicBlock::iterator MBBI, +- Register TargetReg, +- bool FrameSetup) const; + #define GET_INSTRINFO_HELPER_DECLS + #include "AArch64GenInstrInfo.inc" + +diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td +index 9b9103e01d67..9e72d37880c5 100644 +--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td ++++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td +@@ -818,12 +818,6 @@ def AArch64stilp : SDNode<"AArch64ISD::STILP", SDT_AArch64stilp, [SDNPHasChain, + def AArch64stnp : SDNode<"AArch64ISD::STNP", SDT_AArch64stnp, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; + + def AArch64tbl : SDNode<"AArch64ISD::TBL", SDT_AArch64TBL>; +- +-def AArch64probedalloca +- : SDNode<"AArch64ISD::PROBED_ALLOCA", +- SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>, +- [SDNPHasChain, SDNPMayStore]>; +- + def AArch64mrs : SDNode<"AArch64ISD::MRS", + SDTypeProfile<1, 1, [SDTCisVT<0, i64>, SDTCisVT<1, i32>]>, + [SDNPHasChain, SDNPOutGlue]>; +@@ -886,8 +880,7 @@ include "SMEInstrFormats.td" + // Miscellaneous instructions. + //===----------------------------------------------------------------------===// + +-let hasSideEffects = 1, isCodeGenOnly = 1 in { +-let Defs = [SP], Uses = [SP] in { ++let Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1 in { + // We set Sched to empty list because we expect these instructions to simply get + // removed in most cases. + def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), +@@ -896,34 +889,7 @@ def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), + def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), + [(AArch64callseq_end timm:$amt1, timm:$amt2)]>, + Sched<[]>; +-} +- +-let Defs = [SP, NZCV], Uses = [SP] in { +-// Probed stack allocation of a constant size, used in function prologues when +-// stack-clash protection is enabled. +-def PROBED_STACKALLOC : Pseudo<(outs GPR64:$scratch), +- (ins i64imm:$stacksize, i64imm:$fixed_offset, +- i64imm:$scalable_offset), +- []>, +- Sched<[]>; +- +-// Probed stack allocation of a variable size, used in function prologues when +-// stack-clash protection is enabled. +-def PROBED_STACKALLOC_VAR : Pseudo<(outs), +- (ins GPR64sp:$target), +- []>, +- Sched<[]>; +- +-// Probed stack allocations of a variable size, used for allocas of unknown size +-// when stack-clash protection is enabled. +-let usesCustomInserter = 1 in +-def PROBED_STACKALLOC_DYN : Pseudo<(outs), +- (ins GPR64common:$target), +- [(AArch64probedalloca GPR64common:$target)]>, +- Sched<[]>; +- +-} // Defs = [SP, NZCV], Uses = [SP] in +-} // hasSideEffects = 1, isCodeGenOnly = 1 ++} // Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1 + + let isReMaterializable = 1, isCodeGenOnly = 1 in { + // FIXME: The following pseudo instructions are only needed because remat +diff --git a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp +index 0bef3c2d2483..961a19317d66 100644 +--- a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp ++++ b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp +@@ -97,45 +97,14 @@ AArch64FunctionInfo::AArch64FunctionInfo(const Function &F, + if (const auto *BTE = mdconst::extract_or_null( + F.getParent()->getModuleFlag("branch-target-enforcement"))) + BranchTargetEnforcement = BTE->getZExtValue(); +- } else { +- const StringRef BTIEnable = +- F.getFnAttribute("branch-target-enforcement").getValueAsString(); +- assert(BTIEnable.equals_insensitive("true") || +- BTIEnable.equals_insensitive("false")); +- BranchTargetEnforcement = BTIEnable.equals_insensitive("true"); ++ return; + } + +- // The default stack probe size is 4096 if the function has no +- // stack-probe-size attribute. This is a safe default because it is the +- // smallest possible guard page size. +- uint64_t ProbeSize = 4096; +- if (F.hasFnAttribute("stack-probe-size")) +- ProbeSize = F.getFnAttributeAsParsedInteger("stack-probe-size"); +- else if (const auto *PS = mdconst::extract_or_null( +- F.getParent()->getModuleFlag("stack-probe-size"))) +- ProbeSize = PS->getZExtValue(); +- assert(int64_t(ProbeSize) > 0 && "Invalid stack probe size"); +- +- if (STI->isTargetWindows()) { +- if (!F.hasFnAttribute("no-stack-arg-probe")) +- StackProbeSize = ProbeSize; +- } else { +- // Round down to the stack alignment. +- uint64_t StackAlign = +- STI->getFrameLowering()->getTransientStackAlign().value(); +- ProbeSize = std::max(StackAlign, ProbeSize & ~(StackAlign - 1U)); +- StringRef ProbeKind; +- if (F.hasFnAttribute("probe-stack")) +- ProbeKind = F.getFnAttribute("probe-stack").getValueAsString(); +- else if (const auto *PS = dyn_cast_or_null( +- F.getParent()->getModuleFlag("probe-stack"))) +- ProbeKind = PS->getString(); +- if (ProbeKind.size()) { +- if (ProbeKind != "inline-asm") +- report_fatal_error("Unsupported stack probing method"); +- StackProbeSize = ProbeSize; +- } +- } ++ const StringRef BTIEnable = ++ F.getFnAttribute("branch-target-enforcement").getValueAsString(); ++ assert(BTIEnable.equals_insensitive("true") || ++ BTIEnable.equals_insensitive("false")); ++ BranchTargetEnforcement = BTIEnable.equals_insensitive("true"); + } + + MachineFunctionInfo *AArch64FunctionInfo::clone( +diff --git a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h +index d50011594eb1..d82fb436925e 100644 +--- a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h ++++ b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h +@@ -192,8 +192,6 @@ class AArch64FunctionInfo final : public MachineFunctionInfo { + /// True if the function need asynchronous unwind information. + mutable std::optional NeedsAsyncDwarfUnwindInfo; + +- int64_t StackProbeSize = 0; +- + public: + AArch64FunctionInfo(const Function &F, const AArch64Subtarget *STI); + +@@ -449,10 +447,6 @@ public: + bool needsDwarfUnwindInfo(const MachineFunction &MF) const; + bool needsAsyncDwarfUnwindInfo(const MachineFunction &MF) const; + +- bool hasStackProbing() const { return StackProbeSize != 0; } +- +- int64_t getStackProbeSize() const { return StackProbeSize; } +- + private: + // Hold the lists of LOHs. + MILOHContainer LOHContainerSet; +diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +index 0dd2b4d48dd6..d905da4eaec3 100644 +--- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp ++++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +@@ -797,9 +797,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) + return Query.Types[0] == p0 && Query.Types[1] == s64; + }); + +- getActionDefinitionsBuilder(G_DYN_STACKALLOC).custom(); +- +- getActionDefinitionsBuilder({G_STACKSAVE, G_STACKRESTORE}).lower(); ++ getActionDefinitionsBuilder(G_DYN_STACKALLOC).lower(); + + if (ST.hasMOPS()) { + // G_BZERO is not supported. Currently it is only emitted by +@@ -993,8 +991,6 @@ bool AArch64LegalizerInfo::legalizeCustom(LegalizerHelper &Helper, + return legalizeMemOps(MI, Helper); + case TargetOpcode::G_FCOPYSIGN: + return legalizeFCopySign(MI, Helper); +- case TargetOpcode::G_DYN_STACKALLOC: +- return legalizeDynStackAlloc(MI, Helper); + } + + llvm_unreachable("expected switch to return"); +@@ -1691,42 +1687,3 @@ bool AArch64LegalizerInfo::legalizeFCopySign(MachineInstr &MI, + MI.eraseFromParent(); + return true; + } +- +-bool AArch64LegalizerInfo::legalizeDynStackAlloc( +- MachineInstr &MI, LegalizerHelper &Helper) const { +- MachineFunction &MF = *MI.getParent()->getParent(); +- MachineIRBuilder &MIRBuilder = Helper.MIRBuilder; +- MachineRegisterInfo &MRI = *MIRBuilder.getMRI(); +- +- // If stack probing is not enabled for this function, use the default +- // lowering. +- if (!MF.getFunction().hasFnAttribute("probe-stack") || +- MF.getFunction().getFnAttribute("probe-stack").getValueAsString() != +- "inline-asm") { +- Helper.lowerDynStackAlloc(MI); +- return true; +- } +- +- Register Dst = MI.getOperand(0).getReg(); +- Register AllocSize = MI.getOperand(1).getReg(); +- Align Alignment = assumeAligned(MI.getOperand(2).getImm()); +- +- assert(MRI.getType(Dst) == LLT::pointer(0, 64) && +- "Unexpected type for dynamic alloca"); +- assert(MRI.getType(AllocSize) == LLT::scalar(64) && +- "Unexpected type for dynamic alloca"); +- +- LLT PtrTy = MRI.getType(Dst); +- Register SPReg = +- Helper.getTargetLowering().getStackPointerRegisterToSaveRestore(); +- Register SPTmp = +- Helper.getDynStackAllocTargetPtr(SPReg, AllocSize, Alignment, PtrTy); +- auto NewMI = +- MIRBuilder.buildInstr(AArch64::PROBED_STACKALLOC_DYN, {}, {SPTmp}); +- MRI.setRegClass(NewMI.getReg(0), &AArch64::GPR64commonRegClass); +- MIRBuilder.setInsertPt(*NewMI->getParent(), NewMI); +- MIRBuilder.buildCopy(Dst, SPTmp); +- +- MI.eraseFromParent(); +- return true; +-} +\ No newline at end of file +diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.h b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.h +index 94484ea59d15..c10f6e071ed4 100644 +--- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.h ++++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.h +@@ -58,7 +58,6 @@ private: + bool legalizeCTTZ(MachineInstr &MI, LegalizerHelper &Helper) const; + bool legalizeMemOps(MachineInstr &MI, LegalizerHelper &Helper) const; + bool legalizeFCopySign(MachineInstr &MI, LegalizerHelper &Helper) const; +- bool legalizeDynStackAlloc(MachineInstr &MI, LegalizerHelper &Helper) const; + const AArch64Subtarget *ST; + }; + } // End llvm namespace. +diff --git a/llvm/lib/Target/X86/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/X86LegalizerInfo.cpp +index 104461cff0a9..a4a247f85f3d 100644 +--- a/llvm/lib/Target/X86/X86LegalizerInfo.cpp ++++ b/llvm/lib/Target/X86/X86LegalizerInfo.cpp +@@ -528,10 +528,6 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI, + // memory intrinsics + getActionDefinitionsBuilder({G_MEMCPY, G_MEMMOVE, G_MEMSET}).libcall(); + +- getActionDefinitionsBuilder({G_DYN_STACKALLOC, +- G_STACKSAVE, +- G_STACKRESTORE}).lower(); +- + // fp intrinsics + getActionDefinitionsBuilder(G_INTRINSIC_ROUNDEVEN) + .scalarize(0) +diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll +index 575cd6b874e3..5f3544add398 100644 +--- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll ++++ b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll +@@ -2392,8 +2392,8 @@ declare ptr @llvm.stacksave() + declare void @llvm.stackrestore(ptr) + define void @test_stacksaverestore() { + ; CHECK-LABEL: name: test_stacksaverestore +- ; CHECK: [[SAVE:%[0-9]+]]:_(p0) = G_STACKSAVE +- ; CHECK-NEXT: G_STACKRESTORE [[SAVE]] ++ ; CHECK: [[SAVE:%[0-9]+]]:_(p0) = COPY $sp ++ ; CHECK-NEXT: $sp = COPY [[SAVE]](p0) + ; CHECK-NEXT: RET_ReallyLR + %sp = call ptr @llvm.stacksave() + call void @llvm.stackrestore(ptr %sp) +diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-dyn-alloca.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-dyn-alloca.mir +index 82781cebc55a..e9188fb89f69 100644 +--- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-dyn-alloca.mir ++++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-dyn-alloca.mir +@@ -19,21 +19,6 @@ + ret i128* %addr + } + +- define i8* @test_simple_alloca_stack_probing(i32 %numelts) "probe-stack"="inline-asm" { +- %addr = alloca i8, i32 %numelts +- ret i8* %addr +- } +- +- define i8* @test_aligned_alloca_stack_probing(i32 %numelts) "probe-stack"="inline-asm" { +- %addr = alloca i8, i32 %numelts, align 32 +- ret i8* %addr +- } +- +- define i128* @test_natural_alloca_stack_probing(i32 %numelts) "probe-stack"="inline-asm" { +- %addr = alloca i128, i32 %numelts +- ret i128* %addr +- } +- + ... + --- + name: test_simple_alloca +@@ -52,23 +37,22 @@ body: | + + ; CHECK-LABEL: name: test_simple_alloca + ; CHECK: liveins: $w0 +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 +- ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 +- ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) +- ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[ZEXT]], [[C]] +- ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15 +- ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[MUL]], [[C1]] +- ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16 +- ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]] +- ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp +- ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0) +- ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]] +- ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[SUB]](s64) +- ; CHECK-NEXT: $sp = COPY [[INTTOPTR]](p0) +- ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) +- ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0) +- ; CHECK-NEXT: RET_ReallyLR implicit $x0 ++ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 ++ ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 ++ ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) ++ ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[ZEXT]], [[C]] ++ ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15 ++ ; CHECK: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[MUL]], [[C1]] ++ ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16 ++ ; CHECK: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]] ++ ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp ++ ; CHECK: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0) ++ ; CHECK: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]] ++ ; CHECK: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[SUB]](s64) ++ ; CHECK: $sp = COPY [[INTTOPTR]](p0) ++ ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) ++ ; CHECK: $x0 = COPY [[COPY2]](p0) ++ ; CHECK: RET_ReallyLR implicit $x0 + %0:_(s32) = COPY $w0 + %3:_(s64) = G_CONSTANT i64 1 + %1:_(s64) = G_ZEXT %0(s32) +@@ -99,25 +83,24 @@ body: | + + ; CHECK-LABEL: name: test_aligned_alloca + ; CHECK: liveins: $w0 +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 +- ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 +- ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) +- ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[ZEXT]], [[C]] +- ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15 +- ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[MUL]], [[C1]] +- ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16 +- ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]] +- ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp +- ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0) +- ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]] +- ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 -32 +- ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C3]] +- ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[AND1]](s64) +- ; CHECK-NEXT: $sp = COPY [[INTTOPTR]](p0) +- ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) +- ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0) +- ; CHECK-NEXT: RET_ReallyLR implicit $x0 ++ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 ++ ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 ++ ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) ++ ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[ZEXT]], [[C]] ++ ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15 ++ ; CHECK: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[MUL]], [[C1]] ++ ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16 ++ ; CHECK: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]] ++ ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp ++ ; CHECK: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0) ++ ; CHECK: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]] ++ ; CHECK: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 -32 ++ ; CHECK: [[AND1:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C3]] ++ ; CHECK: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[AND1]](s64) ++ ; CHECK: $sp = COPY [[INTTOPTR]](p0) ++ ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) ++ ; CHECK: $x0 = COPY [[COPY2]](p0) ++ ; CHECK: RET_ReallyLR implicit $x0 + %0:_(s32) = COPY $w0 + %3:_(s64) = G_CONSTANT i64 1 + %1:_(s64) = G_ZEXT %0(s32) +@@ -148,23 +131,22 @@ body: | + + ; CHECK-LABEL: name: test_natural_alloca + ; CHECK: liveins: $w0 +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 +- ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16 +- ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) +- ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[ZEXT]], [[C]] +- ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15 +- ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[MUL]], [[C1]] +- ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16 +- ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]] +- ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp +- ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0) +- ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]] +- ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[SUB]](s64) +- ; CHECK-NEXT: $sp = COPY [[INTTOPTR]](p0) +- ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) +- ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0) +- ; CHECK-NEXT: RET_ReallyLR implicit $x0 ++ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 ++ ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16 ++ ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) ++ ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[ZEXT]], [[C]] ++ ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15 ++ ; CHECK: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[MUL]], [[C1]] ++ ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16 ++ ; CHECK: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]] ++ ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp ++ ; CHECK: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0) ++ ; CHECK: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]] ++ ; CHECK: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[SUB]](s64) ++ ; CHECK: $sp = COPY [[INTTOPTR]](p0) ++ ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) ++ ; CHECK: $x0 = COPY [[COPY2]](p0) ++ ; CHECK: RET_ReallyLR implicit $x0 + %0:_(s32) = COPY $w0 + %3:_(s64) = G_CONSTANT i64 16 + %1:_(s64) = G_ZEXT %0(s32) +@@ -178,139 +160,3 @@ body: | + RET_ReallyLR implicit $x0 + + ... +---- +-name: test_simple_alloca_stack_probing +-alignment: 4 +-tracksRegLiveness: true +-liveins: +- - { reg: '$w0' } +-frameInfo: +- maxAlignment: 1 +-stack: +- - { id: 0, name: addr, type: variable-sized, alignment: 1 } +-machineFunctionInfo: {} +-body: | +- bb.1 (%ir-block.0): +- liveins: $w0 +- ; CHECK-LABEL: name: test_simple_alloca_stack_probing +- ; CHECK: liveins: $w0 +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 +- ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) +- ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0 +- ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ZEXT]], [[C]](s64) +- ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15 +- ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[SHL]], [[C1]] +- ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16 +- ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]] +- ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp +- ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0) +- ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]] +- ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:gpr64common(p0) = G_INTTOPTR [[SUB]](s64) +- ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) +- ; CHECK-NEXT: PROBED_STACKALLOC_DYN [[INTTOPTR]](p0), implicit-def $sp, implicit-def $nzcv, implicit $sp +- ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0) +- ; CHECK-NEXT: RET_ReallyLR implicit $x0 +- %0:_(s32) = COPY $w0 +- %1:_(s64) = G_ZEXT %0(s32) +- %9:_(s64) = G_CONSTANT i64 0 +- %2:_(s64) = G_SHL %1, %9(s64) +- %4:_(s64) = G_CONSTANT i64 15 +- %5:_(s64) = nuw G_ADD %2, %4 +- %6:_(s64) = G_CONSTANT i64 -16 +- %7:_(s64) = G_AND %5, %6 +- %8:_(p0) = G_DYN_STACKALLOC %7(s64), 1 +- $x0 = COPY %8(p0) +- RET_ReallyLR implicit $x0 +-... +---- +-name: test_aligned_alloca_stack_probing +-alignment: 4 +-tracksRegLiveness: true +-liveins: +- - { reg: '$w0' } +-frameInfo: +- maxAlignment: 32 +-stack: +- - { id: 0, name: addr, type: variable-sized, alignment: 32 } +-machineFunctionInfo: {} +-body: | +- bb.1 (%ir-block.0): +- liveins: $w0 +- ; CHECK-LABEL: name: test_aligned_alloca_stack_probing +- ; CHECK: liveins: $w0 +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 +- ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) +- ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0 +- ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ZEXT]], [[C]](s64) +- ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15 +- ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[SHL]], [[C1]] +- ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16 +- ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]] +- ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp +- ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0) +- ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]] +- ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 -32 +- ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C3]] +- ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:gpr64common(p0) = G_INTTOPTR [[AND1]](s64) +- ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) +- ; CHECK-NEXT: PROBED_STACKALLOC_DYN [[INTTOPTR]](p0), implicit-def $sp, implicit-def $nzcv, implicit $sp +- ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0) +- ; CHECK-NEXT: RET_ReallyLR implicit $x0 +- %0:_(s32) = COPY $w0 +- %1:_(s64) = G_ZEXT %0(s32) +- %9:_(s64) = G_CONSTANT i64 0 +- %2:_(s64) = G_SHL %1, %9(s64) +- %4:_(s64) = G_CONSTANT i64 15 +- %5:_(s64) = nuw G_ADD %2, %4 +- %6:_(s64) = G_CONSTANT i64 -16 +- %7:_(s64) = G_AND %5, %6 +- %8:_(p0) = G_DYN_STACKALLOC %7(s64), 32 +- $x0 = COPY %8(p0) +- RET_ReallyLR implicit $x0 +-... +---- +-name: test_natural_alloca_stack_probing +-alignment: 4 +-tracksRegLiveness: true +-liveins: +- - { reg: '$w0' } +-frameInfo: +- maxAlignment: 1 +-stack: +- - { id: 0, name: addr, type: variable-sized, alignment: 1 } +-machineFunctionInfo: {} +-body: | +- bb.1 (%ir-block.0): +- liveins: $w0 +- ; CHECK-LABEL: name: test_natural_alloca_stack_probing +- ; CHECK: liveins: $w0 +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 +- ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) +- ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4 +- ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ZEXT]], [[C]](s64) +- ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15 +- ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[SHL]], [[C1]] +- ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16 +- ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]] +- ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp +- ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0) +- ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]] +- ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:gpr64common(p0) = G_INTTOPTR [[SUB]](s64) +- ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) +- ; CHECK-NEXT: PROBED_STACKALLOC_DYN [[INTTOPTR]](p0), implicit-def $sp, implicit-def $nzcv, implicit $sp +- ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0) +- ; CHECK-NEXT: RET_ReallyLR implicit $x0 +- %0:_(s32) = COPY $w0 +- %1:_(s64) = G_ZEXT %0(s32) +- %9:_(s64) = G_CONSTANT i64 4 +- %2:_(s64) = G_SHL %1, %9(s64) +- %4:_(s64) = G_CONSTANT i64 15 +- %5:_(s64) = nuw G_ADD %2, %4 +- %6:_(s64) = G_CONSTANT i64 -16 +- %7:_(s64) = G_AND %5, %6 +- %8:_(p0) = G_DYN_STACKALLOC %7(s64), 1 +- $x0 = COPY %8(p0) +- RET_ReallyLR implicit $x0 +\ No newline at end of file +diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +index efae9b66b53d..b4fe73d29fa6 100644 +--- a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir ++++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +@@ -641,22 +641,7 @@ + # DEBUG-NEXT: G_JUMP_TABLE (opcode {{[0-9]+}}): 1 type index, 0 imm indices + # DEBUG-NEXT: .. the first uncovered type index: 1, OK + # DEBUG-NEXT: .. the first uncovered imm index: 0, OK +-# DEBUG-NEXT: G_DYN_STACKALLOC (opcode [[DYN_STACKALLOC:[0-9]+]]): 2 type indices, 0 imm indices +-# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected +-# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected +-# DEBUG-NEXT: G_STACKSAVE (opcode {{[0-9]+}}): 1 type index, 0 imm indices +-# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to [[DYN_STACKALLOC]] +-# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected +-# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected +-# DEBUG-NEXT: G_STACKRESTORE (opcode {{[0-9]+}}): 1 type index, 0 imm indices +-# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to [[DYN_STACKALLOC]] +-# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected +-# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected +-# DEBUG-NEXT: G_STACKSAVE (opcode [[STACKSAVE:[0-9]+]]): 1 type index, 0 imm indices +-# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected +-# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected +-# DEBUG-NEXT: G_STACKRESTORE (opcode {{[0-9]+}}): 1 type index, 0 imm indices +-# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to [[STACKSAVE]] ++# DEBUG-NEXT: G_DYN_STACKALLOC (opcode {{[0-9]+}}): 2 type indices, 0 imm indices + # DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected + # DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected + # DEBUG-NEXT: G_STRICT_FADD (opcode {{[0-9]+}}): 1 type index, 0 imm indices +diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/stacksave-stackrestore.ll b/llvm/test/CodeGen/AArch64/GlobalISel/stacksave-stackrestore.ll +deleted file mode 100644 +index 97ecca0bd77b..000000000000 +--- a/llvm/test/CodeGen/AArch64/GlobalISel/stacksave-stackrestore.ll ++++ /dev/null +@@ -1,39 +0,0 @@ +-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2 +-; RUN: llc -global-isel=1 -mtriple=aarch64-linux-gnu -o - %s | FileCheck %s +- +-declare void @use_addr(ptr) +-declare ptr @llvm.stacksave.p0() +-declare void @llvm.stackrestore.p0(ptr) +- +-define void @test_scoped_alloca(i64 %n) { +-; CHECK-LABEL: test_scoped_alloca: +-; CHECK: // %bb.0: +-; CHECK-NEXT: stp x29, x30, [sp, #-32]! // 16-byte Folded Spill +-; CHECK-NEXT: str x19, [sp, #16] // 8-byte Folded Spill +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 32 +-; CHECK-NEXT: .cfi_offset w19, -16 +-; CHECK-NEXT: .cfi_offset w30, -24 +-; CHECK-NEXT: .cfi_offset w29, -32 +-; CHECK-NEXT: mov x19, x0 +-; CHECK-NEXT: bl llvm.stacksave.p0 +-; CHECK-NEXT: add x9, x19, #15 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: and x9, x9, #0xfffffffffffffff0 +-; CHECK-NEXT: mov x19, x0 +-; CHECK-NEXT: sub x8, x8, x9 +-; CHECK-NEXT: mov sp, x8 +-; CHECK-NEXT: mov x0, x8 +-; CHECK-NEXT: bl use_addr +-; CHECK-NEXT: mov x0, x19 +-; CHECK-NEXT: bl llvm.stackrestore.p0 +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: ldr x19, [sp, #16] // 8-byte Folded Reload +-; CHECK-NEXT: ldp x29, x30, [sp], #32 // 16-byte Folded Reload +-; CHECK-NEXT: ret +- %sp = call ptr @llvm.stacksave.p0() +- %addr = alloca i8, i64 %n +- call void @use_addr(ptr %addr) +- call void @llvm.stackrestore.p0(ptr %sp) +- ret void +-} +diff --git a/llvm/test/CodeGen/AArch64/framelayout-sve-basepointer.mir b/llvm/test/CodeGen/AArch64/framelayout-sve-basepointer.mir +index 265c474fbc5d..623c0f240be4 100644 +--- a/llvm/test/CodeGen/AArch64/framelayout-sve-basepointer.mir ++++ b/llvm/test/CodeGen/AArch64/framelayout-sve-basepointer.mir +@@ -4,8 +4,8 @@ + name: hasBasepointer + # CHECK-LABEL: name: hasBasepointer + # CHECK: bb.0: +-# CHECK: $sp = frame-setup SUBXri $sp, 16, 0 +-# CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -1 ++# CHECK: $sp = frame-setup ADDVL_XXI $sp, -1 ++# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 + # CHECK-NEXT: $x19 = ADDXri $sp, 0, 0 + # CHECK: STRXui $x0, $x19, 0 + tracksRegLiveness: true +diff --git a/llvm/test/CodeGen/AArch64/framelayout-sve-fixed-width-access.mir b/llvm/test/CodeGen/AArch64/framelayout-sve-fixed-width-access.mir +index 35fd7ca77d5c..e367a380f8ba 100644 +--- a/llvm/test/CodeGen/AArch64/framelayout-sve-fixed-width-access.mir ++++ b/llvm/test/CodeGen/AArch64/framelayout-sve-fixed-width-access.mir +@@ -7,9 +7,9 @@ + ; CHECK: // %bb.0: // %entry + ; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill + ; CHECK-NEXT: mov x29, sp +- ; CHECK-NEXT: sub sp, sp, #2064 + ; CHECK-NEXT: addvl sp, sp, #-32 + ; CHECK-NEXT: addvl sp, sp, #-28 ++ ; CHECK-NEXT: sub sp, sp, #2064 + ; CHECK-NEXT: ldr x8, [sp, #2048] + ; CHECK-NEXT: addvl sp, sp, #31 + ; CHECK-NEXT: addvl sp, sp, #29 +diff --git a/llvm/test/CodeGen/AArch64/framelayout-sve-scavengingslot.mir b/llvm/test/CodeGen/AArch64/framelayout-sve-scavengingslot.mir +index 680f9c335c25..d54f67634d02 100644 +--- a/llvm/test/CodeGen/AArch64/framelayout-sve-scavengingslot.mir ++++ b/llvm/test/CodeGen/AArch64/framelayout-sve-scavengingslot.mir +@@ -4,9 +4,9 @@ + name: LateScavengingSlot + # CHECK-LABEL: name: LateScavengingSlot + # CHECK: bb.0: +-# CHECK: $sp = frame-setup SUBXri $sp, 8, 12 ++# CHECK: $sp = frame-setup ADDVL_XXI $sp, -1 ++# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 8, 12 + # CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 +-# CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -1 + # CHECK: STRXui killed $[[SCRATCH:x[0-9]+]], $sp, 0 + # CHECK-NEXT: $[[SCRATCH]] = ADDVL_XXI $fp, -1 + # CHECK-NEXT: STRXui $x0, killed $[[SCRATCH]], 0 +diff --git a/llvm/test/CodeGen/AArch64/framelayout-sve.mir b/llvm/test/CodeGen/AArch64/framelayout-sve.mir +index 8b657c95bfc7..7c87587c6dc4 100644 +--- a/llvm/test/CodeGen/AArch64/framelayout-sve.mir ++++ b/llvm/test/CodeGen/AArch64/framelayout-sve.mir +@@ -60,10 +60,10 @@ + # CHECK-NEXT: $sp = frame-setup STRXpre killed $[[SCRATCH:[a-z0-9]+]], $sp, -16 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -16 +-# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 +-# CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 32 + # CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -2 +-# CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 ++# CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 ++# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 ++# CHECK-NEXT: CFI_INSTRUCTION escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 + + # CHECK-NEXT: $sp = frame-destroy ADDVL_XXI $sp, 2 + # CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa $wsp, 32 +@@ -77,7 +77,7 @@ + # ASM-LABEL: test_allocate_sve: + # ASM: .cfi_def_cfa_offset 16 + # ASM-NEXT: .cfi_offset w29, -16 +-# ASM: .cfi_def_cfa_offset 32 ++# ASM: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG + # ASM: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 32 + 16 * VG + # ASM: .cfi_def_cfa wsp, 32 + # ASM: .cfi_def_cfa_offset 16 +@@ -87,7 +87,7 @@ + # + # UNWINDINFO: DW_CFA_def_cfa_offset: +16 + # UNWINDINFO-NEXT: DW_CFA_offset: reg29 -16 +-# UNWINDINFO: DW_CFA_def_cfa_offset: +32 ++# UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +16, DW_OP_plus, DW_OP_consts +16, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +32, DW_OP_plus, DW_OP_consts +16, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # UNWINDINFO: DW_CFA_def_cfa: reg31 +32 + # UNWINDINFO: DW_CFA_def_cfa_offset: +16 +@@ -125,9 +125,9 @@ body: | + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w20, -8 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w21, -16 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -32 +-# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 +-# CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 48 + # CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -2 ++# CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 ++# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x30, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 + # + # CHECK-NEXT: $x20 = IMPLICIT_DEF +@@ -149,7 +149,7 @@ body: | + # ASM: .cfi_offset w20, -8 + # ASM-NEXT: .cfi_offset w21, -16 + # ASM-NEXT: .cfi_offset w29, -32 +-# ASM: .cfi_def_cfa_offset 48 ++# ASM: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 32 + 16 * VG + # ASM: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x30, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 48 + 16 * VG + # + # ASM: .cfi_def_cfa wsp, 48 +@@ -164,7 +164,7 @@ body: | + # UNWINDINFO: DW_CFA_offset: reg20 -8 + # UNWINDINFO-NEXT: DW_CFA_offset: reg21 -16 + # UNWINDINFO-NEXT: DW_CFA_offset: reg29 -32 +-# UNWINDINFO: DW_CFA_def_cfa_offset: +48 ++# UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +32, DW_OP_plus, DW_OP_consts +16, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +48, DW_OP_plus, DW_OP_consts +16, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # + # UNWINDINFO: DW_CFA_def_cfa: reg31 +48 +@@ -205,9 +205,9 @@ body: | + # CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa $w29, 16 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -8 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -16 ++# CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -2 + # CHECK-NEXT: $[[TMP:x[0-9]+]] = frame-setup SUBXri $sp, 16, 0 +-# CHECK-NEXT: $[[TMP]] = frame-setup ADDVL_XXI $[[TMP]], -2 +-# CHECK-NEXT: $sp = frame-setup ANDXri killed $[[TMP]] ++# CHECK-NEXT: $sp = ANDXri killed $[[TMP]] + # CHECK-NEXT: $sp = frame-destroy ADDXri $fp, 0, 0 + # CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa $wsp, 16 + # CHECK-NEXT: $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2 +@@ -267,9 +267,9 @@ body: | + # CHECK-NEXT: $sp = frame-setup STRXpre killed $[[SCRATCH:[a-z0-9]+]], $sp, -16 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -16 +-# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 +-# CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 32 + # CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -3 ++# CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x18, 0x92, 0x2e, 0x00, 0x1e, 0x22 ++# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x18, 0x92, 0x2e, 0x00, 0x1e, 0x22 + + # CHECK-NEXT: $[[TMP:x[0-9]+]] = ADDXri $sp, 16 +@@ -292,7 +292,7 @@ body: | + # ASM-LABEL: test_address_sve: + # ASM: .cfi_def_cfa_offset 16 + # ASM-NEXT: .cfi_offset w29, -16 +-# ASM: .cfi_def_cfa_offset 32 ++# ASM: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x18, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 24 * VG + # ASM: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x18, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 32 + 24 * VG + # + # ASM: .cfi_def_cfa wsp, 32 +@@ -302,7 +302,7 @@ body: | + # + # UNWINDINFO: DW_CFA_def_cfa_offset: +16 + # UNWINDINFO-NEXT: DW_CFA_offset: reg29 -16 +-# UNWINDINFO: DW_CFA_def_cfa_offset: +32 ++# UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +16, DW_OP_plus, DW_OP_consts +24, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +32, DW_OP_plus, DW_OP_consts +24, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # + # UNWINDINFO: DW_CFA_def_cfa: reg31 +32 +@@ -353,8 +353,8 @@ body: | + # CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa $w29, 16 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -8 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -16 +-# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 + # CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -3 ++# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 + + # CHECK-NEXT: STR_ZXI $z0, $fp, -1 + # CHECK-NEXT: STR_ZXI $z1, $fp, -2 +@@ -429,9 +429,9 @@ body: | + # CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -16 + +-# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 +-# CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 32 + # CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -1 ++# CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 ++# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 + # CHECK: $[[TMP:x[0-9]+]] = ADDVL_XXI $sp, 1 + # CHECK-NEXT: $x0 = LDRXui killed $[[TMP]], 4 +@@ -448,7 +448,7 @@ body: | + # ASM-LABEL: test_stack_arg_sve: + # ASM: .cfi_def_cfa_offset 16 + # ASM-NEXT: .cfi_offset w29, -16 +-# ASM: .cfi_def_cfa_offset 32 ++# ASM: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 8 * VG + # ASM: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 32 + 8 * VG + # + # ASM: .cfi_def_cfa wsp, 32 +@@ -458,7 +458,7 @@ body: | + + # UNWINDINFO: DW_CFA_def_cfa_offset: +16 + # UNWINDINFO-NEXT: DW_CFA_offset: reg29 -16 +-# UNWINDINFO: DW_CFA_def_cfa_offset: +32 ++# UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +16, DW_OP_plus, DW_OP_consts +8, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +32, DW_OP_plus, DW_OP_consts +8, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # + # UNWINDINFO: DW_CFA_def_cfa: reg31 +32 +@@ -640,8 +640,8 @@ body: | + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w19, -16 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -24 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -32 +-# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 + # CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -1 ++# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 + # CHECK-NEXT: $x19 = ADDXri $sp, 0, 0 + # CHECK-NEXT: STRXui $xzr, $x19, 0 + # CHECK-NEXT: $sp = frame-destroy ADDXri $fp, 0, 0 +@@ -863,9 +863,9 @@ body: | + # CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x10, 0x4d, 0x0a, 0x11, 0x60, 0x22, 0x11, 0x50, 0x92, 0x2e, 0x00, 0x1e, 0x22 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x10, 0x4e, 0x0a, 0x11, 0x60, 0x22, 0x11, 0x48, 0x92, 0x2e, 0x00, 0x1e, 0x22 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x10, 0x4f, 0x0a, 0x11, 0x60, 0x22, 0x11, 0x40, 0x92, 0x2e, 0x00, 0x1e, 0x22 +-# CHECK: $sp = frame-setup SUBXri $sp, 32, 0 +-# CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0e, 0x8f, 0x00, 0x11, 0xc0, 0x00, 0x22, 0x11, 0x90, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 + # CHECK: $sp = frame-setup ADDVL_XXI $sp, -1 ++# CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x98, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 ++# CHECK: $sp = frame-setup SUBXri $sp, 32, 0 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0e, 0x8f, 0x00, 0x11, 0xc0, 0x00, 0x22, 0x11, 0x98, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 + + # CHECK: $sp = frame-destroy ADDXri $sp, 32, 0 +@@ -916,7 +916,7 @@ body: | + # ASM-NEXT: .cfi_escape 0x10, 0x4d, 0x0a, 0x11, 0x60, 0x22, 0x11, 0x50, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d13 @ cfa - 32 - 48 * VG + # ASM-NEXT: .cfi_escape 0x10, 0x4e, 0x0a, 0x11, 0x60, 0x22, 0x11, 0x48, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d14 @ cfa - 32 - 56 * VG + # ASM-NEXT: .cfi_escape 0x10, 0x4f, 0x0a, 0x11, 0x60, 0x22, 0x11, 0x40, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d15 @ cfa - 32 - 64 * VG +-# ASM: .cfi_escape 0x0f, 0x0e, 0x8f, 0x00, 0x11, 0xc0, 0x00, 0x22, 0x11, 0x90, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 64 + 144 * VG ++# ASM: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x98, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 32 + 152 * VG + # ASM: .cfi_escape 0x0f, 0x0e, 0x8f, 0x00, 0x11, 0xc0, 0x00, 0x22, 0x11, 0x98, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 64 + 152 * VG + # + # ASM: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x98, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 32 + 152 * VG +@@ -950,7 +950,7 @@ body: | + # UNWINDINFO-NEXT: DW_CFA_expression: reg77 DW_OP_consts -32, DW_OP_plus, DW_OP_consts -48, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # UNWINDINFO-NEXT: DW_CFA_expression: reg78 DW_OP_consts -32, DW_OP_plus, DW_OP_consts -56, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # UNWINDINFO-NEXT: DW_CFA_expression: reg79 DW_OP_consts -32, DW_OP_plus, DW_OP_consts -64, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus +-# UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +64, DW_OP_plus, DW_OP_consts +144, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus ++# UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +32, DW_OP_plus, DW_OP_consts +152, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +64, DW_OP_plus, DW_OP_consts +152, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus + # + # UNWINDINFO: DW_CFA_def_cfa_expression: DW_OP_breg31 +0, DW_OP_consts +32, DW_OP_plus, DW_OP_consts +152, DW_OP_bregx 0x2e +0, DW_OP_mul, DW_OP_plus +@@ -1031,9 +1031,9 @@ body: | + # CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x10, 0x4d, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x50, 0x92, 0x2e, 0x00, 0x1e, 0x22 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x10, 0x4e, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x48, 0x92, 0x2e, 0x00, 0x1e, 0x22 + # CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x10, 0x4f, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x40, 0x92, 0x2e, 0x00, 0x1e, 0x22 ++# CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -1 + # CHECK-NEXT: $[[TMP:x[0-9]+]] = frame-setup SUBXri $sp, 16, 0 +-# CHECK-NEXT: $[[TMP]] = frame-setup ADDVL_XXI $[[TMP]], -1 +-# CHECK-NEXT: $sp = frame-setup ANDXri killed $[[TMP]] ++# CHECK-NEXT: $sp = ANDXri killed $[[TMP]] + + # CHECK: $sp = frame-destroy ADDVL_XXI $fp, -18 + # CHECK-NEXT: $p15 = frame-destroy LDR_PXI $sp, 4 +diff --git a/llvm/test/CodeGen/AArch64/spill-stack-realignment.mir b/llvm/test/CodeGen/AArch64/spill-stack-realignment.mir +index f6fc627ac2d3..1b9411d07f43 100644 +--- a/llvm/test/CodeGen/AArch64/spill-stack-realignment.mir ++++ b/llvm/test/CodeGen/AArch64/spill-stack-realignment.mir +@@ -21,7 +21,7 @@ stack: + - { id: 1, size: 4, alignment: 4, local-offset: -68 } + + # CHECK: body: +-# CHECK: $sp = frame-setup ANDXri killed ${{x[0-9]+}}, 7865 ++# CHECK: $sp = ANDXri killed ${{x[0-9]+}}, 7865 + # CHECK: STRSui $s0, $sp, 0 + # CHECK: STRSui $s0, $fp, 7 + body: | +diff --git a/llvm/test/CodeGen/AArch64/stack-guard-sve.ll b/llvm/test/CodeGen/AArch64/stack-guard-sve.ll +index 5acbb22bf1ab..1672a7eb8739 100644 +--- a/llvm/test/CodeGen/AArch64/stack-guard-sve.ll ++++ b/llvm/test/CodeGen/AArch64/stack-guard-sve.ll +@@ -148,9 +148,9 @@ entry: + + ; CHECK-LABEL: local_stack_alloc: + ; CHECK: mov x29, sp ++; CHECK: addvl sp, sp, #-2 + ; CHECK: sub sp, sp, #16, lsl #12 + ; CHECK: sub sp, sp, #16 +-; CHECK: addvl sp, sp, #-2 + + ; Stack guard is placed below the SVE stack area (and above all fixed-width objects) + ; CHECK-DAG: add [[STACK_GUARD_SPILL_PART_LOC:x[0-9]+]], sp, #8, lsl #12 +@@ -198,9 +198,9 @@ entry: + + ; CHECK-LABEL: local_stack_alloc_strong: + ; CHECK: mov x29, sp ++; CHECK: addvl sp, sp, #-3 + ; CHECK: sub sp, sp, #16, lsl #12 + ; CHECK: sub sp, sp, #16 +-; CHECK: addvl sp, sp, #-3 + + ; Stack guard is placed at the top of the SVE stack area + ; CHECK-DAG: ldr [[STACK_GUARD:x[0-9]+]], [{{x[0-9]+}}, :lo12:__stack_chk_guard] +diff --git a/llvm/test/CodeGen/AArch64/stack-probing-64k.ll b/llvm/test/CodeGen/AArch64/stack-probing-64k.ll +deleted file mode 100644 +index 0a3198fc520e..000000000000 +--- a/llvm/test/CodeGen/AArch64/stack-probing-64k.ll ++++ /dev/null +@@ -1,392 +0,0 @@ +-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +-; RUN: llc -mtriple aarch64-none-eabi < %s -verify-machineinstrs -enable-post-misched=false | FileCheck %s +-; RUN: llc -mtriple aarch64-none-eabi < %s -verify-machineinstrs -enable-post-misched=false -global-isel | FileCheck %s +- +-; Tests for prolog sequences for stack probing, when using a 64KiB stack guard. +- +-; 64k bytes is the largest frame we can probe in one go. +-define void @static_65536(ptr %out) #0 { +-; CHECK-LABEL: static_65536: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 65552 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 65536, align 1 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; 64k+16 bytes, still needs just one probe. +-define void @static_65552(ptr %out) #0 { +-; CHECK-LABEL: static_65552: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 65552 +-; CHECK-NEXT: str xzr, [sp], #-16 +-; CHECK-NEXT: .cfi_def_cfa_offset 65568 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 32 +-; CHECK-NEXT: add sp, sp, #16 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 65552, align 1 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; 64k+1024 bytes, the largest frame which needs just one probe. +-define void @static_66560(ptr %out) #0 { +-; CHECK-LABEL: static_66560: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 65552 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 66576 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 1040 +-; CHECK-NEXT: add sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 66560, align 1 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; 64k+1024+16 bytes, the smallest frame which needs two probes. +-define void @static_66576(ptr %out) #0 { +-; CHECK-LABEL: static_66576: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 65552 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 66592 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 1056 +-; CHECK-NEXT: add sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 66576, align 1 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; 2*64k+1024, the largest frame needing two probes. +-define void @static_132096(ptr %out) #0 { +-; CHECK-LABEL: static_132096: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 65552 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 131088 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 132112 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #32, lsl #12 // =131072 +-; CHECK-NEXT: .cfi_def_cfa_offset 1040 +-; CHECK-NEXT: add sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 132096, align 1 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; 5*64k-16, the largest frame probed without a loop. +-define void @static_327664(ptr %out) #0 { +-; CHECK-LABEL: static_327664: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 65552 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 131088 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 196624 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: .cfi_def_cfa_offset 262160 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #15, lsl #12 // =61440 +-; CHECK-NEXT: .cfi_def_cfa_offset 323600 +-; CHECK-NEXT: sub sp, sp, #4080 +-; CHECK-NEXT: .cfi_def_cfa_offset 327680 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #79, lsl #12 // =323584 +-; CHECK-NEXT: .cfi_def_cfa_offset 4096 +-; CHECK-NEXT: add sp, sp, #4080 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 327664, align 1 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; 5*64k, smallest frame probed with a loop. +-define void @static_327680(ptr %out) #0 { +-; CHECK-LABEL: static_327680: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #80, lsl #12 // =327680 +-; CHECK-NEXT: .cfi_def_cfa w9, 327696 +-; CHECK-NEXT: .LBB6_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.ne .LBB6_1 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: .cfi_def_cfa_register wsp +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #80, lsl #12 // =327680 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 327680, align 1 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; 5*64k+1024, large enough to use a loop, but not a multiple of 64KiB +-; so has a reminder, but no extra probe. +-define void @static_328704(ptr %out) #0 { +-; CHECK-LABEL: static_328704: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #80, lsl #12 // =327680 +-; CHECK-NEXT: .cfi_def_cfa w9, 327696 +-; CHECK-NEXT: .LBB7_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.ne .LBB7_1 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: .cfi_def_cfa_register wsp +-; CHECK-NEXT: sub sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 328720 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #80, lsl #12 // =327680 +-; CHECK-NEXT: .cfi_def_cfa_offset 1040 +-; CHECK-NEXT: add sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 328704, align 1 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; 5*64k+1040, large enough to use a loop, has a reminder and +-; an extra probe. +-define void @static_328720(ptr %out) #0 { +-; CHECK-LABEL: static_328720: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #80, lsl #12 // =327680 +-; CHECK-NEXT: .cfi_def_cfa w9, 327696 +-; CHECK-NEXT: .LBB8_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.ne .LBB8_1 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: .cfi_def_cfa_register wsp +-; CHECK-NEXT: sub sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 328736 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #80, lsl #12 // =327680 +-; CHECK-NEXT: .cfi_def_cfa_offset 1056 +-; CHECK-NEXT: add sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 328720, align 1 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; A small allocation, but with a very large alignment requirement. We do this +-; by moving SP far enough that a sufficiently-aligned block will exist +-; somewhere in the stack frame, so must probe the whole of that larger SP move. +-define void @static_16_align_131072(ptr %out) #0 { +-; CHECK-LABEL: static_16_align_131072: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #31, lsl #12 // =126976 +-; CHECK-NEXT: sub x9, x9, #4080 +-; CHECK-NEXT: and x9, x9, #0xfffffffffffe0000 +-; CHECK-NEXT: .LBB9_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.le .LBB9_3 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: // in Loop: Header=BB9_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB9_1 +-; CHECK-NEXT: .LBB9_3: // %entry +-; CHECK-NEXT: mov sp, x9 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 16, align 131072 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; A small allocation, but with a very large alignment requirement which +-; is nevertheless small enough as to not need a loop. +-define void @static_16_align_8192(ptr %out) #0 { +-; CHECK-LABEL: static_16_align_8192: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: sub x9, x9, #4080 +-; CHECK-NEXT: and sp, x9, #0xffffffffffffe000 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 16, align 8192 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-; A large allocation with a very large alignment requirement which +-; is nevertheless small enough as to not need a loop. +-define void @static_32752_align_32k(ptr %out) #0 { +-; CHECK-LABEL: static_32752_align_32k: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #7, lsl #12 // =28672 +-; CHECK-NEXT: sub x9, x9, #4080 +-; CHECK-NEXT: and sp, x9, #0xffffffffffff8000 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 32752, align 32768 +- store i8* %v, ptr %out, align 8 +- ret void +-} +- +-attributes #0 = { uwtable(async) "probe-stack"="inline-asm" "stack-probe-size"="65536" "frame-pointer"="none" } +\ No newline at end of file +diff --git a/llvm/test/CodeGen/AArch64/stack-probing-dynamic-no-frame-setup.ll b/llvm/test/CodeGen/AArch64/stack-probing-dynamic-no-frame-setup.ll +deleted file mode 100644 +index 673f9038a35f..000000000000 +--- a/llvm/test/CodeGen/AArch64/stack-probing-dynamic-no-frame-setup.ll ++++ /dev/null +@@ -1,14 +0,0 @@ +-; RUN: llc --stop-after=finalize-isel -o - | FileCheck %s +-target triple = "aarch64-linux" +- +-; Check dynamic stack allocation and probing instructions do not have +-; the FrameSetup flag. +- +-; CHECK-NOT: frame-setup +-define void @no_frame_setup(i64 %size, ptr %out) #0 { +- %v = alloca i8, i64 %size, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-attributes #0 = { uwtable(async) "probe-stack"="inline-asm" "frame-pointer"="none" } +\ No newline at end of file +diff --git a/llvm/test/CodeGen/AArch64/stack-probing-dynamic.ll b/llvm/test/CodeGen/AArch64/stack-probing-dynamic.ll +deleted file mode 100644 +index 3cbcf7749b2a..000000000000 +--- a/llvm/test/CodeGen/AArch64/stack-probing-dynamic.ll ++++ /dev/null +@@ -1,365 +0,0 @@ +-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +-; RUN: llc -mtriple aarch64-none-eabi < %s -verify-machineinstrs | FileCheck %s +-; RUN: llc -mtriple aarch64-none-eabi < %s -verify-machineinstrs -global-isel -global-isel-abort=2 | FileCheck %s +- +-; Dynamically-sized allocation, needs a loop which can handle any size at +-; runtime. The final iteration of the loop will temporarily put SP below the +-; target address, but this doesn't break any of the ABI constraints on the +-; stack, and also doesn't probe below the target SP value. +-define void @dynamic(i64 %size, ptr %out) #0 { +-; CHECK-LABEL: dynamic: +-; CHECK: // %bb.0: +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: add x9, x0, #15 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: and x9, x9, #0xfffffffffffffff0 +-; CHECK-NEXT: sub x8, x8, x9 +-; CHECK-NEXT: .LBB0_1: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x8 +-; CHECK-NEXT: b.le .LBB0_3 +-; CHECK-NEXT: // %bb.2: // in Loop: Header=BB0_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB0_1 +-; CHECK-NEXT: .LBB0_3: +-; CHECK-NEXT: mov sp, x8 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: str x8, [x1] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +- %v = alloca i8, i64 %size, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; This function has a fixed-size stack slot and a dynamic one. The fixed size +-; slot isn't large enough that we would normally probe it, but we need to do so +-; here otherwise the gap between the CSR save and the first probe of the +-; dynamic allocation could be too far apart when the size of the dynamic +-; allocation is close to the guard size. +-define void @dynamic_fixed(i64 %size, ptr %out1, ptr %out2) #0 { +-; CHECK-LABEL: dynamic_fixed: +-; CHECK: // %bb.0: +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: str xzr, [sp, #-64]! +-; CHECK-NEXT: add x9, x0, #15 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: and x9, x9, #0xfffffffffffffff0 +-; CHECK-NEXT: sub x10, x29, #64 +-; CHECK-NEXT: sub x8, x8, x9 +-; CHECK-NEXT: str x10, [x1] +-; CHECK-NEXT: .LBB1_1: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x8 +-; CHECK-NEXT: b.le .LBB1_3 +-; CHECK-NEXT: // %bb.2: // in Loop: Header=BB1_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB1_1 +-; CHECK-NEXT: .LBB1_3: +-; CHECK-NEXT: mov sp, x8 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: str x8, [x2] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +- %v1 = alloca i8, i64 64, align 1 +- store ptr %v1, ptr %out1, align 8 +- %v2 = alloca i8, i64 %size, align 1 +- store ptr %v2, ptr %out2, align 8 +- ret void +-} +- +-; Dynamic allocation, with an alignment requirement greater than the alignment +-; of SP. Done by ANDing the target SP with a constant to align it down, then +-; doing the loop as normal. Note that we also re-align the stack in the prolog, +-; which isn't actually needed because the only aligned allocations are dynamic, +-; this is done even without stack probing. +-define void @dynamic_align_64(i64 %size, ptr %out) #0 { +-; CHECK-LABEL: dynamic_align_64: +-; CHECK: // %bb.0: +-; CHECK-NEXT: stp x29, x30, [sp, #-32]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 32 +-; CHECK-NEXT: str x19, [sp, #16] // 8-byte Folded Spill +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 32 +-; CHECK-NEXT: .cfi_offset w19, -16 +-; CHECK-NEXT: .cfi_offset w30, -24 +-; CHECK-NEXT: .cfi_offset w29, -32 +-; CHECK-NEXT: sub x9, sp, #32 +-; CHECK-NEXT: and sp, x9, #0xffffffffffffffc0 +-; CHECK-NEXT: add x9, x0, #15 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: and x9, x9, #0xfffffffffffffff0 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub x8, x8, x9 +-; CHECK-NEXT: mov x19, sp +-; CHECK-NEXT: and x8, x8, #0xffffffffffffffc0 +-; CHECK-NEXT: .LBB2_1: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x8 +-; CHECK-NEXT: b.le .LBB2_3 +-; CHECK-NEXT: // %bb.2: // in Loop: Header=BB2_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB2_1 +-; CHECK-NEXT: .LBB2_3: +-; CHECK-NEXT: mov sp, x8 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: str x8, [x1] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 32 +-; CHECK-NEXT: ldr x19, [sp, #16] // 8-byte Folded Reload +-; CHECK-NEXT: ldp x29, x30, [sp], #32 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w19 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +- %v = alloca i8, i64 %size, align 64 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; Dynamic allocation, with an alignment greater than the stack guard size. The +-; only difference to the dynamic allocation is the constant used for aligning +-; the target SP, the loop will probe the whole allocation without needing to +-; know about the alignment padding. +-define void @dynamic_align_8192(i64 %size, ptr %out) #0 { +-; CHECK-LABEL: dynamic_align_8192: +-; CHECK: // %bb.0: +-; CHECK-NEXT: stp x29, x30, [sp, #-32]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 32 +-; CHECK-NEXT: str x19, [sp, #16] // 8-byte Folded Spill +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 32 +-; CHECK-NEXT: .cfi_offset w19, -16 +-; CHECK-NEXT: .cfi_offset w30, -24 +-; CHECK-NEXT: .cfi_offset w29, -32 +-; CHECK-NEXT: sub x9, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: sub x9, x9, #4064 +-; CHECK-NEXT: and x9, x9, #0xffffffffffffe000 +-; CHECK-NEXT: .LBB3_1: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.le .LBB3_3 +-; CHECK-NEXT: // %bb.2: // in Loop: Header=BB3_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB3_1 +-; CHECK-NEXT: .LBB3_3: +-; CHECK-NEXT: mov sp, x9 +-; CHECK-NEXT: add x9, x0, #15 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: and x9, x9, #0xfffffffffffffff0 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub x8, x8, x9 +-; CHECK-NEXT: mov x19, sp +-; CHECK-NEXT: and x8, x8, #0xffffffffffffe000 +-; CHECK-NEXT: .LBB3_4: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x8 +-; CHECK-NEXT: b.le .LBB3_6 +-; CHECK-NEXT: // %bb.5: // in Loop: Header=BB3_4 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB3_4 +-; CHECK-NEXT: .LBB3_6: +-; CHECK-NEXT: mov sp, x8 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: str x8, [x1] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 32 +-; CHECK-NEXT: ldr x19, [sp, #16] // 8-byte Folded Reload +-; CHECK-NEXT: ldp x29, x30, [sp], #32 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w19 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +- %v = alloca i8, i64 %size, align 8192 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; For 64k guard pages, the only difference is the constant subtracted from SP +-; in the loop. +-define void @dynamic_64k_guard(i64 %size, ptr %out) #0 "stack-probe-size"="65536" { +-; CHECK-LABEL: dynamic_64k_guard: +-; CHECK: // %bb.0: +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: add x9, x0, #15 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: and x9, x9, #0xfffffffffffffff0 +-; CHECK-NEXT: sub x8, x8, x9 +-; CHECK-NEXT: .LBB4_1: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: cmp sp, x8 +-; CHECK-NEXT: b.le .LBB4_3 +-; CHECK-NEXT: // %bb.2: // in Loop: Header=BB4_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB4_1 +-; CHECK-NEXT: .LBB4_3: +-; CHECK-NEXT: mov sp, x8 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: str x8, [x1] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +- %v = alloca i8, i64 %size, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; If a function has variable-sized stack objects, then any function calls which +-; need to pass arguments on the stack must allocate the stack space for them +-; dynamically, to ensure they are at the bottom of the frame. We need to probe +-; that space when it is larger than the unprobed space allowed by the ABI (1024 +-; bytes), so this needs a very large number of arguments. +-define void @no_reserved_call_frame(i64 %n) #0 { +-; CHECK-LABEL: no_reserved_call_frame: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: lsl x9, x0, #2 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: add x9, x9, #15 +-; CHECK-NEXT: and x9, x9, #0xfffffffffffffff0 +-; CHECK-NEXT: sub x0, x8, x9 +-; CHECK-NEXT: .LBB5_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x0 +-; CHECK-NEXT: b.le .LBB5_3 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: // in Loop: Header=BB5_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB5_1 +-; CHECK-NEXT: .LBB5_3: // %entry +-; CHECK-NEXT: mov sp, x0 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1104 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1104 +-; CHECK-NEXT: bl callee_stack_args +-; CHECK-NEXT: add sp, sp, #1104 +-; CHECK-NEXT: add sp, sp, #1104 +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i32, i64 %n +- call void @callee_stack_args(ptr %v, [138 x i64] undef) +- ret void +-} +- +-; Same as above but without a variable-sized allocation, so the reserved call +-; frame can be folded into the fixed-size allocation in the prologue. +-define void @reserved_call_frame(i64 %n) #0 { +-; CHECK-LABEL: reserved_call_frame: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: stp x29, x30, [sp, #-32]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 32 +-; CHECK-NEXT: str x28, [sp, #16] // 8-byte Folded Spill +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 32 +-; CHECK-NEXT: .cfi_offset w28, -16 +-; CHECK-NEXT: .cfi_offset w30, -24 +-; CHECK-NEXT: .cfi_offset w29, -32 +-; CHECK-NEXT: sub sp, sp, #1504 +-; CHECK-NEXT: add x0, sp, #1104 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: bl callee_stack_args +-; CHECK-NEXT: add sp, sp, #1504 +-; CHECK-NEXT: .cfi_def_cfa wsp, 32 +-; CHECK-NEXT: ldr x28, [sp, #16] // 8-byte Folded Reload +-; CHECK-NEXT: ldp x29, x30, [sp], #32 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w28 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i32, i64 100 +- call void @callee_stack_args(ptr %v, [138 x i64] undef) +- ret void +-} +- +-declare void @callee_stack_args(ptr, [138 x i64]) +- +-; Dynamic allocation of SVE vectors +-define void @dynamic_sve(i64 %size, ptr %out) #0 "target-features"="+sve" { +-; CHECK-LABEL: dynamic_sve: +-; CHECK: // %bb.0: +-; CHECK-NEXT: stp x29, x30, [sp, #-32]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 32 +-; CHECK-NEXT: str x19, [sp, #16] // 8-byte Folded Spill +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 32 +-; CHECK-NEXT: .cfi_offset w19, -16 +-; CHECK-NEXT: .cfi_offset w30, -24 +-; CHECK-NEXT: .cfi_offset w29, -32 +-; CHECK-NEXT: rdvl x9, #1 +-; CHECK-NEXT: mov x10, #15 // =0xf +-; CHECK-NEXT: madd x9, x0, x9, x10 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: and x9, x9, #0xfffffffffffffff0 +-; CHECK-NEXT: sub x8, x8, x9 +-; CHECK-NEXT: .LBB7_1: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x8 +-; CHECK-NEXT: b.le .LBB7_3 +-; CHECK-NEXT: // %bb.2: // in Loop: Header=BB7_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB7_1 +-; CHECK-NEXT: .LBB7_3: +-; CHECK-NEXT: mov sp, x8 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: str x8, [x1] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 32 +-; CHECK-NEXT: ldr x19, [sp, #16] // 8-byte Folded Reload +-; CHECK-NEXT: ldp x29, x30, [sp], #32 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w19 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +- %v = alloca , i64 %size, align 16 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-attributes #0 = { uwtable(async) "probe-stack"="inline-asm" "frame-pointer"="none" } +\ No newline at end of file +diff --git a/llvm/test/CodeGen/AArch64/stack-probing-last-in-block.mir b/llvm/test/CodeGen/AArch64/stack-probing-last-in-block.mir +deleted file mode 100644 +index 9a173be5857e..000000000000 +--- a/llvm/test/CodeGen/AArch64/stack-probing-last-in-block.mir ++++ /dev/null +@@ -1,144 +0,0 @@ +-# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4 +-# RUN: llc -run-pass=prologepilog %s -o - | FileCheck %s +-# Regression test for a crash when the probing instruction +-# to replace is last in the block. +---- | +- source_filename = "tt.ll" +- target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +- target triple = "aarch64-linux" +- +- declare i1 @g(ptr) +- +- define void @f(ptr %out) #0 { +- entry: +- %p = alloca i32, i32 50000, align 4 +- br label %loop +- +- loop: ; preds = %loop, %entry +- %c = call i1 @g(ptr %p) +- br i1 %c, label %loop, label %exit +- +- exit: ; preds = %loop +- ret void +- } +- +- attributes #0 = { uwtable "frame-pointer"="none" "probe-stack"="inline-asm" "target-features"="+sve" } +- +-... +---- +-name: f +-alignment: 4 +-exposesReturnsTwice: false +-legalized: false +-regBankSelected: false +-selected: false +-failedISel: false +-tracksRegLiveness: true +-hasWinCFI: false +-callsEHReturn: false +-callsUnwindInit: false +-hasEHCatchret: false +-hasEHScopes: false +-hasEHFunclets: false +-isOutlined: false +-debugInstrRef: false +-failsVerification: false +-tracksDebugUserValues: true +-registers: [] +-liveins: [] +-frameInfo: +- isFrameAddressTaken: false +- isReturnAddressTaken: false +- hasStackMap: false +- hasPatchPoint: false +- stackSize: 0 +- offsetAdjustment: 0 +- maxAlignment: 4 +- adjustsStack: true +- hasCalls: true +- stackProtector: '' +- functionContext: '' +- maxCallFrameSize: 0 +- cvBytesOfCalleeSavedRegisters: 0 +- hasOpaqueSPAdjustment: false +- hasVAStart: false +- hasMustTailInVarArgFunc: false +- hasTailCall: false +- localFrameSize: 200000 +- savePoint: '' +- restorePoint: '' +-fixedStack: [] +-stack: +- - { id: 0, name: p, type: default, offset: 0, size: 200000, alignment: 4, +- stack-id: default, callee-saved-register: '', callee-saved-restored: true, +- local-offset: -200000, debug-info-variable: '', debug-info-expression: '', +- debug-info-location: '' } +-entry_values: [] +-callSites: [] +-debugValueSubstitutions: [] +-constants: [] +-machineFunctionInfo: {} +-body: | +- ; CHECK-LABEL: name: f +- ; CHECK: bb.0.entry: +- ; CHECK-NEXT: successors: %bb.3(0x80000000) +- ; CHECK-NEXT: liveins: $lr, $fp +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: early-clobber $sp = frame-setup STPXpre killed $fp, killed $lr, $sp, -2 :: (store (s64) into %stack.2), (store (s64) into %stack.1) +- ; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16 +- ; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -8 +- ; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -16 +- ; CHECK-NEXT: $x9 = frame-setup SUBXri $sp, 48, 12 +- ; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa $w9, 196624 +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: bb.3.entry: +- ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000) +- ; CHECK-NEXT: liveins: $x9 +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 1, 12 +- ; CHECK-NEXT: frame-setup STRXui $xzr, $sp, 0 +- ; CHECK-NEXT: $xzr = frame-setup SUBSXrx64 $sp, $x9, 24, implicit-def $nzcv +- ; CHECK-NEXT: frame-setup Bcc 1, %bb.3, implicit $nzcv +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: bb.4.entry: +- ; CHECK-NEXT: successors: %bb.1(0x80000000) +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_register $wsp +- ; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 3392, 0 +- ; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 200016 +- ; CHECK-NEXT: frame-setup STRXui $xzr, $sp, 0 +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: bb.1.loop: +- ; CHECK-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000) +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: $x0 = ADDXri $sp, 0, 0 +- ; CHECK-NEXT: BL @g, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp, implicit-def $w0 +- ; CHECK-NEXT: TBNZW killed renamable $w0, 0, %bb.1 +- ; CHECK-NEXT: B %bb.2 +- ; CHECK-NEXT: {{ $}} +- ; CHECK-NEXT: bb.2.exit: +- ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 48, 12 +- ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 3408 +- ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 3392, 0 +- ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 16 +- ; CHECK-NEXT: early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2 :: (load (s64) from %stack.2), (load (s64) from %stack.1) +- ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 0 +- ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $w30 +- ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $w29 +- ; CHECK-NEXT: RET_ReallyLR +- bb.0.entry: +- successors: %bb.1(0x80000000) +- +- +- bb.1.loop: +- successors: %bb.1(0x7c000000), %bb.2(0x04000000) +- +- ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp +- $x0 = ADDXri %stack.0.p, 0, 0 +- BL @g, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp, implicit-def $w0 +- ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp +- TBNZW killed renamable $w0, 0, %bb.1 +- B %bb.2 +- +- bb.2.exit: +- RET_ReallyLR +\ No newline at end of file +diff --git a/llvm/test/CodeGen/AArch64/stack-probing-sve.ll b/llvm/test/CodeGen/AArch64/stack-probing-sve.ll +deleted file mode 100644 +index e765d071e722..000000000000 +--- a/llvm/test/CodeGen/AArch64/stack-probing-sve.ll ++++ /dev/null +@@ -1,724 +0,0 @@ +-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +-; RUN: llc -mtriple aarch64-none-eabi < %s -verify-machineinstrs | FileCheck %s +-; RUN: llc -mtriple aarch64-none-eabi < %s -verify-machineinstrs -global-isel -global-isel-abort=2 | FileCheck %s +- +-; Test prolog sequences for stack probing when SVE objects are involved. +- +-; The space for SVE objects needs probing in the general case, because +-; the stack adjustment may happen to be too big (i.e. greater than the +-; probe size) to allocate with a single `addvl`. +-; When we do know that the stack adjustment cannot exceed the probe size +-; we can avoid emitting a probe loop and emit a simple `addvl; str` +-; sequence instead. +- +-define void @sve_1_vector(ptr %out) #0 { +-; CHECK-LABEL: sve_1_vector: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-1 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 8 * VG +-; CHECK-NEXT: addvl sp, sp, #1 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %vec = alloca , align 16 +- ret void +-} +- +-; As above, but with 4 SVE vectors of stack space. +-define void @sve_4_vector(ptr %out) #0 { +-; CHECK-LABEL: sve_4_vector: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-4 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x20, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 32 * VG +-; CHECK-NEXT: addvl sp, sp, #4 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %vec1 = alloca , align 16 +- %vec2 = alloca , align 16 +- %vec3 = alloca , align 16 +- %vec4 = alloca , align 16 +- ret void +-} +- +-; As above, but with 16 SVE vectors of stack space. +-; The stack adjustment is less than or equal to 16 x 256 = 4096, so +-; we can allocate the locals at once. +-define void @sve_16_vector(ptr %out) #0 { +-; CHECK-LABEL: sve_16_vector: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-16 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 128 * VG +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: addvl sp, sp, #16 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %vec1 = alloca , align 16 +- %vec2 = alloca , align 16 +- %vec3 = alloca , align 16 +- %vec4 = alloca , align 16 +- %vec5 = alloca , align 16 +- %vec6 = alloca , align 16 +- %vec7 = alloca , align 16 +- %vec8 = alloca , align 16 +- %vec9 = alloca , align 16 +- %vec10 = alloca , align 16 +- %vec11 = alloca , align 16 +- %vec12 = alloca , align 16 +- %vec13 = alloca , align 16 +- %vec14 = alloca , align 16 +- %vec15 = alloca , align 16 +- %vec16 = alloca , align 16 +- ret void +-} +- +-; As above, but with 17 SVE vectors of stack space. Now we need +-; a probing loops since stack adjustment may be greater than +-; the probe size (17 x 256 = 4354 bytes) +-; TODO: Allocating `k*16+r` SVE vectors can be unrolled into +-; emiting the `k + r` sequences of `addvl sp, sp, #-N; str xzr, [sp]` +-define void @sve_17_vector(ptr %out) #0 { +-; CHECK-LABEL: sve_17_vector: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl x9, sp, #-17 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x88, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 136 * VG +-; CHECK-NEXT: .LBB3_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.le .LBB3_3 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: // in Loop: Header=BB3_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB3_1 +-; CHECK-NEXT: .LBB3_3: // %entry +-; CHECK-NEXT: mov sp, x9 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: .cfi_def_cfa_register wsp +-; CHECK-NEXT: addvl sp, sp, #17 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %vec1 = alloca , align 16 +- %vec2 = alloca , align 16 +- %vec3 = alloca , align 16 +- %vec4 = alloca , align 16 +- %vec5 = alloca , align 16 +- %vec6 = alloca , align 16 +- %vec7 = alloca , align 16 +- %vec8 = alloca , align 16 +- %vec9 = alloca , align 16 +- %vec10 = alloca , align 16 +- %vec11 = alloca , align 16 +- %vec12 = alloca , align 16 +- %vec13 = alloca , align 16 +- %vec14 = alloca , align 16 +- %vec15 = alloca , align 16 +- %vec16 = alloca , align 16 +- %vec17 = alloca , align 16 +- ret void +-} +- +-; Space for callee-saved SVE register is allocated similarly to allocating +-; space for SVE locals. When we know the stack adjustment cannot exceed the +-; probe size we can skip the explict probe, since saving SVE registers serves +-; as an implicit probe. +-define void @sve_1v_csr( %a) #0 { +-; CHECK-LABEL: sve_1v_csr: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-1 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 8 * VG +-; CHECK-NEXT: str z8, [sp] // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_escape 0x10, 0x48, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x78, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d8 @ cfa - 16 - 8 * VG +-; CHECK-NEXT: //APP +-; CHECK-NEXT: //NO_APP +-; CHECK-NEXT: ldr z8, [sp] // 16-byte Folded Reload +-; CHECK-NEXT: addvl sp, sp, #1 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: .cfi_restore z8 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- call void asm sideeffect "", "~{z8}" () +- ret void +-} +- +-define void @sve_4v_csr( %a) #0 { +-; CHECK-LABEL: sve_4v_csr: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-4 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x20, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 32 * VG +-; CHECK-NEXT: str z11, [sp] // 16-byte Folded Spill +-; CHECK-NEXT: str z10, [sp, #1, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z9, [sp, #2, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z8, [sp, #3, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_escape 0x10, 0x48, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x78, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d8 @ cfa - 16 - 8 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x49, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x70, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d9 @ cfa - 16 - 16 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4a, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x68, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d10 @ cfa - 16 - 24 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4b, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x60, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d11 @ cfa - 16 - 32 * VG +-; CHECK-NEXT: //APP +-; CHECK-NEXT: //NO_APP +-; CHECK-NEXT: ldr z11, [sp] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z10, [sp, #1, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z9, [sp, #2, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z8, [sp, #3, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: addvl sp, sp, #4 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: .cfi_restore z8 +-; CHECK-NEXT: .cfi_restore z9 +-; CHECK-NEXT: .cfi_restore z10 +-; CHECK-NEXT: .cfi_restore z11 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- call void asm sideeffect "", "~{z8},~{z9},~{z10},~{z11}" () +- ret void +-} +- +-define void @sve_16v_csr( %a) #0 { +-; CHECK-LABEL: sve_16v_csr: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-16 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 128 * VG +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: str z23, [sp] // 16-byte Folded Spill +-; CHECK-NEXT: str z22, [sp, #1, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z21, [sp, #2, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z20, [sp, #3, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z19, [sp, #4, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z18, [sp, #5, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z17, [sp, #6, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z16, [sp, #7, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z15, [sp, #8, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z14, [sp, #9, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z13, [sp, #10, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z12, [sp, #11, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z11, [sp, #12, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z10, [sp, #13, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z9, [sp, #14, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z8, [sp, #15, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_escape 0x10, 0x48, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x78, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d8 @ cfa - 16 - 8 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x49, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x70, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d9 @ cfa - 16 - 16 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4a, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x68, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d10 @ cfa - 16 - 24 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4b, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x60, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d11 @ cfa - 16 - 32 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4c, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x58, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d12 @ cfa - 16 - 40 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4d, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x50, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d13 @ cfa - 16 - 48 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4e, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x48, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d14 @ cfa - 16 - 56 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4f, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x40, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d15 @ cfa - 16 - 64 * VG +-; CHECK-NEXT: //APP +-; CHECK-NEXT: //NO_APP +-; CHECK-NEXT: ldr z23, [sp] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z22, [sp, #1, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z21, [sp, #2, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z20, [sp, #3, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z19, [sp, #4, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z18, [sp, #5, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z17, [sp, #6, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z16, [sp, #7, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z15, [sp, #8, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z14, [sp, #9, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z13, [sp, #10, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z12, [sp, #11, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z11, [sp, #12, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z10, [sp, #13, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z9, [sp, #14, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z8, [sp, #15, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: addvl sp, sp, #16 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: .cfi_restore z8 +-; CHECK-NEXT: .cfi_restore z9 +-; CHECK-NEXT: .cfi_restore z10 +-; CHECK-NEXT: .cfi_restore z11 +-; CHECK-NEXT: .cfi_restore z12 +-; CHECK-NEXT: .cfi_restore z13 +-; CHECK-NEXT: .cfi_restore z14 +-; CHECK-NEXT: .cfi_restore z15 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- call void asm sideeffect "", "~{z8},~{z9},~{z10},~{z11},~{z12},~{z13},~{z14},~{z15},~{z16},~{z17},~{z18},~{z19},~{z20},~{z21},~{z22},~{z23}" () +- ret void +-} +- +-define void @sve_1p_csr( %a) #0 { +-; CHECK-LABEL: sve_1p_csr: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-1 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 8 * VG +-; CHECK-NEXT: str p8, [sp, #7, mul vl] // 2-byte Folded Spill +-; CHECK-NEXT: //APP +-; CHECK-NEXT: //NO_APP +-; CHECK-NEXT: ldr p8, [sp, #7, mul vl] // 2-byte Folded Reload +-; CHECK-NEXT: addvl sp, sp, #1 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- call void asm sideeffect "", "~{p8}" () +- ret void +-} +- +-define void @sve_4p_csr( %a) #0 { +-; CHECK-LABEL: sve_4p_csr: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-1 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 8 * VG +-; CHECK-NEXT: str p11, [sp, #4, mul vl] // 2-byte Folded Spill +-; CHECK-NEXT: str p10, [sp, #5, mul vl] // 2-byte Folded Spill +-; CHECK-NEXT: str p9, [sp, #6, mul vl] // 2-byte Folded Spill +-; CHECK-NEXT: str p8, [sp, #7, mul vl] // 2-byte Folded Spill +-; CHECK-NEXT: //APP +-; CHECK-NEXT: //NO_APP +-; CHECK-NEXT: ldr p11, [sp, #4, mul vl] // 2-byte Folded Reload +-; CHECK-NEXT: ldr p10, [sp, #5, mul vl] // 2-byte Folded Reload +-; CHECK-NEXT: ldr p9, [sp, #6, mul vl] // 2-byte Folded Reload +-; CHECK-NEXT: ldr p8, [sp, #7, mul vl] // 2-byte Folded Reload +-; CHECK-NEXT: addvl sp, sp, #1 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- call void asm sideeffect "", "~{p8},~{p9},~{p10},~{p11}" () +- ret void +-} +- +-define void @sve_16v_1p_csr( %a) #0 { +-; CHECK-LABEL: sve_16v_1p_csr: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl x9, sp, #-17 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x88, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 136 * VG +-; CHECK-NEXT: .LBB9_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.le .LBB9_3 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: // in Loop: Header=BB9_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB9_1 +-; CHECK-NEXT: .LBB9_3: // %entry +-; CHECK-NEXT: mov sp, x9 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: .cfi_def_cfa_register wsp +-; CHECK-NEXT: str p8, [sp, #7, mul vl] // 2-byte Folded Spill +-; CHECK-NEXT: str z23, [sp, #1, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z22, [sp, #2, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z21, [sp, #3, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z20, [sp, #4, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z19, [sp, #5, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z18, [sp, #6, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z17, [sp, #7, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z16, [sp, #8, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z15, [sp, #9, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z14, [sp, #10, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z13, [sp, #11, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z12, [sp, #12, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z11, [sp, #13, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z10, [sp, #14, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z9, [sp, #15, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z8, [sp, #16, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_escape 0x10, 0x48, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x78, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d8 @ cfa - 16 - 8 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x49, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x70, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d9 @ cfa - 16 - 16 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4a, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x68, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d10 @ cfa - 16 - 24 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4b, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x60, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d11 @ cfa - 16 - 32 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4c, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x58, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d12 @ cfa - 16 - 40 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4d, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x50, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d13 @ cfa - 16 - 48 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4e, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x48, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d14 @ cfa - 16 - 56 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4f, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x40, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d15 @ cfa - 16 - 64 * VG +-; CHECK-NEXT: //APP +-; CHECK-NEXT: //NO_APP +-; CHECK-NEXT: ldr p8, [sp, #7, mul vl] // 2-byte Folded Reload +-; CHECK-NEXT: ldr z23, [sp, #1, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z22, [sp, #2, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z21, [sp, #3, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z20, [sp, #4, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z19, [sp, #5, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z18, [sp, #6, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z17, [sp, #7, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z16, [sp, #8, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z15, [sp, #9, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z14, [sp, #10, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z13, [sp, #11, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z12, [sp, #12, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z11, [sp, #13, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z10, [sp, #14, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z9, [sp, #15, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z8, [sp, #16, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: addvl sp, sp, #17 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: .cfi_restore z8 +-; CHECK-NEXT: .cfi_restore z9 +-; CHECK-NEXT: .cfi_restore z10 +-; CHECK-NEXT: .cfi_restore z11 +-; CHECK-NEXT: .cfi_restore z12 +-; CHECK-NEXT: .cfi_restore z13 +-; CHECK-NEXT: .cfi_restore z14 +-; CHECK-NEXT: .cfi_restore z15 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- call void asm sideeffect "", "~{p8},~{z8},~{z9},~{z10},~{z11},~{z12},~{z13},~{z14},~{z15},~{z16},~{z17},~{z18},~{z19},~{z20},~{z21},~{z22},~{z23}" () +- ret void +-} +- +-; A SVE vector and a 16-byte fixed size object. +-define void @sve_1_vector_16_arr(ptr %out) #0 { +-; CHECK-LABEL: sve_1_vector_16_arr: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #16 +-; CHECK-NEXT: .cfi_def_cfa_offset 32 +-; CHECK-NEXT: addvl sp, sp, #-1 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 32 + 8 * VG +-; CHECK-NEXT: addvl sp, sp, #1 +-; CHECK-NEXT: .cfi_def_cfa wsp, 32 +-; CHECK-NEXT: add sp, sp, #16 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %vec = alloca , align 16 +- %arr = alloca i8, i64 16, align 1 +- ret void +-} +- +-; A large SVE stack object and a large stack slot, both of which need probing. +-; TODO: This could be optimised by combining the fixed-size offset into the +-; loop. +-define void @sve_1_vector_4096_arr(ptr %out) #0 { +-; CHECK-LABEL: sve_1_vector_4096_arr: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #3, lsl #12 // =12288 +-; CHECK-NEXT: .cfi_def_cfa w9, 12304 +-; CHECK-NEXT: addvl x9, x9, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0f, 0x79, 0x00, 0x11, 0x90, 0xe0, 0x00, 0x22, 0x11, 0x80, 0x02, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 12304 + 256 * VG +-; CHECK-NEXT: addvl x9, x9, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0f, 0x79, 0x00, 0x11, 0x90, 0xe0, 0x00, 0x22, 0x11, 0x80, 0x04, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 12304 + 512 * VG +-; CHECK-NEXT: .LBB11_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.le .LBB11_3 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: // in Loop: Header=BB11_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB11_1 +-; CHECK-NEXT: .LBB11_3: // %entry +-; CHECK-NEXT: mov sp, x9 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: .cfi_def_cfa_register wsp +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0f, 0x8f, 0x00, 0x11, 0x90, 0xe0, 0x00, 0x22, 0x11, 0x88, 0x02, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 12304 + 264 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0e, 0x8f, 0x00, 0x11, 0x90, 0xe0, 0x00, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 12304 + 16 * VG +-; CHECK-NEXT: addvl sp, sp, #2 +-; CHECK-NEXT: .cfi_def_cfa wsp, 12304 +-; CHECK-NEXT: add sp, sp, #3, lsl #12 // =12288 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %vec = alloca , align 16 +- %arr = alloca i8, i64 12288, align 1 +- ret void +-} +- +-; Not tested: SVE stack objects with alignment >16 bytes, which isn't currently +-; supported even without stack-probing. +- +-; An SVE vector, and a 16-byte fixed size object, which +-; has a large alignment requirement. +-define void @sve_1_vector_16_arr_align_8192(ptr %out) #0 { +-; CHECK-LABEL: sve_1_vector_16_arr_align_8192: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: sub x9, x9, #4080 +-; CHECK-NEXT: addvl x9, x9, #-1 +-; CHECK-NEXT: and x9, x9, #0xffffffffffffe000 +-; CHECK-NEXT: .LBB12_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.le .LBB12_3 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: // in Loop: Header=BB12_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB12_1 +-; CHECK-NEXT: .LBB12_3: // %entry +-; CHECK-NEXT: mov sp, x9 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %vec = alloca , align 16 +- %arr = alloca i8, i64 16, align 8192 +- ret void +-} +- +-; With 64k guard pages, we can allocate bigger SVE space without a probing loop. +-define void @sve_1024_64k_guard(ptr %out) #0 "stack-probe-size"="65536" { +-; CHECK-LABEL: sve_1024_64k_guard: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x02, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 256 * VG +-; CHECK-NEXT: addvl sp, sp, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x04, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 512 * VG +-; CHECK-NEXT: addvl sp, sp, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x06, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 768 * VG +-; CHECK-NEXT: addvl sp, sp, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1024 * VG +-; CHECK-NEXT: addvl sp, sp, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x0a, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1280 * VG +-; CHECK-NEXT: addvl sp, sp, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x0c, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1536 * VG +-; CHECK-NEXT: addvl sp, sp, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x0e, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1792 * VG +-; CHECK-NEXT: addvl sp, sp, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 2048 * VG +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x88, 0x0e, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1800 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x90, 0x0c, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1552 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x98, 0x0a, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1304 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xa0, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1056 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xa8, 0x06, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 808 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xb0, 0x04, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 560 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xb8, 0x02, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 312 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xc0, 0x00, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 64 * VG +-; CHECK-NEXT: addvl sp, sp, #8 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %vec = alloca , align 16 +- ret void +-} +- +-define void @sve_1028_64k_guard(ptr %out) #0 "stack-probe-size"="65536" { +-; CHECK-LABEL: sve_1028_64k_guard: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl x9, sp, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x02, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 256 * VG +-; CHECK-NEXT: addvl x9, x9, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x04, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 512 * VG +-; CHECK-NEXT: addvl x9, x9, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x06, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 768 * VG +-; CHECK-NEXT: addvl x9, x9, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 1024 * VG +-; CHECK-NEXT: addvl x9, x9, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x0a, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 1280 * VG +-; CHECK-NEXT: addvl x9, x9, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x0c, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 1536 * VG +-; CHECK-NEXT: addvl x9, x9, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x0e, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 1792 * VG +-; CHECK-NEXT: addvl x9, x9, #-32 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x80, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 2048 * VG +-; CHECK-NEXT: addvl x9, x9, #-1 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x79, 0x00, 0x11, 0x10, 0x22, 0x11, 0x88, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $x9 + 16 + 2056 * VG +-; CHECK-NEXT: .LBB14_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #16, lsl #12 // =65536 +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.le .LBB14_3 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: // in Loop: Header=BB14_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB14_1 +-; CHECK-NEXT: .LBB14_3: // %entry +-; CHECK-NEXT: mov sp, x9 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: .cfi_def_cfa_register wsp +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x90, 0x0e, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1808 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x98, 0x0c, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1560 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xa0, 0x0a, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1312 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xa8, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 1064 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xb0, 0x06, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 816 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xb8, 0x04, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 568 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xc0, 0x02, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 320 * VG +-; CHECK-NEXT: addvl sp, sp, #31 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xc8, 0x00, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 72 * VG +-; CHECK-NEXT: addvl sp, sp, #9 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %vec = alloca , align 16 +- %vec1 = alloca , align 16 +- ret void +-} +- +-; With 5 SVE vectors of stack space the unprobed area +-; at the top of the stack can exceed 1024 bytes (5 x 256 == 1280), +-; hence we need to issue a probe. +-define void @sve_5_vector(ptr %out) #0 { +-; CHECK-LABEL: sve_5_vector: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-5 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x28, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 40 * VG +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: addvl sp, sp, #5 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %vec1 = alloca , align 16 +- %vec2 = alloca , align 16 +- %vec3 = alloca , align 16 +- %vec4 = alloca , align 16 +- %vec5 = alloca , align 16 +- ret void +-} +- +-; Test with a 14 scalable bytes (so up to 14 * 16 = 224) of unprobed +-; are bellow the save location of `p9`. +-define void @sve_unprobed_area( %a, i32 %n) #0 { +-; CHECK-LABEL: sve_unprobed_area: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: addvl sp, sp, #-4 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x20, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 32 * VG +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: str p9, [sp, #7, mul vl] // 2-byte Folded Spill +-; CHECK-NEXT: str z10, [sp, #1, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z9, [sp, #2, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: str z8, [sp, #3, mul vl] // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_escape 0x10, 0x48, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x78, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d8 @ cfa - 16 - 8 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x49, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x70, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d9 @ cfa - 16 - 16 * VG +-; CHECK-NEXT: .cfi_escape 0x10, 0x4a, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x68, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d10 @ cfa - 16 - 24 * VG +-; CHECK-NEXT: addvl sp, sp, #-4 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xc0, 0x00, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 64 * VG +-; CHECK-NEXT: //APP +-; CHECK-NEXT: //NO_APP +-; CHECK-NEXT: addvl sp, sp, #4 +-; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x20, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 32 * VG +-; CHECK-NEXT: ldr p9, [sp, #7, mul vl] // 2-byte Folded Reload +-; CHECK-NEXT: ldr z10, [sp, #1, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z9, [sp, #2, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: ldr z8, [sp, #3, mul vl] // 16-byte Folded Reload +-; CHECK-NEXT: addvl sp, sp, #4 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: .cfi_restore z8 +-; CHECK-NEXT: .cfi_restore z9 +-; CHECK-NEXT: .cfi_restore z10 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- call void asm sideeffect "", "~{z8},~{z9},~{z10},~{p9}" () +- +- %v0 = alloca , align 16 +- %v1 = alloca , align 16 +- %v2 = alloca , align 16 +- %v3 = alloca , align 16 +- +- ret void +-} +- +-attributes #0 = { uwtable(async) "probe-stack"="inline-asm" "frame-pointer"="none" "target-features"="+sve" } +\ No newline at end of file +diff --git a/llvm/test/CodeGen/AArch64/stack-probing.ll b/llvm/test/CodeGen/AArch64/stack-probing.ll +deleted file mode 100644 +index 95001450622f..000000000000 +--- a/llvm/test/CodeGen/AArch64/stack-probing.ll ++++ /dev/null +@@ -1,539 +0,0 @@ +-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +-; RUN: llc -mtriple aarch64-none-eabi < %s -verify-machineinstrs -enable-post-misched=false | FileCheck %s +-; RUN: llc -mtriple aarch64-none-eabi < %s -verify-machineinstrs -enable-post-misched=false -global-isel | FileCheck %s +- +-; Tests for prolog sequences for stack probing, when using a 4KiB stack guard. +- +-; The stack probing parameters in function attributes take precedence over +-; ones in the module flags. +- +-; Small stack frame, no probing required. +-define void @static_64(ptr %out) #0 { +-; CHECK-LABEL: static_64: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: sub sp, sp, #64 +-; CHECK-NEXT: .cfi_def_cfa_offset 64 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #64 +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 64, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; At 256 bytes we start to always create a frame pointer. No frame smaller then +-; this needs a probe, so we can use the saving of at least one CSR as a probe +-; at the top of our frame. +-define void @static_256(ptr %out) #0 { +-; CHECK-LABEL: static_256: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: sub sp, sp, #272 +-; CHECK-NEXT: .cfi_def_cfa_offset 272 +-; CHECK-NEXT: str x29, [sp, #256] // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #272 +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 256, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; At 1024 bytes, this is the largest frame which doesn't need probing. +-define void @static_1024(ptr %out) #0 { +-; CHECK-LABEL: static_1024: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 1040 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 1024, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; At 1024+16 bytes, this is the smallest frame which needs probing. +-define void @static_1040(ptr %out) #0 { +-; CHECK-LABEL: static_1040: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 1056 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 1040, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; 4k bytes is the largest frame we can probe in one go. +-define void @static_4096(ptr %out) #0 { +-; CHECK-LABEL: static_4096: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 4112 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 4096, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; 4k+16 bytes, still needs just one probe. +-define void @static_4112(ptr %out) #0 { +-; CHECK-LABEL: static_4112: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 4112 +-; CHECK-NEXT: str xzr, [sp], #-16 +-; CHECK-NEXT: .cfi_def_cfa_offset 4128 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 32 +-; CHECK-NEXT: add sp, sp, #16 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 4112, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; 4k+1024 bytes, the largest frame which needs just one probe. +-define void @static_5120(ptr %out) #0 { +-; CHECK-LABEL: static_5120: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 4112 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 5136 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 1040 +-; CHECK-NEXT: add sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 5120, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; 4k+1024+16, the smallest frame which needs two probes. +-define void @static_5136(ptr %out) #0 { +-; CHECK-LABEL: static_5136: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 4112 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 5152 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 1056 +-; CHECK-NEXT: add sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 5136, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; 2*4k+1024, the largest frame needing two probes +-define void @static_9216(ptr %out) #0 { +-; CHECK-LABEL: static_9216: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 4112 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 8208 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 9232 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #2, lsl #12 // =8192 +-; CHECK-NEXT: .cfi_def_cfa_offset 1040 +-; CHECK-NEXT: add sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 9216, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; 5*4k-16, the largest frame probed without a loop +-define void @static_20464(ptr %out) #0 { +-; CHECK-LABEL: static_20464: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 4112 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 8208 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 12304 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: .cfi_def_cfa_offset 16400 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: sub sp, sp, #4080 +-; CHECK-NEXT: .cfi_def_cfa_offset 20480 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #4, lsl #12 // =16384 +-; CHECK-NEXT: .cfi_def_cfa_offset 4096 +-; CHECK-NEXT: add sp, sp, #4080 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 20464, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; 5*4k, the smallest frame probed with a loop +-define void @static_20480(ptr %out) #0 { +-; CHECK-LABEL: static_20480: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #5, lsl #12 // =20480 +-; CHECK-NEXT: .cfi_def_cfa w9, 20496 +-; CHECK-NEXT: .LBB10_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.ne .LBB10_1 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: .cfi_def_cfa_register wsp +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #5, lsl #12 // =20480 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 20480, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; 5*4k + 1024, large enough to use a loop, but not a multiple of 4KiB +-; so has a reminder, but no extra probe. +-define void @static_21504(ptr %out) #0 { +-; CHECK-LABEL: static_21504: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #5, lsl #12 // =20480 +-; CHECK-NEXT: .cfi_def_cfa w9, 20496 +-; CHECK-NEXT: .LBB11_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.ne .LBB11_1 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: .cfi_def_cfa_register wsp +-; CHECK-NEXT: sub sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 21520 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #5, lsl #12 // =20480 +-; CHECK-NEXT: .cfi_def_cfa_offset 1040 +-; CHECK-NEXT: add sp, sp, #1024 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 21504, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; 5*4k+1040, large enough to use a loop, has a reminder and +-; an extra probe. +-define void @static_21520(ptr %out) #0 { +-; CHECK-LABEL: static_21520: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #5, lsl #12 // =20480 +-; CHECK-NEXT: .cfi_def_cfa w9, 20496 +-; CHECK-NEXT: .LBB12_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.ne .LBB12_1 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: .cfi_def_cfa_register wsp +-; CHECK-NEXT: sub sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 21536 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #5, lsl #12 // =20480 +-; CHECK-NEXT: .cfi_def_cfa_offset 1056 +-; CHECK-NEXT: add sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 21520, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; A small allocation, but with a very large alignment requirement. We do this +-; by moving SP far enough that a sufficiently-aligned block will exist +-; somewhere in the stack frame, so must probe the whole of that larger SP move. +-define void @static_16_align_8192(ptr %out) #0 { +-; CHECK-LABEL: static_16_align_8192: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: sub x9, x9, #4080 +-; CHECK-NEXT: and x9, x9, #0xffffffffffffe000 +-; CHECK-NEXT: .LBB13_1: // %entry +-; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 +-; CHECK-NEXT: sub sp, sp, #1, lsl #12 // =4096 +-; CHECK-NEXT: cmp sp, x9 +-; CHECK-NEXT: b.le .LBB13_3 +-; CHECK-NEXT: // %bb.2: // %entry +-; CHECK-NEXT: // in Loop: Header=BB13_1 Depth=1 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: b .LBB13_1 +-; CHECK-NEXT: .LBB13_3: // %entry +-; CHECK-NEXT: mov sp, x9 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 16, align 8192 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; A small allocation with a very large alignment requirement, but +-; nevertheless small enough as to not need a loop. +-define void @static_16_align_2048(ptr %out) #0 { +-; CHECK-LABEL: static_16_align_2048: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #2032 +-; CHECK-NEXT: and sp, x9, #0xfffffffffffff800 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 16, align 2048 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; A large(-ish) allocation with a very large alignment requirement, but +-; nevertheless small enough as to not need a loop. +-define void @static_2032_align_2048(ptr %out) #0 { +-; CHECK-LABEL: static_2032_align_2048: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #2032 +-; CHECK-NEXT: and sp, x9, #0xfffffffffffff800 +-; CHECK-NEXT: str xzr, [sp] +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 2032, align 2048 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; Test stack probing is enabled by module flags +-define void @static_9232(ptr %out) uwtable(async) { +-; CHECK-LABEL: static_9232: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub sp, sp, #2, lsl #12 // =8192 +-; CHECK-NEXT: .cfi_def_cfa_offset 8208 +-; CHECK-NEXT: sub sp, sp, #800 +-; CHECK-NEXT: .cfi_def_cfa_offset 9008 +-; CHECK-NEXT: str xzr, [sp], #-240 +-; CHECK-NEXT: .cfi_def_cfa_offset 9248 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: add sp, sp, #2, lsl #12 // =8192 +-; CHECK-NEXT: .cfi_def_cfa_offset 1056 +-; CHECK-NEXT: add sp, sp, #1040 +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i64 9232, align 1 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-; Test for a tight upper bound on the amount of stack adjustment +-; due to stack realignment. No probes should appear. +-define void @static_1008(ptr %out) #0 { +-; CHECK-LABEL: static_1008: +-; CHECK: // %bb.0: // %entry +-; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: mov x29, sp +-; CHECK-NEXT: .cfi_def_cfa w29, 16 +-; CHECK-NEXT: .cfi_offset w30, -8 +-; CHECK-NEXT: .cfi_offset w29, -16 +-; CHECK-NEXT: sub x9, sp, #1008 +-; CHECK-NEXT: and sp, x9, #0xffffffffffffffe0 +-; CHECK-NEXT: mov x8, sp +-; CHECK-NEXT: str x8, [x0] +-; CHECK-NEXT: mov sp, x29 +-; CHECK-NEXT: .cfi_def_cfa wsp, 16 +-; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload +-; CHECK-NEXT: .cfi_def_cfa_offset 0 +-; CHECK-NEXT: .cfi_restore w30 +-; CHECK-NEXT: .cfi_restore w29 +-; CHECK-NEXT: ret +-entry: +- %v = alloca i8, i32 1008, align 32 +- store ptr %v, ptr %out, align 8 +- ret void +-} +- +-attributes #0 = { uwtable(async) "probe-stack"="inline-asm" "stack-probe-size"="4096" "frame-pointer"="none" } +- +-!llvm.module.flags = !{!0, !1} +- +-!0 = !{i32 4, !"probe-stack", !"inline-asm"} +-!1 = !{i32 8, !"stack-probe-size", i32 9000} +\ No newline at end of file +diff --git a/llvm/test/CodeGen/AArch64/sve-calling-convention-mixed.ll b/llvm/test/CodeGen/AArch64/sve-calling-convention-mixed.ll +index 235364ac2321..a97649523565 100644 +--- a/llvm/test/CodeGen/AArch64/sve-calling-convention-mixed.ll ++++ b/llvm/test/CodeGen/AArch64/sve-calling-convention-mixed.ll +@@ -56,8 +56,8 @@ define float @foo2(ptr %x0, ptr %x1) nounwind { + ; CHECK-LABEL: foo2: + ; CHECK: // %bb.0: // %entry + ; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: sub sp, sp, #16 + ; CHECK-NEXT: addvl sp, sp, #-4 ++; CHECK-NEXT: sub sp, sp, #16 + ; CHECK-NEXT: ptrue p0.b + ; CHECK-NEXT: add x8, sp, #16 + ; CHECK-NEXT: ld4d { z1.d - z4.d }, p0/z, [x0] +@@ -699,8 +699,8 @@ define void @verify_all_operands_are_initialised() { + ; CHECK-LABEL: verify_all_operands_are_initialised: + ; CHECK: // %bb.0: + ; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill +-; CHECK-NEXT: sub sp, sp, #16 + ; CHECK-NEXT: addvl sp, sp, #-1 ++; CHECK-NEXT: sub sp, sp, #16 + ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x20, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 32 + 8 * VG + ; CHECK-NEXT: .cfi_offset w30, -8 + ; CHECK-NEXT: .cfi_offset w29, -16 +diff --git a/llvm/test/CodeGen/AArch64/sve-fixed-length-fp128.ll b/llvm/test/CodeGen/AArch64/sve-fixed-length-fp128.ll +index b3529549c22b..31ff9287046c 100644 +--- a/llvm/test/CodeGen/AArch64/sve-fixed-length-fp128.ll ++++ b/llvm/test/CodeGen/AArch64/sve-fixed-length-fp128.ll +@@ -9,8 +9,8 @@ define void @fcvt_v4f64_v4f128(ptr %a, ptr %b) vscale_range(2,0) #0 { + ; CHECK: // %bb.0: + ; CHECK-NEXT: str x29, [sp, #-32]! // 8-byte Folded Spill + ; CHECK-NEXT: stp x30, x19, [sp, #16] // 16-byte Folded Spill +-; CHECK-NEXT: sub sp, sp, #48 + ; CHECK-NEXT: addvl sp, sp, #-2 ++; CHECK-NEXT: sub sp, sp, #48 + ; CHECK-NEXT: ptrue p0.d, vl4 + ; CHECK-NEXT: add x8, sp, #48 + ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0] +@@ -59,8 +59,8 @@ define void @fcvt_v4f128_v4f64(ptr %a, ptr %b) vscale_range(2,0) #0 { + ; CHECK: // %bb.0: + ; CHECK-NEXT: str x29, [sp, #-32]! // 8-byte Folded Spill + ; CHECK-NEXT: stp x30, x19, [sp, #16] // 16-byte Folded Spill +-; CHECK-NEXT: sub sp, sp, #128 + ; CHECK-NEXT: addvl sp, sp, #-2 ++; CHECK-NEXT: sub sp, sp, #128 + ; CHECK-NEXT: ldr q1, [x0, #64] + ; CHECK-NEXT: mov x19, x1 + ; CHECK-NEXT: ldr q0, [x0, #80] +diff --git a/llvm/test/CodeGen/X86/GlobalISel/stacksave-stackrestore.ll b/llvm/test/CodeGen/X86/GlobalISel/stacksave-stackrestore.ll +deleted file mode 100644 +index 8f665924577f..000000000000 +--- a/llvm/test/CodeGen/X86/GlobalISel/stacksave-stackrestore.ll ++++ /dev/null +@@ -1,43 +0,0 @@ +-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2 +-; RUN: llc -global-isel=1 -mtriple=x86_64-linux-gnu -o - %s | FileCheck %s +- +-declare void @use_addr(ptr) +-declare ptr @llvm.stacksave.p0() +-declare void @llvm.stackrestore.p0(ptr) +- +-define void @test_scoped_alloca(i64 %n) { +-; CHECK-LABEL: test_scoped_alloca: +-; CHECK: # %bb.0: +-; CHECK-NEXT: pushq %rbp +-; CHECK-NEXT: .cfi_def_cfa_offset 16 +-; CHECK-NEXT: .cfi_offset %rbp, -16 +-; CHECK-NEXT: movq %rsp, %rbp +-; CHECK-NEXT: .cfi_def_cfa_register %rbp +-; CHECK-NEXT: pushq %r14 +-; CHECK-NEXT: pushq %rbx +-; CHECK-NEXT: .cfi_offset %rbx, -32 +-; CHECK-NEXT: .cfi_offset %r14, -24 +-; CHECK-NEXT: movq %rdi, %rbx +-; CHECK-NEXT: callq llvm.stacksave.p0 +-; CHECK-NEXT: movq %rax, %r14 +-; CHECK-NEXT: movq %rsp, %rdi +-; CHECK-NEXT: imulq $1, %rbx, %rax +-; CHECK-NEXT: addq $15, %rax +-; CHECK-NEXT: andq $-16, %rax +-; CHECK-NEXT: subq %rax, %rdi +-; CHECK-NEXT: movq %rdi, %rsp +-; CHECK-NEXT: callq use_addr +-; CHECK-NEXT: movq %r14, %rdi +-; CHECK-NEXT: callq llvm.stackrestore.p0 +-; CHECK-NEXT: leaq -16(%rbp), %rsp +-; CHECK-NEXT: popq %rbx +-; CHECK-NEXT: popq %r14 +-; CHECK-NEXT: popq %rbp +-; CHECK-NEXT: .cfi_def_cfa %rsp, 8 +-; CHECK-NEXT: retq +- %sp = call ptr @llvm.stacksave.p0() +- %addr = alloca i8, i64 %n +- call void @use_addr(ptr %addr) +- call void @llvm.stackrestore.p0(ptr %sp) +- ret void +-} +-- +2.33.0 + diff --git a/1801-Add-triples-for-X86_64-AArch64-Riscv64-openEuler-gcc.patch b/1801-Add-triples-for-X86_64-AArch64-Riscv64-openEuler-gcc.patch new file mode 100644 index 0000000000000000000000000000000000000000..5b75b97cc564b77d8cd3e9368d6ea006d2298d94 --- /dev/null +++ b/1801-Add-triples-for-X86_64-AArch64-Riscv64-openEuler-gcc.patch @@ -0,0 +1,42 @@ +From a833e7fa829764f8e3bf6b059c9e91080ca55253 Mon Sep 17 00:00:00 2001 +From: liyunfei +Date: Mon, 24 Jul 2023 19:16:45 +0800 +Subject: [PATCH] Add triples for X86_64/AArch64/Riscv64 openEuler gcc + +--- + clang/lib/Driver/ToolChains/Gnu.cpp | 6 ++-- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp +index 665cdc3132fb..fc56935e7513 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -2178,7 +2178,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( + static const char *const AArch64LibDirs[] = {"/lib64", "/lib"}; + static const char *const AArch64Triples[] = { + "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", +- "aarch64-suse-linux"}; ++ "aarch64-suse-linux", "aarch64-openEuler-linux"}; + static const char *const AArch64beLibDirs[] = {"/lib"}; + static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu", + "aarch64_be-linux-gnu"}; +@@ -2208,7 +2208,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( + "x86_64-redhat-linux", "x86_64-suse-linux", + "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", + "x86_64-slackware-linux", "x86_64-unknown-linux", +- "x86_64-amazon-linux"}; ++ "x86_64-amazon-linux", "x86_64-openEuler-linux"}; + static const char *const X32Triples[] = {"x86_64-linux-gnux32", + "x86_64-pc-linux-gnux32"}; + static const char *const X32LibDirs[] = {"/libx32", "/lib"}; +@@ -2404,7 +2404,7 @@ + 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-openEuler-linux"}; + + static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; + static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", +-- +2.28.0.windows.1 diff --git a/1802-Always-build-shared-libs-for-LLD.patch b/1802-Always-build-shared-libs-for-LLD.patch new file mode 100644 index 0000000000000000000000000000000000000000..307727199f648e66d46cc9b693ef2f55a4bd4531 --- /dev/null +++ b/1802-Always-build-shared-libs-for-LLD.patch @@ -0,0 +1,29 @@ +From b1c60d7fa322a2d208556087df9e7ef94bfbffb8 Mon Sep 17 00:00:00 2001 +From: Nikita Popov +Date: Wed, 8 May 2024 12:30:36 +0900 +Subject: [PATCH] Always build shared libs for LLD + +We don't want to enable BUILD_SHARED_LIBS for the whole build, +but we do want to build lld libraries. +--- + lld/cmake/modules/AddLLD.cmake | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake +index 2ee066b41535..270c03f096ac 100644 +--- a/lld/cmake/modules/AddLLD.cmake ++++ b/lld/cmake/modules/AddLLD.cmake +@@ -7,9 +7,8 @@ macro(add_lld_library name) + "" + "" + ${ARGN}) +- if(ARG_SHARED) +- set(ARG_ENABLE_SHARED SHARED) +- endif() ++ # Always build shared libs for LLD. ++ set(ARG_ENABLE_SHARED SHARED) + llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS}) + set_target_properties(${name} PROPERTIES FOLDER "lld libraries") + +-- +2.44.0 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..27702031efa0022ded12f87403136c8cf70dc4bc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.13.4) +project(Runtimes C CXX ASM) +add_subdirectory(libcxxabi) +add_subdirectory(libcxx) +add_subdirectory(libunwind) \ No newline at end of file diff --git a/llvm-project-17.0.6.src.tar.xz b/llvm-project-17.0.6.src.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..42dab53aeac1eccc96cfb06dd99b47138bbd93f2 Binary files /dev/null and b/llvm-project-17.0.6.src.tar.xz differ diff --git a/llvm-toolset-17.spec b/llvm-toolset-17.spec new file mode 100644 index 0000000000000000000000000000000000000000..6a7ca27e7b81577e2eef6a6f6bf25431bc12fedd --- /dev/null +++ b/llvm-toolset-17.spec @@ -0,0 +1,2732 @@ +#region globals +#region version +%global maj_ver 17 +%global min_ver 0 +%global patch_ver 6 + +%global os_version %{lua: print(tonumber(rpm.expand("%{dist}"):match("oe(%d+)") or 9999))} + +# Build sys_llvm packages or compat packages +%bcond_with sys_llvm +%bcond_with check +%if %{os_version} <= 2203 +%bcond_with toolchain_clang +%else +%bcond_without toolchain_clang +%endif + +# mlir requires pybind11-2.9 but 22.03 only have pybind11-2.8 +%if %{os_version} <= 2203 +%bcond_with mlir +%else +%bcond_without mlir +%endif +%bcond_without lldb +%bcond_without libcxx + +%if %{with toolchain_clang} + %global toolchain clang +%endif + +%undefine __cmake_in_source_build + +%global src_tarball_dir llvm-project-%{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:-rc%{rc_ver}}.src + +#region LLVM globals + +%if %{with sys_llvm} +%global pkg_name_llvm llvm +%global install_prefix /usr +%global install_bindir %{_bindir} +%global install_datadir %{_datadir} +%global install_libdir %{_libdir} +%global install_includedir %{_includedir} +%global install_libexecdir %{_libexecdir} +%global install_docdir %{_docdir} +%global unprefixed_libdir %{_lib} +%global pkg_datadir %{_datadir} +%global pkg_suffix %{nil} +%global exec_suffix %{nil} +%else +%global _scl_prefix /opt/openEuler +%{?scl:%scl_package %scl} +%{!?scl:%global scl_prefix llvm-toolset-%{maj_ver}-} +%{!?scl:%global pkg_name %{name}} +%{!?scl:%global _scl_root %{_scl_prefix}/llvm-toolset-%{maj_ver}/root} +%{!?scl:%global _scl_scripts %{_scl_prefix}/llvm-toolset-%{maj_ver}} +%global pkg_name_llvm %{?scl_prefix}llvm +%global pkg_suffix %{maj_ver} +%global exec_suffix -%{maj_ver} +%global install_prefix %{!?scl:%{_scl_prefix}/llvm-toolset-%{maj_ver}/root}%{_prefix} +%global install_bindir %{install_prefix}/bin +%global install_includedir %{install_prefix}/include +%global install_libdir %{install_prefix}/%{_lib} +%global install_datadir %{install_prefix}/share +%global install_libexecdir %{install_prefix}/libexec +%global install_docdir %{install_datadir}/doc +%global unprefixed_libdir %{_lib} +%global pkg_includedir %{_includedir}/%{pkg_name_llvm} +%global pkg_datadir %{install_prefix}/share +%endif + +%global targets_to_build "all" +%global experimental_targets_to_build "" + +%global build_install_prefix %{buildroot}%{install_prefix} + +%global llvm_triple %{_target_platform} + +%global max_link_jobs %{_smp_build_ncpus} + +%global llvm_triple %{_host} + +%global build_src_dir %{_builddir}/llvm-project-%{version}.src +%if %{os_version} <= 2203 +%global build_dir _build +%else +%global build_dir llvm/%{_vpath_builddir} +%endif +%global build_libdir %{build_src_dir}/%{build_dir}/%{_lib} + +# Disable LTO as this causes crash if gcc lto enabled. +%define _lto_cflags %{nil} + +#endregion LLVM globals + +#region CLANG globals + +%global pkg_name_clang %{?scl_prefix}clang + +#endregion CLANG globals + +#region COMPILER-RT globals + +%global pkg_name_compiler_rt %{?scl_prefix}compiler-rt + +%global optflags %(echo %{optflags} | sed 's/-fgcc-compatible//') +%global optflags %(echo %{optflags} | sed 's/-specs=\/usr\/lib\/rpm\/generic-hardened-cc1//') +%ifnarch x86_64 +%global optflags %(echo %{optflags} | sed 's/-fstack-clash-protection//') +# may affect cmake check for fpic +%endif + +# Copy CFLAGS into ASMFLAGS, so -fcf-protection is used when compiling assembly files. +# export ASMFLAGS=$CFLAGS +#endregion COMPILER-RT globals + +#region LLD globals + +%global pkg_name_libomp %{?scl_prefix}libomp + +%global so_suffix %{maj_ver}.%{min_ver} + +%ifarch ppc64le +%global libomp_arch ppc64 +%else +%global libomp_arch %{_arch} +%endif + +#endregion LLD globals + +#region LLD globals +%global pkg_name_lld %{?scl_prefix}lld +#endregion LLD globals + +#region LLDB globals +%global pkg_name_lldb %{?scl_prefix}lldb +#endregion LLDB globals +#endregion globals + +#region MLIR globals +%global pkg_name_mlir %{?scl_prefix}mlir +#endregion MLIR globals + +#region libcxx globals +%global pkg_name_libcxx %{?scl_prefix}libcxx +%global pkg_name_libcxxabi %{?scl_prefix}libcxxabi +%global pkg_name_llvm_libunwind %{?scl_prefix}llvm-libunwind +#endregion libcxx globals + +#region packages +#region main package +Name: llvm-toolset-%{maj_ver} +Version: %{maj_ver}.%{min_ver}.%{patch_ver} +Release: 1 +Summary: The Low Level Virtual Machine + +License: NCSA +URL: http://llvm.org + +Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ver}.%{min_ver}.%{patch_ver}/%{src_tarball_dir}.tar.xz +#Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ver}.%{min_ver}.%{patch_ver}/%{src_tarball_dir}.tar.xz.sig + +# CMakeLists for libcxx build +%if %{maj_ver} == 17 +Source2: CMakeLists.txt +%endif + +Patch0001: 0001-PATCH-clang-Don-t-install-static-libraries.patch + +Patch1701: 1701-Always-build-shared-libs-for-LLD.patch +Patch1702: 1702-fedora-standalone.patch +Patch1703: 1703-Revert-68-backport-Support-stack-clash-protection-in.patch + +Patch1801: 1801-Add-triples-for-X86_64-AArch64-Riscv64-openEuler-gcc.patch +Patch1802: 1802-Always-build-shared-libs-for-LLD.patch + +Patch1901: 1801-Add-triples-for-X86_64-AArch64-Riscv64-openEuler-gcc.patch +Patch1902: 1802-Always-build-shared-libs-for-LLD.patch + +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: clang +BuildRequires: cmake +BuildRequires: chrpath +BuildRequires: ninja-build +BuildRequires: zlib-devel +BuildRequires: libzstd-devel +BuildRequires: libffi-devel +BuildRequires: ncurses-devel +BuildRequires: binutils-devel +BuildRequires: libedit-devel +BuildRequires: multilib-rpm-config +BuildRequires: python3-devel +BuildRequires: python3-psutil +BuildRequires: python3-sphinx +BuildRequires: python3-setuptools +%if %{maj_ver} >= 18 +BuildRequires: python3-myst-parser +%endif +%if %{with toolchain_clang} +BuildRequires: clang +BuildRequires: llvm +%endif + +# LLVM's LineEditor library will use libedit if it is available. +BuildRequires: libedit-devel + +BuildRequires: swig +BuildRequires: libxml2-devel +BuildRequires: doxygen + +# For clang-offload-packager +BuildRequires: elfutils-libelf-devel +BuildRequires: perl +BuildRequires: perl-Data-Dumper +BuildRequires: perl-Encode +BuildRequires: libffi-devel + +BuildRequires: perl-generators + +# According to https://fedoraproject.org/wiki/Packaging:Emacs a package +# should BuildRequires: emacs if it packages emacs integration files. +BuildRequires: emacs + +BuildRequires: libatomic + +# scan-build uses these perl modules so they need to be installed in order +# to run the tests. +BuildRequires: perl(Digest::MD5) +BuildRequires: perl(File::Copy) +BuildRequires: perl(File::Find) +BuildRequires: perl(File::Path) +BuildRequires: perl(File::Temp) +BuildRequires: perl(FindBin) +BuildRequires: perl(Hash::Util) +BuildRequires: perl(lib) +BuildRequires: perl(Term::ANSIColor) +BuildRequires: perl(Text::ParseWords) +BuildRequires: perl(Sys::Hostname) + +%if %{with mlir} +BuildRequires: python%{python3_pkgversion}-numpy +BuildRequires: python%{python3_pkgversion}-pybind11 +BuildRequires: python%{python3_pkgversion}-pyyaml +%if %{maj_ver} >= 20 +BuildRequires: python%{python3_pkgversion}-nanobind-devel +%endif +%endif + +BuildRequires: graphviz + +# This is required because we need "ps" when running LLDB tests +BuildRequires: procps-ng + +%description +LLVM is a compiler infrastructure designed for compile-time, link-time, +runtime, and idle-time optimization of programs from arbitrary programming +languages. The compiler infrastructure includes mirror sets of programming +tools as well as libraries with equivalent functionality. + +#endregion main package + +#region LLVM packages +%package -n %{pkg_name_llvm} +Summary: The Low Level Virtual Machine + +Requires: %{pkg_name_llvm}-libs%{?_isa} = %{version}-%{release} + +Provides: llvm(major) = %{maj_ver} + +%description -n %{pkg_name_llvm} +LLVM is a compiler infrastructure designed for compile-time, link-time, +runtime, and idle-time optimization of programs from arbitrary programming +languages. The compiler infrastructure includes mirror sets of programming +tools as well as libraries with equivalent functionality. + +%package -n %{pkg_name_llvm}-devel +Summary: Libraries and header files for LLVM +Requires: %{pkg_name_llvm}%{?_isa} = %{version}-%{release} +Requires: %{pkg_name_llvm}-libs%{?_isa} = %{version}-%{release} +# The installed LLVM cmake files will add -ledit to the linker flags for any +# app that requires the libLLVMLineEditor, so we need to make sure +# libedit-devel is available. +Requires: libedit-devel +Requires: libzstd-devel +# The installed cmake files reference binaries from llvm-test, llvm-static, and +# llvm-gtest. We tried in the past to split the cmake exports for these binaries +# out into separate files, so that llvm-devel would not need to Require these packages, +# but this caused bugs (rhbz#1773678) and forced us to carry two non-upstream +# patches. +Requires: %{pkg_name_llvm}-static%{?_isa} = %{version}-%{release} +Requires: %{pkg_name_llvm}-test%{?_isa} = %{version}-%{release} +Requires: %{pkg_name_llvm}-googletest%{?_isa} = %{version}-%{release} + + +Requires(post): %{_sbindir}/alternatives +Requires(postun): %{_sbindir}/alternatives + +Provides: llvm-devel(major) = %{maj_ver} + +%description -n %{pkg_name_llvm}-devel +This package contains library and header files needed to develop new native +programs that use the LLVM infrastructure. + +%package -n %{pkg_name_llvm}-doc +Summary: Documentation for LLVM +BuildArch: noarch +Requires: %{pkg_name_llvm} = %{version}-%{release} +Provides: %{pkg_name_llvm}-help = %{version}-%{release} +Obsoletes: %{pkg_name_llvm}-help < %{version}-%{release} + +%description -n %{pkg_name_llvm}-doc +Documentation for the LLVM compiler infrastructure. + +%package -n %{pkg_name_llvm}-libs +Summary: LLVM shared libraries + +%description -n %{pkg_name_llvm}-libs +Shared libraries for the LLVM compiler infrastructure. + +%package -n %{pkg_name_llvm}-static +Summary: LLVM static libraries +Conflicts: %{pkg_name_llvm}-devel < 8 + +Provides: llvm-static(major) = %{maj_ver} + +%description -n %{pkg_name_llvm}-static +Static libraries for the LLVM compiler infrastructure. + +%package -n %{pkg_name_llvm}-cmake-utils +Summary: CMake utilities shared across LLVM subprojects + +%description -n %{pkg_name_llvm}-cmake-utils +CMake utilities shared across LLVM subprojects. +This is for internal use by LLVM packages only. + +%package -n %{pkg_name_llvm}-test +Summary: LLVM regression tests +Requires: %{pkg_name_llvm}%{?_isa} = %{version}-%{release} +Requires: %{pkg_name_llvm}-libs%{?_isa} = %{version}-%{release} + +Provides: llvm-test(major) = %{maj_ver} + +%description -n %{pkg_name_llvm}-test +LLVM regression tests. + +%package -n %{pkg_name_llvm}-googletest +Summary: LLVM's modified googletest sources + +%description -n %{pkg_name_llvm}-googletest +LLVM's modified googletest sources. + +#endregion LLVM packages + +#region CLANG packages + +%package -n %{pkg_name_clang} +Summary: A C language family front-end for LLVM + +Requires: %{pkg_name_clang}-libs%{?_isa} = %{version}-%{release} + +# clang requires gcc, clang++ requires libstdc++-devel +# - https://bugzilla.redhat.com/show_bug.cgi?id=1021645 +# - https://bugzilla.redhat.com/show_bug.cgi?id=1158594 +Requires: libstdc++-devel +Requires: gcc-c++ + +Provides: clang(major) = %{maj_ver} + +Conflicts: compiler-rt < 11.0.0 + +%description -n %{pkg_name_clang} +clang: noun + 1. A loud, resonant, metallic sound. + 2. The strident call of a crane or goose. + 3. C-language family front-end toolkit. + +The goal of the Clang project is to create a new C, C++, Objective C +and Objective C++ front-end for the LLVM compiler. Its tools are built +as libraries and designed to be loosely-coupled and extensible. + +Install compiler-rt if you want the Blocks C language extension or to +enable sanitization and profiling options when building, and +libomp-devel to enable -fopenmp. + +%package -n %{pkg_name_clang}-libs +Summary: Runtime library for clang +Requires: %{pkg_name_clang}-resource-filesystem%{?_isa} = %{version}-%{release} +Recommends: %{pkg_name_compiler_rt}%{?_isa} = %{version}-%{release} +Requires: %{pkg_name_llvm}-libs = %{version}-%{release} +# atomic support is not part of compiler-rt +Recommends: libatomic%{?_isa} +# libomp-devel is required, so clang can find the omp.h header when compiling +# with -fopenmp. +Recommends: %{pkg_name_libomp}-devel%{_isa} = %{version}-%{release} +Recommends: %{pkg_name_libomp}%{_isa} = %{version}-%{release} + +%description -n %{pkg_name_clang}-libs +Runtime library for clang. + +%package -n %{pkg_name_clang}-devel +Summary: Development header files for clang +Requires: %{pkg_name_clang}-libs = %{version}-%{release} +Requires: %{pkg_name_clang}%{?_isa} = %{version}-%{release} +# The clang CMake files reference tools from clang-tools-extra. +Requires: %{pkg_name_clang}-tools-extra%{?_isa} = %{version}-%{release} +Provides: clang-devel(major) = %{maj_ver} +# For the clangd language server contained in this subpackage, +# add a Provides so users can just run "dnf install clangd." +# This Provides is only present in the primary, unversioned clang package. +# Users who want the compat versions can install them using the full name. +%if %{with sys_llvm} +Provides: clangd = %{version}-%{release} +%endif + +%description -n %{pkg_name_clang}-devel +Development header files for clang. + +%package -n %{pkg_name_clang}-resource-filesystem +Summary: Filesystem package that owns the clang resource directory +Provides: clang-resource-filesystem(major) = %{maj_ver} + +%description -n %{pkg_name_clang}-resource-filesystem +This package owns the clang resouce directory: $libdir/clang/$version/ + +%package -n %{pkg_name_clang}-analyzer +Summary: A source code analysis framework +License: Apache-2.0 WITH LLVM-exception OR NCSA OR MIT +BuildArch: noarch +Requires: %{pkg_name_clang} = %{version}-%{release} + +%description -n %{pkg_name_clang}-analyzer +The Clang Static Analyzer consists of both a source code analysis +framework and a standalone tool that finds bugs in C and Objective-C +programs. The standalone tool is invoked from the command-line, and is +intended to run in tandem with a build of a project or code base. + +%package -n %{pkg_name_clang}-tools-extra +Summary: Extra tools for clang +Requires: %{pkg_name_clang}-libs%{?_isa} = %{version}-%{release} +Requires: emacs-filesystem + +%description -n %{pkg_name_clang}-tools-extra +A set of extra tools built using Clang's tooling API. + +%package -n %{pkg_name_clang}-tools-extra-devel +Summary: Development header files for clang tools +Requires: %{pkg_name_clang}-tools-extra = %{version}-%{release} + +%description -n %{pkg_name_clang}-tools-extra-devel +Development header files for clang tools. + +# Put git-clang-format in its own package, because it Requires git +# and we don't want to force users to install all those dependenices if they +# just want clang. +%package -n %{?scl_prefix}git-clang-format%{?pkg_suffix} +Summary: Integration of clang-format for git +Requires: %{pkg_name_clang}-tools-extra = %{version}-%{release} +Requires: git +Requires: python3 + +%description -n %{?scl_prefix}git-clang-format%{pkg_suffix} +clang-format integration for git. + +%if %{with sys_llvm} +%package -n python3-clang +Summary: Python3 bindings for clang +Requires: %{pkg_name_clang}-devel%{?_isa} = %{version}-%{release} +Requires: python%{python3_pkgversion} + +%description -n python%{python3_pkgversion}-clang +%{summary}. + +%endif + +#endregion CLANG packages + +#region COMPILER-RT packages + +%package -n %{pkg_name_compiler_rt} +Summary: LLVM "compiler-rt" runtime libraries + +License: Apache-2.0 WITH LLVM-exception OR NCSA OR MIT + +Requires: %{pkg_name_clang}-resource-filesystem%{?_isa} = %{version}-%{release} +Provides: compiler-rt(major) = %{maj_ver} + +%description -n %{pkg_name_compiler_rt} +The compiler-rt project is a part of the LLVM project. It provides +implementation of the low-level target-specific hooks required by +code generation, sanitizer runtimes and profiling library for code +instrumentation, and Blocks C language extension. + +#endregion COMPILER-RT packages + +#region OPENMP packages + +%package -n %{pkg_name_libomp} +Summary: OpenMP runtime for clang + +URL: http://openmp.llvm.org + +Requires: %{pkg_name_llvm}-libs%{?_isa} = %{version}-%{release} +Requires: elfutils-libelf%{?_isa} + +Provides: libomp(major) = %{maj_ver} + +%description -n %{pkg_name_libomp} +OpenMP runtime for clang. + +%package -n %{pkg_name_libomp}-devel +Summary: OpenMP header files + +URL: http://openmp.llvm.org + +Requires: %{pkg_name_libomp}%{?_isa} = %{version}-%{release} +Requires: %{pkg_name_clang}-resource-filesystem%{?_isa} = %{version}-%{release} + +Provides: libomp-devel(major) = %{maj_ver} + +%description -n %{pkg_name_libomp}-devel +OpenMP header files. +URL: http://openmp.llvm.org + +#endregion OPENMP packages + +#region LLD packages + +%package -n %{pkg_name_lld} +Summary: The LLVM Linker + +Requires(post): %{_sbindir}/update-alternatives +Requires(preun): %{_sbindir}/update-alternatives + +Requires: %{pkg_name_lld}-libs = %{version}-%{release} +Provides: lld(major) = %{maj_ver} + +%description -n %{pkg_name_lld} +The LLVM project linker. + +%package -n %{pkg_name_lld}-devel +Summary: Libraries and header files for LLD +Requires: %{pkg_name_lld}-libs%{?_isa} = %{version}-%{release} +# %if %{with sys_llvm} +# lld tools are referenced in the cmake files, so we need to add lld as a +# dependency. +# Requires: %{pkg_name_lld}%{?_isa} = %{version}-%{release} +# %endif +Provides: lld-devel(major) = %{maj_ver} + +%description -n %{pkg_name_lld}-devel +This package contains library and header files needed to develop new native +programs that use the LLD infrastructure. + +%package -n %{pkg_name_lld}-libs +Summary: LLD shared libraries + +Requires: %{pkg_name_llvm}-libs%{?_isa} = %{version}-%{release} + +%description -n %{pkg_name_lld}-libs +Shared libraries for LLD. + +#endregion LLD packages + +#region LLDB packages +%if %{with lldb} +%package -n %{pkg_name_lldb} +Summary: Next generation high-performance debugger +License: Apache-2.0 WITH LLVM-exception OR NCSA +URL: http://lldb.llvm.org/ + +Requires: %{pkg_name_clang}-libs%{?_isa} = %{version}-%{release} +Requires: %{?scl_prefix}python3-lldb + +%description -n %{pkg_name_lldb} +LLDB is a next generation, high-performance debugger. It is built as a set +of reusable components which highly leverage existing libraries in the +larger LLVM Project, such as the Clang expression parser and LLVM +disassembler. + +%package -n %{pkg_name_lldb}-devel +Summary: Development header files for LLDB +Requires: %{pkg_name_lldb}%{?_isa} = %{version}-%{release} + +%description -n %{pkg_name_lldb}-devel +The package contains header files for the LLDB debugger. + +%package -n %{?scl_prefix}python3-lldb +%{?python_provide:%python_provide python3-lldb} +Summary: Python module for LLDB + +Requires: %{pkg_name_lldb}%{?_isa} = %{version}-%{release} + +%description -n %{?scl_prefix}python3-lldb +The package contains the LLDB Python module. +%endif +#endregion LLDB packages + +#region MLIR packages +%if %{with mlir} +%package -n %{pkg_name_mlir} +Summary: Multi-Level Intermediate Representation Overview +License: Apache-2.0 WITH LLVM-exception +URL: http://mlir.llvm.org + +%description -n %{pkg_name_mlir} +The MLIR project is a novel approach to building reusable and extensible +compiler infrastructure. MLIR aims to address software fragmentation, +improve compilation for heterogeneous hardware, significantly reduce +the cost of building domain specific compilers, and aid in connecting +existing compilers together. + +%package -n %{pkg_name_mlir}-static +Summary: MLIR static files +Requires: %{pkg_name_mlir}%{?_isa} = %{version}-%{release} + +%description -n %{pkg_name_mlir}-static +MLIR static files. + +%package -n %{pkg_name_mlir}-devel +Summary: MLIR development files +Requires: %{pkg_name_mlir}%{?_isa} = %{version}-%{release} +Requires: %{pkg_name_mlir}-static%{?_isa} = %{version}-%{release} + +%description -n %{pkg_name_mlir}-devel +MLIR development files. + +%package -n %{?scl_prefix}python3-mlir +%{?python_provide:%python_provide python3-mlir} +Summary: MLIR python bindings + +Requires: python3 +Requires: python3-numpy + +%description -n %{?scl_prefix}python3-mlir +MLIR python bindings. +%endif +#endregion MLIR packages + +#region libcxx packages +%if %{with libcxx} +%package -n %{pkg_name_libcxx} +Summary: C++ standard library targeting C++11 +License: Apache-2.0 WITH LLVM-exception OR MIT OR NCSA +URL: http://libcxx.llvm.org/ + +Requires: %{pkg_name_libcxxabi}%{?_isa} = %{version}-%{release} + +%description -n %{pkg_name_libcxx} +libc++ is a new implementation of the C++ standard library, targeting C++11 and above. + +%package -n %{pkg_name_libcxx}-devel +Summary: Headers and libraries for %{pkg_name_libcxx} devel +Requires: %{pkg_name_libcxx}%{?_isa} = %{version}-%{release} +Requires: %{pkg_name_libcxxabi}-devel + +%description -n %{pkg_name_libcxx}-devel +Headers and libraries for %{pkg_name_libcxx} devel. + +%package -n %{pkg_name_libcxx}-static +Summary: Static libraries for %{pkg_name_libcxx} + +%description -n %{pkg_name_libcxx}-static +Static libraries for %{pkg_name_libcxx}. + +%package -n %{pkg_name_libcxxabi} +Summary: Low level support for a standard C++ library + +%description -n %{pkg_name_libcxxabi} +libcxxabi provides low level support for a standard C++ library. + +%package -n %{pkg_name_libcxx}abi-devel +Summary: Headers and libraries for %{pkg_name_libcxxabi} devel +Requires: %{pkg_name_libcxxabi}%{?_isa} = %{version}-%{release} + +%description -n %{pkg_name_libcxxabi}-devel +Headers and libraries for %{pkg_name_libcxxabi} devel. + +%package -n %{pkg_name_libcxxabi}-static +Summary: Static libraries for %{pkg_name_libcxxabi} + +%description -n %{pkg_name_libcxxabi}-static +Static libraries for %{pkg_name_libcxxabi}. + +%package -n %{pkg_name_llvm_libunwind} +Summary: LLVM libunwind + +%description -n %{pkg_name_llvm_libunwind} + +LLVM libunwind is an implementation of the interface defined by the HP libunwind +project. It was contributed Apple as a way to enable clang++ to port to +platforms that do not have a system unwinder. It is intended to be a small and +fast implementation of the ABI, leaving off some features of HP's libunwind +that never materialized (e.g. remote unwinding). + +%package -n %{pkg_name_llvm_libunwind}-devel +Summary: LLVM libunwind development files +Provides: %{pkg_name_llvm_libunwind}(major) = %{maj_ver} +Requires: %{pkg_name_llvm_libunwind}%{?_isa} = %{version}-%{release} + +%description -n %{pkg_name_llvm_libunwind}-devel +Unversioned shared library for LLVM libunwind + +%package -n %{pkg_name_llvm_libunwind}-static +Summary: Static library for LLVM libunwind + +%description -n %{pkg_name_llvm_libunwind}-static +Static library for LLVM libunwind. + +%package -n %{pkg_name_llvm_libunwind}-doc +Summary: libunwind documentation +License: BSD AND (Apache-2.0 WITH LLVM-exception OR NCSA OR MIT) + +%description -n %{pkg_name_llvm_libunwind}-doc +Documentation for LLVM libunwind +%endif +#endregion libcxx packages + +#endregion packages + +#region prep +%prep + +# -T : Do Not Perform Default Archive Unpacking (without this, the th source would be unpacked twice) +# -b : Unpack The nth Sources Before Changing Directory +# -n : Set Name of Build Directory +# +# see http://ftp.rpm.org/max-rpm/s1-rpm-inside-macros.html +%autosetup -N -T -b 0 -n %{src_tarball_dir} + +# Apply all patches with number < 500 (unconditionally) +# See https://rpm-software-management.github.io/rpm/manual/autosetup.html +%autopatch -M499 -p1 + +# automatically apply patches based on LLVM version +%autopatch -m%{maj_ver}00 -M%{maj_ver}99 -p1 + +# shebang_fix part removed + +#endregion prep + +#region build +%build +# TODO(kkleine): In clang we had this %ifarch s390 s390x aarch64 %ix86 ppc64le +# Decrease debuginfo verbosity to reduce memory consumption during final library linking. +%global reduce_debuginfo 0 + +%if %reduce_debuginfo == 1 +# Decrease debuginfo verbosity to reduce memory consumption during final library linking +%global optflags %(echo %{optflags} | sed 's/-g /-g1 /') + +%endif + +%global projects clang;clang-tools-extra;lld +%if %{with lldb} +%global projects %{projects};lldb +%endif +%if %{with mlir} +%global projects %{projects};mlir +%endif + +%global runtimes compiler-rt;openmp + +%if %{with libcxx} +%global runtimes %{runtimes};libcxx;libcxxabi;libunwind +%endif + +# Copy CFLAGS into ASMFLAGS, so -fcf-protection is used when compiling assembly files. +export ASMFLAGS="%{build_cflags}" + +# We set CLANG_DEFAULT_PIE_ON_LINUX=OFF and PPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON to match the +# defaults used by Fedora's GCC. + +#region cmake options + +# Common cmake arguments used by both the normal build and bundle_compat_lib. +# Any ABI-affecting flags should be in here. +%global cmake_common_args \\\ + -DLLVM_ENABLE_EH=ON \\\ + -DLLVM_ENABLE_RTTI=ON \\\ + -DLLVM_USE_PERF=ON \\\ + -DLLVM_TARGETS_TO_BUILD=%{targets_to_build} \\\ + -DBUILD_SHARED_LIBS=OFF \\\ + -DLLVM_BUILD_LLVM_DYLIB=ON + +%global cmake_config_args %{cmake_common_args} + +#region clang options +%global cmake_config_args %{cmake_config_args} \\\ + -DCLANG_BUILD_EXAMPLES:BOOL=OFF \\\ + -DCLANG_CONFIG_FILE_SYSTEM_DIR=%{_sysconfdir}/%{pkg_name_clang}/ \\\ + -DCLANG_DEFAULT_PIE_ON_LINUX=OFF \\\ + -DCLANG_DEFAULT_UNWINDLIB=libgcc \\\ + -DCLANG_ENABLE_ARCMT:BOOL=ON \\\ + -DCLANG_ENABLE_STATIC_ANALYZER:BOOL=ON \\\ + -DCLANG_INCLUDE_DOCS:BOOL=ON \\\ + -DCLANG_INCLUDE_TESTS:BOOL=ON \\\ + -DCLANG_LINK_CLANG_DYLIB=ON \\\ + -DCLANG_PLUGIN_SUPPORT:BOOL=ON \\\ + -DCLANG_REPOSITORY_STRING="%{?dist_vendor} %{version}-%{release}" \\\ + -DCLANG_RESOURCE_DIR=../%{_lib}/clang/%{maj_ver} \\\ + -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=../clang-tools-extra +#endregion clang options + +#region compiler-rt options +%global cmake_config_args %{cmake_config_args} \\\ + -DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF \\\ + -DCOMPILER_RT_INSTALL_PATH=%{install_libdir}/clang/%{maj_ver} +#endregion compiler-rt options + +#region docs options + +# Add all *enabled* documentation targets (no doxygen but sphinx) +%global cmake_config_args %{cmake_config_args} \\\ + -DLLVM_ENABLE_DOXYGEN:BOOL=OFF \\\ + -DLLVM_ENABLE_SPHINX:BOOL=ON \\\ + -DLLVM_BUILD_DOCS:BOOL=ON + +# Configure sphinx: +# Build man-pages but no HTML docs using sphinx +%global cmake_config_args %{cmake_config_args} \\\ + -DSPHINX_EXECUTABLE=%{_bindir}/sphinx-build-3 \\\ + -DSPHINX_OUTPUT_HTML:BOOL=OFF \\\ + -DSPHINX_OUTPUT_MAN:BOOL=ON \\\ + -DSPHINX_WARNINGS_AS_ERRORS=OFF +#endregion docs options + +#region lldb options +%if %{with lldb} + %global cmake_config_args %{cmake_config_args} -DLLDB_DISABLE_CURSES:BOOL=OFF + %global cmake_config_args %{cmake_config_args} -DLLDB_DISABLE_LIBEDIT:BOOL=OFF + %global cmake_config_args %{cmake_config_args} -DLLDB_DISABLE_PYTHON:BOOL=OFF +%ifarch ppc64le + %global cmake_config_args %{cmake_config_args} -DLLDB_TEST_USER_ARGS=--skip-category=watchpoint +%endif +%endif +#endregion lldb options + +#region libcxx options +%if %{with libcxx} +%global cmake_config_args %{cmake_config_args} \\\ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \\\ + -DLIBCXX_INCLUDE_BENCHMARKS=OFF \\\ + -DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON \\\ + -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=ON \\\ + -DLIBCXXABI_USE_LLVM_UNWINDER=OFF \\\ + -DLIBUNWIND_INSTALL_INCLUDE_DIR=%{install_includedir}/llvm-libunwind + +# If we don't set the .._INSTALL_LIBRARY_DIR variables, +# the *.so files will be placed in a subdirectory that includes the triple +%global cmake_config_args %{cmake_config_args} \\\ + -DLIBCXX_INSTALL_LIBRARY_DIR=%{install_libdir} \\\ + -DLIBCXXABI_INSTALL_LIBRARY_DIR=%{install_libdir} \\\ + -DLIBUNWIND_INSTALL_LIBRARY_DIR=%{install_libdir} + +# If we don't adjust this, we will install into this unwanted location: +# /usr/include/i686-redhat-linux-gnu/c++/v1/__config_site +%global cmake_config_args %{cmake_config_args} \\\ + -DLIBCXX_INSTALL_INCLUDE_TARGET_DIR=%{install_includedir}/c++/v1 + +%endif +#endregion libcxx options + +#region llvm options +%global cmake_config_args %{cmake_config_args} \\\ + -DLLVM_APPEND_VC_REV:BOOL=OFF \\\ + -DLLVM_BUILD_EXAMPLES:BOsOL=OFF \\\ + -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \\\ + -DLLVM_BUILD_RUNTIME:BOOL=ON \\\ + -DLLVM_BUILD_TOOLS:BOOL=ON \\\ + -DLLVM_BUILD_UTILS:BOOL=ON \\\ + -DLLVM_COMMON_CMAKE_UTILS=%{install_datadir}/llvm/cmake \\\ + -DLLVM_DEFAULT_TARGET_TRIPLE=%{llvm_triple} \\\ + -DLLVM_DYLIB_COMPONENTS="all" \\\ + -DLLVM_ENABLE_FFI:BOOL=ON \\\ + -DLLVM_ENABLE_LIBCXX:BOOL=OFF \\\ + -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \\\ + -DLLVM_ENABLE_PROJECTS="%{projects}" \\\ + -DLLVM_ENABLE_RUNTIMES="%{runtimes}" \\\ + -DLLVM_ENABLE_ZLIB:BOOL=FORCE_ON \\\ + -DLLVM_ENABLE_ZSTD:BOOL=FORCE_ON \\\ + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=%{experimental_targets_to_build} \\\ + -DLLVM_INCLUDE_BENCHMARKS=OFF \\\ + -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \\\ + -DLLVM_INCLUDE_TOOLS:BOOL=ON \\\ + -DLLVM_INCLUDE_UTILS:BOOL=ON \\\ + -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=OFF \\\ + -DLLVM_INSTALL_UTILS:BOOL=ON \\\ + -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \\\ + -DLLVM_PARALLEL_LINK_JOBS=1 \\\ + -DLLVM_TOOLS_INSTALL_DIR:PATH=bin \\\ + -DLLVM_UNREACHABLE_OPTIMIZE:BOOL=OFF \\\ + -DLLVM_UTILS_INSTALL_DIR:PATH=bin +#endregion llvm options + +#region mlir options +%if %{with mlir} +%global cmake_config_args %{cmake_config_args} \\\ + -DMLIR_INCLUDE_DOCS:BOOL=ON \\\ + -DMLIR_INCLUDE_TESTS:BOOL=ON \\\ + -DMLIR_INCLUDE_INTEGRATION_TESTS:BOOL=OFF \\\ + -DMLIR_INSTALL_AGGREGATE_OBJECTS=OFF \\\ + -DMLIR_BUILD_MLIR_C_DYLIB=ON \\\ + -DMLIR_ENABLE_BINDINGS_PYTHON:BOOL=ON +%endif +#endregion mlir options + +#region openmp options +%global cmake_config_args %{cmake_config_args} \\\ + -DLIBOMP_INSTALL_ALIASES=OFF + +%if 0%{?__isa_bits} == 64 + %global cmake_config_args %{cmake_config_args} -DOPENMP_LIBDIR_SUFFIX=64 +%else + %global cmake_config_args %{cmake_config_args} -DOPENMP_LIBDIR_SUFFIX= +%endif +#endregion openmp options + +#region test options +%global cmake_config_args %{cmake_config_args} \\\ + -DLLVM_BUILD_TESTS:BOOL=ON \\\ + -DLLVM_INCLUDE_TESTS:BOOL=ON \\\ + -DLLVM_INSTALL_GTEST:BOOL=ON \\\ + -DLLVM_LIT_ARGS="-vv" + +%if %{with lto_build} +%if 0%{?fedora} >= 41 + %global cmake_config_args %{cmake_config_args} -DLLVM_UNITTEST_LINK_FLAGS="-fno-lto" +%else + %global cmake_config_args %{cmake_config_args} -DLLVM_UNITTEST_LINK_FLAGS="-Wl,-plugin-opt=O0" +%endif +%endif +#endregion test options + +#region misc options +%global cmake_config_args %{cmake_config_args} \\\ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \\\ + -DCMAKE_INSTALL_PREFIX=%{install_prefix} \\\ + -DENABLE_LINKER_BUILD_ID:BOOL=ON \\\ + -DPython3_EXECUTABLE=%{__python3} + +# During the build, we use both the system clang and the just-built clang, and +# they need to use the system and just-built shared objects respectively. If +# we use LD_LIBRARY_PATH to point to our build directory, the system clang +# may use the just-built shared objects instead, which may not be compatible +# even if the version matches (e.g. when building compat libs or different rcs). +# Instead, we make use of rpath during the build and only strip it on +# installation using the CMAKE_SKIP_INSTALL_RPATH option. +%global cmake_config_args %{cmake_config_args} -DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON + +%if %reduce_debuginfo == 1 + %global cmake_config_args %{cmake_config_args} -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" + %global cmake_config_args %{cmake_config_args} -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" +%endif + +%if 0%{?__isa_bits} == 64 + %global cmake_config_args %{cmake_config_args} -DLLVM_LIBDIR_SUFFIX=64 +%else + %global cmake_config_args %{cmake_config_args} -DLLVM_LIBDIR_SUFFIX= +%endif + + %global cmake_config_args %{cmake_config_args} -DLLVM_BINUTILS_INCDIR=%{_includedir} + +%ifarch x86_64 + %global cmake_config_args %{cmake_config_args} -DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS" + # removed -Wl,-z,cet-report=error, which cause error: missing IBT and SHSTK properties. +%endif +#endregion misc options + +extra_cmake_args='' +#endregion cmake options + +%if %{os_version} <= 2203 +mkdir _build +cd _build +%define __cmake_in_source_build 1 +%define build_tool %ninja_build +%define install_tool %ninja_install +%define cmake_target_opts %{nil} +%else +cd llvm +%define build_tool %cmake_build +%define install_tool %cmake_install +%define cmake_target_opts --target +%endif + +%cmake ../llvm -G Ninja %cmake_config_args $extra_cmake_args + +# Build libLLVM.so first. This ensures that when libLLVM.so is linking, there +# are no other compile jobs running. This will help reduce OOM errors on the +# builders without having to artificially limit the number of concurrent jobs. +%build_tool %cmake_target_opts LLVM + +# Also build libclang-cpp.so separately to avoid OOM errors. +# This is to fix occasional OOM errors on the ppc64le COPR builders. +%build_tool %cmake_target_opts libclang-cpp.so + +%build_tool +# If we don't build the runtimes target here, we'll have to wait for the %%check +# section until these files are available but they need to be installed. +# +# /usr/lib64/libomptarget.devicertl.a +# /usr/lib64/libomptarget-amdgpu-*.bc +# /usr/lib64/libomptarget-nvptx-*.bc + +%if %{maj_ver} >= 18 + +%build_tool %cmake_target_opts runtimes + +%else + +# add fix for llvm17 runtimes build +#region libcxx build +cp %{SOURCE2} %{build_src_dir} + +mkdir %{build_src_dir}/_build_libcxx +cd %{build_src_dir}/_build_libcxx + +%cmake %{build_src_dir} -GNinja \ + -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ + -DLLVM_CMAKE_DIR=%{build_src_dir}/%{build_dir} \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DLLVM_DIR=%{build_src_dir}/%{build_dir}/%{_lib}/cmake/llvm/ \ + -DCMAKE_MODULE_PATH="%{build_src_dir}/%{build_dir}/lib64/cmake/llvm;%{build_src_dir}/%{build_dir}/cmake/modules" \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ +%if 0%{?__isa_bits} == 64 + -DLIBCXX_LIBDIR_SUFFIX:STRING=64 \ + -DLIBCXXABI_LIBDIR_SUFFIX:STRING=64 \ + -DLIBUNWIND_LIBDIR_SUFFIX:STRING=64 \ +%endif + -DCMAKE_C_COMPILER=%{build_src_dir}/%{build_dir}/bin/clang \ + -DCMAKE_CXX_COMPILER=%{build_src_dir}/%{build_dir}/bin/clang++ \ + -DCMAKE_ASM_COMPILER=%{build_src_dir}/%{build_dir}/bin/clang \ + -DCMAKE_LINKER=%{build_src_dir}/%{build_dir}/bin/ld.lld \ + -DCMAKE_AR=%{build_src_dir}/%{build_dir}/bin/llvm-ar \ + -DCMAKE_RANLIB=%{build_src_dir}/%{build_dir}/bin/llvm-ranlib \ + -DCMAKE_NM=%{build_src_dir}/%{build_dir}/bin/llvm-nm \ + -DCMAKE_OBJDUMP=%{build_src_dir}/%{build_dir}/bin/llvm-objdump \ + -DCMAKE_OBJCOPY=%{build_src_dir}/%{build_dir}/bin/llvm-objcopy \ + -DCMAKE_STRIP=%{build_src_dir}/%{build_dir}/bin/llvm-strip \ + -DCMAKE_READELF=%{build_src_dir}/%{build_dir}/bin/llvm-readelf \ + -DLIBCXX_INCLUDE_BENCHMARKS=OFF \ + -DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON \ + -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=ON \ + -DLLVM_BUILD_DOCS=ON \ + -DLLVM_ENABLE_SPHINX=ON \ + -DLIBUNWIND_INCLUDE_DOCS=ON \ + -DLIBUNWIND_INSTALL_INCLUDE_DIR=%{install_includedir}/llvm-libunwind \ + -DLIBUNWIND_INSTALL_SPHINX_HTML_DIR=%{_pkgdocdir}/html \ + -DCMAKE_SKIP_RPATH:BOOL=ON +%build_tool +#endregion libcxx build + +#region libomp build + +mkdir %{build_src_dir}/_build_openmp +cd %{build_src_dir}/_build_openmp + +%cmake %{build_src_dir}/openmp -GNinja \ + -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ + -DLIBOMP_INSTALL_ALIASES=OFF \ + -DLLVM_DIR=%{build_src_dir}/%{build_dir}/%{_lib}/cmake/llvm/ \ + -DCMAKE_INSTALL_INCLUDEDIR=%{install_libdir}/clang/%{maj_ver}/include \ +%if 0%{?__isa_bits} == 64 + -DOPENMP_LIBDIR_SUFFIX=64 \ +%else + -DOPENMP_LIBDIR_SUFFIX= \ +%endif + -DCMAKE_C_COMPILER=%{build_src_dir}/%{build_dir}/bin/clang \ + -DCMAKE_CXX_COMPILER=%{build_src_dir}/%{build_dir}/bin/clang++ \ + -DCMAKE_ASM_COMPILER=%{build_src_dir}/%{build_dir}/bin/clang \ + -DCMAKE_LINKER=%{build_src_dir}/%{build_dir}/bin/ld.lld \ + -DCMAKE_AR=%{build_src_dir}/%{build_dir}/bin/llvm-ar \ + -DCMAKE_RANLIB=%{build_src_dir}/%{build_dir}/bin/llvm-ranlib \ + -DCMAKE_NM=%{build_src_dir}/%{build_dir}/bin/llvm-nm \ + -DCMAKE_OBJDUMP=%{build_src_dir}/%{build_dir}/bin/llvm-objdump \ + -DCMAKE_OBJCOPY=%{build_src_dir}/%{build_dir}/bin/llvm-objcopy \ + -DCMAKE_STRIP=%{build_src_dir}/%{build_dir}/bin/llvm-strip \ + -DCMAKE_READELF=%{build_src_dir}/%{build_dir}/bin/llvm-readelf \ + -DCMAKE_SKIP_RPATH:BOOL=ON + +%build_tool +#endregion libomp build +#region compiler-rt build + +mkdir %{build_src_dir}/_build_compiler-rt +cd %{build_src_dir}/_build_compiler-rt + +%cmake %{build_src_dir}/compiler-rt \ + -DLLVM_CMAKE_DIR=../_build \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ +%if 0%{?__isa_bits} == 64 + -DLLVM_LIBDIR_SUFFIX=64 \ +%else + -DLLVM_LIBDIR_SUFFIX= \ +%endif + -DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF \ + -DCOMPILER_RT_BUILD_BUILTINS=ON \ + -DCOMPILER_RT_BUILD_SANITIZERS=ON \ + -DCOMPILER_RT_BUILD_PROFILE=ON \ + -DCOMPILER_RT_BUILD_XRAY=ON \ + -DCOMPILER_RT_BUILD_ORC=ON \ + -DCOMPILER_RT_BUILD_FUZZER=ON \ + -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \ + -DCMAKE_C_COMPILER=%{build_src_dir}/%{build_dir}/bin/clang \ + -DCMAKE_CXX_COMPILER=%{build_src_dir}/%{build_dir}/bin/clang++ \ + -DCMAKE_ASM_COMPILER=%{build_src_dir}/%{build_dir}/bin/clang \ + -DCMAKE_LINKER=%{build_src_dir}/%{build_dir}/bin/ld.lld \ + -DCMAKE_AR=%{build_src_dir}/%{build_dir}/bin/llvm-ar \ + -DCMAKE_RANLIB=%{build_src_dir}/%{build_dir}/bin/llvm-ranlib \ + -DCMAKE_NM=%{build_src_dir}/%{build_dir}/bin/llvm-nm \ + -DCMAKE_OBJDUMP=%{build_src_dir}/%{build_dir}/bin/llvm-objdump \ + -DCMAKE_OBJCOPY=%{build_src_dir}/%{build_dir}/bin/llvm-objcopy \ + -DCMAKE_STRIP=%{build_src_dir}/%{build_dir}/bin/llvm-strip \ + -DCMAKE_READELF=%{build_src_dir}/%{build_dir}/bin/llvm-readelf \ + -DCOMPILER_RT_INSTALL_PATH=%{install_libdir}/clang/%{maj_ver} \ + -DCMAKE_SKIP_RPATH:BOOL=ON \ + -DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF # could be on? + +%if %{os_version} <= 2203 +%make_build +%else +%build_tool +%endif +cd %{build_src_dir} +#endregion compiler-rt build +%endif +#endregion build + +#region install +%install +#region LLVM installation + +%if %{os_version} <= 2203 +cd %{build_src_dir}/%{build_dir} +%else +cd %{build_src_dir}/llvm +%endif + +%install_tool + +%if %{maj_ver} <= 17 +cd %{build_src_dir}/_build_libcxx +%install_tool + +cd %{build_src_dir}/_build_openmp +%install_tool + +cd %{build_src_dir}/_build_compiler-rt +%if %{os_version} > 2203 +%install_tool +%else +%make_install +%endif + +rm %{build_install_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}/clang_rt.crtbegin.o +rm %{build_install_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}/clang_rt.crtend.o +rm %{build_install_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}/libclang_rt.builtins.a +%endif + +cd %{build_src_dir} + +mkdir -p %{buildroot}/%{_bindir} + +# Install binaries needed for lit tests +%global test_binaries llvm-isel-fuzzer llvm-opt-fuzzer + +for f in %{test_binaries} +do + install -m 0755 %{build_src_dir}/%{build_dir}/bin/$f %{buildroot}%{install_bindir} + chrpath --delete %{buildroot}%{install_bindir}/$f +done + +# Install libraries needed for unittests +install %{build_libdir}/libLLVMTestingSupport.a %{buildroot}%{install_libdir} +install %{build_libdir}/libLLVMTestingAnnotations.a %{buildroot}%{install_libdir} + +# Fix multi-lib +%multilib_fix_c_header --file %{install_includedir}/llvm/Config/llvm-config.h + +%if %{with sys_llvm} + +# Fix some man pages +ln -s llvm-config.1 %{buildroot}%{_mandir}/man1/llvm-config%{exec_suffix}-%{__isa_bits}.1 + +%if %{with gold} +# Add symlink to lto plugin in the binutils plugin directory. +%{__mkdir_p} %{buildroot}%{_libdir}/bfd-plugins/ +ln -s -t %{buildroot}%{_libdir}/bfd-plugins/ ../LLVMgold.so +%endif + +%else + +# Create ld.so.conf.d entry +mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d +cat >> %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{pkg_name_llvm}-%{_arch}.conf << EOF +%{install_libdir} +EOF + +# Add version suffix to man pages and move them to mandir. +mkdir -p %{buildroot}/%{_mandir}/man1 +for f in %{build_install_prefix}/share/man/man1/*; do + filename=`basename $f | cut -f 1 -d '.'` + mv $f %{buildroot}%{_mandir}/man1/$filename%{exec_suffix}.1 +done + +%endif + +mkdir -p %{buildroot}%{pkg_datadir}/llvm/cmake +cp -Rv cmake/* %{buildroot}%{pkg_datadir}/llvm/cmake + +# Install a placeholder to redirect users of the formerly shipped +# HTML documentation to the upstream HTML documentation. +mkdir -pv %{buildroot}%{_pkgdocdir}/html +cat < %{buildroot}%{_pkgdocdir}/html/index.html + + + + LLVM %{maj_ver}.%{min_ver} documentation + + +

+ LLVM %{maj_ver}.%{min_ver} Documentation +

+ + + +EOF + +#endregion LLVM installation + +#region CLANG installation + +# Add a symlink in /usr/bin to clang-format-diff +ln -s %{install_datadir}/clang/clang-format-diff.py %{buildroot}%{install_bindir}/clang-format-diff + +# File in the macros file for other packages to use. We are not doing this +# in the compat package, because the version macros would # conflict with +# eachother if both clang and the clang compat package were installed together. +%if %{with sys_llvm} + +# install clang python bindings +mkdir -p %{buildroot}%{python3_sitelib}/clang/ +# If we don't default to true here, we'll see this error: +# install: omitting directory 'bindings/python/clang/__pycache__' +# NOTE: this only happens if we include the gdb plugin of libomp. +# Remove the plugin with command and we're good: rm -rf %{buildroot}/%{_datarootdir}/gdb +install -p -m644 clang/bindings/python/clang/* %{buildroot}%{python3_sitelib}/clang/ +%py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/clang + +# install scanbuild-py to python sitelib. +mv %{buildroot}%{_prefix}/%{lib}/{libear,libscanbuild} %{buildroot}%{python3_sitelib} +# Cannot use {libear,libscanbuild} style expansion in py_byte_compile. +%py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/libear +%py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/libscanbuild + +# Move emacs integration files to the correct directory +mkdir -p %{buildroot}%{_emacs_sitestartdir} +for f in clang-format.el clang-include-fixer.el; do +mv %{buildroot}{%{_datadir}/clang,%{_emacs_sitestartdir}}/$f +done +%if %{maj_ver} < 20 +mv %{buildroot}{%{_datadir}/clang,%{_emacs_sitestartdir}}/clang-rename.el +%endif + +# Add clang++-{version} symlink +ln -s clang++ %{buildroot}%{_bindir}/clang++-%{maj_ver} + +%else + +# Fix permission +chmod u-x %{buildroot}%{_mandir}/man1/scan-build%{exec_suffix}.1* + +# Not sure where to put these python modules for the compat build. +rm -Rf %{buildroot}%{install_libdir}/{libear,libscanbuild} + +# Not sure where to put the emacs integration files for the compat build. +rm -Rf %{buildroot}%{install_datadir}/clang/*.el + +# Add clang++-{version} symlink +ln -s clang++ %{buildroot}%{install_bindir}/clang++-%{maj_ver} + +%endif + +# Create Manpage symlinks +ln -s clang%{exec_suffix}.1.gz %{buildroot}%{_mandir}/man1/clang++%{exec_suffix}.1.gz +%if %{with sys_llvm} +ln -s clang.1.gz %{buildroot}%{_mandir}/man1/clang-%{maj_ver}.1.gz +ln -s clang.1.gz %{buildroot}%{_mandir}/man1/clang++-%{maj_ver}.1.gz +%endif + +# Fix permissions of scan-view scripts +chmod a+x %{buildroot}%{install_datadir}/scan-view/{Reporter.py,startfile.py} + +# multilib fix +%multilib_fix_c_header --file %{install_includedir}/clang/Config/config.h + +# remove editor integrations (bbedit, sublime, emacs, vim) +rm -vf %{buildroot}%{install_datadir}/clang/clang-format-bbedit.applescript +rm -vf %{buildroot}%{install_datadir}/clang/clang-format-sublime.py* + +# Remove unpackaged files +rm -Rvf %{buildroot}%{install_datadir}/clang/clang-doc-default-stylesheet.css +rm -Rvf %{buildroot}%{install_datadir}/clang/index.js + +# TODO: What are the Fedora guidelines for packaging bash autocomplete files? +rm -vf %{buildroot}%{install_datadir}/clang/bash-autocomplete.sh + +# Create sub-directories in the clang resource directory that will be +# populated by other packages +mkdir -p %{buildroot}%{_libdir}/clang/%{maj_ver}/{bin,include,lib,share}/ + +#endregion CLANG installation + +#region COMPILER-RT installation + +# Triple where compiler-rt libs are installed. If it differs from llvm_triple, then there is +# also a symlink llvm_triple -> compiler_rt_triple. +%global compiler_rt_triple %{llvm_triple} + +%ifarch ppc64le +# Fix install path on ppc64le so that the directory name matches the triple used +# by clang. +mv %{buildroot}%{_prefix}/%{lib}/clang/%{maj_ver}/lib/powerpc64le-redhat-linux-gnu %{buildroot}%{_prefix}/%{lib}/clang/%{maj_ver}/lib/%{llvm_triple} +%endif + +%ifarch %{ix86} +# Fix install path on ix86 so that the directory name matches the triple used +# by clang on both actual ix86 (i686) and on x86_64 with -m32 (i386): +%global compiler_rt_triple i386-redhat-linux-gnu +%if "%{llvm_triple}" != "%{compiler_rt_triple}" +ln -s %{compiler_rt_triple} %{buildroot}%{_prefix}/%{lib}/clang/%{maj_ver}/lib/%{llvm_triple} +%endif +%endif + +#endregion COMPILER-RT installation + +#region OPENMP installation + +# Remove static libraries with equivalent shared libraries +rm -rf %{buildroot}%{install_libdir}/libarcher_static.a + +# Remove the openmp gdb plugin for now +rm -rf %{buildroot}/%{install_datadir}/gdb +# # TODO(kkleine): These was added to avoid a permission issue +# chmod go+w %{buildroot}/%{_datarootdir}/gdb/python/ompd/ompdModule.so +# chmod +w %{buildroot}/%{_datarootdir}/gdb/python/ompd/ompdModule.so + +%ifnarch %{ix86} +# Remove files that we don't package, yet. +%if %{os_version} > 2203 +rm %{buildroot}%{install_bindir}/llvm-omp-device-info +rm %{buildroot}%{install_bindir}/llvm-omp-kernel-replay +%endif +%endif + +#endregion OPENMP installation + +#region LLD installation + +%if %{with sys_llvm} +# Required when using update-alternatives: +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Alternatives/ +touch %{buildroot}%{_bindir}/ld + +install -D -m 644 -t %{buildroot}%{_mandir}/man1/ lld/docs/ld.lld.1 +%endif + +#endregion LLD installation + +#region LLDB installation +%if %{with lldb} +%multilib_fix_c_header --file %{install_includedir}/lldb/Host/Config.h + +# python: fix binary libraries location +liblldb=$(basename $(readlink -e %{buildroot}%{install_libdir}/liblldb.so)) +mkdir -p %{buildroot}%{python3_sitearch} +mv %{buildroot}%{install_prefix}/..%{python3_sitearch}/lldb %{buildroot}%{python3_sitearch}/lldb +ln -vsf "../../../${liblldb}" %{buildroot}%{python3_sitearch}/lldb/_lldb.so +%py_byte_compile %{__python3} %{buildroot}%{python3_sitearch}/lldb +%endif +#endregion LLDB installation + +#region mlir installation +%if %{with mlir} +mkdir -p %{buildroot}/%{python3_sitearch} +mv %{buildroot}%{install_prefix}/python_packages/mlir_core/mlir %{buildroot}/%{python3_sitearch} +# These directories should be empty now. +rmdir %{buildroot}%{install_prefix}/python_packages/mlir_core %{buildroot}%{install_prefix}/python_packages +# Unneeded files. +rm -rf %{buildroot}%{install_prefix}/src/python +%endif +#endregion mlir installation + +#region libcxx installation +%if %{with libcxx} +# We can't install the unversionned path on default location because that would conflict with +# https://src.fedoraproject.org/rpms/libunwind +# +# The versionned path has a different soname (libunwind.so.1 compared to +# libunwind.so.8) so they can live together in %%{_libdir} +# +# ABI wise, even though llvm-libunwind's library is named libunwind, it doesn't +# have the exact same ABI as gcc's libunwind (it actually provides a subset). +rm %{buildroot}%{install_libdir}/libunwind.so +mkdir -p %{buildroot}/%{install_libdir}/llvm-unwind/ + +pushd %{buildroot}/%{install_libdir}/llvm-unwind +ln -s ../libunwind.so.1.0 libunwind.so +popd +%endif +#endregion libcxx installation + +%if %{without sys_llvm} +# Add version suffix to binaries. Do this at the end so it includes any +# additional binaries that may be been added by other steps. +for f in %{buildroot}/%{install_bindir}/*; do + filename=`basename $f` + if echo $filename | grep -e '%{maj_ver}'; then + continue + fi + ln -s ../../%{install_bindir}/$filename %{buildroot}/%{_bindir}/$filename%{exec_suffix} +done +%endif + +# llvm-config special casing. llvm-config is managed by update-alternatives. +# the original file must remain available for compatibility with the CMake +# infrastructure. Without compat, cmake points to the symlink, with compat it +# points to the original file. + +%if %{with sys_llvm} + +mv %{buildroot}/%{install_bindir}/llvm-config %{buildroot}/%{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} +# We still maintain a versionned symlink for consistency across llvm versions. +# This is specific to the non-compat build and matches the exec prefix for +# compat builds. An isa-agnostic versionned symlink is also maintained in the (un)install +# steps. +(cd %{buildroot}/%{install_bindir} ; ln -s llvm-config%{exec_suffix}-%{__isa_bits} llvm-config-%{maj_ver}-%{__isa_bits} ) +# ghost presence +touch %{buildroot}%{_bindir}/llvm-config-%{maj_ver} + +%else + +rm %{buildroot}%{_bindir}/llvm-config%{exec_suffix} +(cd %{buildroot}/%{install_bindir} ; ln -s llvm-config llvm-config%{exec_suffix}-%{__isa_bits} ) + +%endif + +# ghost presence +touch %{buildroot}%{_bindir}/llvm-config%{exec_suffix} + +%if %{with bundle_compat_lib} +install -m 0755 ../llvm-compat-libs/lib/libLLVM.so.%{compat_maj_ver}* %{buildroot}%{_libdir} +install -m 0755 ../llvm-compat-libs/lib/libclang.so.%{compat_maj_ver}* %{buildroot}%{_libdir} +install -m 0755 ../llvm-compat-libs/lib/libclang-cpp.so.%{compat_maj_ver}* %{buildroot}%{_libdir} +install -m 0755 ../llvm-compat-libs/lib/liblldb.so.%{compat_maj_ver}* %{buildroot}%{_libdir} +%endif +#endregion install + +#region check +%check +# TODO(kkleine): Instead of deleting test files we should mark them as expected +# to fail. See https://llvm.org/docs/CommandGuide/lit.html#cmdoption-lit-xfail + +%ifarch ppc64le +# TODO: Re-enable when ld.gold fixed its internal error. +rm llvm/test/tools/gold/PowerPC/mtriple.ll +%endif + +# non reproducible errors +# TODO(kkleine): Add this to XFAIL instead? +rm llvm/test/tools/dsymutil/X86/swift-interface.test + +%if %{with check} + +cd llvm + +#region Helper functions +# Call this function before setting up a next component to test. +function reset_test_opts() +{ + # Some libraries will not be found if we don't set this + export LD_LIBRARY_PATH="%{buildroot}/%{install_libdir}:%{buildroot}/%{_libdir}"; + + # See https://llvm.org/docs/CommandGuide/lit.html#general-options + export LIT_OPTS="-vv --time-tests" + + # Set to mark tests as expected to fail. + # See https://llvm.org/docs/CommandGuide/lit.html#cmdoption-lit-xfail + unset LIT_XFAIL + + # Set to mark tests to not even run. + # See https://llvm.org/docs/CommandGuide/lit.html#cmdoption-lit-filter-out + # Unfortunately LIT_FILTER_OUT is not accepting a list but a regular expression. + # To make this easily maintainable, we'll create an associate array in bash, + # to which you can append and later we'll join that array and escape dots (".") + # in your test paths. The following line resets this array. + # See also the function "test_list_to_regex". + test_list_filter_out=() + unset LIT_FILTER_OUT + + # Set for filtering out unit tests. + # See http://google.github.io/googletest/advanced.html#running-a-subset-of-the-tests + unset GTEST_FILTER + + # Some test (e.g. mlir) require this to be set. + unset PYTHONPATH +} + +# Convert array of test names into a regex. +# Call this function with an indexed array. +# +# Example: +# +# testlist=() +# testlist+=("foo") +# testlist+=("bar") +# export LIT_FILTER_OUT=$(test_list_to_regex testlist) +# +# Then $LIT_FILTER_OUT should evaluate to: (foo|bar) +function test_list_to_regex() +{ + local -n arr=$1 + # Prepare LIT_FILTER_OUT regex from index bash array + # Join each element with a pipe symbol (regex for "or") + arr=$(printf "|%s" "${arr[@]}") + # Remove the initial pipe symbol + arr=${arr:1} + # Properly escape path dots (".") for use in regular expression + arr=$(echo $arr | sed 's/\./\\./g') + # Add enclosing parenthesis + echo "($arr)" +} + +# Similar to test_list_to_regex() except that this function exports +# the LIT_FILTER_OUT if there are tests in the given list. +# If there are no tests, the LIT_FILTER_OUT is unset in order to +# avoid issues with the llvm test system. +function adjust_lit_filter_out() +{ + local -n arr=$1 + local res=$(test_list_to_regex test_list_filter_out) + if [[ "$res" != "()" ]]; then + export LIT_FILTER_OUT=$res + else + unset LIT_FILTER_OUT + fi +} +#endregion Helper functions + +#region Test LLVM lit +# It's fine to always run this, even if we're not shipping python-lit. +reset_test_opts +%cmake_build --target check-lit +#endregion Test LLVM lit + +#region Test LLVM +reset_test_opts +# Xfail testing of update utility tools +export LIT_XFAIL="tools/UpdateTestChecks" +%cmake_build --target check-llvm +#endregion Test LLVM + +#region Test CLANG +reset_test_opts +export LIT_XFAIL="$LIT_XFAIL;clang/test/CodeGen/profile-filter.c" +%cmake_build --target check-clang +#endregion Test Clang + +#region Test Clang Tools +reset_test_opts +%ifarch %ix86 +# Clang Tools :: clang-tidy/checkers/altera/struct-pack-align.cpp +export LIT_XFAIL="$LIT_XFAIL;clang-tidy/checkers/altera/struct-pack-align.cpp" +%endif +%cmake_build --target check-clang-tools +#endregion Test Clang Tools + +#region Test OPENMP +reset_test_opts + +# TODO(kkleine): OpenMP tests are currently not run on rawhide (see https://bugzilla.redhat.com/show_bug.cgi?id=2252966): +# +# + /usr/bin/cmake --build redhat-linux-build -j6 --verbose --target check-openmp +# Change Dir: '/builddir/build/BUILD/openmp-17.0.6.src/redhat-linux-build' +# Run Build Command(s): /usr/bin/ninja-build -v -j 6 check-openmp +# [1/1] cd /builddir/build/BUILD/openmp-17.0.6.src/redhat-linux-build && /usr/bin/cmake -E echo check-openmp\ does\ nothing,\ dependencies\ not\ found. +# +# We're marking the tests that are failing with the follwing error as expected to fail (XFAIL): +# +# gdb.error: No symbol "ompd_sizeof____kmp_gtid" in current context +# +# NOTE: It could be a different symbol in some tests. +export LIT_XFAIL="api_tests/test_ompd_get_curr_task_handle.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_enclosing_parallel_handle.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_generating_task_handle.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_icv_from_scope.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_scheduling_task_handle.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_state.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_task_frame.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_task_function.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_task_in_parallel.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_task_parallel_handle.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_thread_id.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_thread_in_parallel.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_parallel_handle_compare.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_rel_parallel_handle.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_rel_task_handle.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_rel_thread_handle.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_task_handle_compare.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_thread_handle_compare.c" +export LIT_XFAIL="$LIT_XFAIL;openmp_examples/ompd_icvs.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_curr_parallel_handle.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_display_control_vars.c" +export LIT_XFAIL="$LIT_XFAIL;api_tests/test_ompd_get_thread_handle.c" + +# The following test is flaky and we'll filter it out +test_list_filter_out+=("libomp :: ompt/teams/distribute_dispatch.c") +test_list_filter_out+=("libomp :: affinity/kmp-abs-hw-subset.c") +test_list_filter_out+=("libomp :: parallel/bug63197.c") +test_list_filter_out+=("libomp :: tasking/issue-69733.c") +test_list_filter_out+=("libarcher :: races/task-taskgroup-unrelated.c") + +# These tests fail more often than not, but not always. +test_list_filter_out+=("libomp :: worksharing/for/omp_collapse_many_GELTGT_int.c") +test_list_filter_out+=("libomp :: worksharing/for/omp_collapse_many_GTGEGT_int.c") +test_list_filter_out+=("libomp :: worksharing/for/omp_collapse_many_LTLEGE_int.c") +test_list_filter_out+=("libomp :: worksharing/for/omp_collapse_one_int.c") + +%ifarch s390x +test_list_filter_out+=("libomp :: flush/omp_flush.c") +test_list_filter_out+=("libomp :: worksharing/for/omp_for_schedule_guided.c") +%endif + +%ifarch aarch64 s390x +# The following test has been failing intermittently on aarch64 and s390x. +# Re-enable it after https://github.com/llvm/llvm-project/issues/117773 +# gets fixed. +test_list_filter_out+=("libarcher :: races/taskwait-depend.c") +%endif + +# The following tests seem pass on ppc64le and x86_64 and aarch64 only: +%ifnarch ppc64le x86_64 s390x aarch64 +# Passes on ppc64le: +# libomptarget :: powerpc64le-ibm-linux-gnu :: mapping/target_derefence_array_pointrs.cpp +# libomptarget :: powerpc64le-ibm-linux-gnu-LTO :: mapping/target_derefence_array_pointrs.cpp +# Passes on x86_64: +# libomptarget :: x86_64-pc-linux-gnu :: mapping/target_derefence_array_pointrs.cpp +# libomptarget :: x86_64-pc-linux-gnu-LTO :: mapping/target_derefence_array_pointrs.cpp +# Passes on s390x: +# libomptarget :: s390x-ibm-linux-gnu :: mapping/target_derefence_array_pointrs.cpp +# libomptarget :: s390x-ibm-linux-gnu-LTO :: mapping/target_derefence_array_pointrs.cpp +export LIT_XFAIL="$LIT_XFAIL;mapping/target_derefence_array_pointrs.cpp" +%endif + +%ifnarch x86_64 +# Passes on x86_64: +# libomptarget :: x86_64-pc-linux-gnu :: api/ompx_3d.c +# libomptarget :: x86_64-pc-linux-gnu :: api/ompx_3d.cpp +# libomptarget :: x86_64-pc-linux-gnu-LTO :: api/ompx_3d.c +# libomptarget :: x86_64-pc-linux-gnu-LTO :: api/ompx_3d.cpp +# libomptarget :: aarch64-unknown-linux-gnu :: +export LIT_XFAIL="$LIT_XFAIL;api/ompx_3d.c" +export LIT_XFAIL="$LIT_XFAIL;api/ompx_3d.cpp" +%endif + +%ifarch ppc64le +export LIT_XFAIL="$LIT_XFAIL;barrier/barrier.c" +export LIT_XFAIL="$LIT_XFAIL;critical/critical.c" +export LIT_XFAIL="$LIT_XFAIL;critical/lock-nested.c" +export LIT_XFAIL="$LIT_XFAIL;critical/lock.c" +export LIT_XFAIL="$LIT_XFAIL;parallel/parallel-firstprivate.c" +export LIT_XFAIL="$LIT_XFAIL;parallel/parallel-nosuppression.c" +export LIT_XFAIL="$LIT_XFAIL;parallel/parallel-simple.c" +export LIT_XFAIL="$LIT_XFAIL;parallel/parallel-simple2.c" +export LIT_XFAIL="$LIT_XFAIL;races/critical-unrelated.c" +export LIT_XFAIL="$LIT_XFAIL;races/lock-nested-unrelated.c" +export LIT_XFAIL="$LIT_XFAIL;races/lock-unrelated.c" +export LIT_XFAIL="$LIT_XFAIL;races/parallel-simple.c" +export LIT_XFAIL="$LIT_XFAIL;races/task-dependency.c" +export LIT_XFAIL="$LIT_XFAIL;races/task-taskgroup-unrelated.c" +export LIT_XFAIL="$LIT_XFAIL;races/task-taskwait-nested.c" +export LIT_XFAIL="$LIT_XFAIL;races/task-two.c" +export LIT_XFAIL="$LIT_XFAIL;races/taskwait-depend.c" +export LIT_XFAIL="$LIT_XFAIL;reduction/parallel-reduction-nowait.c" +export LIT_XFAIL="$LIT_XFAIL;reduction/parallel-reduction.c" +export LIT_XFAIL="$LIT_XFAIL;task/omp_task_depend_all.c" +export LIT_XFAIL="$LIT_XFAIL;task/task-barrier.c" +export LIT_XFAIL="$LIT_XFAIL;task/task-create.c" +export LIT_XFAIL="$LIT_XFAIL;task/task-dependency.c" +export LIT_XFAIL="$LIT_XFAIL;task/task-taskgroup-nested.c" +export LIT_XFAIL="$LIT_XFAIL;task/task-taskgroup.c" +export LIT_XFAIL="$LIT_XFAIL;task/task-taskwait-nested.c" +export LIT_XFAIL="$LIT_XFAIL;task/task-taskwait.c" +export LIT_XFAIL="$LIT_XFAIL;task/task_early_fulfill.c" +export LIT_XFAIL="$LIT_XFAIL;task/task_late_fulfill.c" +export LIT_XFAIL="$LIT_XFAIL;task/taskwait-depend.c" +export LIT_XFAIL="$LIT_XFAIL;worksharing/ordered.c" +export LIT_XFAIL="$LIT_XFAIL;api/omp_dynamic_shared_memory.c" +export LIT_XFAIL="$LIT_XFAIL;jit/empty_kernel_lvl1.c" +export LIT_XFAIL="$LIT_XFAIL;jit/empty_kernel_lvl2.c" +export LIT_XFAIL="$LIT_XFAIL;jit/type_punning.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/barrier_fence.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/bug49334.cpp" +export LIT_XFAIL="$LIT_XFAIL;offloading/default_thread_limit.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/ompx_bare.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/ompx_coords.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/ompx_saxpy_mixed.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/small_trip_count.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/small_trip_count_thread_limit.cpp" +export LIT_XFAIL="$LIT_XFAIL;offloading/spmdization.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/target_critical_region.cpp" +export LIT_XFAIL="$LIT_XFAIL;offloading/thread_limit.c" +export LIT_XFAIL="$LIT_XFAIL;api/omp_dynamic_shared_memory.c" +export LIT_XFAIL="$LIT_XFAIL;jit/empty_kernel_lvl1.c" +export LIT_XFAIL="$LIT_XFAIL;jit/empty_kernel_lvl2.c" +export LIT_XFAIL="$LIT_XFAIL;jit/type_punning.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/barrier_fence.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/bug49334.cpp" +export LIT_XFAIL="$LIT_XFAIL;offloading/default_thread_limit.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/ompx_bare.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/ompx_coords.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/ompx_saxpy_mixed.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/small_trip_count.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/small_trip_count_thread_limit.cpp" +export LIT_XFAIL="$LIT_XFAIL;offloading/spmdization.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/target_critical_region.cpp" +export LIT_XFAIL="$LIT_XFAIL;offloading/thread_limit.c" +export LIT_XFAIL="$LIT_XFAIL;mapping/auto_zero_copy.cpp" +export LIT_XFAIL="$LIT_XFAIL;mapping/auto_zero_copy_globals.cpp" +export LIT_XFAIL="$LIT_XFAIL;offloading/workshare_chunk.c" +export LIT_XFAIL="$LIT_XFAIL;ompt/target_memcpy.c" +export LIT_XFAIL="$LIT_XFAIL;ompt/target_memcpy_emi.c" +%endif + +%ifarch s390x ppc64le +export LIT_XFAIL="$LIT_XFAIL;offloading/thread_state_1.c" +export LIT_XFAIL="$LIT_XFAIL;offloading/thread_state_2.c" +%endif + +adjust_lit_filter_out test_list_filter_out + +%if 0%{?rhel} +# libomp tests are often very slow on s390x brew builders +%ifnarch s390x +%cmake_build --target check-openmp +%endif +%else +%cmake_build --target check-openmp +%endif +#endregion Test OPENMP + +%if %{with lldb} +# Don't run LLDB tests on s390x because more than 150 tests are failing there +%ifnarch s390x +## TODO(kkleine): Come back and re-enable testing for LLDB +## #region LLDB unit tests +## reset_test_opts +## %%cmake_build --target check-lldb-unit +## #endregion LLDB unit tests +## +## #region LLDB SB API tests +## reset_test_opts +## %%cmake_build --target check-lldb-api +## #endregion LLDB SB API tests +## +## #region LLDB shell tests +## reset_test_opts +## %%cmake_build --target check-lldb-shell +## #endregion LLDB shell tests +%endif +%endif + +#region test libcxx +# TODO(kkleine): Fedora rawhide didn't contain check runs. Evaluate if we want them here. +#endregion test libcxx + +#region Test LLD +reset_test_opts +%cmake_build --target check-lld +#endregion Test LLD + +#region Test MLIR +%if %{with mlir} +reset_test_opts + +# The ml_dtypes python module required by mlir/test/python/execution_engine.py +# isn't packaged. +test_list_filter_out+=("MLIR :: python/execution_engine.py") + +%ifarch s390x +# s390x does not support half-float +test_list_filter_out+=("MLIR :: python/ir/array_attributes.py") +%endif + +adjust_lit_filter_out test_list_filter_out + +export PYTHONPATH=%{buildroot}/%{python3_sitearch} +%cmake_build --target check-mlir +%endif +#endregion Test MLIR + +%endif + +#endregion check + +#region misc +%ldconfig_scriptlets -n %{pkg_name-llvm}-libs + +%if %{with sys_llvm} +%ldconfig_scriptlets -n %{pkg_name_lld}-libs +%endif + +%post -n %{pkg_name_llvm}-devel +%{_sbindir}/update-alternatives --install %{_bindir}/llvm-config%{exec_suffix} llvm-config%{exec_suffix} %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} %{__isa_bits} +%if %{with sys_llvm} +%{_sbindir}/update-alternatives --install %{_bindir}/llvm-config-%{maj_ver} llvm-config-%{maj_ver} %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} %{__isa_bits} + +# During the upgrade from LLVM 16 (F38) to LLVM 17 (F39), we found out the +# main llvm-devel package was leaving entries in the alternatives system. +# Try to remove them now. +for v in 14 15 16; do + if [[ -e %{_bindir}/llvm-config-$v + && "x$(%{_bindir}/llvm-config-$v --version | awk -F . '{ print $1 }')" != "x$v" ]]; then + %{_sbindir}/update-alternatives --remove llvm-config-$v %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} + fi +done +%endif + +%postun -n %{pkg_name_llvm}-devel +if [ $1 -eq 0 ]; then + %{_sbindir}/update-alternatives --remove llvm-config%{exec_suffix} %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} +fi +%if %{with sys_llvm} +# When upgrading between minor versions (i.e. from x.y.1 to x.y.2), we must +# not remove the alternative. +# However, during a major version upgrade (i.e. from 16.x.y to 17.z.w), the +# alternative must be removed in order to give priority to a newly installed +# compat package. +if [[ $1 -eq 0 + || "x$(%{_bindir}/llvm-config%{exec_suffix} --version | awk -F . '{ print $1 }')" != "x%{maj_ver}" ]]; then + %{_sbindir}/update-alternatives --remove llvm-config-%{maj_ver} %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} +fi +%endif + +%if %{with sys_llvm} +%post -n %{pkg_name_lld} +%{_sbindir}/update-alternatives --install %{_bindir}/ld ld %{_bindir}/ld.lld 1 + +%postun -n %{pkg_name_lld} +if [ $1 -eq 0 ] ; then + %{_sbindir}/update-alternatives --remove ld %{_bindir}/ld.lld +fi +%endif +#endregion misc + +#region files +#region LLVM lit files +%if %{with python_lit} +%files -n python%{python3_pkgversion}-lit +%license llvm/utils/lit/LICENSE.TXT +%doc llvm/utils/lit/README.rst +%{python3_sitelib}/lit/ +%{python3_sitelib}/lit-*-info/ +%{_bindir}/lit +%endif +#endregion LLVM lit files + +#region LLVM files + +%files -n %{pkg_name_llvm} +%license llvm/LICENSE.TXT +%exclude %{_mandir}/man1/llvm-config* + +%{_mandir}/man1/bugpoint%{exec_suffix}.1.gz +%{_mandir}/man1/clang-tblgen%{exec_suffix}.1.gz +%{_mandir}/man1/dsymutil%{exec_suffix}.1.gz +%{_mandir}/man1/FileCheck%{exec_suffix}.1.gz +%{_mandir}/man1/lit%{exec_suffix}.1.gz +%{_mandir}/man1/llc%{exec_suffix}.1.gz +%{_mandir}/man1/lldb-tblgen%{exec_suffix}.1.gz +%{_mandir}/man1/lli%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-addr2line%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-ar%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-as%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-bcanalyzer%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-cov%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-cxxfilt%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-cxxmap%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-debuginfo-analyzer%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-diff%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-dis%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-dwarfdump%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-dwarfutil%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-exegesis%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-extract%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-ifs%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-install-name-tool%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-lib%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-libtool-darwin%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-link%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-lipo%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-locstats%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-mc%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-mca%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-nm%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-objcopy%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-objdump%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-opt-report%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-otool%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-pdbutil%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-profdata%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-profgen%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-ranlib%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-readelf%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-readobj%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-reduce%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-remarkutil%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-size%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-stress%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-strings%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-strip%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-symbolizer%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-tblgen%{exec_suffix}.1.gz +%{_mandir}/man1/llvm-tli-checker%{exec_suffix}.1.gz +%{_mandir}/man1/mlir-tblgen%{exec_suffix}.1.gz +%{_mandir}/man1/opt%{exec_suffix}.1.gz +%{_mandir}/man1/tblgen%{exec_suffix}.1.gz +%if %{maj_ver} >= 20 +%{_mandir}/man1/llvm-cgdata%{exec_suffix}.1.gz +%endif +%if %{maj_ver} <= 17 +%{_mandir}/man1/llvm-remark-size-diff%{exec_suffix}.1.gz +%endif + +%{install_bindir}/bugpoint +%{install_bindir}/dsymutil +%{install_bindir}/FileCheck +%{install_bindir}/llc +%{install_bindir}/lli +%{install_bindir}/llvm-addr2line +%{install_bindir}/llvm-ar +%{install_bindir}/llvm-as +%{install_bindir}/llvm-bcanalyzer +%{install_bindir}/llvm-bitcode-strip +%{install_bindir}/llvm-c-test +%{install_bindir}/llvm-cat +%{install_bindir}/llvm-cfi-verify +%{install_bindir}/llvm-cov +%{install_bindir}/llvm-cvtres +%{install_bindir}/llvm-cxxdump +%{install_bindir}/llvm-cxxfilt +%{install_bindir}/llvm-cxxmap +%{install_bindir}/llvm-debuginfo-analyzer +%{install_bindir}/llvm-debuginfod +%{install_bindir}/llvm-debuginfod-find +%{install_bindir}/llvm-diff +%{install_bindir}/llvm-dis +%{install_bindir}/llvm-dlltool +%{install_bindir}/llvm-dwarfdump +%{install_bindir}/llvm-dwarfutil +%{install_bindir}/llvm-dwp +%{install_bindir}/llvm-exegesis +%{install_bindir}/llvm-extract +%{install_bindir}/llvm-gsymutil +%{install_bindir}/llvm-ifs +%{install_bindir}/llvm-install-name-tool +%{install_bindir}/llvm-jitlink +%{install_bindir}/llvm-jitlink-executor +%{install_bindir}/llvm-lib +%{install_bindir}/llvm-libtool-darwin +%{install_bindir}/llvm-link +%{install_bindir}/llvm-lipo +%{install_bindir}/llvm-lto +%{install_bindir}/llvm-lto2 +%{install_bindir}/llvm-mc +%{install_bindir}/llvm-mca +%{install_bindir}/llvm-ml +%{install_bindir}/llvm-modextract +%{install_bindir}/llvm-mt +%{install_bindir}/llvm-nm +%{install_bindir}/llvm-objcopy +%{install_bindir}/llvm-objdump +%{install_bindir}/llvm-opt-report +%{install_bindir}/llvm-otool +%{install_bindir}/llvm-pdbutil +%{install_bindir}/llvm-PerfectShuffle +%{install_bindir}/llvm-profdata +%{install_bindir}/llvm-profgen +%{install_bindir}/llvm-ranlib +%{install_bindir}/llvm-rc +%{install_bindir}/llvm-readelf +%{install_bindir}/llvm-readobj +%if %{maj_ver} >=18 +%{install_bindir}/llvm-readtapi +%endif +%{install_bindir}/llvm-reduce +%{install_bindir}/llvm-remarkutil +%{install_bindir}/llvm-rtdyld +%{install_bindir}/llvm-sim +%{install_bindir}/llvm-size +%{install_bindir}/llvm-split +%{install_bindir}/llvm-stress +%{install_bindir}/llvm-strings +%{install_bindir}/llvm-strip +%{install_bindir}/llvm-symbolizer +%{install_bindir}/llvm-tblgen +%{install_bindir}/llvm-tli-checker +%{install_bindir}/llvm-undname +%{install_bindir}/llvm-windres +%{install_bindir}/llvm-xray +%{install_bindir}/obj2yaml +%{install_bindir}/opt +%{install_bindir}/sancov +%{install_bindir}/sanstats +%{install_bindir}/split-file +%{install_bindir}/UnicodeNameMappingGenerator +%{install_bindir}/verify-uselistorder +%{install_bindir}/yaml2obj +%if %{maj_ver} >= 20 +%{install_bindir}/llvm-cgdata +%{install_bindir}/llvm-ctxprof-util +%endif +%if %{maj_ver} <= 17 +%{install_bindir}/llvm-remark-size-diff +%{install_bindir}/llvm-tapi-diff +%endif + +%if %{without sys_llvm} +# This is for all the binaries with the version suffix. +%{_bindir}/bugpoint%{exec_suffix} +%{_bindir}/dsymutil%{exec_suffix} +%{_bindir}/FileCheck%{exec_suffix} +%{_bindir}/llc%{exec_suffix} +%{_bindir}/lli%{exec_suffix} +%{_bindir}/llvm-addr2line%{exec_suffix} +%{_bindir}/llvm-ar%{exec_suffix} +%{_bindir}/llvm-as%{exec_suffix} +%{_bindir}/llvm-bcanalyzer%{exec_suffix} +%{_bindir}/llvm-bitcode-strip%{exec_suffix} +%{_bindir}/llvm-c-test%{exec_suffix} +%{_bindir}/llvm-cat%{exec_suffix} +%{_bindir}/llvm-cfi-verify%{exec_suffix} +%{_bindir}/llvm-cov%{exec_suffix} +%{_bindir}/llvm-cvtres%{exec_suffix} +%{_bindir}/llvm-cxxdump%{exec_suffix} +%{_bindir}/llvm-cxxfilt%{exec_suffix} +%{_bindir}/llvm-cxxmap%{exec_suffix} +%{_bindir}/llvm-debuginfo-analyzer%{exec_suffix} +%{_bindir}/llvm-debuginfod%{exec_suffix} +%{_bindir}/llvm-debuginfod-find%{exec_suffix} +%{_bindir}/llvm-diff%{exec_suffix} +%{_bindir}/llvm-dis%{exec_suffix} +%{_bindir}/llvm-dlltool%{exec_suffix} +%{_bindir}/llvm-dwarfdump%{exec_suffix} +%{_bindir}/llvm-dwarfutil%{exec_suffix} +%{_bindir}/llvm-dwp%{exec_suffix} +%{_bindir}/llvm-exegesis%{exec_suffix} +%{_bindir}/llvm-extract%{exec_suffix} +%{_bindir}/llvm-gsymutil%{exec_suffix} +%{_bindir}/llvm-ifs%{exec_suffix} +%{_bindir}/llvm-install-name-tool%{exec_suffix} +%{_bindir}/llvm-jitlink%{exec_suffix} +%{_bindir}/llvm-jitlink-executor%{exec_suffix} +%{_bindir}/llvm-lib%{exec_suffix} +%{_bindir}/llvm-libtool-darwin%{exec_suffix} +%{_bindir}/llvm-link%{exec_suffix} +%{_bindir}/llvm-lipo%{exec_suffix} +%{_bindir}/llvm-lto%{exec_suffix} +%{_bindir}/llvm-lto2%{exec_suffix} +%{_bindir}/llvm-mc%{exec_suffix} +%{_bindir}/llvm-mca%{exec_suffix} +%{_bindir}/llvm-ml%{exec_suffix} +%{_bindir}/llvm-modextract%{exec_suffix} +%{_bindir}/llvm-mt%{exec_suffix} +%{_bindir}/llvm-nm%{exec_suffix} +%{_bindir}/llvm-objcopy%{exec_suffix} +%{_bindir}/llvm-objdump%{exec_suffix} +%{_bindir}/llvm-opt-report%{exec_suffix} +%{_bindir}/llvm-otool%{exec_suffix} +%{_bindir}/llvm-pdbutil%{exec_suffix} +%{_bindir}/llvm-PerfectShuffle%{exec_suffix} +%{_bindir}/llvm-profdata%{exec_suffix} +%{_bindir}/llvm-profgen%{exec_suffix} +%{_bindir}/llvm-ranlib%{exec_suffix} +%{_bindir}/llvm-rc%{exec_suffix} +%{_bindir}/llvm-readelf%{exec_suffix} +%{_bindir}/llvm-readobj%{exec_suffix} +%if %{maj_ver} >=18 +%{_bindir}/llvm-readtapi%{exec_suffix} +%endif +%{_bindir}/llvm-reduce%{exec_suffix} +%{_bindir}/llvm-remarkutil%{exec_suffix} +%{_bindir}/llvm-rtdyld%{exec_suffix} +%{_bindir}/llvm-sim%{exec_suffix} +%{_bindir}/llvm-size%{exec_suffix} +%{_bindir}/llvm-split%{exec_suffix} +%{_bindir}/llvm-stress%{exec_suffix} +%{_bindir}/llvm-strings%{exec_suffix} +%{_bindir}/llvm-strip%{exec_suffix} +%{_bindir}/llvm-symbolizer%{exec_suffix} +%{_bindir}/llvm-tblgen%{exec_suffix} +%{_bindir}/llvm-tli-checker%{exec_suffix} +%{_bindir}/llvm-undname%{exec_suffix} +%{_bindir}/llvm-windres%{exec_suffix} +%{_bindir}/llvm-xray%{exec_suffix} +%{_bindir}/obj2yaml%{exec_suffix} +%{_bindir}/opt%{exec_suffix} +%{_bindir}/sancov%{exec_suffix} +%{_bindir}/sanstats%{exec_suffix} +%{_bindir}/split-file%{exec_suffix} +%{_bindir}/UnicodeNameMappingGenerator%{exec_suffix} +%{_bindir}/verify-uselistorder%{exec_suffix} +%{_bindir}/yaml2obj%{exec_suffix} +%if %{maj_ver} >= 20 +%{_bindir}/llvm-cgdata%{exec_suffix} +%{_bindir}/llvm-ctxprof-util%{exec_suffix} +%endif +%if %{maj_ver} <= 17 +%{_bindir}/llvm-remark-size-diff%{exec_suffix} +%{_bindir}/llvm-tapi-diff%{exec_suffix} +%endif + +%endif + +%exclude %{_bindir}/llvm-config%{exec_suffix} +%exclude %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} + +%exclude %{_bindir}/llvm-config-%{maj_ver} +%exclude %{install_bindir}/llvm-config-%{maj_ver}-%{__isa_bits} +%exclude %{install_bindir}/not +%exclude %{install_bindir}/count +%exclude %{install_bindir}/yaml-bench +%exclude %{install_bindir}/lli-child-target +%exclude %{install_bindir}/llvm-isel-fuzzer +%exclude %{install_bindir}/llvm-opt-fuzzer +%{pkg_datadir}/opt-viewer + +%files -n %{pkg_name_llvm}-libs +%license llvm/LICENSE.TXT +%{install_libdir}/libLLVM-%{maj_ver}%{?llvm_snapshot_version_suffix}.so +%if %{with gold} +%{install_libdir}/LLVMgold.so +%if %{with sys_llvm} +%{_libdir}/bfd-plugins/LLVMgold.so +%endif +%else +%if %{maj_ver} <= 18 +%{install_libdir}/LLVMgold.so +%endif +%endif +%if %{maj_ver} >= 18 +%{install_libdir}/libLLVM.so.%{maj_ver}.%{min_ver}%{?llvm_snapshot_version_suffix} +%else +%{install_libdir}/libLLVM-%{maj_ver}.%{min_ver}*.so +%endif +%{install_libdir}/libLTO.so* +%{install_libdir}/libRemarks.so* +%if %{without sys_llvm} +%config(noreplace) %{_sysconfdir}/ld.so.conf.d/%{pkg_name_llvm}-%{_arch}.conf +%endif + +%files -n %{pkg_name_llvm}-devel +%license llvm/LICENSE.TXT + +%if %{with sys_llvm} +%ghost %{_bindir}/llvm-config +%{install_bindir}/llvm-config-%{__isa_bits} +%else +%{install_bindir}/llvm-config +%endif +%ghost %{_bindir}/llvm-config-%{maj_ver} +%{install_bindir}/llvm-config-%{maj_ver}-%{__isa_bits} + +%{_mandir}/man1/llvm-config* +%{install_includedir}/llvm +%{install_includedir}/llvm-c +%{install_libdir}/libLLVM.so +%{install_libdir}/cmake/llvm + +%files -n %{pkg_name_llvm}-doc +%license llvm/LICENSE.TXT +%doc %{_pkgdocdir}/html/index.html + +%files -n %{pkg_name_llvm}-static +%license llvm/LICENSE.TXT +%{install_libdir}/libLLVM*.a +%exclude %{install_libdir}/libLLVMTestingSupport.a +%exclude %{install_libdir}/libLLVMTestingAnnotations.a + +%files -n %{pkg_name_llvm}-cmake-utils +%license llvm/LICENSE.TXT +%{pkg_datadir}/llvm/cmake + +%files -n %{pkg_name_llvm}-test +%license llvm/LICENSE.TXT +%{install_bindir}/not +%{install_bindir}/count +%{install_bindir}/yaml-bench +%{install_bindir}/lli-child-target +%{install_bindir}/llvm-isel-fuzzer +%{install_bindir}/llvm-opt-fuzzer +%if %{without sys_llvm} +%{_bindir}/not%{exec_suffix} +%{_bindir}/count%{exec_suffix} +%{_bindir}/yaml-bench%{exec_suffix} +%{_bindir}/lli-child-target%{exec_suffix} +%{_bindir}/llvm-isel-fuzzer%{exec_suffix} +%{_bindir}/llvm-opt-fuzzer%{exec_suffix} +%endif + +%files -n %{pkg_name_llvm}-googletest +%license llvm/LICENSE.TXT +%{install_libdir}/libLLVMTestingSupport.a +%{install_libdir}/libLLVMTestingAnnotations.a +%{install_libdir}/libllvm_gtest.a +%{install_libdir}/libllvm_gtest_main.a +%{install_includedir}/llvm-gtest +%{install_includedir}/llvm-gmock + +%if %{with snapshot_build} +%files -n %{pkg_name_llvm}-build-stats +%{pkg_datadir}/.ninja_log +%endif + +#endregion LLVM files + +#region CLANG files + +%files -n %{pkg_name_clang} +%license clang/LICENSE.TXT +%{install_bindir}/clang +%{install_bindir}/clang++ +%{install_bindir}/clang-%{maj_ver} +%{install_bindir}/clang++-%{maj_ver} +%{install_bindir}/clang-cl +%{install_bindir}/clang-cpp +%{_mandir}/man1/clang-%{maj_ver}.1.gz +%{_mandir}/man1/clang++-%{maj_ver}.1.gz +%if %{with sys_llvm} +%{_mandir}/man1/clang.1.gz +%{_mandir}/man1/clang++.1.gz +%else +%{_bindir}/clang-%{maj_ver} +%{_bindir}/clang++-%{maj_ver} +%{_bindir}/clang-cl-%{maj_ver} +%{_bindir}/clang-cpp-%{maj_ver} +%endif + +%files -n %{pkg_name_clang}-libs +%license clang/LICENSE.TXT +%{install_libdir}/clang/%{maj_ver}/include/* +%{install_libdir}/libclang.so.%{maj_ver}* +%{install_libdir}/libclang-cpp.so.%{maj_ver}* + +%files -n %{pkg_name_clang}-devel +%license clang/LICENSE.TXT +%{install_libdir}/libclang-cpp.so +%{install_libdir}/libclang.so +%{install_includedir}/clang/ +%{install_includedir}/clang-c/ +%{install_libdir}/cmake/clang +%{install_bindir}/clang-tblgen +%if %{without sys_llvm} +%{_bindir}/clang-tblgen-%{maj_ver} +%endif +%dir %{install_datadir}/clang/ + +%files -n %{pkg_name_clang}-resource-filesystem +%license clang/LICENSE.TXT +%dir %{_libdir}/clang/ +%dir %{_libdir}/clang/%{maj_ver}/ +%dir %{_libdir}/clang/%{maj_ver}/bin/ +%dir %{_libdir}/clang/%{maj_ver}/include/ +%dir %{_libdir}/clang/%{maj_ver}/lib/ +%dir %{_libdir}/clang/%{maj_ver}/share/ + +%files -n %{pkg_name_clang}-analyzer +%license clang/LICENSE.TXT +%{install_bindir}/scan-view +%{install_bindir}/scan-build +%{install_bindir}/analyze-build +%{install_bindir}/intercept-build +%{install_bindir}/scan-build-py +%if %{without sys_llvm} +%{_bindir}/scan-view-%{maj_ver} +%{_bindir}/scan-build-%{maj_ver} +%{_bindir}/analyze-build-%{maj_ver} +%{_bindir}/intercept-build-%{maj_ver} +%{_bindir}/scan-build-py-%{maj_ver} +%endif +%{install_libexecdir}/ccc-analyzer +%{install_libexecdir}/c++-analyzer +%{install_libexecdir}/analyze-c++ +%{install_libexecdir}/analyze-cc +%{install_libexecdir}/intercept-c++ +%{install_libexecdir}/intercept-cc +%{install_datadir}/scan-view/ +%{install_datadir}/scan-build/ +%{_mandir}/man1/scan-build%{exec_suffix}.1.* +%if %{with sys_llvm} +%{python3_sitelib}/libear +%{python3_sitelib}/libscanbuild +%endif + +%files -n %{pkg_name_clang}-tools-extra +%license clang-tools-extra/LICENSE.TXT +%{install_bindir}/amdgpu-arch +%{install_bindir}/clang-apply-replacements +%{install_bindir}/clang-change-namespace +%{install_bindir}/clang-check +%{install_bindir}/clang-doc +%{install_bindir}/clang-extdef-mapping +%{install_bindir}/clang-format +%{install_bindir}/clang-include-cleaner +%{install_bindir}/clang-include-fixer +%{install_bindir}/clang-move +%{install_bindir}/clang-offload-bundler +%{install_bindir}/clang-offload-packager +%{install_bindir}/clang-linker-wrapper +%{install_bindir}/clang-query +%{install_bindir}/clang-refactor +%{install_bindir}/clang-reorder-fields +%{install_bindir}/clang-repl +%{install_bindir}/clang-scan-deps +%if %{maj_ver} >= 20 +%{install_bindir}/clang-sycl-linker +%endif +%{install_bindir}/clang-tidy +%{install_bindir}/clangd +%{install_bindir}/diagtool +%{install_bindir}/hmaptool +%{install_bindir}/nvptx-arch +%{install_bindir}/pp-trace +%{install_bindir}/c-index-test +%{install_bindir}/find-all-symbols +%{install_bindir}/modularize +%{install_bindir}/clang-format-diff +%{install_bindir}/run-clang-tidy +%if %{maj_ver} < 20 +%{install_bindir}/clang-pseudo +%{install_bindir}/clang-rename +%endif +%if %{without sys_llvm} +%{_bindir}/amdgpu-arch-%{maj_ver} +%{_bindir}/clang-apply-replacements-%{maj_ver} +%{_bindir}/clang-change-namespace-%{maj_ver} +%{_bindir}/clang-check-%{maj_ver} +%{_bindir}/clang-doc-%{maj_ver} +%{_bindir}/clang-extdef-mapping-%{maj_ver} +%{_bindir}/clang-format-%{maj_ver} +%{_bindir}/clang-include-cleaner-%{maj_ver} +%{_bindir}/clang-include-fixer-%{maj_ver} +%{_bindir}/clang-move-%{maj_ver} +%{_bindir}/clang-offload-bundler-%{maj_ver} +%{_bindir}/clang-offload-packager-%{maj_ver} +%{_bindir}/clang-linker-wrapper-%{maj_ver} +%{_bindir}/clang-query-%{maj_ver} +%{_bindir}/clang-refactor-%{maj_ver} +%{_bindir}/clang-reorder-fields-%{maj_ver} +%{_bindir}/clang-repl-%{maj_ver} +%{_bindir}/clang-scan-deps-%{maj_ver} +%if %{maj_ver} >= 20 +%{_bindir}/clang-sycl-linker-%{maj_ver} +%endif +%{_bindir}/clang-tidy-%{maj_ver} +%{_bindir}/clangd-%{maj_ver} +%{_bindir}/diagtool-%{maj_ver} +%{_bindir}/hmaptool-%{maj_ver} +%{_bindir}/nvptx-arch-%{maj_ver} +%{_bindir}/pp-trace-%{maj_ver} +%{_bindir}/c-index-test-%{maj_ver} +%{_bindir}/find-all-symbols-%{maj_ver} +%{_bindir}/modularize-%{maj_ver} +%{_bindir}/clang-format-diff-%{maj_ver} +%{_bindir}/run-clang-tidy-%{maj_ver} +%if %{maj_ver} < 20 +%{_bindir}/clang-pseudo-%{maj_ver} +%{_bindir}/clang-rename-%{maj_ver} +%endif +%else +%{_emacs_sitestartdir}/clang-format.el +%if %{maj_ver} < 20 +%{_emacs_sitestartdir}/clang-rename.el +%endif +%{_emacs_sitestartdir}/clang-include-fixer.el +%endif +%{_mandir}/man1/diagtool%{exec_suffix}.1.gz +%{_mandir}/man1/extraclangtools%{exec_suffix}.1.gz +%{install_datadir}/clang/clang-format.py* +%{install_datadir}/clang/clang-format-diff.py* +%{install_datadir}/clang/clang-include-fixer.py* +%{install_datadir}/clang/clang-tidy-diff.py* +%{install_datadir}/clang/run-find-all-symbols.py* +%if %{maj_ver} < 20 +%{install_datadir}/clang/clang-rename.py* +%endif + +%files -n %{pkg_name_clang}-tools-extra-devel +%license clang-tools-extra/LICENSE.TXT +%{install_includedir}/clang-tidy/ + +%files -n %{?scl_prefix}git-clang-format%{pkg_suffix} +%license clang/LICENSE.TXT +%{install_bindir}/git-clang-format +%if %{without sys_llvm} +%{_bindir}/git-clang-format-%{maj_ver} +%endif + +%if %{with sys_llvm} +%files -n python%{python3_pkgversion}-clang +%license clang/LICENSE.TXT +%{python3_sitelib}/clang/ +%endif + +#endregion CLANG files + +#region COMPILER-RT files + +%files -n %{pkg_name_compiler_rt} +%license compiler-rt/LICENSE.TXT +%ifarch x86_64 aarch64 riscv64 +%{install_libdir}/clang/%{maj_ver}/bin/hwasan_symbolize +%endif +%{install_libdir}/clang/%{maj_ver}/include/fuzzer +%{install_libdir}/clang/%{maj_ver}/include/orc +%{install_libdir}/clang/%{maj_ver}/include/profile +%{install_libdir}/clang/%{maj_ver}/include/sanitizer +%{install_libdir}/clang/%{maj_ver}/include/xray + +%{install_libdir}/clang/%{maj_ver}/share/*.txt + +# Files that appear on all targets +%{install_libdir}/clang/%{maj_ver}/lib/%{compiler_rt_triple}/libclang_rt.* + +%ifnarch s390x +%{install_libdir}/clang/%{maj_ver}/lib/%{compiler_rt_triple}/clang_rt.crtbegin.o +%{install_libdir}/clang/%{maj_ver}/lib/%{compiler_rt_triple}/clang_rt.crtend.o +%endif + +%ifnarch %{ix86} s390x +%{install_libdir}/clang/%{maj_ver}/lib/%{compiler_rt_triple}/liborc_rt.a +%endif + +# Additional symlink if two triples are in use. +%if "%{llvm_triple}" != "%{compiler_rt_triple}" +%{install_libdir}/clang/%{maj_ver}/lib/%{llvm_triple} +%endif + +#endregion COMPILER-RT files + +#region OPENMP files + +%files -n %{pkg_name_libomp} +%license openmp/LICENSE.TXT +%{install_libdir}/libomp.so +%{install_libdir}/libompd.so +%{install_libdir}/libarcher.so +%ifnarch %{ix86} %{arm} riscv64 loongarch64 +# libomptarget is not supported on 32-bit systems. +# s390x does not support the offloading plugins. +%if %{maj_ver} >= 20 +%{install_libdir}/libLLVMOffload.so.%{so_suffix} +%endif +%if %{maj_ver} >= 18 +%{install_libdir}/libomptarget.rtl.amdgpu.so.%{so_suffix} +%{install_libdir}/libomptarget.rtl.cuda.so.%{so_suffix} +%{install_libdir}/libomptarget.rtl.%{libomp_arch}.so.%{so_suffix} +%else +%{install_libdir}/libomptarget.rtl.amdgpu.so.%{maj_ver} +%{install_libdir}/libomptarget.rtl.cuda.so.%{maj_ver} +%{install_libdir}/libomptarget.rtl.%{libomp_arch}.so.%{maj_ver} +%endif +%endif +%if %{maj_ver} >= 18 +%{install_libdir}/libomptarget.so.%{so_suffix} +%else +%{install_libdir}/libomptarget.so.%{maj_ver} +%endif + +%files -n %{pkg_name_libomp}-devel +%license openmp/LICENSE.TXT +%{install_libdir}/clang/%{maj_ver}/include/omp.h +%if %{maj_ver} >= 18 +%{install_libdir}/clang/%{maj_ver}/include/ompx.h +%endif +%{install_libdir}/clang/%{maj_ver}/include/omp-tools.h +%{install_libdir}/clang/%{maj_ver}/include/ompt.h +%{install_libdir}/clang/%{maj_ver}/include/ompt-multiplex.h +%{install_libdir}/cmake/openmp/ +%ifnarch %{ix86} +# libomptarget is not supported on 32-bit systems. +# s390x does not support the offloading plugins. +%ifnarch riscv64 +%{install_libdir}/libomptarget.rtl.amdgpu.so +%{install_libdir}/libomptarget.rtl.cuda.so +%{install_libdir}/libomptarget.rtl.%{libomp_arch}.so +%endif +%{install_libdir}/libomptarget.devicertl.a +%{install_libdir}/libomptarget-amdgpu-*.bc +%{install_libdir}/libomptarget-nvptx-*.bc +%{install_libdir}/libomptarget.so +%if %{maj_ver} >= 20 +%{install_libdir}/libLLVMOffload.so +%{install_includedir}/offload +%endif +%endif + +#endregion OPENMP files + +#region LLD files + +%files -n %{pkg_name_lld} +%license lld/LICENSE.TXT +%ghost %{_bindir}/ld +%{install_bindir}/lld +%{install_bindir}/lld-link +%{install_bindir}/ld.lld +%{install_bindir}/ld64.lld +%{install_bindir}/wasm-ld +%if %{with sys_llvm} +%{_mandir}/man1/ld.lld.1* +%else +%{_bindir}/lld%{exec_suffix} +%{_bindir}/lld-link%{exec_suffix} +%{_bindir}/ld.lld%{exec_suffix} +%{_bindir}/ld64.lld%{exec_suffix} +%{_bindir}/wasm-ld%{exec_suffix} +%endif + +%files -n %{pkg_name_lld}-devel +%license lld/LICENSE.TXT +%{install_includedir}/lld +%{install_libdir}/liblldCOFF.so +%{install_libdir}/liblldCommon.so +%{install_libdir}/liblldELF.so +%{install_libdir}/liblldMachO.so +%{install_libdir}/liblldMinGW.so +%{install_libdir}/liblldWasm.so +%{install_libdir}/cmake/lld/ + +%files -n %{pkg_name_lld}-libs +%license lld/LICENSE.TXT +%{install_libdir}/liblldCOFF.so.* +%{install_libdir}/liblldCommon.so.* +%{install_libdir}/liblldELF.so.* +%{install_libdir}/liblldMachO.so.* +%{install_libdir}/liblldMinGW.so.* +%{install_libdir}/liblldWasm.so.* + +#endregion LLD files + +#region Toolset files +%if 0%{?rhel} +%files -n %{pkg_name_llvm}-toolset +%license LICENSE.TXT +%endif +#endregion Toolset files + +#region LLDB files +%if %{with lldb} +%files -n %{pkg_name_lldb} +%license lldb/LICENSE.TXT +%{install_bindir}/lldb* +%if %{without sys_llvm} +%{_bindir}/lldb* +%endif +# Usually, *.so symlinks are kept in devel subpackages. However, the python +# bindings depend on this symlink at runtime. +%{install_libdir}/liblldb*.so +%{install_libdir}/liblldb.so.* +%{install_libdir}/liblldbIntelFeatures.so.* +%{_mandir}/man1/lldb-server%{exec_suffix}.1.gz +%{_mandir}/man1/lldb%{exec_suffix}.1.gz +%if %{with bundle_compat_lib} +%{_libdir}/liblldb.so.%{compat_maj_ver}* +%endif + +%files -n %{pkg_name_lldb}-devel +%{install_includedir}/lldb + +%files -n %{?scl_prefix}python3-lldb +%{python3_sitearch}/lldb +%endif +#endregion LLDB files + +#region MLIR files +%if %{with mlir} +%files -n %{pkg_name_mlir} +%license LICENSE.TXT +%if %{maj_ver} >= 18 +%{install_libdir}/libmlir_arm_runner_utils.so.%{maj_ver}* +%{install_libdir}/libmlir_arm_sme_abi_stubs.so.%{maj_ver}* +%endif +%{install_libdir}/libmlir_async_runtime.so.%{maj_ver}* +%{install_libdir}/libmlir_c_runner_utils.so.%{maj_ver}* +%{install_libdir}/libmlir_float16_utils.so.%{maj_ver}* +%{install_libdir}/libmlir_runner_utils.so.%{maj_ver}* +%{install_libdir}/libMLIR*.so.%{maj_ver}* + +%files -n %{pkg_name_mlir}-static +%{install_libdir}/libMLIR*.a + +%files -n %{pkg_name_mlir}-devel +%{install_bindir}/mlir-cpu-runner +%{install_bindir}/mlir-linalg-ods-yaml-gen +%{install_bindir}/mlir-lsp-server +%{install_bindir}/mlir-opt +%{install_bindir}/mlir-pdll +%{install_bindir}/mlir-pdll-lsp-server +%{install_bindir}/mlir-reduce +%{install_bindir}/mlir-tblgen +%{install_bindir}/mlir-translate +%{install_bindir}/tblgen-lsp-server +%if %{maj_ver} >= 18 +%{install_bindir}/mlir-query +%{install_bindir}/tblgen-to-irdl +%endif +%if %{maj_ver} >= 20 +%{install_bindir}/mlir-rewrite +%endif +%if %{without sys_llvm} +%{_bindir}/mlir-tblgen-%{maj_ver} +%{_bindir}/mlir-pdll-%{maj_ver} +%{_bindir}/mlir-cpu-runner-%{maj_ver} +%{_bindir}/mlir-linalg-ods-yaml-gen-%{maj_ver} +%{_bindir}/mlir-lsp-server-%{maj_ver} +%{_bindir}/mlir-opt-%{maj_ver} +%{_bindir}/mlir-pdll-lsp-server-%{maj_ver} +%{_bindir}/tblgen-lsp-server-%{maj_ver} +%{_bindir}/mlir-reduce-%{maj_ver} +%{_bindir}/mlir-translate-%{maj_ver} +%if %{maj_ver} >= 18 +%{_bindir}/mlir-query-%{maj_ver} +%{_bindir}/tblgen-to-irdl-%{maj_ver} +%endif +%if %{maj_ver} >= 20 +%{_bindir}/mlir-rewrite-%{maj_ver} +%endif +%endif +%{install_includedir}/mlir +%{install_includedir}/mlir-c +%{install_libdir}/cmake/mlir +%if %{maj_ver} >= 18 +%{install_libdir}/libmlir_arm_runner_utils.so +%{install_libdir}/libmlir_arm_sme_abi_stubs.so +%endif +%{install_libdir}/libmlir_async_runtime.so +%{install_libdir}/libmlir_c_runner_utils.so +%{install_libdir}/libmlir_float16_utils.so +%{install_libdir}/libmlir_runner_utils.so +%{install_libdir}/libMLIR*.so + +%files -n %{?scl_prefix}python3-mlir +%{python3_sitearch}/mlir/ +%endif +#endregion MLIR files + +#region libcxx files +%if %{with libcxx} + +%files -n %{pkg_name_libcxx} +%license libcxx/LICENSE.TXT +%doc libcxx/CREDITS.TXT libcxx/TODO.TXT +%{install_libdir}/libc++.so.* + +%files -n %{pkg_name_libcxx}-devel +%{install_includedir}/c++/ +%exclude %{install_includedir}/c++/v1/cxxabi.h +%exclude %{install_includedir}/c++/v1/__cxxabi_config.h +%{install_libdir}/libc++.so + +%files -n %{pkg_name_libcxx}-static +%license libcxx/LICENSE.TXT +%{install_libdir}/libc++.a +%{install_libdir}/libc++experimental.a + +%files -n %{pkg_name_libcxxabi} +%license libcxxabi/LICENSE.TXT +%doc libcxxabi/CREDITS.TXT +%{install_libdir}/libc++abi.so.* + +%files -n %{pkg_name_libcxxabi}-devel +%{install_includedir}/c++/v1/cxxabi.h +%{install_includedir}/c++/v1/__cxxabi_config.h +%{install_libdir}/libc++abi.so + +%files -n %{pkg_name_libcxxabi}-static +%{install_libdir}/libc++abi.a + +%files -n %{pkg_name_llvm_libunwind} +%license libunwind/LICENSE.TXT +%{install_libdir}/libunwind.so.1 +%{install_libdir}/libunwind.so.1.0 + +%files -n %{pkg_name_llvm_libunwind}-devel +%{install_includedir}/llvm-libunwind/__libunwind_config.h +%{install_includedir}/llvm-libunwind/libunwind.h +%{install_includedir}/llvm-libunwind/libunwind.modulemap +%{install_includedir}/llvm-libunwind/mach-o/compact_unwind_encoding.h +%{install_includedir}/llvm-libunwind/mach-o/compact_unwind_encoding.modulemap +%{install_includedir}/llvm-libunwind/unwind.h +%{install_includedir}/llvm-libunwind/unwind_arm_ehabi.h +%{install_includedir}/llvm-libunwind/unwind_itanium.h +%dir %{install_libdir}/llvm-unwind +%{install_libdir}/llvm-unwind/libunwind.so + +%files -n %{pkg_name_llvm_libunwind}-static +%{install_libdir}/libunwind.a +%endif + +%files -n %{pkg_name_llvm_libunwind}-doc +%license libunwind/LICENSE.TXT +%doc %{_pkgdocdir}/html +#endregion libcxx files + +#endregion files + +%changelog +* Wed Feb 5 2025 liyunfei - 17.0.6-1 +- Package init \ No newline at end of file diff --git a/llvm-toolset-17.yaml b/llvm-toolset-17.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7d98bd835f0acc97da741f20f900a6ebae1512c5 --- /dev/null +++ b/llvm-toolset-17.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: llvm/llvm-project +tag_prefix: ^llvmorg- +seperator: .