[PATCH] D147707: Make BPF stack size overridable

Eduard Zingerman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 17 14:27:40 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ee6b197f5cd: Make BPF stack size overridable (authored by niclashedam, committed by eddyz87).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147707/new/

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 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 @@
 
 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.514407.patch
Type: text/x-patch
Size: 1652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230417/a081595b/attachment.bin>


More information about the llvm-commits mailing list