diff options
author | Chris Lattner <sabre@nondot.org> | 2003-07-23 22:03:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-07-23 22:03:18 +0000 |
commit | 1078d1185400cb0f7a6e7971346e3534d8d9ff72 (patch) | |
tree | e2adfe9f47d5749e4a205912efc576d8de700749 /lib/Transforms/IPO/FunctionResolution.cpp | |
parent | a99d4f2975440934236f0d076b23999926f34709 (diff) |
Fix bug: FunctionResolve/2003-07-23-CPR-Reference.ll
This fixes a long time annoyance which caused prototypes for bzero, bcopy,
bcmp, fputs, and fputs_unlocked to never get deleted. Grr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/FunctionResolution.cpp')
-rw-r--r-- | lib/Transforms/IPO/FunctionResolution.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp index 8acddf5900..86352d46a8 100644 --- a/lib/Transforms/IPO/FunctionResolution.cpp +++ b/lib/Transforms/IPO/FunctionResolution.cpp @@ -80,12 +80,14 @@ static bool ResolveFunctions(Module &M, std::vector<GlobalValue*> &Globals, // functions and that the Old function has no varargs fns specified. In // otherwords it's just <retty> (...) // - Value *Replacement = Concrete; - if (Concrete->getType() != Old->getType()) - Replacement = ConstantExpr::getCast(ConstantPointerRef::get(Concrete), - Old->getType()); - NumResolved += Old->use_size(); - Old->replaceAllUsesWith(Replacement); + if (!Old->use_empty()) { // Avoid making the CPR unless we really need it + Value *Replacement = Concrete; + if (Concrete->getType() != Old->getType()) + Replacement = ConstantExpr::getCast(ConstantPointerRef::get(Concrete), + Old->getType()); + NumResolved += Old->use_size(); + Old->replaceAllUsesWith(Replacement); + } // Since there are no uses of Old anymore, remove it from the module. M.getFunctionList().erase(Old); |