Skip to content

Commit a5ff907

Browse files
Merge pull request swiftlang#29508 from aschwaighofer/silgen_fix_return_arg_type_lowering
SILGen: Lower the type of the return value merge phi in the context of the current function
2 parents 1fff12f + 18babf7 commit a5ff907

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/SILGen/SILGenEpilog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ void SILGenFunction::prepareEpilog(Type resultType, bool isThrowing,
3030
// emits unreachable if there is no source level return.
3131
NeedsReturn = (fnConv.funcTy->getNumResults() != 0);
3232
for (auto directResult : fnConv.getDirectSILResults()) {
33-
SILType resultType =
34-
F.mapTypeIntoContext(fnConv.getSILType(directResult));
33+
SILType resultType = F.getLoweredType(
34+
F.mapTypeIntoContext(fnConv.getSILType(directResult)));
3535
epilogBB->createPhiArgument(resultType, ValueOwnershipKind::Owned);
3636
}
3737
}

test/SILGen/opaque_result_type.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,19 @@ struct S2 : X {
149149
return foo
150150
}
151151
}
152+
153+
class Base {}
154+
class Sub1 : Base {}
155+
class Sub2 : Base {}
156+
157+
public class D {
158+
var cond = true
159+
// CHECK-LABEL: sil private [ossa] @$s18opaque_result_type1DC1c33_C2C55A4BAF30C3244D4A165D48A91142LLQrvg
160+
// CHECK: bb3([[RET:%[0-9]+]] : @owned $Base):
161+
// CHECH: return [[RET]]
162+
// CHECK: } // end sil function '$s18opaque_result_type1DC1c33_C2C55A4BAF30C3244D4A165D48A91142LLQrvg'
163+
private lazy var c: some Base = {
164+
let d = cond ? Sub1() : Sub2()
165+
return d
166+
}()
167+
}

0 commit comments

Comments
 (0)