Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions llvm/lib/Target/BPF/BPFRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ BitVector BPFRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
return Reserved;
}

static void WarnSize(int Offset, MachineFunction &MF, DebugLoc& DL)
{
static void WarnSize(int Offset, MachineFunction &MF, DebugLoc& DL,
MachineBasicBlock& MBB) {
if (Offset <= -BPFStackSizeOption) {
if (!DL)
/* try harder to get some debug loc */
for (auto &I : MBB)
if (I.getDebugLoc()) {
DL = I.getDebugLoc();
break;
}

const Function &F = MF.getFunction();
DiagnosticInfoUnsupported DiagStackSize(
F,
Expand All @@ -73,14 +81,6 @@ bool BPFRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
MachineFunction &MF = *MBB.getParent();
DebugLoc DL = MI.getDebugLoc();

if (!DL)
/* try harder to get some debug loc */
for (auto &I : MBB)
if (I.getDebugLoc()) {
DL = I.getDebugLoc();
break;
}

while (!MI.getOperand(i).isFI()) {
++i;
assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
Expand All @@ -93,7 +93,7 @@ bool BPFRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
if (MI.getOpcode() == BPF::MOV_rr) {
int Offset = MF.getFrameInfo().getObjectOffset(FrameIndex);

WarnSize(Offset, MF, DL);
WarnSize(Offset, MF, DL, MBB);
MI.getOperand(i).ChangeToRegister(FrameReg, false);
Register reg = MI.getOperand(i - 1).getReg();
BuildMI(MBB, ++II, DL, TII.get(BPF::ADD_ri), reg)
Expand All @@ -108,7 +108,7 @@ bool BPFRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
if (!isInt<32>(Offset))
llvm_unreachable("bug in frame offset");

WarnSize(Offset, MF, DL);
WarnSize(Offset, MF, DL, MBB);

if (MI.getOpcode() == BPF::FI_ri) {
// architecture does not really support FI_ri, replace it with
Expand Down