[llvm-commits] [llvm] r110601 - /llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
Nick Lewycky
nicholas at mxc.ca
Mon Aug 9 14:03:28 PDT 2010
Author: nicholas
Date: Mon Aug 9 16:03:28 2010
New Revision: 110601
URL: http://llvm.org/viewvc/llvm-project?rev=110601&view=rev
Log:
Fix a use after free error caught by the valgrind builders.
Modified:
llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=110601&r1=110600&r2=110601&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Mon Aug 9 16:03:28 2010
@@ -559,7 +559,7 @@
}
/// 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 @@
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);
More information about the llvm-commits
mailing list