[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 Craig Topper via cfe-commits
topperc wrote: I should have a fix for the buildbot failure in a few minutes 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-10 Thread LLVM Continuous Integration via cfe-commits
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-clang-x86_64-expensive-checks-debian` running on `gribozavr4` while building `clang,llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/1

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

2024-12-10 Thread Sam Elliott via cfe-commits
https://github.com/lenary closed 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-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 Sam Elliott via cfe-commits
lenary 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 LLVM. See [LLVM Disc

[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 Craig Topper via cfe-commits
topperc wrote: @rzinsly do you need someone to commit this? 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 Sam Elliott via cfe-commits
https://github.com/lenary approved this pull request. LGTM 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 Craig Topper via cfe-commits
https://github.com/topperc approved this pull request. LGTM 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-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 Craig Topper 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 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 Craig Topper 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
@@ -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 Craig Topper via cfe-commits
topperc wrote: > @topperc thanks for the review, I followed your suggestions. Yes. Our github configuration will only allow PRs to "squash and merge" so the separate commit won't survive. https://github.com/llvm/llvm-project/pull/117612 ___ cfe-commi

[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 Craig Topper via cfe-commits
@@ -22156,3 +22156,25 @@ namespace llvm::RISCVVIntrinsicsTable { #include "RISCVGenSearchableTables.inc" } // namespace llvm::RISCVVIntrinsicsTable + +bool RISCVTargetLowering::hasInlineStackProbe(const MachineFunction &MF) const { + + // If the function specifically request

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

2024-11-25 Thread Craig Topper via cfe-commits
@@ -26,6 +27,35 @@ MachineFunctionInfo *RISCVMachineFunctionInfo::clone( return DestMF.cloneInfo(*this); } +RISCVMachineFunctionInfo::RISCVMachineFunctionInfo(const Function &F, + const RISCVSubtarget *STI) { + + // The defa

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

2024-11-25 Thread Craig Topper via cfe-commits
https://github.com/topperc deleted 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-25 Thread Craig Topper via cfe-commits
@@ -26,6 +27,35 @@ MachineFunctionInfo *RISCVMachineFunctionInfo::clone( return DestMF.cloneInfo(*this); } +RISCVMachineFunctionInfo::RISCVMachineFunctionInfo(const Function &F, + const RISCVSubtarget *STI) { + + // The defa

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

2024-11-25 Thread Craig Topper via cfe-commits
@@ -1939,3 +2049,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-11-25 Thread Craig Topper 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-25 Thread Craig Topper via cfe-commits
@@ -22156,3 +22156,25 @@ namespace llvm::RISCVVIntrinsicsTable { #include "RISCVGenSearchableTables.inc" } // namespace llvm::RISCVVIntrinsicsTable + +bool RISCVTargetLowering::hasInlineStackProbe(const MachineFunction &MF) const { + + // If the function specifically request

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

2024-11-25 Thread Craig Topper 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-25 Thread Sam Elliott 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 lenary wrote: Why is this only testing rv64? https://github.com/ll

[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 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 7ad1084b521ea191245c47b4e63e4f97035e3786 118415f00f96ffd005da8dddc5e776cb78c45f9f --e

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

2024-11-25 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-backend-risc-v Author: Raphael Moreira Zinsly (rzinsly) Changes 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

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

2024-11-25 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Raphael Moreira Zinsly (rzinsly) Changes 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 Pro

[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