mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-17 21:25:33 +00:00
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
This commit is contained in:
@@ -696,11 +696,24 @@ void MergeFunctions::Remove(Function *F) {
|
|||||||
// RemoveUsers - For each instruction used by the value, Remove() the function
|
// RemoveUsers - For each instruction used by the value, Remove() the function
|
||||||
// that contains the instruction. This should happen right before a call to RAUW.
|
// that contains the instruction. This should happen right before a call to RAUW.
|
||||||
void MergeFunctions::RemoveUsers(Value *V) {
|
void MergeFunctions::RemoveUsers(Value *V) {
|
||||||
for (Value::use_iterator UI = V->use_begin(), UE = V->use_end();
|
std::vector<Value *> Worklist;
|
||||||
UI != UE; ++UI) {
|
Worklist.push_back(V);
|
||||||
Use &U = UI.getUse();
|
while (!Worklist.empty()) {
|
||||||
if (Instruction *I = dyn_cast<Instruction>(U.getUser())) {
|
Value *V = Worklist.back();
|
||||||
Remove(I->getParent()->getParent());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user