[AMDGPU] Update LiveVariables in convertToThreeAddress()
authorRuiling Song <ruiling.song@amd.com>
Fri, 9 Oct 2020 01:26:19 +0000 (09:26 +0800)
committerRuiling Song <ruiling.song@amd.com>
Tue, 13 Oct 2020 00:12:20 +0000 (08:12 +0800)
commitb215a26628feae349d663f687efe475d622970b7
tree4dc934be841560efc19bff738285d112028d05da
parent7f8dc347c9552f339b4410b679d91bceb2cc456e
[AMDGPU] Update LiveVariables in convertToThreeAddress()

This can fix an asan failure like below.
==15856==ERROR: AddressSanitizer: use-after-poison on address ...
READ of size 8 at 0x6210001a3cb0 thread T0
    #0 llvm::MachineInstr::getParent()
    #1 llvm::LiveVariables::VarInfo::findKill()
    #2 TwoAddressInstructionPass::rescheduleMIBelowKill()
    #3 TwoAddressInstructionPass::tryInstructionTransform()
    #4 TwoAddressInstructionPass::runOnMachineFunction()

We need to update the Kills if we replace instructions. The Kills
may be later accessed within TwoAddressInstruction pass.

Differential Revision: https://reviews.llvm.org/D89092
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/test/CodeGen/AMDGPU/stale-livevar-in-twoaddr-pass.mir [new file with mode: 0644]