[all-commits] [llvm/llvm-project] a8ca40: [LSR] Fix crash in Phi node with EHPad block

qcolombet via All-commits all-commits at lists.llvm.org
Fri Jan 14 18:53:49 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a8ca4046e22d79c0521df3e78924255362d2be4a
      https://github.com/llvm/llvm-project/commit/a8ca4046e22d79c0521df3e78924255362d2be4a
  Author: Quentin Colombet <qcolombet at apple.com>
  Date:   2022-01-14 (Fri, 14 Jan 2022)

  Changed paths:
    M llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    A llvm/test/Transforms/LoopStrengthReduce/phi_ehpad_ignore_sameval.ll

  Log Message:
  -----------
  [LSR] Fix crash in Phi node with EHPad block

This fixes a crash I observed in issue #48708 where the LSR
pass tries to insert an instruction in a basic block with only a
catchswitch statement in there. This happens because the Phi node
being evaluated assumes the same value for different basic blocks.

If the basic block associated with the incoming value of the operand
being evaluated has an EHPad terminator LSR skips optimizing it.
But if that incoming value can come from multiple different blocks
there can be some incoming basic blocks which are terminated in
an EHPad. If these are then rewritten in RewriteForPhi the ones
containing an EHPad terminator will hit the "Insertion point must
be a normal instruction" assert in AdjustInsertPositionForExpand.

This fix makes CollectLoopInvariantFixupsAndFormulae also ignore
cases where the same value has another incoming basic block with an
EHPad, same as it already does in case the primary value has one.

Patch by Lorenz Brun <lorenz at brun.one>

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




More information about the All-commits mailing list