summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2016-03-25 18:33:16 +0000
committerJustin Bogner <mail@justinbogner.com>2016-03-25 18:33:16 +0000
commitf2a0d349a68cd6e3f94c34743b4adf1f1ce6730b (patch)
tree2120a896745b7db0c87cf3cdb53ee129e0c5c5e8
parent20e24193f3403f007c35e85d8ce9d7f5793ea078 (diff)
downloadbcm5719-llvm-f2a0d349a68cd6e3f94c34743b4adf1f1ce6730b.tar.gz
bcm5719-llvm-f2a0d349a68cd6e3f94c34743b4adf1f1ce6730b.zip
AMDGPU: Fix a use-after free and a missing break
We're erasing MI here, but then immediately using it again inside the `if`. This moves the erase after we're done using it. Doing that reveals a second problem though - this case is missing a break, so we fall through to the default and dereference MI again. This is obviously a bug, though I don't know how to write a test that triggers it - all we do in the error case is print some extra debug output. Both of these issue crash on lots of tests under ASAN with the recycling allocator changes from PR26808 applied. llvm-svn: 264442
-rw-r--r--llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp b/llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp
index bb4bda25470..434d5a9aacb 100644
--- a/llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp
+++ b/llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp
@@ -625,15 +625,16 @@ public:
case AMDGPU::RETURN: {
BuildMI(MBB, MI, MBB.findDebugLoc(MI), getHWInstrDesc(CF_END));
CfCount++;
- MI->eraseFromParent();
if (CfCount % 2) {
BuildMI(MBB, I, MBB.findDebugLoc(MI), TII->get(AMDGPU::PAD));
CfCount++;
}
+ MI->eraseFromParent();
for (unsigned i = 0, e = FetchClauses.size(); i < e; i++)
EmitFetchClause(I, FetchClauses[i], CfCount);
for (unsigned i = 0, e = AluClauses.size(); i < e; i++)
EmitALUClause(I, AluClauses[i], CfCount);
+ break;
}
default:
if (TII->isExport(MI->getOpcode())) {
OpenPOWER on IntegriCloud