@@ -111,7 +111,8 @@ getAccessorForComputedComponent(IRGenModule &IGM,
111
111
return accessorFn;
112
112
}
113
113
114
- auto accessorFnTy = accessorFn->getType ()->getPointerElementType ();
114
+ auto accessorFnTy = cast<llvm::FunctionType>(
115
+ accessorFn->getType ()->getPointerElementType ());;
115
116
116
117
// Otherwise, we need a thunk to unmarshal the generic environment from the
117
118
// argument area. It'd be nice to have a good way to represent this
@@ -140,7 +141,7 @@ getAccessorForComputedComponent(IRGenModule &IGM,
140
141
141
142
SmallVector<llvm::Type *, 4 > thunkParams;
142
143
for (unsigned i = 0 ; i < numArgsToForward; ++i)
143
- thunkParams.push_back (accessorFnTy->getFunctionParamType (i));
144
+ thunkParams.push_back (accessorFnTy->getParamType (i));
144
145
145
146
switch (whichAccessor) {
146
147
case Getter:
@@ -153,7 +154,8 @@ getAccessorForComputedComponent(IRGenModule &IGM,
153
154
}
154
155
thunkParams.push_back (IGM.SizeTy );
155
156
156
- auto thunkType = llvm::FunctionType::get (IGM.VoidTy , thunkParams,
157
+ auto thunkType = llvm::FunctionType::get (accessorFnTy->getReturnType (),
158
+ thunkParams,
157
159
/* vararg*/ false );
158
160
159
161
auto accessorThunk = llvm::Function::Create (thunkType,
@@ -228,9 +230,12 @@ getAccessorForComputedComponent(IRGenModule &IGM,
228
230
forwardedArgs);
229
231
auto fnPtr = FunctionPointer::forDirect (IGM, accessorFn,
230
232
accessor->getLoweredFunctionType ());
231
- IGF.Builder .CreateCall (fnPtr, forwardedArgs.claimAll ());
233
+ auto call = IGF.Builder .CreateCall (fnPtr, forwardedArgs.claimAll ());
232
234
233
- IGF.Builder .CreateRetVoid ();
235
+ if (call->getType ()->isVoidTy ())
236
+ IGF.Builder .CreateRetVoid ();
237
+ else
238
+ IGF.Builder .CreateRet (call);
234
239
}
235
240
236
241
return accessorThunk;
0 commit comments