[PATCH] D147707: Make BPF stack size overridable

Niclas Hedam via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 6 06:58:34 PDT 2023


niclashedam created this revision.
niclashedam added a reviewer: ast.
Herald added a subscriber: hiraditya.
Herald added a project: All.
niclashedam requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147707

Files:
  llvm/lib/Target/BPF/BPFRegisterInfo.cpp


Index: llvm/lib/Target/BPF/BPFRegisterInfo.cpp
===================================================================
--- llvm/lib/Target/BPF/BPFRegisterInfo.cpp
+++ 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 llvm::cl::opt<int>
+    BPFStackSizeOption("bpf-stack-size",
+                       llvm::cl::desc("Specify the BPF stack size limit"),
+                       llvm::cl::init(512));
+
 BPFRegisterInfo::BPFRegisterInfo()
     : BPFGenRegisterInfo(BPF::R0) {}
 
@@ -43,13 +49,16 @@
 
 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);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147707.511402.patch
Type: text/x-patch
Size: 1670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230406/90352b21/attachment-0001.bin>


More information about the llvm-commits mailing list