forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
Showing
2 changed files
with
99 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
llvm/test/CodeGen/AMDGPU/stale-livevar-in-twoaddr-pass.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# RUN: llc -march=amdgcn -mcpu=gfx900 -run-pass=livevars,phi-node-elimination,twoaddressinstruction -verify-machineinstrs -o - %s | FileCheck %s | ||
# This used to fail under ASAN enabled build because we didn't update LiveVariables in SIInstrInfo::convertToThreeAddress() | ||
# CHECK: _amdgpu_ps_main | ||
|
||
--- | ||
name: _amdgpu_ps_main | ||
alignment: 1 | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
liveins: $sgpr2, $vgpr2, $vgpr3 | ||
%0:vgpr_32 = COPY $vgpr3 | ||
%1:vgpr_32 = COPY $vgpr2 | ||
S_BRANCH %bb.3 | ||
bb.1: | ||
%2:vgpr_32 = V_MAC_F32_e32 0, %0, %1, implicit $mode, implicit $exec | ||
%3:vgpr_32 = V_MED3_F32 0, %1, 0, %2, 0, %2, 0, 0, implicit $mode, implicit $exec | ||
bb.2: | ||
%4:vgpr_32 = PHI %5, %bb.3, %3, %bb.1 | ||
SI_END_CF %6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
EXP_DONE 0, %4, %4, %4, %4, -1, 0, 15, implicit $exec | ||
S_ENDPGM 0 | ||
bb.3: | ||
successors: %bb.1, %bb.2 | ||
%5:vgpr_32 = V_MAC_F32_e32 0, %1, %0, implicit $mode, implicit $exec | ||
%7:vgpr_32 = V_CVT_I32_F32_e32 %5, implicit $mode, implicit $exec | ||
%8:sreg_64 = V_CMP_NE_U32_e64 1, %7, implicit $exec | ||
%6:sreg_64 = SI_IF %8, %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
S_BRANCH %bb.1 | ||
... |