diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index f03208f..3a7d1ab 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1062,8 +1062,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function::arg_iterator EI = CurFn->arg_end(); --EI; llvm::Value *Addr = Builder.CreateStructGEP(nullptr, &*EI, Idx); + llvm::Type *Ty = + cast<llvm::GetElementPtrInst>(Addr)->getResultElementType(); ReturnValuePointer = Address(Addr, getPointerAlign()); - Addr = Builder.CreateAlignedLoad(Addr, getPointerAlign(), "agg.result"); + Addr = Builder.CreateAlignedLoad(Ty, Addr, getPointerAlign(), "agg.result"); ReturnValue = Address(Addr, CGM.getNaturalTypeAlignment(RetTy)); } else { ReturnValue = CreateIRTemp(RetTy, "retval"); |