aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/MergeFunctions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/IPO/MergeFunctions.cpp')
-rw-r--r--lib/Transforms/IPO/MergeFunctions.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp
index 0b36204fc5..d7075b9277 100644
--- a/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/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);