File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -1703,8 +1703,11 @@ llvm::Value *IRGenFunction::getLocalSelfMetadata() {
1703
1703
// with the correct value.
1704
1704
1705
1705
llvm::IRBuilderBase::InsertPointGuard guard (Builder);
1706
- Builder.SetInsertPoint (&CurFn->getEntryBlock (),
1707
- CurFn->getEntryBlock ().begin ());
1706
+ auto insertPt = isa<llvm::Instruction>(LocalSelf)
1707
+ ? std::next (llvm::BasicBlock::iterator (
1708
+ cast<llvm::Instruction>(LocalSelf)))
1709
+ : CurFn->getEntryBlock ().begin ();
1710
+ Builder.SetInsertPoint (&CurFn->getEntryBlock (), insertPt);
1708
1711
1709
1712
switch (SelfKind) {
1710
1713
case SwiftMetatype:
Original file line number Diff line number Diff line change @@ -112,3 +112,18 @@ bb0(%0 : $@objc_metatype K<P>.Type):
112
112
%3 = apply %2<P>() : $@convention(thin) <τ_0_0 > () -> ()
113
113
return undef : $()
114
114
}
115
+
116
+ public class D {
117
+ }
118
+
119
+ // CHECK: define void @testDynamicSelfMetatype(i8*, i8*)
120
+ // CHECK: [[C:%.*]] = bitcast i8* %0 to %T27objc_generic_class_metadata1DC*
121
+ // CHECK: [[O:%.*]] = bitcast %T27objc_generic_class_metadata1DC* [[C]] to %objc_object*
122
+ // CHECK: call %swift.type* @swift_getObjectType(%objc_object* [[O]]
123
+ sil @testDynamicSelfMetatype : $@convention(objc_method) (@owned D) -> () {
124
+ bb0(%0 : $D):
125
+ %1 = metatype $@thick @dynamic_self D.Type
126
+ return undef : $()
127
+ }
128
+
129
+ sil_vtable D {}
You can’t perform that action at this time.
0 commit comments