[all-commits] [llvm/llvm-project] f85c50: Pipe potentially invalid InstructionCost through C...

Philip Reames via All-commits all-commits at lists.llvm.org
Thu Jun 9 15:17:41 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f85c5079b8d093ed9867733fac2946e3a50ed039
      https://github.com/llvm/llvm-project/commit/f85c5079b8d093ed9867733fac2946e3a50ed039
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2022-06-09 (Thu, 09 Jun 2022)

  Changed paths:
    M llvm/include/llvm/Analysis/CodeMetrics.h
    M llvm/lib/Analysis/CodeMetrics.cpp
    M llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
    M llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
    M llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
    M llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
    M llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
    M llvm/test/Transforms/LoopRotate/RISCV/invalid-cost.ll

  Log Message:
  -----------
  Pipe potentially invalid InstructionCost through CodeMetrics

Per the documentation in Support/InstructionCost.h, the purpose of an invalid cost is so that clients can change behavior on impossible to cost inputs. CodeMetrics was instead asserting that invalid costs never occurred.

On a target with an incomplete cost model - e.g. RISCV - this means that transformations would crash on (falsely) invalid constructs - e.g. scalable vectors. While we certainly should improve the cost model - and I plan to do so in the near future - we also shouldn't be crashing. This violates the explicitly stated purpose of an invalid InstructionCost.

I updated all of the "easy" consumers where bailouts were locally obvious. I plan to follow up with loop unroll in a following change.

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




More information about the All-commits mailing list