summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/MergeFunctions.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-01-02 19:16:44 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-01-02 19:16:44 +0000
commitd081b04f99de015519357ccaef29868c38c57d87 (patch)
treeefb4ec44bed63010dc335c42e67e6557f483e358 /lib/Transforms/IPO/MergeFunctions.cpp
parent62c50fdf69064c0d086aedfadb6ceb7c303bbcb9 (diff)
downloadllvm-d081b04f99de015519357ccaef29868c38c57d87.tar.gz
llvm-d081b04f99de015519357ccaef29868c38c57d87.tar.bz2
llvm-d081b04f99de015519357ccaef29868c38c57d87.tar.xz
Also remove functions that use complex constant expressions in terms of
another function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122705 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/MergeFunctions.cpp')
-rw-r--r--lib/Transforms/IPO/MergeFunctions.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp
index 74d4105151..c678db8590 100644
--- a/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/lib/Transforms/IPO/MergeFunctions.cpp
@@ -696,11 +696,24 @@ void MergeFunctions::Remove(Function *F) {
// RemoveUsers - For each instruction used by the value, Remove() the function
// that contains the instruction. This should happen right before a call to RAUW.
void MergeFunctions::RemoveUsers(Value *V) {
- for (Value::use_iterator UI = V->use_begin(), UE = V->use_end();
- UI != UE; ++UI) {
- Use &U = UI.getUse();
- if (Instruction *I = dyn_cast<Instruction>(U.getUser())) {
- Remove(I->getParent()->getParent());
+ std::vector<Value *> Worklist;
+ Worklist.push_back(V);
+ while (!Worklist.empty()) {
+ Value *V = Worklist.back();
+ Worklist.pop_back();
+
+ for (Value::use_iterator UI = V->use_begin(), UE = V->use_end();
+ UI != UE; ++UI) {
+ Use &U = UI.getUse();
+ if (Instruction *I = dyn_cast<Instruction>(U.getUser())) {
+ Remove(I->getParent()->getParent());
+ } else if (isa<GlobalValue>(U.getUser())) {
+ // do nothing
+ } else if (Constant *C = dyn_cast<Constant>(U.getUser())) {
+ for (Value::use_iterator CUI = C->use_begin(), CUE = C->use_end();
+ CUI != CUE; ++CUI)
+ Worklist.push_back(*CUI);
+ }
}
}
}