diff options
author | Chris Lattner <sabre@nondot.org> | 2011-07-13 03:59:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-07-13 03:59:32 +0000 |
commit | 6af13f3a3538d6c075a6282a7f393c26ee1563c7 (patch) | |
tree | dd20860fd68cd6959a637dd819c2104aff718777 /lib/CodeGen/CGCall.cpp | |
parent | 8f62992730c88e3b9d6815c322e045e79251d3d5 (diff) |
PR10337 reminds me that calls return values, lets handle them just
like arguments. Thanks PR10337! :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135030 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCall.cpp')
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index ee0e26e0da..39a143feec 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -1742,8 +1742,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, case ABIArgInfo::Extend: case ABIArgInfo::Direct: { - if (RetAI.getCoerceToType() == ConvertType(RetTy) && - RetAI.getDirectOffset() == 0) { + llvm::Type *RetIRTy = ConvertType(RetTy); + if (RetAI.getCoerceToType() == RetIRTy && RetAI.getDirectOffset() == 0) { if (RetTy->isAnyComplexType()) { llvm::Value *Real = Builder.CreateExtractValue(CI, 0); llvm::Value *Imag = Builder.CreateExtractValue(CI, 1); @@ -1760,7 +1760,13 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, BuildAggStore(*this, CI, DestPtr, DestIsVolatile, false); return RValue::getAggregate(DestPtr); } - return RValue::get(CI); + + // If the argument doesn't match, perform a bitcast to coerce it. This + // can happen due to trivial type mismatches. + llvm::Value *V = CI; + if (V->getType() != RetIRTy) + V = Builder.CreateBitCast(V, RetIRTy); + return RValue::get(V); } llvm::Value *DestPtr = ReturnValue.getValue(); |