Skip to content

Commit de6ed3c

Browse files
authored
[PowerPC] Fix some instruction sizes (llvm#188227)
This fixes: * PADDIdtprel: Lowers to PADDI8, which is prefixed. * PATCHABLE_FUNTION_ENTER/PATCHABLE_RET: Handle xray sleds. These came up when generalizing the instruction size verification infrastructure.
1 parent ce44d63 commit de6ed3c

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

llvm/lib/Target/PowerPC/PPCInstr64Bit.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,7 @@ def ADDIdtprelL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm
16191619
[(set i64:$rD,
16201620
(PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
16211621
isPPC64;
1622+
let Size = 8 in
16221623
def PADDIdtprel : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
16231624
"#PADDIdtprel",
16241625
[(set i64:$rD,

llvm/lib/Target/PowerPC/PPCInstrInfo.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3027,7 +3027,17 @@ unsigned PPCInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
30273027
(void)F.getFnAttribute("patchable-function-entry")
30283028
.getValueAsString()
30293029
.getAsInteger(10, Num);
3030-
return Num * 4;
3030+
if (Num || MF->getTarget().getTargetTriple().isOSAIX() ||
3031+
!MF->getTarget().getTargetTriple().isLittleEndian())
3032+
return Num * 4;
3033+
// Size of xray sled.
3034+
return 7 * 4;
3035+
}
3036+
case TargetOpcode::PATCHABLE_RET: {
3037+
// Size of xray sled.
3038+
unsigned RetOpcode = MI.getOperand(0).getImm();
3039+
bool IsConditional = RetOpcode == PPC::BCCLR;
3040+
return (8 + IsConditional) * 4;
30313041
}
30323042
default:
30333043
return get(Opcode).getSize();

0 commit comments

Comments
 (0)