diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2010-08-09 21:03:28 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2010-08-09 21:03:28 +0000 |
commit | f0067b668ca207d425b2aba9f4b6c3dc17f704e7 (patch) | |
tree | 5963a93e998739b499a6721de3c134044e46b006 | |
parent | 6d9f9feb2b60c3002b63f2c8ccee8fdf8c2c733b (diff) | |
download | bcm5719-llvm-f0067b668ca207d425b2aba9f4b6c3dc17f704e7.tar.gz bcm5719-llvm-f0067b668ca207d425b2aba9f4b6c3dc17f704e7.zip |
Fix a use after free error caught by the valgrind builders.
llvm-svn: 110601
-rw-r--r-- | llvm/lib/Transforms/IPO/MergeFunctions.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp index 0b36204fc57..d7075b9277d 100644 --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp @@ -559,7 +559,7 @@ void MergeFunctions::WriteThunk(Function *F, Function *G) const { } /// MergeTwoFunctions - Merge two equivalent functions. Upon completion, -/// FnVec[j] should never be visited again. +/// FnVec[j] is deleted but not removed from the vector. void MergeFunctions::MergeTwoFunctions(std::vector<Function *> &FnVec, unsigned i, unsigned j) const { Function *F = FnVec[i]; @@ -580,10 +580,12 @@ void MergeFunctions::MergeTwoFunctions(std::vector<Function *> &FnVec, H->takeName(F); F->replaceAllUsesWith(H); + unsigned MaxAlignment = std::max(G->getAlignment(), H->getAlignment()); + WriteThunk(F, G); WriteThunk(F, H); - F->setAlignment(std::max(G->getAlignment(), H->getAlignment())); + F->setAlignment(MaxAlignment); F->setLinkage(GlobalValue::InternalLinkage); } else { WriteThunk(F, G); |