[llvm] r260688 - [Hexagon] Handle out-of-range offsets in eliminateFrameIndex
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 12 08:27:23 PST 2016
Author: kparzysz
Date: Fri Feb 12 10:27:23 2016
New Revision: 260688
URL: http://llvm.org/viewvc/llvm-project?rev=260688&view=rev
Log:
[Hexagon] Handle out-of-range offsets in eliminateFrameIndex
Create a virtual register that will hold the actual address and use it
with the offset of 0 in the place of the original FI.
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonRegisterInfo.cpp
Modified: llvm/trunk/lib/Target/Hexagon/HexagonRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonRegisterInfo.cpp?rev=260688&r1=260687&r2=260688&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonRegisterInfo.cpp Fri Feb 12 10:27:23 2016
@@ -135,6 +135,7 @@ void HexagonRegisterInfo::eliminateFrame
int Offset = HFI.getFrameIndexReference(MF, FI, BP);
// Add the offset from the instruction.
int RealOffset = Offset + MI.getOperand(FIOp+1).getImm();
+ bool IsKill = false;
unsigned Opc = MI.getOpcode();
switch (Opc) {
@@ -149,20 +150,22 @@ void HexagonRegisterInfo::eliminateFrame
break;
}
- if (HII.isValidOffset(Opc, RealOffset)) {
- MI.getOperand(FIOp).ChangeToRegister(BP, false);
- MI.getOperand(FIOp+1).ChangeToImmediate(RealOffset);
- return;
+ if (!HII.isValidOffset(Opc, RealOffset)) {
+ // If the offset is not valid, calculate the address in a temporary
+ // register and use it with offset 0.
+ auto &MRI = MF.getRegInfo();
+ unsigned TmpR = MRI.createVirtualRegister(&Hexagon::IntRegsRegClass);
+ DebugLoc DL = MI.getDebugLoc();
+ BuildMI(MB, II, DL, HII.get(Hexagon::A2_addi), TmpR)
+ .addReg(BP)
+ .addImm(RealOffset);
+ BP = TmpR;
+ RealOffset = 0;
+ IsKill = true;
}
-#ifndef NDEBUG
- const Function *F = MF.getFunction();
- dbgs() << "In function ";
- if (F) dbgs() << F->getName();
- else dbgs() << "<?>";
- dbgs() << ", BB#" << MB.getNumber() << "\n" << MI;
-#endif
- llvm_unreachable("Unhandled instruction");
+ MI.getOperand(FIOp).ChangeToRegister(BP, false, false, IsKill);
+ MI.getOperand(FIOp+1).ChangeToImmediate(RealOffset);
}
More information about the llvm-commits
mailing list