[all-commits] [llvm/llvm-project] d51581: [RISCV][TableGen] Mark MachineInstr with FrameInde...

Piggy via All-commits all-commits at lists.llvm.org
Tue Aug 23 22:31:25 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d51581ff2c3ef5355a52a7445c1fe40fe83e5be0
      https://github.com/llvm/llvm-project/commit/d51581ff2c3ef5355a52a7445c1fe40fe83e5be0
  Author: ZHU Zijia <piggynl at outlook.com>
  Date:   2022-08-24 (Wed, 24 Aug 2022)

  Changed paths:
    M llvm/test/TableGen/AsmPredicateCombiningRISCV.td
    M llvm/utils/TableGen/CompressInstEmitter.cpp

  Log Message:
  -----------
  [RISCV][TableGen] Mark MachineInstr with FrameIndex as not compressible

If a MachineInstr's operand should be Reg in compiler's output but is
currently FrameIndex, `isCompressibleInst()` will terminate at
`MachineOperandType::getReg()`.

This patch adds `.isReg()` checks to make `isCompressibleInst()` return
false for these MachineInstr, allowing `getInstSizeInBytes()` to return
a value and `EstimateFunctionSizeInBytes()` to work as intended.

See https://reviews.llvm.org/D129999#3694222 for details.

Reviewed By: luismarques

Differential Revision: https://reviews.llvm.org/D129999


  Commit: 9c85382aded804ddf55aa0e5ed60a5cb9fb275fe
      https://github.com/llvm/llvm-project/commit/9c85382aded804ddf55aa0e5ed60a5cb9fb275fe
  Author: ZHU Zijia <piggynl at outlook.com>
  Date:   2022-08-24 (Wed, 24 Aug 2022)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
    M llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
    M llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h
    M llvm/test/CodeGen/RISCV/branch-relaxation.ll

  Log Message:
  -----------
  [RISCV] Handle register spill in branch relaxation

In branch relaxation pass, `j`'s with offset over 1MiB will be relaxed
to `jump` pseudo-instructions.

This patch allocates a stack slot for functions with a size greater than
1MiB. If the register scavenger cannot find a scratch register for
`jump`, spill a register to the slot before the jump and restore it
after the jump.

.mbb:
        foo
        j       .dest_bb
        bar
        bar
        bar
.dest_bb:
        baz

The above code will be relaxed to the following code.

.mbb:
        foo
        sd      s11, 0(sp)
        jump    .restore_bb, s11
        bar
        bar
        bar
        j       .dest_bb
.restore_bb:
        ld      s11, 0(sp)
.dest_bb:
        baz

Depends on D129999.

Reviewed By: StephenFan

Differential Revision: https://reviews.llvm.org/D130560


Compare: https://github.com/llvm/llvm-project/compare/ad714d5b7420...9c85382aded8


More information about the All-commits mailing list