Skip to content

[RISCV] [Relax] J instr is not relaxed to auipc + jalr in RISCVAsmBackend which is not handled before in BranchRelax Pass #95516

Closed
@zixuan-wu

Description

@zixuan-wu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorclang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions