Skip to content

Commit 3d4163a

Browse files
committed
Address review feedback
1 parent d9bc2cb commit 3d4163a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,15 @@ static void addIndirectResultAttributes(IRGenModule &IGM,
373373
attrs = attrs.addParamAttributes(IGM.getLLVMContext(), paramIndex, b);
374374
}
375375

376+
// This function should only be called with directly returnable
377+
// result and error types. Errors can only be returned directly if
378+
// they consists solely of int and ptr values.
376379
CombinedResultAndErrorType irgen::combineResultAndTypedErrorType(
377380
const IRGenModule &IGM, const NativeConventionSchema &resultSchema,
378381
const NativeConventionSchema &errorSchema) {
382+
assert(!resultSchema.requiresIndirect());
383+
assert(!errorSchema.shouldReturnTypedErrorIndirectly());
384+
379385
CombinedResultAndErrorType result;
380386
SmallVector<llvm::Type *, 8> elts;
381387
resultSchema.enumerateComponents(
@@ -403,6 +409,8 @@ CombinedResultAndErrorType irgen::combineResultAndTypedErrorType(
403409
}
404410

405411
auto *error = *errorIt;
412+
assert(error->isIntOrPtrTy() &&
413+
"Direct errors must only consist of int or ptr values");
406414
result.errorValueMapping.push_back(combined.size());
407415
if (res->getPrimitiveSizeInBits() >= error->getPrimitiveSizeInBits()) {
408416
combined.push_back(res);

0 commit comments

Comments
 (0)