summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-07-23 22:03:18 +0000
committerChris Lattner <sabre@nondot.org>2003-07-23 22:03:18 +0000
commite9340228c92a76777c2fc174629c257c2d2debcc (patch)
treec78276e0f447ac2e28a42aa61b48a3a879600bfe /llvm/lib
parent092fb6c66c8677a9915925a8800e366a9129472b (diff)
downloadbcm5719-llvm-e9340228c92a76777c2fc174629c257c2d2debcc.tar.gz
bcm5719-llvm-e9340228c92a76777c2fc174629c257c2d2debcc.zip
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. llvm-svn: 7285
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionResolution.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionResolution.cpp b/llvm/lib/Transforms/IPO/FunctionResolution.cpp
index 8acddf59008..86352d46a80 100644
--- a/llvm/lib/Transforms/IPO/FunctionResolution.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud