]> granicus.if.org Git - llvm/commitdiff
[AMDGPU] Fix asan error after last commit
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Wed, 2 Aug 2017 01:18:57 +0000 (01:18 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Wed, 2 Aug 2017 01:18:57 +0000 (01:18 +0000)
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

lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp

index 156c51fcc9e8a0f8f74a97a02ceb95bf4d06c2c2..d54bde49e659c1dc737723e390b5ed8f80d044e7 100644 (file)
@@ -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;