summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2016-10-07 08:40:14 +0000
committerNicolai Haehnle <nhaehnle@gmail.com>2016-10-07 08:40:14 +0000
commit87bc4c218bb8aa0479c3775de451f2552ab4a8f1 (patch)
tree4b42e0fd6094e0276e5c6a67f2c3c086420af6b2 /llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp
parenta0016ec95faa172e00896a4c13396ae7d775d13b (diff)
downloadbcm5719-llvm-87bc4c218bb8aa0479c3775de451f2552ab4a8f1.tar.gz
bcm5719-llvm-87bc4c218bb8aa0479c3775de451f2552ab4a8f1.zip
AMDGPU: Fix use-after-free in SIOptimizeExecMasking
Summary: There was a bug with sequences like s_mov_b64 s[0:1], exec s_and_b64 s[2:3]<def>, s[0:1], s[2:3]<kill> ... s_mov_b64_term exec, s[2:3] because s[2:3] was defined and used in the same instruction, ending up with SaveExecInst inside OtherUseInsts. Note that the test case also exposes an unrelated bug. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98028 Reviewers: tstellarAMD, arsenm Subscribers: kzhuravl, wdng, yaxunl, llvm-commits, tony-tye Differential Revision: https://reviews.llvm.org/D25306 llvm-svn: 283528
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp b/llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp
index 32a0db7265e..4d2f917278e 100644
--- a/llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp
+++ b/llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp
@@ -248,14 +248,17 @@ bool SIOptimizeExecMasking::runOnMachineFunction(MachineFunction &MF) {
if (J->readsRegister(CopyFromExec, TRI)) {
SaveExecInst = &*J;
DEBUG(dbgs() << "Found save exec op: " << *SaveExecInst << '\n');
+ continue;
} else {
DEBUG(dbgs() << "Instruction does not read exec copy: " << *J << '\n');
break;
}
}
- if (SaveExecInst && J->readsRegister(CopyToExec, TRI))
+ if (SaveExecInst && J->readsRegister(CopyToExec, TRI)) {
+ assert(SaveExecInst != &*J);
OtherUseInsts.push_back(&*J);
+ }
}
if (!SaveExecInst)
OpenPOWER on IntegriCloud