Skip to content

Commit 923689c

Browse files
committed
[Embedded] Only reserve 4KB in embedded Darwin targets
Non-embedded Darwin targets reserve the first 4GB of address space. All other targets reserve 4KB of address space. Make Embedded Darwin targets only reserve the first 4KB (as with other targets), since they aren't in userspace. Fixes rdar://158981013.
1 parent 358d6bd commit 923689c

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

lib/IRGen/SwiftTargetInfo.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ static void configureARM64(IRGenModule &IGM, const llvm::Triple &triple,
4949
}
5050
setToMask(target.IsObjCPointerBit, 64, SWIFT_ABI_ARM64_IS_OBJC_BIT);
5151

52-
if (triple.isOSDarwin()) {
52+
// Non-embedded Darwin reserves the low 4GB of address space.
53+
if (triple.isOSDarwin() &&
54+
!IGM.getSwiftModule()->getASTContext().LangOpts.hasFeature(
55+
Feature::Embedded)) {
5356
target.LeastValidPointerValue =
5457
SWIFT_ABI_DARWIN_ARM64_LEAST_VALID_POINTER;
5558
}
@@ -104,7 +107,9 @@ static void configureX86_64(IRGenModule &IGM, const llvm::Triple &triple,
104107
SWIFT_ABI_X86_64_OBJC_RESERVED_BITS_MASK);
105108
}
106109

107-
if (triple.isOSDarwin()) {
110+
if (triple.isOSDarwin() &&
111+
!IGM.getSwiftModule()->getASTContext().LangOpts.hasFeature(
112+
Feature::Embedded)) {
108113
target.LeastValidPointerValue =
109114
SWIFT_ABI_DARWIN_X86_64_LEAST_VALID_POINTER;
110115
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
// RUN: %target-swift-emit-ir %s -module-name main -parse-as-library -enable-experimental-feature Embedded -O -min-valid-pointer-value=0x1000 | %FileCheck %s
3+
// RUN: %target-swift-emit-ir %s -module-name main -parse-as-library -enable-experimental-feature Embedded -O | %FileCheck %s
4+
5+
// REQUIRES: OS=macosx
6+
// REQUIRES: swift_feature_Embedded
7+
8+
public func testit(_ s: S?) -> Bool {
9+
return s != nil
10+
}
11+
12+
class C {}
13+
14+
public struct S {
15+
var a = InlineArray<57, UInt8>(repeating: 0)
16+
var b = C()
17+
var c = InlineArray<49, UInt8>(repeating: 0)
18+
}
19+
20+
// CHECK-LABEL: define {{.*}} @"$e4main1SVSgWOg"(ptr %0)
21+
// CHECK: icmp {{.*}}, 4095
22+
// CHECK-LABEL: }

0 commit comments

Comments
 (0)