[all-commits] [llvm/llvm-project] fd9373: [RISCV] Replace untested code with assert

Fraser Cormack via All-commits all-commits at lists.llvm.org
Tue May 24 21:14:27 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fd937366579e68e4413cda13b1b78a74b234be81
      https://github.com/llvm/llvm-project/commit/fd937366579e68e4413cda13b1b78a74b234be81
  Author: Fraser Cormack <fraser at codeplay.com>
  Date:   2022-05-25 (Wed, 25 May 2022)

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

  Log Message:
  -----------
  [RISCV] Replace untested code with assert

We found untested code where negative frame indices were ostensibly
handled despite it being in a block guarded by !MFI.isFixedObjectIndex.

While the implementation of MachineFrameInfo::isFixedObjectIndex
suggests this is possible (i.e., if a frame index was more negative - less than the
number of fixed objects), I couldn't find any test in tree -- for any
target -- where a negative frame index wasn't also a fixed object
offset. I couldn't find a way of creating such a object with the
public MachineFrameInfo creation APIs. Even
MachineFrameInfo::getObjectIndexBegin starts counting at the negative
number of fixed objects, so such frame indices wouldn't be covered by
loops using the provided begin/end methods.

Given all this, an assert that any object encountered in the block is
non-negative seems reasonable.

Reviewed By: StephenFan, kito-cheng

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




More information about the All-commits mailing list