[all-commits] [llvm/llvm-project] b6a562: [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutati...

Björn Pettersson via All-commits all-commits at lists.llvm.org
Mon Aug 26 00:15:04 PDT 2024


  Branch: refs/heads/release/19.x
  Home:   https://github.com/llvm/llvm-project
  Commit: b6a562d90fa08543171bafbb9c897c03f6cf691f
      https://github.com/llvm/llvm-project/commit/b6a562d90fa08543171bafbb9c897c03f6cf691f
  Author: Björn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2024-08-26 (Mon, 26 Aug 2024)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    A llvm/test/CodeGen/AArch64/dag-combine-freeze.ll

  Log Message:
  -----------
  [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE (#104924)

In visitFREEZE we have been collecting a set/vector of
MaybePoisonOperands that later was iterated over, applying a freeze to
those operands. However, C-level fuzzy testing has discovered that the
recursiveness of ReplaceAllUsesOfValueWith may cause later operands in
the MaybePoisonOperands vector to be replaced when replacing an earlier
operand. That would then turn up as
   Assertion `N1.getOpcode() != ISD::DELETED_NODE &&
              "Operand is DELETED_NODE!"' failed.
failures when trying to freeze those later operands.

So we need to make sure that the vector with MaybePoisonOperands is
mutated as well when needed. Or as the solution used in this patch, make
sure to keep track of operand numbers that should be frozen instead of
having a vector of SDValues. And then we can refetch the operands while
iterating over operand numbers.

The problem was seen after adding SELECT_CC to the set of operations
including in "AllowMultipleMaybePoisonOperands". I'm not sure, but I
guess that this could happen for other operations as well for which we
allow multiple maybe poison operands.

(cherry picked from commit 278fc8efdf004a1959a31bb4c208df5ee733d5c8)



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