[llvm] 6ee6b19 - Make BPF stack size overridable
Eduard Zingerman via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 17 14:27:35 PDT 2023
Author: Niclas Hedam
Date: 2023-04-18T00:19:20+03:00
New Revision: 6ee6b197f5cd7a681e02e59edc43fb896c0d78b8
URL: https://github.com/llvm/llvm-project/commit/6ee6b197f5cd7a681e02e59edc43fb896c0d78b8
DIFF: https://github.com/llvm/llvm-project/commit/6ee6b197f5cd7a681e02e59edc43fb896c0d78b8.diff
LOG: Make BPF stack size overridable
With the emergence of TP 4091 for NVMe, eBPF can be used to offload programs to computational storage processors.
This change introduces the possibility of overriding the default stack size of 512 bytes for non-kernel runtime environments.
Reviewed By: yonghong-song, eddyz87
Differential Revision: https://reviews.llvm.org/D147707
Added:
Modified:
llvm/lib/Target/BPF/BPFRegisterInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/BPF/BPFRegisterInfo.cpp b/llvm/lib/Target/BPF/BPFRegisterInfo.cpp
index 9bd39fd285a0f..8761e4aa258c2 100644
--- a/llvm/lib/Target/BPF/BPFRegisterInfo.cpp
+++ b/llvm/lib/Target/BPF/BPFRegisterInfo.cpp
@@ -20,12 +20,18 @@
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/IR/DiagnosticInfo.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#define GET_REGINFO_TARGET_DESC
#include "BPFGenRegisterInfo.inc"
using namespace llvm;
+static cl::opt<int>
+ BPFStackSizeOption("bpf-stack-size",
+ cl::desc("Specify the BPF stack size limit"),
+ cl::init(512));
+
BPFRegisterInfo::BPFRegisterInfo()
: BPFGenRegisterInfo(BPF::R0) {}
@@ -43,13 +49,16 @@ BitVector BPFRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
static void WarnSize(int Offset, MachineFunction &MF, DebugLoc& DL)
{
- if (Offset <= -512) {
- const Function &F = MF.getFunction();
- DiagnosticInfoUnsupported DiagStackSize(F,
- "Looks like the BPF stack limit of 512 bytes is exceeded. "
- "Please move large on stack variables into BPF per-cpu array map.\n",
- DL);
- F.getContext().diagnose(DiagStackSize);
+ if (Offset <= -BPFStackSizeOption) {
+ const Function &F = MF.getFunction();
+ DiagnosticInfoUnsupported DiagStackSize(
+ F,
+ "Looks like the BPF stack limit is exceeded. "
+ "Please move large on stack variables into BPF per-cpu array map. For "
+ "non-kernel uses, the stack can be increased using -mllvm "
+ "-bpf-stack-size.\n",
+ DL);
+ F.getContext().diagnose(DiagStackSize);
}
}
More information about the llvm-commits
mailing list