File tree Expand file tree Collapse file tree 3 files changed +63
-4
lines changed Expand file tree Collapse file tree 3 files changed +63
-4
lines changed Original file line number Diff line number Diff line change 136
136
// / Darwin reserves the low 4GB of address space.
137
137
#define SWIFT_ABI_DARWIN_ARM64_LEAST_VALID_POINTER 0x100000000ULL
138
138
139
- // TBI guarantees the top byte of pointers is unused.
139
+ // TBI guarantees the top byte of pointers is unused, but ARMv8.5-A
140
+ // claims the bottom four bits of that for memory tagging.
140
141
// Heap objects are eight-byte aligned.
141
- #define SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK 0xFF00000000000007ULL
142
+ #define SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK 0xF000000000000007ULL
142
143
143
144
// Objective-C reserves just the high bit for tagged pointers.
144
145
#define SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK 0x8000000000000000ULL
Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ entry(%c : $C, %w : $Builtin.Word):
35
35
// CHECK: [[TAGGED_RESULT:%.*]] = bitcast [[BRIDGE]] %0 to [[C:%objc_object\*]]
36
36
// CHECK: br label %tagged-cont
37
37
// CHECK: not-tagged-pointer:
38
- // -- 0x00ff_ffff_ffff_fff8
39
- // CHECK: [[MASKED_BITS:%.*]] = and i64 [[BOBITS]], 72057594037927928
38
+ // -- 0x0fff_ffff_ffff_fff8
39
+ // CHECK: [[MASKED_BITS:%.*]] = and i64 [[BOBITS]], 1152921504606846968
40
40
// CHECK: [[MASKED_RESULT:%.*]] = inttoptr i64 [[MASKED_BITS]] to [[C]]
41
41
// CHECK: br label %tagged-cont
42
42
// CHECK: tagged-cont:
Original file line number Diff line number Diff line change
1
+ // RUN: %swift -module-name test -emit-ir -target arm64-apple-ios10.0 %s | %FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-arm64
2
+ // RUN: %swift -module-name test -emit-ir -target x86_64-apple-macosx10.12 %s | %FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-x86_64
3
+
4
+ class NativeClass {}
5
+ sil_vtable NativeClass {}
6
+
7
+ // On 64-bit targets, there are 3 spare bits in the alignment bits and
8
+ // either 4 (arm64) or 8 (everywhere else) spare bits in the high byte.
9
+ // Consume those bits one by one.
10
+
11
+ enum A {
12
+ case either(NativeClass)
13
+ case or(NativeClass)
14
+ }
15
+
16
+ enum B {
17
+ case either(A)
18
+ case or(A)
19
+ }
20
+
21
+ enum C {
22
+ case either(B)
23
+ case or(B)
24
+ }
25
+
26
+ enum D {
27
+ case either(C)
28
+ case or(C)
29
+ }
30
+
31
+ enum E {
32
+ case either(D)
33
+ case or(D)
34
+ }
35
+
36
+ enum F {
37
+ case either(E)
38
+ case or(E)
39
+ }
40
+
41
+ enum G {
42
+ case either(F)
43
+ case or(F)
44
+ }
45
+
46
+ // Okay, we've claimed 7 spare bits. On ARM64, the eighth spare bit will
47
+ // require an extra discriminator.
48
+
49
+ // CHECK-LABEL: @"$s4test1HOWV" = internal constant %swift.enum_vwtable
50
+ // CHECK-x86_64-SAME: i64 8,
51
+ // CHECK-x86_64-SAME: i64 8,
52
+ // CHECK-arm64-SAME: i64 9,
53
+ // CHECK-arm64-SAME: i64 16,
54
+
55
+ enum H {
56
+ case either(G)
57
+ case or(G)
58
+ }
You can’t perform that action at this time.
0 commit comments