Skip to content

Commit c148e11

Browse files
committed
[TypeLowering] Allow SILToken to !BitwiseCopyable.
Like `ModuleType`, there's no reason to conform this flavor of trivial type to `BitwiseCopyable`. So permit it during verification.
1 parent 159571c commit c148e11

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/SIL/IR/TypeLowering.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2793,6 +2793,17 @@ TypeConverter::getTypeLowering(AbstractionPattern origType,
27932793
}
27942794

27952795
namespace swift::test {
2796+
static FunctionTest PrintASTTypeLowering(
2797+
"print_ast_type_lowering", [](auto &function, auto &arguments, auto &test) {
2798+
auto value = arguments.takeValue();
2799+
auto silTy = value->getType();
2800+
auto canTy = silTy.getRawASTType();
2801+
auto *ty = canTy.getPointer();
2802+
function.getModule()
2803+
.Types.getTypeLowering(AbstractionPattern(ty), ty, function)
2804+
.print(llvm::outs());
2805+
});
2806+
27962807
// Arguments:
27972808
// - value: whose type will be printed
27982809
// Dumps:
@@ -3034,6 +3045,7 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
30343045
// unconditionally but in this particular instantiation is trivial
30353046
// (3) being a special type that's not worth forming a conformance for
30363047
// - ModuleType
3048+
// - SILTokenType
30373049
// (4) being an unowned(unsafe) reference to a class/class-bound existential
30383050
// NOTE: ReferenceStorageType(C) does not conform HOWEVER the presence
30393051
// of an unowned(unsafe) field within an aggregate DOES NOT allow
@@ -3076,7 +3088,7 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
30763088

30773089
// ModuleTypes are trivial but don't warrant being given a
30783090
// conformance to BitwiseCopyable (case (3)).
3079-
if (isa<ModuleType>(ty)) {
3091+
if (isa<ModuleType, SILTokenType>(ty)) {
30803092
// These types should never appear within aggregates.
30813093
assert(isTopLevel && "aggregate containing marker type!?");
30823094
// If they did, though, they would not justify the aggregate's

test/SIL/type_lowering_unit.sil

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,14 @@ entry(%instance : $*GE<T>):
9494
%retval = tuple ()
9595
return %retval : $()
9696
}
97+
98+
// CHECK-LABEL: begin {{.*}} token: print_ast_type_lowering with: %instance
99+
// CHECK: isTrivial: true
100+
// CHECK-LABEL: end {{.*}} token: print_ast_type_lowering with: %instance
101+
sil @token : $@convention(thin) (@in Builtin.RawPointer) -> () {
102+
entry(%addr : $*Builtin.RawPointer):
103+
%ptr = address_to_pointer %addr : $*Builtin.RawPointer to $Builtin.RawPointer
104+
%instance = builtin "once"(%ptr : $Builtin.RawPointer, undef : $()) : $Builtin.SILToken
105+
specify_test "print_ast_type_lowering %instance"
106+
return undef : $()
107+
}

0 commit comments

Comments
 (0)