From: Stanislav Mekhanoshin Date: Wed, 2 Aug 2017 01:18:57 +0000 (+0000) Subject: [AMDGPU] Fix asan error after last commit X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbd873dceb685962f5be9bb84c7fd1fb61f64530;p=llvm [AMDGPU] Fix asan error after last commit Previous change "Turn s_and_saveexec_b64 into s_and_b64 if result is unused" introduced asan use-after-poison error. Instruction was analyzed after eraseFromParent() calls. Move analysys higher than erase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309779 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp b/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp index 156c51fcc9e..d54bde49e65 100644 --- a/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp +++ b/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp @@ -138,6 +138,7 @@ bool SIOptimizeExecMaskingPreRA::runOnMachineFunction(MachineFunction &MF) { DEBUG(dbgs() << "Redundant EXEC = S_OR_B64 found: " << *Lead << '\n'); + auto SaveExec = getOrExecSource(*Lead, *TII, MRI); unsigned SaveExecReg = getOrNonExecReg(*Lead, *TII); LIS->RemoveMachineInstrFromMaps(*Lead); Lead->eraseFromParent(); @@ -150,7 +151,6 @@ bool SIOptimizeExecMaskingPreRA::runOnMachineFunction(MachineFunction &MF) { // If the only use of saved exec in the removed instruction is S_AND_B64 // fold the copy now. - auto SaveExec = getOrExecSource(*Lead, *TII, MRI); if (!SaveExec || !SaveExec->isFullCopy()) continue;