Skip to content

Commit dba641c

Browse files
Merge pull request #21176 from aschwaighofer/drop_witnesses_visitThickToObjCMetatypeInst_5.0
[5.0] IRGen: Drop the witness table pointer in visitThickToObjCMetaty…
2 parents b33997f + e8d34bc commit dba641c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4700,6 +4700,8 @@ void IRGenSILFunction::visitThinToThickFunctionInst(
47004700
void IRGenSILFunction::visitThickToObjCMetatypeInst(ThickToObjCMetatypeInst *i){
47014701
Explosion from = getLoweredExplosion(i->getOperand());
47024702
llvm::Value *swiftMeta = from.claimNext();
4703+
// Claim any conformances.
4704+
(void)from.claimAll();
47034705
CanType instanceType(i->getType().castTo<AnyMetatypeType>().getInstanceType());
47044706
Explosion to;
47054707
llvm::Value *classPtr =

test/IRGen/metatype.sil

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,18 @@ bb0(%0 : $AnyObject):
7575
%1 = existential_metatype $@objc_metatype AnyObject.Type, %0 : $AnyObject
7676
return %1 : $@objc_metatype AnyObject.Type
7777
}
78+
79+
80+
public protocol ClassProto : AnyObject {
81+
var other: ClassProto? { get }
82+
}
83+
84+
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @drop_witness_table(%swift.type*, i8**)
85+
// CHECK: call %objc_class* @swift_getObjCClassFromMetadata(%swift.type* %0)
86+
// CHECK: ret void
87+
sil @drop_witness_table : $@convention(thin) (@thick ClassProto.Type) -> () {
88+
bb0(%0 : $@thick ClassProto.Type):
89+
%1 = thick_to_objc_metatype %0 : $@thick ClassProto.Type to $@objc_metatype ClassProto.Type
90+
%2 = tuple ()
91+
return %2 : $()
92+
}

0 commit comments

Comments
 (0)