Skip to content

Commit deb73a2

Browse files
committed
[AArch64][GlobalISel] Constrain the right MOs when lowering calls.
This was constraining the stale Info.Callee MO instead of the one we copied into the MI. In addition, with c8b8c8e, when there's an attachedcall, the Callee is at position 1 rather than 0. Differential Revision: https://reviews.llvm.org/D120161
1 parent 6438783 commit deb73a2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,10 +1059,10 @@ bool AArch64CallLowering::lowerTailCall(
10591059

10601060
// If Callee is a reg, since it is used by a target specific instruction,
10611061
// it must have a register class matching the constraint of that instruction.
1062-
if (Info.Callee.isReg())
1062+
if (MIB->getOperand(0).isReg())
10631063
constrainOperandRegClass(MF, *TRI, MRI, *MF.getSubtarget().getInstrInfo(),
10641064
*MF.getSubtarget().getRegBankInfo(), *MIB,
1065-
MIB->getDesc(), Info.Callee, 0);
1065+
MIB->getDesc(), MIB->getOperand(0), 0);
10661066

10671067
MF.getFrameInfo().setHasTailCall();
10681068
Info.LoweredTailCall = true;
@@ -1139,12 +1139,16 @@ bool AArch64CallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
11391139
Opc = getCallOpcode(MF, Info.Callee.isReg(), false);
11401140

11411141
auto MIB = MIRBuilder.buildInstrNoInsert(Opc);
1142+
unsigned CalleeOpNo = 0;
1143+
11421144
if (Opc == AArch64::BLR_RVMARKER) {
11431145
// Add a target global address for the retainRV/claimRV runtime function
11441146
// just before the call target.
11451147
Function *ARCFn = *objcarc::getAttachedARCFunction(Info.CB);
11461148
MIB.addGlobalAddress(ARCFn);
1149+
++CalleeOpNo;
11471150
}
1151+
11481152
MIB.add(Info.Callee);
11491153

11501154
// Tell the call which registers are clobbered.
@@ -1175,10 +1179,10 @@ bool AArch64CallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
11751179
// If Callee is a reg, since it is used by a target specific
11761180
// instruction, it must have a register class matching the
11771181
// constraint of that instruction.
1178-
if (Info.Callee.isReg())
1182+
if (MIB->getOperand(CalleeOpNo).isReg())
11791183
constrainOperandRegClass(MF, *TRI, MRI, *Subtarget.getInstrInfo(),
11801184
*Subtarget.getRegBankInfo(), *MIB, MIB->getDesc(),
1181-
Info.Callee, 0);
1185+
MIB->getOperand(CalleeOpNo), CalleeOpNo);
11821186

11831187
// Finally we can copy the returned value back into its virtual-register. In
11841188
// symmetry with the arguments, the physical register must be an

0 commit comments

Comments
 (0)