[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-10 Thread Raphael Moreira Zinsly via cfe-commits
rzinsly wrote: @topperc I opened a PR to fix it: https://github.com/llvm/llvm-project/pull/119451 But go ahead and push yours. https://github.com/llvm/llvm-project/pull/117612 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-10 Thread Raphael Moreira Zinsly via cfe-commits
rzinsly wrote: > > > @rzinsly do you need someone to commit this? > > > > > > Yes, please. > > Please turn off [Keep my email addresses > private](https://github.com/settings/emails) setting in your account. > Otherwise the commit will be from the github hidden email which we don't use > in

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-10 Thread Raphael Moreira Zinsly via cfe-commits
rzinsly wrote: > @rzinsly do you need someone to commit this? Yes, please. https://github.com/llvm/llvm-project/pull/117612 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-09 Thread Raphael Moreira Zinsly via cfe-commits
@@ -0,0 +1,208 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv64 -mattr=+m,+v -O2 < %s \ +; RUN: | FileCheck %s -check-prefix=RV64I rzinsly wrote: @lenary hi, is there anything else I should change?

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-05 Thread Raphael Moreira Zinsly via cfe-commits
@@ -0,0 +1,537 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv64 -mattr=+m -O2 < %s \ +; RUN: | FileCheck %s -check-prefix=RV64I +; RUN: llc -mtriple=riscv32 -mattr=+m -O2 < %s \ +; RUN: | FileCheck %s -check-prefix=

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-05 Thread Raphael Moreira Zinsly via cfe-commits
https://github.com/rzinsly updated https://github.com/llvm/llvm-project/pull/117612 >From f9c0f9c25c1fea047a7c0cc7b22889ed7c45afba Mon Sep 17 00:00:00 2001 From: Raphael Moreira Zinsly Date: Mon, 25 Nov 2024 14:51:35 -0300 Subject: [PATCH 1/2] [RISCV] Add initial stack clash protection Enable

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-05 Thread Raphael Moreira Zinsly via cfe-commits
https://github.com/rzinsly updated https://github.com/llvm/llvm-project/pull/117612 >From 9872154335da3b6f80c0ceb2d5756a99fb78df08 Mon Sep 17 00:00:00 2001 From: Raphael Moreira Zinsly Date: Mon, 25 Nov 2024 14:51:35 -0300 Subject: [PATCH 1/2] [RISCV] Add initial stack clash protection Enable

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-05 Thread Raphael Moreira Zinsly via cfe-commits
@@ -157,6 +159,9 @@ class RISCVMachineFunctionInfo : public MachineFunctionInfo { bool isVectorCall() const { return IsVectorCall; } void setIsVectorCall() { IsVectorCall = true; } + + bool hasStackProbing() const { return StackProbeSize != 0; } rzinsly

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-05 Thread Raphael Moreira Zinsly via cfe-commits
@@ -1910,3 +2023,72 @@ bool RISCVFrameLowering::isSupportedStackID(TargetStackID::Value ID) const { TargetStackID::Value RISCVFrameLowering::getStackIDForScalableVectors() const { return TargetStackID::ScalableVector; } + +// Synthesize the probe loop. +static void emitStack

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-05 Thread Raphael Moreira Zinsly via cfe-commits
@@ -580,25 +580,134 @@ static MCCFIInstruction createDefCFAOffset(const TargetRegisterInfo &TRI, Comment.str()); } +// Allocate stack space and probe it if necessary. void RISCVFrameLowering::allocateStack(MachineBasicBlock &MBB,

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-05 Thread Raphael Moreira Zinsly via cfe-commits
@@ -580,25 +580,134 @@ static MCCFIInstruction createDefCFAOffset(const TargetRegisterInfo &TRI, Comment.str()); } +// Allocate stack space and probe it if necessary. void RISCVFrameLowering::allocateStack(MachineBasicBlock &MBB,

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-04 Thread Raphael Moreira Zinsly via cfe-commits
rzinsly wrote: Rebased to fix the merge conflicts. https://github.com/llvm/llvm-project/pull/117612 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-04 Thread Raphael Moreira Zinsly via cfe-commits
https://github.com/rzinsly updated https://github.com/llvm/llvm-project/pull/117612 >From 708dce34f76fc361a2093459efd3b14705045f6f Mon Sep 17 00:00:00 2001 From: Raphael Moreira Zinsly Date: Mon, 25 Nov 2024 14:51:35 -0300 Subject: [PATCH 1/2] [RISCV] Add initial stack clash protection Enable

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-28 Thread Raphael Moreira Zinsly via cfe-commits
@@ -610,22 +610,134 @@ static MCCFIInstruction createDefCFAOffset(const TargetRegisterInfo &TRI, Comment.str()); } +// Allocate stack space and probe it if necessary. void RISCVFrameLowering::allocateStack(MachineBasicBlock &MBB,

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-28 Thread Raphael Moreira Zinsly via cfe-commits
https://github.com/rzinsly updated https://github.com/llvm/llvm-project/pull/117612 >From f6bb44ca2242623399eb0ea946f38399fed3807c Mon Sep 17 00:00:00 2001 From: Raphael Moreira Zinsly Date: Tue, 26 Nov 2024 16:40:37 -0300 Subject: [PATCH 1/3] [NFC][RISCV] Remove CFIIndex argument from RISCVFr

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-27 Thread Raphael Moreira Zinsly via cfe-commits
@@ -610,22 +610,134 @@ static MCCFIInstruction createDefCFAOffset(const TargetRegisterInfo &TRI, Comment.str()); } +// Allocate stack space and probe it if necessary. void RISCVFrameLowering::allocateStack(MachineBasicBlock &MBB,

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-27 Thread Raphael Moreira Zinsly via cfe-commits
https://github.com/rzinsly edited https://github.com/llvm/llvm-project/pull/117612 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-27 Thread Raphael Moreira Zinsly via cfe-commits
https://github.com/rzinsly updated https://github.com/llvm/llvm-project/pull/117612 >From f6bb44ca2242623399eb0ea946f38399fed3807c Mon Sep 17 00:00:00 2001 From: Raphael Moreira Zinsly Date: Tue, 26 Nov 2024 16:40:37 -0300 Subject: [PATCH 1/3] [NFC][RISCV] Remove CFIIndex argument from RISCVFr

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-26 Thread Raphael Moreira Zinsly via cfe-commits
@@ -0,0 +1,208 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv64 -mattr=+m,+v -O2 < %s \ +; RUN: | FileCheck %s -check-prefix=RV64I rzinsly wrote: It was an oversight on my part, fixed now. https://g

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-26 Thread Raphael Moreira Zinsly via cfe-commits
rzinsly wrote: @topperc thanks for the review, I followed your suggestions. https://github.com/llvm/llvm-project/pull/117612 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-26 Thread Raphael Moreira Zinsly via cfe-commits
@@ -610,22 +610,134 @@ static MCCFIInstruction createDefCFAOffset(const TargetRegisterInfo &TRI, Comment.str()); } +// Allocate stack space and probe it if necessary. void RISCVFrameLowering::allocateStack(MachineBasicBlock &MBB,

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-26 Thread Raphael Moreira Zinsly via cfe-commits
https://github.com/rzinsly updated https://github.com/llvm/llvm-project/pull/117612 >From f6bb44ca2242623399eb0ea946f38399fed3807c Mon Sep 17 00:00:00 2001 From: Raphael Moreira Zinsly Date: Tue, 26 Nov 2024 16:40:37 -0300 Subject: [PATCH 1/3] [NFC][RISCV] Remove CFIIndex argument from RISCVFr

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-25 Thread Raphael Moreira Zinsly via cfe-commits
https://github.com/rzinsly updated https://github.com/llvm/llvm-project/pull/117612 >From ca1c76549c09fe1f46dfcd369648d145069ef1fc Mon Sep 17 00:00:00 2001 From: Raphael Moreira Zinsly Date: Mon, 25 Nov 2024 14:51:35 -0300 Subject: [PATCH 1/2] [RISCV] Add initial stack clash protection Enable

[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-11-25 Thread Raphael Moreira Zinsly via cfe-commits
https://github.com/rzinsly created https://github.com/llvm/llvm-project/pull/117612 Enable `-fstack-clash-protection` for RISCV and stack probe for function prologues. We probe the stack by creating a loop that allocates and probe the stack in ProbeSize chunks. We emit an unrolled probe loop f