[llvm] [clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-11-21 Thread Momchil Velikov via cfe-commits
@@ -1076,6 +1076,16 @@ void CodeGenModule::Release() { "sign-return-address-with-bkey", 1); } + if (Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be) { +auto *InlineAsm = llvm::MDString::get(TheModule.getContext(), "inli

[llvm] [clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-11-21 Thread Momchil Velikov via cfe-commits
@@ -9460,6 +9461,94 @@ bool AArch64InstrInfo::isReallyTriviallyReMaterializable( return TargetInstrInfo::isReallyTriviallyReMaterializable(MI); } +MachineBasicBlock::iterator +AArch64InstrInfo::insertStackProbingLoop(MachineBasicBlock::iterator MBBI, +

[llvm] [clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-11-21 Thread Momchil Velikov via cfe-commits
@@ -26262,3 +26262,37 @@ bool AArch64TargetLowering::preferScalarizeSplat(SDNode *N) const { } return true; } + +bool AArch64TargetLowering::hasInlineStackProbe( +const MachineFunction &MF) const { + // If the function specifically requests inline stack probes, emit t

[llvm] [clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-11-21 Thread Momchil Velikov via cfe-commits
@@ -9460,6 +9461,94 @@ bool AArch64InstrInfo::isReallyTriviallyReMaterializable( return TargetInstrInfo::isReallyTriviallyReMaterializable(MI); } +MachineBasicBlock::iterator +AArch64InstrInfo::insertStackProbingLoop(MachineBasicBlock::iterator MBBI, +

[llvm] [clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-11-21 Thread Momchil Velikov via cfe-commits
@@ -672,6 +673,74 @@ void AArch64FrameLowering::emitCalleeSavedSVERestores( emitCalleeSavedRestores(MBB, MBBI, true); } +void AArch64FrameLowering::allocateSVEStackSpace( +MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, +StackOffset AllocSize, StackOffset I

[llvm] [clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-11-21 Thread Momchil Velikov via cfe-commits
@@ -4052,3 +4193,192 @@ 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

[llvm] [clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-11-21 Thread Momchil Velikov via cfe-commits
@@ -1827,12 +1908,36 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &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. -

[llvm] [clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-11-21 Thread Momchil Velikov via cfe-commits
@@ -26262,3 +26262,37 @@ bool AArch64TargetLowering::preferScalarizeSplat(SDNode *N) const { } return true; } + +bool AArch64TargetLowering::hasInlineStackProbe( +const MachineFunction &MF) const { + // If the function specifically requests inline stack probes, emit t

[llvm] [clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-11-01 Thread Oskar Wirga via cfe-commits
@@ -688,6 +689,68 @@ void AArch64FrameLowering::emitCalleeSavedSVERestores( emitCalleeSavedRestores(MBB, MBBI, true); } +void AArch64FrameLowering::allocateSVEStackSpace( +MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, +StackOffset AllocSize, StackOffset I

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-26 Thread Oskar Wirga via cfe-commits
@@ -9460,6 +9461,94 @@ bool AArch64InstrInfo::isReallyTriviallyReMaterializable( return TargetInstrInfo::isReallyTriviallyReMaterializable(MI); } +MachineBasicBlock::iterator +AArch64InstrInfo::insertStackProbingLoop(MachineBasicBlock::iterator MBBI, +

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-26 Thread Momchil Velikov via cfe-commits
momchil-velikov wrote: > Apologies for still not being able to create a reproducible example I can > share but what I am seeing is the stack probe write overwriting the value at > the tip of the stack when I step debug execution: Can you spot a place where the probe instruction is *not* immedi

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-25 Thread Oskar Wirga via cfe-commits
oskarwirga wrote: Apologies for still not being able to create a reproducible example I can share but what I am seeing is the stack probe write overwriting the value at the tip of the stack when I step debug execution: ``` str xzr, [sp, #-0x10 {var_70}]! {0x0} ... sturx8, [x29, #-0x10

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-25 Thread Eli Friedman via cfe-commits
@@ -1076,6 +1076,16 @@ void CodeGenModule::Release() { "sign-return-address-with-bkey", 1); } + if (Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be) { +auto *InlineAsm = llvm::MDString::get(TheModule.getContext(), "inli

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-25 Thread Eli Friedman via cfe-commits
@@ -1757,46 +1826,55 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF, } } - StackOffset AllocateBefore = SVEStackSize, AllocateAfter = {}; + StackOffset SVECalleeSavedSize = {}, SVELocalsSize = SVEStackSize; MachineBasicBlock::iterator CalleeSavesBeg

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-25 Thread Eli Friedman via cfe-commits
@@ -1757,46 +1826,55 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF, } } - StackOffset AllocateBefore = SVEStackSize, AllocateAfter = {}; + StackOffset SVECalleeSavedSize = {}, SVELocalsSize = SVEStackSize; MachineBasicBlock::iterator CalleeSavesBeg

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-25 Thread Eli Friedman via cfe-commits
@@ -97,14 +97,45 @@ AArch64FunctionInfo::AArch64FunctionInfo(const Function &F, if (const auto *BTE = mdconst::extract_or_null( F.getParent()->getModuleFlag("branch-target-enforcement"))) BranchTargetEnforcement = BTE->getZExtValue(); -return; + } els

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-25 Thread Momchil Velikov via cfe-commits
momchil-velikov wrote: > I haven't been able to produce a minimal, sharable example as of yet, but I'm > encountering a runtime error associated with an inlined function where stack > probing is active. The error manifests as a null pointer dereference, > originating from a stack value that i

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-24 Thread Oskar Wirga via cfe-commits
oskarwirga wrote: > Upon function entry the caller guarantees that it has probed the stack (e.g. > performed a store) at some address [sp, #N], where0 <= N <= 1024. I haven't been able to produce a minimal, sharable example as of yet, but I'm encountering a runtime error associated with an inl

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-20 Thread Momchil Velikov via cfe-commits
momchil-velikov wrote: Ping? https://github.com/llvm/llvm-project/pull/66524 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [AArch64] Stack probing for function prologues (PR #66524)

2023-10-13 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 8d59fc5fd1599bd7153817d2af903ae9a6103343 7b66d75f43bfd4e52f48307e9fcc2992eefb8bdd --