#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) {}
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);
}
}