summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-07-30 00:50:49 +0000
committerChris Lattner <sabre@nondot.org>2002-07-30 00:50:49 +0000
commitaacadd1a9545eff2d60cb2fa2494cd402990de3d (patch)
tree1035e74e872a0541954cf5c203c4d9a3a82b3b0d /llvm/lib/Transforms
parent38d4ae67eb7b2d365d2efcd8a29aaa6a611721b8 (diff)
downloadbcm5719-llvm-aacadd1a9545eff2d60cb2fa2494cd402990de3d.tar.gz
bcm5719-llvm-aacadd1a9545eff2d60cb2fa2494cd402990de3d.zip
* Make sure the resolved function call instructions get the name from the
old call instruction * Implement conversion of return values for calls. This fixes bug: test/Regression/Transforms/FunctionResolve/retmismatch3.ll llvm-svn: 3140
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionResolution.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionResolution.cpp b/llvm/lib/Transforms/IPO/FunctionResolution.cpp
index 44f84851211..2306df999db 100644
--- a/llvm/lib/Transforms/IPO/FunctionResolution.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionResolution.cpp
@@ -80,6 +80,9 @@ static void ConvertCallTo(CallInst *CI, Function *Dest) {
// Remove the old call instruction from the program...
BB->getInstList().remove(BBI);
+ // Transfer the name over...
+ NewCall->setName(CI->getName());
+
// Replace uses of the old instruction with the appropriate values...
//
if (NewCall->getType() == CI->getType()) {
@@ -94,10 +97,19 @@ static void ConvertCallTo(CallInst *CI, Function *Dest) {
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
} else if (CI->getType() == Type::VoidTy) {
// If we are gaining a new return value, we don't have to do anything
- // special.
+ // special here, because it will automatically be ignored.
} else {
- assert(0 && "This should have been checked before!");
- abort();
+ // Insert a cast instruction to convert the return value of the function
+ // into it's new type. Of course we only need to do this if the return
+ // value of the function is actually USED.
+ //
+ if (!CI->use_empty()) {
+ CastInst *NewCast = new CastInst(NewCall, CI->getType(),
+ NewCall->getName());
+ CI->replaceAllUsesWith(NewCast);
+ // Insert the new cast instruction...
+ BB->getInstList().insert(BBI, NewCast);
+ }
}
// The old instruction is no longer needed, destroy it!
@@ -190,10 +202,6 @@ bool FunctionResolvingPass::run(Module &M) {
const FunctionType *ConcreteMT = Concrete->getFunctionType();
bool Broken = false;
- assert((Old->getReturnType() == Concrete->getReturnType() ||
- Concrete->getReturnType() == Type::VoidTy ||
- Old->getReturnType() == Type::VoidTy) &&
- "Differing return types not handled yet!");
assert(OldMT->getParamTypes().size() <=
ConcreteMT->getParamTypes().size() &&
"Concrete type must have more specified parameters!");
OpenPOWER on IntegriCloud