summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineBlockPlacement.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-11-24 11:23:15 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-11-24 11:23:15 +0000
commit4aae4f90071f64854ec771496bd164149b0a1352 (patch)
treea79d236ff20fd5ee89e5e0081625f5780e9035af /lib/CodeGen/MachineBlockPlacement.cpp
parenta2deea1dcf8363f46bda8935283c5c701b5a278d (diff)
downloadllvm-4aae4f90071f64854ec771496bd164149b0a1352.tar.gz
llvm-4aae4f90071f64854ec771496bd164149b0a1352.tar.bz2
llvm-4aae4f90071f64854ec771496bd164149b0a1352.tar.xz
Fix a silly use-after-free issue. A much earlier version of this code
need lots of fanciness around retaining a reference to a Chain's slot in the BlockToChain map, but that's all gone now. We can just go directly to allocating the new chain (which will update the mapping for us) and using it. Somewhat gross mechanically generated test case replicates the issue Duncan spotted when actually testing this out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145120 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r--lib/CodeGen/MachineBlockPlacement.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/CodeGen/MachineBlockPlacement.cpp b/lib/CodeGen/MachineBlockPlacement.cpp
index 870e24884a..55d804b31e 100644
--- a/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/lib/CodeGen/MachineBlockPlacement.cpp
@@ -640,8 +640,8 @@ void MachineBlockPlacement::buildCFGChains(MachineFunction &F) {
SmallVector<MachineOperand, 4> Cond; // For AnalyzeBranch.
for (MachineFunction::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) {
MachineBasicBlock *BB = FI;
- BlockChain *&Chain = BlockToChain[BB];
- Chain = new (ChainAllocator.Allocate()) BlockChain(BlockToChain, BB);
+ BlockChain *Chain
+ = new (ChainAllocator.Allocate()) BlockChain(BlockToChain, BB);
// Also, merge any blocks which we cannot reason about and must preserve
// the exact fallthrough behavior for.
for (;;) {