[all-commits] [llvm/llvm-project] d58cc0: [RISCV] reorganize getFrameIndexReference to reduc...

Philip Reames via All-commits all-commits at lists.llvm.org
Thu May 26 09:45:19 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d58cc0839ee5935e649dbbc18c898a8e4bcd6724
      https://github.com/llvm/llvm-project/commit/d58cc0839ee5935e649dbbc18c898a8e4bcd6724
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2022-05-26 (Thu, 26 May 2022)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

  Log Message:
  -----------
  [RISCV] reorganize getFrameIndexReference to reduce code duplication [nfc]

This change reorganizes the majority of frame index resolution into a two strep process.

    Step 1 - Select which base register we're going to use.
    Step 2 - Compute the offset from that base register.

The key point is that this allows us to share the step 2 logic for the SP case. This reduces the code duplication, and (I think) makes the code much easier to follow.

I also went ahead and added assertions into phase 2 to catch errors where we select an illegal base pointer. In general, we can't index from a base register to a stack location if that requires crossing a variable and unknown region. In practice, we have two such cases: dynamic stack realign and var sized objects. Note that crossing the scalable region is fine since while variable, it's a known variability which can be expressed in the offset.

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




More information about the All-commits mailing list