[all-commits] [llvm/llvm-project] fb6153: [CodeGen] Fix ShrinkWrap crash when FindIDom recei...

陈子昂 via All-commits all-commits at lists.llvm.org
Wed Jun 3 03:08:31 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fb6153a65039b06319cb4b9ce2fafa84d75daa6b
      https://github.com/llvm/llvm-project/commit/fb6153a65039b06319cb4b9ce2fafa84d75daa6b
  Author: 陈子昂 <2802328816 at qq.com>
  Date:   2026-06-03 (Wed, 03 Jun 2026)

  Changed paths:
    M llvm/lib/CodeGen/ShrinkWrap.cpp
    A llvm/test/CodeGen/RISCV/shrinkwrap-save-restore-fixed-reg.ll

  Log Message:
  -----------
  [CodeGen] Fix ShrinkWrap crash when FindIDom receives empty predecessor/successor list (#198995)

When using `-msave-restore` with `-ffixed-x5` on RISC-V,
`canUseAsPrologue` returns false for all blocks because the save-restore
prologue requires t0 (x5) which is reserved. This causes the shrink-wrap
loop to keep searching for a valid save point, eventually reaching the
entry block. On the next iteration, it calls FindIDom with the entry
block's empty predecessor list, triggering an assertion in
findNearestCommonDominator.

Fix by returning nullptr from FindIDom when the block list is empty,
which signals the caller to stop searching and give up the optimization.

Fixes #166759



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list