[PATCH] D147707: Make BPF stack size overridable

Niclas Hedam via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 9 08:06:56 PDT 2023


niclashedam updated this revision to Diff 512013.
niclashedam added a comment.

Sorry for the revision spam.
It looks like using an unsigned integer had adverse effects on the tests. I am reverting to signed integers but keeping the namespace change.


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


More information about the llvm-commits mailing list