[all-commits] [llvm/llvm-project] 8669a9: [AMDGPU] Cope with SelectionDAG::UpdateNodeOperand...

Jay Foad via All-commits all-commits at lists.llvm.org
Fri Sep 8 08:16:17 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8669a9f93adb2d3d3ca44a0b0873000927762177
      https://github.com/llvm/llvm-project/commit/8669a9f93adb2d3d3ca44a0b0873000927762177
  Author: Jay Foad <jay.foad at amd.com>
  Date:   2023-09-08 (Fri, 08 Sep 2023)

  Changed paths:
    M llvm/lib/Target/AMDGPU/SIISelLowering.cpp
    A llvm/test/CodeGen/AMDGPU/adjust-writemask-cse.ll

  Log Message:
  -----------
  [AMDGPU] Cope with SelectionDAG::UpdateNodeOperands returning a different SDNode (#65765)

SITargetLowering::adjustWritemask calls SelectionDAG::UpdateNodeOperands
to update an EXTRACT_SUBREG node in-place to refer to a new IMAGE_LOAD
instruction, before we delete the old IMAGE_LOAD instruction. But in
UpdateNodeOperands can do CSE on the fly and return a different
EXTRACT_SUBREG node, so the original EXTRACT_SUBREG node would still
exist and would refer to the old deleted IMAGE_LOAD instruction. This
caused errors like:

t31: v3i32,ch = <<Deleted Node!>> # D:1
This target-independent node should have been selected!
UNREACHABLE executed at lib/CodeGen/SelectionDAG/InstrEmitter.cpp:1209!

Fix it by detecting the CSE case and replacing all uses of the original
EXTRACT_SUBREG node with the CSE'd one.

Recommit with a fix for a use-after-free bug in the first version of
this patch (#65340) which was caught by asan.




More information about the All-commits mailing list