Closed
Description
getInstSizeInBytes estimate the size of compressed instruction incorrectly because the instructions between the branchrelax source and target may be relaxed in assembler later. In such case, unconditional jump(J instr) would be kept to assembler without being handled in BranchRelax Pass. But in the end, target addresss of J instr is out of range.
unsigned RISCVInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
...
if (MI.getParent() && MI.getParent()->getParent()) {
if (isCompressibleInst(MI, STI))
return 2;
}
...
So it also needs to relax J/JAL in assembler to fix up the output of branchrelax process.