diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-01-02 19:16:44 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-01-02 19:16:44 +0000 |
commit | 5361b841848e8f4851ed9a6f935f31276e89d263 (patch) | |
tree | 7da773369b5ade663d8e683971a22147a7b39e16 /llvm/lib/Transforms/IPO/MergeFunctions.cpp | |
parent | 8455b6e45ef29d2c268ab595bff016f10f62829c (diff) | |
download | bcm5719-llvm-5361b841848e8f4851ed9a6f935f31276e89d263.tar.gz bcm5719-llvm-5361b841848e8f4851ed9a6f935f31276e89d263.zip |
Also remove functions that use complex constant expressions in terms of
another function.
llvm-svn: 122705
Diffstat (limited to 'llvm/lib/Transforms/IPO/MergeFunctions.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/MergeFunctions.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp index 74d41051516..c678db85900 100644 --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/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); + } } } } |