File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -3798,6 +3798,15 @@ class AssignAddressToDef : SILInstructionVisitor<AssignAddressToDef> {
37983798 assignment.mapValueToAddress (origValue, newAddr);
37993799 assignment.markForDeletion (bc);
38003800 }
3801+
3802+ void visitUncheckedBitwiseCastInst (UncheckedBitwiseCastInst *bc) {
3803+ auto builder = assignment.getBuilder (bc->getIterator ());
3804+ auto opdAddr = assignment.getAddressForValue (bc->getOperand ());
3805+ auto newAddr = builder.createUncheckedAddrCast (
3806+ bc->getLoc (), opdAddr, bc->getType ().getAddressType ());
3807+ assignment.mapValueToAddress (origValue, newAddr);
3808+ assignment.markForDeletion (bc);
3809+ }
38013810};
38023811} // namespace
38033812
@@ -3852,6 +3861,10 @@ class RewriteUser : SILInstructionVisitor<RewriteUser> {
38523861 userInstructionFallback (kp);
38533862 }
38543863
3864+ void visitYieldInst (YieldInst *yield) { userInstructionFallback (yield); }
3865+
3866+ void visitThrowInst (ThrowInst *t) { userInstructionFallback (t); }
3867+
38553868 void visitFixLifetimeInst (FixLifetimeInst *f) {
38563869 auto addr = assignment.getAddressForValue (f->getOperand ());
38573870 auto builder = assignment.getBuilder (f->getIterator ());
Original file line number Diff line number Diff line change @@ -24,6 +24,25 @@ struct X {
2424 var x16: Int
2525}
2626
27+ struct X2 {
28+ var x1 : Int
29+ var x2 : Int
30+ var x3 : Int
31+ var x4: Int
32+ var x5: Int
33+ var x6: Int
34+ var x7: Int
35+ var x8: Int
36+ var x9: Int
37+ var x10: Int
38+ var x11: Int
39+ var x12: Int
40+ var x13: Int
41+ var x14: Int
42+ var x15: Int
43+ var x16: Int
44+ }
45+
2746struct Y {
2847 var y1 : X
2948 var y2: X
@@ -269,3 +288,34 @@ bb0(%0 : $*C1, %1 : $*Small):
269288 %t = tuple ()
270289 return %t : $()
271290}
291+
292+ // CHECK: sil @test13
293+ // CHECK: [[ADDR:%.*]] = unchecked_addr_cast %1 : $*X to $*Y
294+ // CHECK: copy_addr [take] [[ADDR]] to [init] %2 : $*Y
295+ // CHECK: } // end sil function 'test13'
296+ sil @test13 : $@convention(thin) (@in X) -> () {
297+ bb0(%0 : $*X):
298+ %1 = alloc_stack $Y
299+ %2 = alloc_stack $X
300+ copy_addr [take] %0 to [init] %2 : $*X
301+ %4 = load %2 : $*X
302+ %7 = unchecked_bitwise_cast %4 : $X to $Y
303+ store %7 to %1: $*Y
304+ %13 = tuple ()
305+ dealloc_stack %2 : $*X
306+ dealloc_stack %1 : $*Y
307+ return %13 : $()
308+ }
309+
310+ // CHECK: sil @test14
311+ // CHECK: [[VAL:%.*]] = load {{.*}} : $*X
312+ // CHECK: throw [[VAL]]
313+ // CHECK: } // end sil function 'test14'
314+ sil @test14 : $@convention(thin) (@in X) -> @error X {
315+ bb0(%0 : $*X):
316+ %1 = alloc_stack $X
317+ copy_addr [take] %0 to [init] %1 : $*X
318+ %3 = load %1 : $*X
319+ dealloc_stack %1 : $*X
320+ throw %3 : $X
321+ }
You can’t perform that action at this time.
0 commit comments