File tree Expand file tree Collapse file tree 2 files changed +29
-10
lines changed Expand file tree Collapse file tree 2 files changed +29
-10
lines changed Original file line number Diff line number Diff line change @@ -1314,16 +1314,7 @@ namespace {
1314
1314
// / Do a primitive copy of the enum from one address to another.
1315
1315
void emitPrimitiveCopy (IRGenFunction &IGF, Address dest, Address src,
1316
1316
SILType T) const {
1317
- // If the layout is fixed, load and store the fixed-size payload and tag.
1318
- if (TIK >= Fixed) {
1319
- EnumPayload payload;
1320
- llvm::Value *extraTag;
1321
- std::tie (payload, extraTag)
1322
- = emitPrimitiveLoadPayloadAndExtraTag (IGF, src);
1323
- emitPrimitiveStorePayloadAndExtraTag (IGF, dest, payload, extraTag);
1324
- return ;
1325
- }
1326
-
1317
+ // If the layout is fixed, the size will be a constant.
1327
1318
// Otherwise, do a memcpy of the dynamic size of the type.
1328
1319
IGF.Builder .CreateMemCpy (dest.getAddress (), src.getAddress (),
1329
1320
TI->getSize (IGF, T),
Original file line number Diff line number Diff line change @@ -2647,6 +2647,34 @@ bb4:
2647
2647
return %9 : $()
2648
2648
}
2649
2649
2650
+ struct LargeStruct {
2651
+ var x: Builtin.Int64
2652
+ var x2: Builtin.Int64
2653
+ var x3: Builtin.Int64
2654
+ var x4: Builtin.Int64
2655
+ var x5: Builtin.Int64
2656
+ var x6: Builtin.NativeObject
2657
+ }
2658
+
2659
+ enum MyOptional {
2660
+ case None
2661
+ case Some(LargeStruct)
2662
+ }
2663
+
2664
+ // Make sure we use a memcpy for the none branch of the enum copy.
2665
+
2666
+ // CHECK-LABEL: define{{.*}} @test_large_optional
2667
+ // CHECK: llvm.memcpy
2668
+ // CHECK: ret void
2669
+ sil @test_large_optional : $@convention(thin) (@in MyOptional) -> () {
2670
+ entry(%x : $*MyOptional):
2671
+ %stk = alloc_stack $MyOptional
2672
+ copy_addr %x to [initialization] %stk : $*MyOptional
2673
+ dealloc_stack %stk: $*MyOptional
2674
+ %tuple = tuple ()
2675
+ return %tuple : $()
2676
+ }
2677
+
2650
2678
// -- Fill function for dynamic singleton. The value witness table flags just
2651
2679
// get copied over from the element.
2652
2680
// CHECK: define{{( protected)?}} private %swift.type* @create_generic_metadata_DynamicSingleton(%swift.type_pattern*, i8**) {{.*}} {
You can’t perform that action at this time.
0 commit comments