Skip to content

Commit

Permalink
[SOL] Bump stack frame size
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored and LucasSte committed Aug 19, 2024
1 parent 37daba6 commit db61ceb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/Target/BPF/BPFISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "BPFISelLowering.h"
#include "BPF.h"
#include "BPFRegisterInfo.h"
#include "BPFSubtarget.h"
#include "BPFTargetMachine.h"
#include "llvm/CodeGen/CallingConvLower.h"
Expand Down Expand Up @@ -388,7 +389,7 @@ SDValue BPFTargetLowering::LowerFormalArguments(

// Arguments relative to BPF::R5
unsigned reg = MF.addLiveIn(BPF::R5, &BPF::GPRRegClass);
SDValue Const = DAG.getConstant(2047 - VA.getLocMemOffset(), DL, MVT::i64);
SDValue Const = DAG.getConstant(FrameLength - VA.getLocMemOffset(), DL, MVT::i64);
SDValue SDV = DAG.getCopyFromReg(Chain, DL, reg, getPointerTy(MF.getDataLayout()));
SDV = DAG.getNode(ISD::SUB, DL, PtrVT, SDV, Const);
SDV = DAG.getLoad(LocVT, DL, Chain, SDV, MachinePointerInfo(), 0);
Expand Down Expand Up @@ -500,7 +501,7 @@ SDValue BPFTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
assert(VA.isMemLoc());

EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
SDValue Const = DAG.getConstant(2047 - VA.getLocMemOffset(), CLI.DL, MVT::i64);
SDValue Const = DAG.getConstant(FrameLength - VA.getLocMemOffset(), CLI.DL, MVT::i64);
SDValue PtrOff = DAG.getNode(ISD::SUB, CLI.DL, PtrVT, FramePtr, Const);
Chain = DAG.getStore(Chain, CLI.DL, Arg, PtrOff, MachinePointerInfo());
}
Expand Down
12 changes: 5 additions & 7 deletions llvm/lib/Target/BPF/BPFRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ BitVector BPFRegisterInfo::getReservedRegs(const MachineFunction &MF) const {

static void WarnSize(int Offset, MachineFunction &MF, DebugLoc& DL)
{
if (Offset <= -2048) {
const Function &F = MF.getFunction();
DiagnosticInfoUnsupported DiagStackSize(F,
"Looks like the BPF stack limit of 2048 bytes is exceeded. "
"Please move large on stack variables into BPF per-cpu array map.\n",
DL);
F.getContext().diagnose(DiagStackSize);
int MaxOffset = -1 * FrameLength;
if (Offset < MaxOffset) {
dbgs() << "Error: Function " << MF.getFunction().getName() << " Stack offset of " << Offset
<< " exceeded max offset of " << MaxOffset << " by "
<< -(Offset - MaxOffset) << " bytes, please minimize large stack variables\n";
}
}

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/BPF/BPFRegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#define GET_REGINFO_HEADER
#include "BPFGenRegisterInfo.inc"

static const unsigned FrameLength = 4096;

namespace llvm {

struct BPFRegisterInfo : public BPFGenRegisterInfo {
Expand Down

0 comments on commit db61ceb

Please sign in to comment.