[Sparc] Report correct size for GETPCX pseudo (#188075)

This currently reports size 4, but the actual size is larger.
This commit is contained in:
Nikita Popov 2026-03-24 15:40:49 +01:00 committed by GitHub
parent 0328820004
commit 4fcc3d7f4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -665,6 +665,22 @@ unsigned SparcInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
return getInlineAsmLength(AsmStr, *MF->getTarget().getMCAsmInfo());
}
if (MI.getOpcode() == SP::GETPCX) {
const TargetMachine &TM = MI.getParent()->getParent()->getTarget();
if (TM.isPositionIndependent())
return 16;
switch (TM.getCodeModel()) {
default:
llvm_unreachable("Unsupported absolute code model");
case CodeModel::Small:
return 8;
case CodeModel::Medium:
return 16;
case CodeModel::Large:
return 24;
}
}
// If the instruction has a delay slot, be conservative and also include
// it for sizing purposes. This is done so that the BranchRelaxation pass
// will not mistakenly mark out-of-range branches as in-range.